Skip to content

Redshift alter column type no set #1912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yoavcloud
Copy link
Contributor

@yoavcloud yoavcloud commented Jun 29, 2025

Expanded the support for ALTER TABLE tbl ALTER COLUMN col TYPE <type> to the Redshift dialect in addition to PostgreSQL. Generalized this option using the supports_xxx functions in the Dialect trait to maintain backwards compatibility with expected error messages in non-supporting dialects.

Improved SQL output from Ast by introducing an option to determine if SET DATA appears before the TYPE keyword.

false
}

/// Returns true if the dialect supports `ALTER TABLE tbl ALTER COLUMN col SET DATA TYPE <type> USING <exp>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns true if the dialect supports `ALTER TABLE tbl ALTER COLUMN col SET DATA TYPE <type> USING <exp>`
/// Returns true if the dialect supports the `USING` clause in an `ALTER COLUMN` statement.
/// Example:
/// ```sql
/// ALTER TABLE tbl ALTER COLUMN col SET DATA TYPE <type> USING <exp>`
/// ```

thinking something like this so that its a bit clearer which part of the statement the flag refers to?

///
/// - [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html#r_ALTER_TABLE-synopsis)
/// - [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html)
fn supports_alter_column_type_without_set(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I followed that this flag is necessary, it looks like we would be able to accept either variant with or without the SET DATA prefix? The error message of existing tests if I understood the PR description correctly we can change to match the new behavior I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is an option. I hesitated a bit because saw specific negative tests, and did not want to break anything.

src/ast/ddl.rs Outdated
Comment on lines 896 to 897
/// Whether the statement included the optional `SET DATA` keywords
had_set: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Whether the statement included the optional `SET DATA` keywords
had_set: bool,
/// Set to true if the statement includes the `SET DATA TYPE` keywords
set_data_type: bool,

@yoavcloud yoavcloud requested a review from iffyio July 1, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants