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-27016][SQL][BUILD] Treat all antlr warnings as errors while generating parser from the sql grammar file. #23925

Closed
wants to merge 1 commit into from

Conversation

dilipbiswal
Copy link
Contributor

@dilipbiswal dilipbiswal commented Feb 28, 2019

What changes were proposed in this pull request?

Use the maven plugin option treatWarningsAsErrors to make sure the warnings are treated as errors while generating the parser file. In the absence of it, we may inadvertently introducing problems while making grammar changes. Please refer to PR-23897 to know more about the context.

How was this patch tested?

We can use two ways to build Spark 1) sbt 2) Maven
This PR, we made a change to configure the maven antlr plugin to include a parameter that makes antlr4 report error on warning. However, when spark is built using sbt, we use the sbt antlr plugin which does not allow us to pass this additional compilation flag. More info on sbt-antlr plugin can be found at link
In summary, this fix only applicable when we use maven to build.

@dilipbiswal dilipbiswal changed the title [SPARK-27016] Treat all antlr warnings as errors while generating parser from the sql grammar file. [SPARK-27016][SQL][BUILD] Treat all antlr warnings as errors while generating parser from the sql grammar file. Feb 28, 2019
@dilipbiswal
Copy link
Contributor Author

dilipbiswal commented Feb 28, 2019

I am expecting the build to fail due to an existing issue with the grammar file. After 23897 is merged, the error should go away.

@dilipbiswal
Copy link
Contributor Author

@srowen Hi Sean, need your help here. In my dev environment, when i use maven to build, i get the expected result and the build fails with the following error :

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:784:90: implicit definition of token SCHEMA in parser
[WARNING] /Users/dbiswal/mygit/apache/spark/org/apache/spark/sql/catalyst/parser/SqlBase.g4 [784:90]: implicit definition of token SCHEMA in parser
[ERROR] error(10):  warning treated as error
[INFO] ------------------------------------------------------------------------

However, from jenkins, it uses sbt and the build seems to skip pass this error/warning. Would you know what may be happening and how to fix this ? Appreciate your help.

@srowen
Copy link
Member

srowen commented Feb 28, 2019

Hm, I'm not sure. SBT 'reads' the pom file via a plugin, but I think the translation is imperfect. I'm still surprised. Sometimes we've worked around it by duplicating the config and hacking it into the SBT build. I'm not sure how to do it here.

We use Maven (also) in the test jobs that aren't PR builders, so this would still get caught eventually, and I presume is a pretty rare thing to update the schemas. We might just live with it unless someone has a better idea.

(Also, I wonder if we should make the PR builders use Maven, as it's the build of record really)

@dilipbiswal
Copy link
Contributor Author

dilipbiswal commented Feb 28, 2019

@srowen Thanks a lot for quick response.

Also, I wonder if we should make the PR builders use Maven, as it's the build of record really.

IMHO we should especially if sbt swallows exceptions/errors like this :-)

@dilipbiswal
Copy link
Contributor Author

@srowen Update : I looked around. In my understanding, we seem to use the sbt-antlr plugin to generate the parser when compiling through sbt (SparkBuild.scala). Unfortunately, there is no (at least i couldn't find) "fail build on warning" option that is exposed through the sbt-antlr plugin
Here is link to the plugin source.

@maropu
Copy link
Member

maropu commented Mar 1, 2019

cc: @shaneknapp @gatorsmile

@SparkQA
Copy link

SparkQA commented Mar 1, 2019

Test build #102876 has finished for PR 23925 at commit df0f530.

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

@dongjoon-hyun
Copy link
Member

@dilipbiswal . Could you update the PR description Verified this after applying PR part according to the latest #23925 (comment) ?

@dilipbiswal
Copy link
Contributor Author

@dongjoon-hyun Sure.. Let me do it.

@SparkQA
Copy link

SparkQA commented Mar 2, 2019

Test build #4586 has started for PR 23925 at commit df0f530.

@dilipbiswal
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Mar 3, 2019

Test build #102942 has finished for PR 23925 at commit df0f530.

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

@srowen
Copy link
Member

srowen commented Mar 3, 2019

Merged to master

@srowen srowen closed this in 04ad559 Mar 3, 2019
@dilipbiswal
Copy link
Contributor Author

Thanks a lot @srowen.
FYI. I have opened an issue against the sbt antlr plugin here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants