Skip to content

Conversation

@dilipbiswal
Copy link
Contributor

What changes were proposed in this pull request?

This PR addresses the following

  1. Supports native execution of SHOW DATABASES command
  2. Fixes SHOW TABLES to apply the identifier_with_wildcards pattern if supplied.

SHOW TABLE syntax

SHOW TABLES [IN database_name] ['identifier_with_wildcards'];

SHOW DATABASES syntax

SHOW (DATABASES|SCHEMAS) [LIKE 'identifier_with_wildcards'];

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.

@dilipbiswal
Copy link
Contributor Author

cc @gatorsmile @yhuai

Copy link
Member

Choose a reason for hiding this comment

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

indents.

@gatorsmile
Copy link
Member

You also need to add test cases in SQLContext for verifying correctness of the Command execution. So far, it only covers the Parsing correctness.

@dilipbiswal
Copy link
Contributor Author

@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.

@gatorsmile
Copy link
Member

@dilipbiswal Sorry for that. Will try to finish that part ASAP. Thanks!

Copy link
Contributor

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

Copy link
Contributor Author

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.

| 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 ?

Copy link
Contributor

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

@andrewor14
Copy link
Contributor

ok to test

@andrewor14
Copy link
Contributor

FYI this blocks on #12009.

@SparkQA
Copy link

SparkQA commented Mar 28, 2016

Test build #54373 has finished for PR 11991 at commit 1e15bc2.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@hvanhovell
Copy link
Contributor

@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.

@dilipbiswal
Copy link
Contributor Author

@hvanhovell Sure Herman. I will give it a try and get back to you with questions :-)

@viirya
Copy link
Member

viirya commented Mar 29, 2016

@hvanhovell Can you please add @dilipbiswal into whitelist? Thanks!

@andrewor14
Copy link
Contributor

add to whitelist

@SparkQA
Copy link

SparkQA commented Mar 29, 2016

Test build #54380 has finished for PR 11991 at commit 92fe39f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 29, 2016

Test build #54395 has finished for PR 11991 at commit 92fe39f.

  • This patch fails Spark unit tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

@rxin
Copy link
Contributor

rxin commented Mar 29, 2016

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.

@dilipbiswal
Copy link
Contributor Author

@rxin Yes.. I am working on using the new ANTLR4 parser. Thank you.

@SparkQA
Copy link

SparkQA commented Mar 29, 2016

Test build #54443 has finished for PR 11991 at commit b66f16e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will do

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets keep it then.

@gatorsmile
Copy link
Member

@dilipbiswal The PR #12009 has been merged. Could you add a test case for show database? Thanks!

@SparkQA
Copy link

SparkQA commented Mar 30, 2016

Test build #54527 has finished for PR 11991 at commit fe60df8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

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?

Copy link
Contributor Author

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" ?

Copy link
Contributor

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.

@SparkQA
Copy link

SparkQA commented Mar 30, 2016

Test build #54539 has finished for PR 11991 at commit 9a11daa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. Sure.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@andrewor14
Copy link
Contributor

Looks great!

@SparkQA
Copy link

SparkQA commented Mar 30, 2016

Test build #54554 has finished for PR 11991 at commit 9a4f356.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 31, 2016

Test build #54565 has finished for PR 11991 at commit 2e16ce4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@andrewor14
Copy link
Contributor

@dilipbiswal can you rebase? I think SparkQl is now deleted.

@dilipbiswal
Copy link
Contributor Author

@andrewor14 Hi Andrew, just rebased. - FYI

@SparkQA
Copy link

SparkQA commented Mar 31, 2016

Test build #54651 has finished for PR 11991 at commit bafca92.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dilipbiswal
Copy link
Contributor Author

cc @andrewor14

@hvanhovell
Copy link
Contributor

LGTM

@hvanhovell
Copy link
Contributor

Merging to master. Thanks!

@asfgit asfgit closed this in 0b04f8f Apr 1, 2016
@dilipbiswal
Copy link
Contributor Author

@hvanhovell Thank you, Herman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants