WIP: Support constraints for ALTER COLUMN TYPE #48516
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #46933
Fixes #48288
Support altering data type of a column that has check constraints. Rewrite constraints to support the new data type of the column.In a check constraint, any binary expression that contains the column will have the opposite side casted to the type of the column.
Example: Given column x INT with check constraint (x > 5) if x is changed to a FLOAT, the new constraint will be (x > 5::FLOAT).
Right now, the DFS naively checks if a BinaryExpr/ComparisonExpr is contains the column and casts the opposite side to the cast. Furthermore if either the Left or Right Expr of a BinaryExpr/Comparison was changed, the opposite side is casted as well.