-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[SQL] add SHOW command #36509
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
[SQL] add SHOW command #36509
Conversation
Summary of ChangesHello @ahmedabu98, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the introspection capabilities of the Beam SQL CLI by adding a suite of Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
Failing tests are unrelated |
|
assign set of reviewers |
|
Assigning reviewers: R: @m-trieu for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Reminder, please take a look at this pr: @m-trieu |
|
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @kennknowles for label java. Available commands:
|
...nsions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowCatalogs.java
Outdated
Show resolved
Hide resolved
...sions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowDatabases.java
Outdated
Show resolved
Hide resolved
...tensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowTables.java
Outdated
Show resolved
Hide resolved
...va/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/catalog/Catalog.java
Outdated
Show resolved
Hide resolved
|
Reminder, please take a look at this pr: @kennknowles |
|
waiting on author |
|
@kennknowles thx for the comments. This is ready for another review cc @talatuyarer |
|
/gemini review |
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.
Code Review
This pull request introduces several SHOW commands to Beam SQL, enhancing its interactive capabilities. Specifically, it adds SHOW CATALOGS, SHOW DATABASES, SHOW TABLES, and SHOW CURRENT ... commands. The implementation is comprehensive, touching the SQL parser, adding new Sql* node classes for the commands, and integrating them with the existing catalog management infrastructure. The code is well-organized and includes extensive tests.
My review focuses on correctness and maintainability. I've identified a few areas for improvement:
- There are a couple of redundant null checks in the new
SHOWcommand implementations. - The string generation for table borders in the output formatting can be made more efficient and readable.
- One of the new tests for
SHOW CATALOGSdoesn't correctly test theLIKEpattern matching.
I've provided specific suggestions for each of these points. Overall, this is a solid contribution that significantly improves the usability of Beam SQL.
...nsions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowCatalogs.java
Outdated
Show resolved
Hide resolved
...sions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowDatabases.java
Outdated
Show resolved
Hide resolved
...tensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowTables.java
Outdated
Show resolved
Hide resolved
...a/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlCliCatalogTest.java
Outdated
Show resolved
Hide resolved
...sions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowDatabases.java
Outdated
Show resolved
Hide resolved
...nsions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowCatalogs.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| /** | ||
| * SHOW TABLES [ ( FROM | IN )? [ catalog_name '.' ] database_name ] [ LIKE regex_pattern ] |
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.
Would [catalog_name '.' ] database_name already exist somewhere as a general construction, or could share between grammar rules? It seems like it is a parsing rule for "database reference"
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 don't have it as a general construction yet (catalogs and databases are relatively new concepts in Beam SQL).
I could put a comment at the top of the doc, something like databaseRef: [ catalog_name '.' ] database_name, and replace the occurrences with databaseRef
Lmk if that's what you had in mind?
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.
Well.. we've have tables named like bigquery.my_dataset.my_tablename and pubsub.my_topic for a long time. Ideally we can merge these two things soonish since they have identical syntax and meaning.
...sions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowDatabases.java
Outdated
Show resolved
Hide resolved
...tensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlShowTables.java
Outdated
Show resolved
Hide resolved
.../extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlCliDatabaseTest.java
Outdated
Show resolved
Hide resolved
|
Reminder, please take a look at this pr: @kennknowles |
|
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @Abacn for label java. Available commands:
|
|
R: @kennknowles |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
kennknowles
left a comment
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.
My comments are improvement suggestions but we don't have to block on it. Please consider them for followups.
| } | ||
|
|
||
| /** | ||
| * SHOW TABLES [ ( FROM | IN )? [ catalog_name '.' ] database_name ] [ LIKE regex_pattern ] |
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.
Well.. we've have tables named like bigquery.my_dataset.my_tablename and pubsub.my_topic for a long time. Ideally we can merge these two things soonish since they have identical syntax and meaning.
| <SHOW> <CURRENT> { s.add(this); } | ||
| { | ||
| List<String> path = new ArrayList<String>(); | ||
| path.add("beamsystem"); |
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.
since this is a weird magic string, maybe also __beamsystem__? But also yea we could leave as beamsystem and that could eventually be something we let users query for more flexible processing of the contents. I know most RDBMSes do that kind of thing, yea?
...tensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/CatalogManagerSchema.java
Outdated
Show resolved
Hide resolved
...tensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/CatalogManagerSchema.java
Show resolved
Hide resolved
...sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlCreateExternalTable.java
Outdated
Show resolved
Hide resolved
...nsions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlDropDatabase.java
Outdated
Show resolved
Hide resolved
| if (schema instanceof CatalogManagerSchema) { | ||
| CatalogSchema catalogSchema = ((CatalogManagerSchema) schema).getCatalogSchema(pathOverride); | ||
| CatalogSchema catalogSchema = | ||
| pathOverride.catalog() != null |
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.
ditto - and I do think doing it in the parse layer is the right way to go. But we should probably be able to make a common "catalog reference" and "table reference" construct.
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.
But we should probably be able to make a common "catalog reference" and "table reference" construct.
Not sure I understand this, but lmk if the new change takes care of it
Addresses #35637
Adds the following commands:
SHOW CATALOGS [ LIKE regex_pattern ]SHOW DATABASES [ ( FROM | IN )? catalog_name ] [ LIKE regex_pattern ]SHOW TABLES [ ( FROM | IN )? [ catalog_name '.' ] database_name ] [ LIKE regex_pattern ]SHOW CURRENT CATALOGSHOW CURRENT DATABASE