Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Jun 12, 2020

What changes were proposed in this pull request?

This PR intends to move keywords ANTI, SEMI, and MINUS from reserved to non-reserved.

Why are the changes needed?

To comply with the ANSI/SQL standard.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added tests.

@maropu maropu changed the title [WIP][SPARK-26905][SQL][TESTS] Follow the SQL:2016 reserved keywords [WIP][SPARK-26905][SQL] Follow the SQL:2016 reserved keywords Jun 12, 2020
@SparkQA
Copy link

SparkQA commented Jun 12, 2020

Test build #123894 has finished for PR 28807 at commit 17b8f2c.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member Author

maropu commented Jun 12, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Jun 12, 2020

Test build #123896 has finished for PR 28807 at commit 17b8f2c.

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

@maropu
Copy link
Member Author

maropu commented Jun 12, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Jun 12, 2020

Test build #123929 has finished for PR 28807 at commit 17b8f2c.

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

@maropu
Copy link
Member Author

maropu commented Jun 12, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Jun 13, 2020

Test build #123946 has finished for PR 28807 at commit f8cbbb1.

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

Files.copy(is, tmpFile.toPath)
val reservedKeywordsInSql2016 = Files.readAllLines(tmpFile.toPath)
.asScala.filterNot(_.startsWith("--")).map(_.trim).toSet
assert(((reservedKeywordsInAnsiMode -- Set("!")) -- reservedKeywordsInSql2016).isEmpty)
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 noticed that, since NOT reserved, ! also reserved, too. (NOT: 'NOT' | '!';);

scala> sql("SET spark.sql.ansi.enabled=false")
scala> spark.sql("create table r2 (! int);")
res2: org.apache.spark.sql.DataFrame = []

scala> sql("SET spark.sql.ansi.enabled=true")
scala> spark.sql("create table r2 (! int);")
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input '!'(line 1, pos 17)
== SQL ==
create table r2 (! int);
-----------------^^^

@cloud-fan Is this expected? FYI: It seems PostgreSQL cannot accept ! in column names;

postgres=# create table r2 (! int);
2020-06-13 11:30:24.495 JST [36406] ERROR:  syntax error at or near "!" at character 18
2020-06-13 11:30:24.495 JST [36406] STATEMENT:  create table r2 (! int);
ERROR:  syntax error at or near "!"
LINE 1: create table r2 (! int);

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's intentional, but we can't break it now. If it's forbidden under ansi mode, I think it's good enough?

@SparkQA
Copy link

SparkQA commented Jun 13, 2020

Test build #123944 has finished for PR 28807 at commit 17b8f2c.

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

@SparkQA
Copy link

SparkQA commented Jun 13, 2020

Test build #123959 has finished for PR 28807 at commit 086a2ba.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member Author

maropu commented Jun 13, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Jun 13, 2020

Test build #123971 has finished for PR 28807 at commit 086a2ba.

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

@maropu maropu changed the title [WIP][SPARK-26905][SQL] Follow the SQL:2016 reserved keywords [SPARK-26905][SQL] Follow the SQL:2016 reserved keywords Jun 15, 2020
s"${reservedKeywordsInAnsiMode.size} found.")
}

test("should follow reserved keywords in SQL:2016") {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make the test name clear? What we are testing is: reserved keywords in Spark are also reserved in SQL 2016

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks clearer, okay, I'll update. Thanks!

Files.copy(is, tmpFile.toPath)
val reservedKeywordsInSql2016 = Files.readAllLines(tmpFile.toPath)
.asScala.filterNot(_.startsWith("--")).map(_.trim).toSet
assert(((reservedKeywordsInAnsiMode -- Set("!")) -- reservedKeywordsInSql2016).isEmpty)
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 symbol is not a keyword. Can we update symbolsToExpandIntoDifferentLiterals?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, will do.


test("check # of reserved keywords") {
val numReservedKeywords = 78
val numReservedKeywords = 74
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: ANTI, SEMI, MINUS, and ! are removed.

@SparkQA
Copy link

SparkQA commented Jun 15, 2020

Test build #124031 has finished for PR 28807 at commit eeceb30.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Jun 15, 2020

Test build #124041 has finished for PR 28807 at commit eeceb30.

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

@maropu maropu closed this in 3698a14 Jun 15, 2020
@maropu
Copy link
Member Author

maropu commented Jun 15, 2020

Thanks! Merged to master.
Note that, since this fix conflicts with branch-3.0, I'll open another PR for that.

maropu added a commit that referenced this pull request Jun 15, 2020
### What changes were proposed in this pull request?

This PR intends to move keywords `ANTI`, `SEMI`, and `MINUS` from reserved to non-reserved.

### Why are the changes needed?

To comply with the ANSI/SQL standard.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Added tests.

Closes #28807 from maropu/SPARK-26905-2.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: Takeshi Yamamuro <[email protected]>
@maropu
Copy link
Member Author

maropu commented Jun 15, 2020

Ah, the cause of the conflict is that I didn't merge #28802 into branch-3.0. Since #28802 is just for test improvements, I've cherry-picked this commit and #28802 together into branch-3.0. If any problem, please let me know.

@dongjoon-hyun
Copy link
Member

No problem. It looks okay, @maropu .

@maropu
Copy link
Member Author

maropu commented Jun 16, 2020

Thanks for the check, @dongjoon-hyun .

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants