-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-26215][SQL][FOLLOW-UP][MINOR] Fix the warning from ANTR4 #23897
Conversation
cc @maropu Kindly check if this looks okay to you. |
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.
Thanks! Looks good to me.
Pending, Jenkins |
retest this please |
@@ -1014,7 +1014,8 @@ SORTED: 'SORTED'; | |||
PURGE: 'PURGE'; | |||
INPUTFORMAT: 'INPUTFORMAT'; | |||
OUTPUTFORMAT: 'OUTPUTFORMAT'; | |||
DATABASE: 'DATABASE' | 'SCHEMA'; | |||
SCHEMA: 'SCHEMA'; | |||
DATABASE: 'DATABASE'; |
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.
Previously, token schema
is synonymous with token database
.
Won't this change drop support of commands like CREATE SCHEMA ...
, ALTER SCHEMA ...
, DROP SCHEMA ...
?
scala> sql("create schema test1")
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input 'create schema'(line 1, pos 7)
== SQL ==
create schema test1
-------^^^
at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:243)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:119)
at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:48)
at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:69)
at org.apache.spark.sql.SparkSession.$anonfun$sql$1(SparkSession.scala:653)
at org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:111)
at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:653)
... 49 elided
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.
@viirya Thanks a lot. Actually i hadn't run the tests locally for this fix and relied on jenkins. Lets me see what to do here.. thanks again.
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 have a test to capture 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.
@gatorsmile Its a compile time warning. Is it possible to test 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.
@gatorsmile Hi Sean, i found out, one of the way we can get this checked is by failing the build on a warning. I tried using treatWarningsAsErrors
option. Do you think, this is a acceptable solution ? If so, should this be under a separate ticket as, if something goes wrong with this option, we can rollback that fix. Please let me know what you think.
https://www.antlr.org/api/maven-plugin/latest/antlr4-mojo.html
Here is the error when i used this option.
INFO]
[INFO] --- antlr4-maven-plugin:4.7.1:antlr4 (default) @ spark-catalyst_2.12 ---
[INFO] ANTLR 4: Processing source directory /Users/dbiswal/mygit/apache/spark/sql/catalyst/src/main/antlr4
[INFO] Processing grammar: org/apache/spark/sql/catalyst/parser/SqlBase.g4
[WARNING] warning(125): org/apache/spark/sql/catalyst/parser/SqlBase.g4:785:90: implicit definition of token SCHEMA in parser
[WARNING] /Users/dbiswal/mygit/apache/spark/org/apache/spark/sql/catalyst/parser/SqlBase.g4 [785:90]: implicit definition of token SCHEMA in parser
[ERROR] error(10): warning treated as error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.901 s
[INFO] Finished at: 2019-02-27T01:01:27-08:00
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.
@dilipbiswal if it's just for the antlr plugin, yes that's a good idea.
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.
@srowen Yeah.. its for the antlr plugin. Thank you.
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.
+1
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.
+1
Test build #102791 has finished for PR 23897 at commit
|
@@ -78,11 +78,11 @@ singleTableSchema | |||
statement | |||
: query #statementDefault | |||
| USE db=identifier #use | |||
| CREATE DATABASE (IF NOT EXISTS)? identifier | |||
| CREATE database (IF NOT EXISTS)? identifier |
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.
Should the keyword database
change to databaseTag
and reduce confuse?
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.
@beliefer I think database in lower case indicates a parser rule and different from database in upper case which is a lexer rule. We already have a precedence in our grammar file for "identifier". IMHO keeping it as database reads better.
LGTM (I checked the console log in Jenkins and I found no warning there) |
@dilipbiswal Ah, one more. Based on the Xiao's comment, can you add a simple test in |
assertEqual("ALTER DATABASE foo SET DBPROPERTIES ('x' = 'y')", | ||
parser.parsePlan("ALTER SCHEMA foo SET DBPROPERTIES ('x' = 'y')")) | ||
assertEqual("DESC DATABASE foo", parser.parsePlan("DESC SCHEMA foo")) | ||
|
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.
nit: remove this empty line.
LGTM, pending Jenkins. |
Test build #102893 has finished for PR 23897 at commit
|
Test build #102895 has finished for PR 23897 at commit
|
Thank you all. Merged to master. |
Thanks a lot @dongjoon-hyun |
## What changes were proposed in this pull request? I see the following new warning from ANTR4 after SPARK-26215 after it added `SCHEMA` keyword in the reserved/unreserved list. This is a minor PR to cleanup the warning. ``` WARNING] warning(125): org/apache/spark/sql/catalyst/parser/SqlBase.g4:784:90: implicit definition of token SCHEMA in parser [WARNING] .../apache/spark/org/apache/spark/sql/catalyst/parser/SqlBase.g4 [784:90]: implicit definition of token SCHEMA in parser ``` ## How was this patch tested? Manually built catalyst after the fix to verify Closes apache#23897 from dilipbiswal/minor_parser_token. Authored-by: Dilip Biswal <dbiswal@us.ibm.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
What changes were proposed in this pull request?
I see the following new warning from ANTR4 after SPARK-26215 after it added
SCHEMA
keyword in the reserved/unreserved list. This is a minor PR to cleanup the warning.How was this patch tested?
Manually built catalyst after the fix to verify