-
Notifications
You must be signed in to change notification settings - Fork 594
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): support show create [materialized] view command #6921
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Should we also support showing the view definition in a pg compatible way (via pg_get_viewdef
or pg_views
)?
Yes, we already support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you a lot! ❤️
// We only stored original sql in catalog, uses parser to parse and format. | ||
let stmt = Parser::parse_sql(&view.sql) | ||
.map_err(|err| anyhow!("Failed to parse view create sql: {}, {}", view.sql, err))?; | ||
assert!(stmt.len() == 1); | ||
stmt[0].to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SQL unparsed from the AST might be incorrect. :( #6801 Will this be a problem, if this is for some programs to read?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, I guess we need to carefully review the fmt::Display
for all AST nodes and add a comprehensive test suite for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥵 I think this is just for user to check how the mview and view are created.
If so, I guess we need to carefully review the
fmt::Display
for all AST nodes and add a comprehensive test suite for it.
But this's also needed, does the tests in sql_parser meet demand? It seems that we only have few tests there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. cc @lmatz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can test roundtrip parsing (parse(unparse(parse(sql))) == parse(sql)
) in sqlsmith. Created an issue #6935
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can test roundtrip parsing (
parse(unparse(parse(sql))) == parse(sql)
) in sqlsmith.
I'm afraid there's a case that some different SQLs are parsed to the same AST, which requires some binder context to distinguish. So when we unparse it, we cannot find the original representation, and this roundtrip test cannot cover this. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's exactly why using AST instead of original sql to compare in xxchan's proposal?
Codecov Report
@@ Coverage Diff @@
## main #6921 +/- ##
==========================================
- Coverage 72.71% 72.68% -0.04%
==========================================
Files 1036 1036
Lines 166192 166289 +97
==========================================
+ Hits 120840 120859 +19
- Misses 45352 45430 +78
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.
What's changed and what's your intention?
Support show create create [materialized] view commands.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.
Types of user-facing changes
Support show create create [materialized] view commands:
Release note
Support show create create [materialized] view commands.
Refer to a related PR or issue link (optional)
Resolve #6913