Skip to content
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

feat(frontend): lossy "purify" column default value #19993

Merged
merged 7 commits into from
Jan 15, 2025

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Jan 2, 2025

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

In #19949 we mentioned that

convert ExprNode back to ast can be a bit tricky.

which is the very missing piece of definition purification.

In this PR, we allow converting persisted DefaultColumnDesc back to ast::ColumnOption::DefaultValue losslessly, by simply storing the encoded value temporarily into the AST.

Apparently this is somehow hacky, as unparsing the AST back to SQL will still lose such information. However, this can still be beneficial for...

...as long as we believe that AST is the best intermediate representation for schema change.

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

Comment on lines -69 to -70

return Ok(base);
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously we short-circuited the procedure once we find all columns are present. Now we should always go through the step for filling the default value.

@BugenZhao BugenZhao marked this pull request as ready for review January 3, 2025 03:32
@BugenZhao BugenZhao force-pushed the bz/purify-sql-part-2 branch from ec38b32 to 6ec6062 Compare January 6, 2025 05:53
@BugenZhao BugenZhao force-pushed the bz/purify-sql-part-3 branch from 34145ee to b958c45 Compare January 6, 2025 05:53
Base automatically changed from bz/purify-sql-part-2 to main January 6, 2025 06:35
@graphite-app graphite-app bot requested a review from a team January 6, 2025 06:35
@BugenZhao BugenZhao force-pushed the bz/purify-sql-part-3 branch from b958c45 to fc48f02 Compare January 7, 2025 06:08
@BugenZhao BugenZhao requested a review from fuyufjh January 7, 2025 10:13
@BugenZhao BugenZhao force-pushed the bz/purify-sql-part-3 branch from fc48f02 to 1126076 Compare January 13, 2025 08:04
@BugenZhao BugenZhao changed the title feat(frontend): "purify" column default value feat(frontend): lossy "purify" column default value Jan 13, 2025
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM

src/sqlparser/src/ast/ddl.rs Outdated Show resolved Hide resolved
@BugenZhao BugenZhao force-pushed the bz/purify-sql-part-3 branch from 1126076 to 1ebc3b2 Compare January 15, 2025 06:04
@BugenZhao BugenZhao added this pull request to the merge queue Jan 15, 2025
Merged via the queue into main with commit 6dbcefd Jan 15, 2025
29 checks passed
@BugenZhao BugenZhao deleted the bz/purify-sql-part-3 branch January 15, 2025 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants