-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-14184][SQL] Support native execution of SHOW DATABASE command and fix SHOW TABLE to use table identifier pattern #11991
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
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.
indents.
|
You also need to add test cases in |
31cd3c0 to
db8a5e8
Compare
|
@gatorsmile Thanks for your review. I have addressed most of your comments except the last one. Currently create/drop database commands are not supported for SQLContext. Thus i am unable to do a meaningful test. |
|
@dilipbiswal Sorry for that. Will try to finish that part ASAP. Thanks! |
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.
why accept FROM? It seems kind of weird. Hive doesn't do this either: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-ShowTables
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.
@andrewor14 Hello, we always transform to TOK_FROM for both TOK_IN and TOK_FROM in the grammer file.
spark/sql/catalyst/src/main/antlr3/org/apache/spark/sql/catalyst/parser/SparkSqlParser.g
Line 1473 in 637a78f
| | KW_SHOW KW_TABLES ((KW_FROM|KW_IN) db_name=identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)? -> ^(TOK_SHOWTABLES ^(TOK_FROM $db_name)? showStmtIdentifier?) |
So now, both form works.
show tables from default
show tables in default I will fix up the comments to use 'IN' as opposed to 'FROM'. Did you want to disallow this syntax in the grammer file ? Would there be a backward-compatibility issue if we do that ?
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 see, that's too bad. Let's just keep it
|
ok to test |
|
FYI this blocks on #12009. |
|
Test build #54373 has finished for PR 11991 at commit
|
1e15bc2 to
92fe39f
Compare
|
@dilipbiswal Could you also add support for the ANTLR4 parser? You'll need to a rule to SqlBase.q4 and do the parsing in SparkSqlParser.scala. Let me know if you need help. |
|
@hvanhovell Sure Herman. I will give it a try and get back to you with questions :-) |
|
@hvanhovell Can you please add @dilipbiswal into whitelist? Thanks! |
|
add to whitelist |
|
Test build #54380 has finished for PR 11991 at commit
|
|
Test build #54395 has finished for PR 11991 at commit
|
|
I just merged #12015 Can you update to use the new ANTLR4 parser instead? We are going to remove the ANTLR3 one in the next day or two. Thanks. |
|
@rxin Yes.. I am working on using the new ANTLR4 parser. Thank you. |
92fe39f to
b66f16e
Compare
|
Test build #54443 has finished for PR 11991 at commit
|
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.
You can remove the 'from' option now.
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.
Sure. Will do
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.
@hvanhovell Actually Herman, i tried the following in Hive.
hive> show tables from default;
OK
default__t1_t1_index__should we keep the from option ? There are also some tests which use from option.
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.
Lets keep it then.
|
@dilipbiswal The PR #12009 has been merged. Could you add a test case for show database? Thanks! |
|
Test build #54527 has finished for PR 11991 at commit
|
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.
Do we need to seperate tokens here? I thought they were synonyms?
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.
@hvanhovell Herman, yeah.. they are synonyms. I was not sure, If we just define it as one Token as say "DATABASES" , we can still refer to it from the nonReserved rule as
"DATABASES" ?
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.
Yeah we can. It would be the same as the DATABASE lexer rule.
|
Test build #54539 has finished for PR 11991 at commit
|
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.
FYI to avoid conflicts with #12071 let's revert all the changes in this file since we're not using this parser anymore anyway.
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.
ok. Sure.
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.
@andrewor14 Hi Andrew, is it ok if i have a very minor change in this file just to make sure compilation goes through. Or it will still cause issue with merging ?
ShowTablesCommand(databaseName, None) => we introduced a new parameter to the command.
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 see... never mind then. It seems that we can't avoid the conflicts after all.
|
Looks great! |
|
Test build #54554 has finished for PR 11991 at commit
|
|
Test build #54565 has finished for PR 11991 at commit
|
|
@dilipbiswal can you rebase? I think |
…ix SHOW TABLE to use table identifier pattern
2e16ce4 to
bafca92
Compare
|
@andrewor14 Hi Andrew, just rebased. - FYI |
|
Test build #54651 has finished for PR 11991 at commit
|
|
cc @andrewor14 |
|
LGTM |
|
Merging to master. Thanks! |
|
@hvanhovell Thank you, Herman. |
What changes were proposed in this pull request?
This PR addresses the following
SHOW TABLE syntax
SHOW DATABASES syntax
How was this patch tested?
Tests added in SQLQuerySuite (both hive and sql contexts) and DDLCommandSuite
Note: Since the table name pattern was not working , tests are added in both SQLQuerySuite to
verify the application of the table pattern.