Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

dilipbiswal
Copy link
Contributor

@dilipbiswal dilipbiswal commented Feb 26, 2019

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

@dilipbiswal
Copy link
Contributor Author

cc @maropu Kindly check if this looks okay to you.

@dilipbiswal dilipbiswal changed the title [SPARK-26215][FOLLOW-UP][MINOR] Fix the warning from ANTR4 [SPARK-26215][SQL][FOLLOW-UP][MINOR] Fix the warning from ANTR4 Feb 26, 2019
Copy link
Member

@maropu maropu left a 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.

@maropu
Copy link
Member

maropu commented Feb 26, 2019

Pending, Jenkins

@dilipbiswal
Copy link
Contributor Author

retest this please

@@ -1014,7 +1014,8 @@ SORTED: 'SORTED';
PURGE: 'PURGE';
INPUTFORMAT: 'INPUTFORMAT';
OUTPUTFORMAT: 'OUTPUTFORMAT';
DATABASE: 'DATABASE' | 'SCHEMA';
SCHEMA: 'SCHEMA';
DATABASE: 'DATABASE';
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

Choose a reason for hiding this comment

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

+1

@SparkQA
Copy link

SparkQA commented Feb 27, 2019

Test build #102791 has finished for PR 23897 at commit ae2adcd.

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

@@ -78,11 +78,11 @@ singleTableSchema
statement
: query #statementDefault
| USE db=identifier #use
| CREATE DATABASE (IF NOT EXISTS)? identifier
| CREATE database (IF NOT EXISTS)? identifier
Copy link
Contributor

@beliefer beliefer Feb 27, 2019

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?

Copy link
Contributor Author

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.

@maropu
Copy link
Member

maropu commented Mar 1, 2019

LGTM (I checked the console log in Jenkins and I found no warning there)

@maropu
Copy link
Member

maropu commented Mar 1, 2019

@dilipbiswal Ah, one more. Based on the Xiao's comment, can you add a simple test in PlanParserSuite to check if Schema can be parsed in antlr?

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

Copy link
Member

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.

@maropu
Copy link
Member

maropu commented Mar 1, 2019

LGTM, pending Jenkins.

@SparkQA
Copy link

SparkQA commented Mar 1, 2019

Test build #102893 has finished for PR 23897 at commit e3cb947.

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

@SparkQA
Copy link

SparkQA commented Mar 1, 2019

Test build #102895 has finished for PR 23897 at commit eb278c9.

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

@dongjoon-hyun
Copy link
Member

Thank you all. Merged to master.

@dilipbiswal
Copy link
Contributor Author

Thanks a lot @dongjoon-hyun

mccheah pushed a commit to palantir/spark that referenced this pull request May 15, 2019
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants