Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Nov 21, 2019

What changes were proposed in this pull request?

This pr is to add a new config only for an optional INTERVAL clause. In the master, this feature is enabled when spark.sql.ansi.enabled=true. This pr proposes to split off the optional interval flag from spark.sql.ansi.enabled.

This comes from the @cloud-fan suggestion: #26584 (comment)

Why are the changes needed?

Actually, an INTERVAL keyword is not optional in the ANSI/SQL standard.

<interval literal> ::=
  INTERVAL [ <sign> ] <interval string> <interval qualifier>

<interval string> ::=
  <quote> <unquoted interval string> <quote>

Does this PR introduce any user-facing change?

No.

How was this patch tested?

No.

@maropu
Copy link
Member Author

maropu commented Nov 21, 2019

cc: @cloud-fan @gengliangwang

@cloud-fan
Copy link
Contributor

one correction: the SQL standard actually requires the INTERVAL prefix

<interval literal> ::=
  INTERVAL [ <sign> ] <interval string> <interval qualifier>

<interval string> ::=
  <quote> <unquoted interval string> <quote>

}

val OPTIONAL_INTERVAL =
buildConf("spark.sql.optionalInterval")
Copy link
Contributor

Choose a reason for hiding this comment

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

let's put it under the spark.sql.parser namespace

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@maropu
Copy link
Member Author

maropu commented Nov 21, 2019

one correction: the SQL standard actually requires the INTERVAL prefix

Oh! I did misunderstand that.... thanks for the correction, @cloud-fan

@maropu
Copy link
Member Author

maropu commented Nov 21, 2019

The PR descripion updated based on the suggsetion above.

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114223 has finished for PR 26623 at commit 6d0223e.

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

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114215 has finished for PR 26623 at commit 5e20371.

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

lexer.addErrorListener(ParseErrorListener)
lexer.legacy_setops_precedence_enbled = conf.setOpsPrecedenceEnforced
lexer.SQL_standard_keyword_behavior = SQLStandardKeywordBehavior
lexer.optional_interval = conf.optionalInterval
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be dialect == Spark && ansi == true && optionalInterval

For pgsql diaelct, INTERVAL can't be optional. for non-ansi mode, year/month/day... are not reserved keywords and we can't ommit INTERVAL prefix anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

}

val OPTIONAL_INTERVAL =
buildConf("spark.sql.parser.optionalInterval")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe "optionalIntervalPrefix"?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114235 has finished for PR 26623 at commit 02f54fd.

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

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114237 has finished for PR 26623 at commit 54a1f07.

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

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114228 has finished for PR 26623 at commit d53ec87.

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

@maropu maropu force-pushed the OptinalInterval branch 2 times, most recently from 354b7a8 to a23ee2c Compare November 21, 2019 12:16
// into the head in this test.
val importedTestCaseName = comments.filter(_.startsWith("--IMPORT ")).map(_.substring(9))
val importedCode = importedTestCaseName.flatMap { testCaseName =>
val importedTestCaseNames = comments.filter(_.startsWith("--IMPORT ")).map(_.substring(9))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not related to this pr though, I found the misleading name here...

@@ -1,17 +1,6 @@
--SET spark.sql.parser.optionalIntervalPrefix=false
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 still need this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just checked if we could turn off the optional prefix with ansi enabled. I personally think keeping this is better because the parser logic is a bit complicated for the combination about ansi + optionalIntervalPrefix...

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114241 has finished for PR 26623 at commit 5868ef1.

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

@SparkQA
Copy link

SparkQA commented Nov 21, 2019

Test build #114240 has finished for PR 26623 at commit 354b7a8.

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

@SparkQA
Copy link

SparkQA commented Nov 22, 2019

Test build #114257 has finished for PR 26623 at commit 7e63c0f.

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

@cloud-fan
Copy link
Contributor

sorry to have this proposal at this stage: can we drop this feature? It looks only useful when we have mysql/hive dialect someday, but I don't think it's going to happen in the near future. Even pgsql dialect is far away from completion.

@maropu
Copy link
Member Author

maropu commented Nov 23, 2019

ok

@maropu maropu closed this Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants