[spark] branch master updated: [SPARK-26215][SQL] Define reserved/non-reserved keywords based on the ANSI SQL standard

2019-02-22 Thread yamamuro
This is an automated email from the ASF dual-hosted git repository.

yamamuro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
 new 967e4cb  [SPARK-26215][SQL] Define reserved/non-reserved keywords 
based on the ANSI SQL standard
967e4cb is described below

commit 967e4cb0112e2dd94bc75251c23bb9e854ee97a0
Author: Takeshi Yamamuro 
AuthorDate: Sat Feb 23 08:38:47 2019 +0900

[SPARK-26215][SQL] Define reserved/non-reserved keywords based on the ANSI 
SQL standard

## What changes were proposed in this pull request?
This pr targeted to define reserved/non-reserved keywords for Spark SQL 
based on the ANSI SQL standards and the other database-like systems (e.g., 
PostgreSQL). We assume that they basically follow the ANSI SQL-2011 standard, 
but it is slightly different between each other. Therefore, this pr documented 
all the keywords in `docs/sql-reserved-and-non-reserved-key-words.md`.

NOTE: This pr only added a small set of keywords as reserved ones and these 
keywords are reserved in all the ANSI SQL standards (SQL-92, SQL-99, SQL-2003, 
SQL-2008, SQL-2011, and SQL-2016) and PostgreSQL. This is because there is room 
to discuss which keyword should be reserved or not, .e.g., interval units (day, 
hour, minute, second, ...) are reserved in the ANSI SQL standards though, they 
are not reserved in PostgreSQL. Therefore, we need more researches about the 
other database-lik [...]

References:
 - The reserved/non-reserved SQL keywords in the ANSI SQL standards: 
https://developer.mimer.com/wp-content/uploads/2018/05/Standard-SQL-Reserved-Words-Summary.pdf
 - SQL Key Words in PostgreSQL: 
https://www.postgresql.org/docs/current/sql-keywords-appendix.html

## How was this patch tested?
Added tests in `TableIdentifierParserSuite`.

Closes #23259 from maropu/SPARK-26215-WIP.

Authored-by: Takeshi Yamamuro 
Signed-off-by: Takeshi Yamamuro 
---
 docs/_data/menu-sql.yaml   |   2 +
 docs/sql-reserved-and-non-reserved-keywords.md | 574 +
 .../apache/spark/sql/catalyst/parser/SqlBase.g4| 127 +++--
 .../spark/sql/catalyst/parser/ParseDriver.scala|   2 +
 .../org/apache/spark/sql/internal/SQLConf.scala|   8 +
 5 files changed, 675 insertions(+), 38 deletions(-)

diff --git a/docs/_data/menu-sql.yaml b/docs/_data/menu-sql.yaml
index cd065ea..9bbb115 100644
--- a/docs/_data/menu-sql.yaml
+++ b/docs/_data/menu-sql.yaml
@@ -70,6 +70,8 @@
   url: sql-migration-guide-upgrade.html
 - text: Compatibility with Apache Hive
   url: sql-migration-guide-hive-compatibility.html
+- text: SQL Reserved/Non-Reserved Keywords
+  url: sql-reserved-and-non-reserved-keywords.html
 - text: Reference
   url: sql-reference.html
   subitems:
diff --git a/docs/sql-reserved-and-non-reserved-keywords.md 
b/docs/sql-reserved-and-non-reserved-keywords.md
new file mode 100644
index 000..321fb3f
--- /dev/null
+++ b/docs/sql-reserved-and-non-reserved-keywords.md
@@ -0,0 +1,574 @@
+---
+layout: global
+title: SQL Reserved/Non-Reserved Keywords
+displayTitle: SQL Reserved/Non-Reserved Keywords
+---
+
+In Spark SQL, there are 2 kinds of keywords: non-reserved and reserved. 
Non-reserved keywords have a
+special meaning only in particular contexts and can be used as identifiers 
(e.g., table names, view names,
+column names, column aliases, table aliases) in other contexts. Reserved 
keywords can't be used as
+table alias, but can be used as other identifiers.
+
+The list of reserved and non-reserved keywords can change according to the 
config
+`spark.sql.parser.ansi.enabled`, which is false by default.
+
+
+  KeywordSpark SQLSQL-2011
+  ANSI modedefault mode
+  
ABSnon-reservednon-reservedreserved
+  
ABSOLUTEnon-reservednon-reservednon-reserved
+  
ACOSnon-reservednon-reservednon-reserved
+  
ACTIONnon-reservednon-reservednon-reserved
+  
ADDnon-reservednon-reservednon-reserved
+  
AFTERnon-reservednon-reservednon-reserved
+  ALLreservednon-reservedreserved
+  
ALLOCATEnon-reservednon-reservedreserved
+  
ALTERnon-reservednon-reservedreserved
+  
ANALYZEnon-reservednon-reservednon-reserved
+  ANDreservednon-reservedreserved
+  ANTIreservedreservednon-reserved
+  ANYreservednon-reservedreserved
+  
AREnon-reservednon-reservedreserved
+  
ARCHIVEnon-reservednon-reservednon-reserved
+  
ARRAYnon-reservednon-reservedreserved
+  
ARRAY_AGGnon-reservednon-reservedreserved
+  
ARRAY_MAX_CARDINALITYnon-reservednon-reservedreserved
+  ASreservednon-reservedreserved
+  
ASCnon-reservednon-reservednon-reserved
+  
ASENSITIVEnon-reservednon-reservedreserved
+  
ASINnon-reservednon-reservedreserved
+  
ASSERTIONnon-reservednon-reservednon-reserved
+  
ASYMMETRICnon-reservednon-reservedreserved
+  
ATnon-reservednon-reservedreserved
+  
ATANnon-reservednon-reservednon-reserved
+  
ATOMICnon-reserved

[spark] branch master updated: [SPARK-26215][SQL] Define reserved/non-reserved keywords based on the ANSI SQL standard

2019-02-22 Thread yamamuro
This is an automated email from the ASF dual-hosted git repository.

yamamuro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
 new 967e4cb  [SPARK-26215][SQL] Define reserved/non-reserved keywords 
based on the ANSI SQL standard
967e4cb is described below

commit 967e4cb0112e2dd94bc75251c23bb9e854ee97a0
Author: Takeshi Yamamuro 
AuthorDate: Sat Feb 23 08:38:47 2019 +0900

[SPARK-26215][SQL] Define reserved/non-reserved keywords based on the ANSI 
SQL standard

## What changes were proposed in this pull request?
This pr targeted to define reserved/non-reserved keywords for Spark SQL 
based on the ANSI SQL standards and the other database-like systems (e.g., 
PostgreSQL). We assume that they basically follow the ANSI SQL-2011 standard, 
but it is slightly different between each other. Therefore, this pr documented 
all the keywords in `docs/sql-reserved-and-non-reserved-key-words.md`.

NOTE: This pr only added a small set of keywords as reserved ones and these 
keywords are reserved in all the ANSI SQL standards (SQL-92, SQL-99, SQL-2003, 
SQL-2008, SQL-2011, and SQL-2016) and PostgreSQL. This is because there is room 
to discuss which keyword should be reserved or not, .e.g., interval units (day, 
hour, minute, second, ...) are reserved in the ANSI SQL standards though, they 
are not reserved in PostgreSQL. Therefore, we need more researches about the 
other database-lik [...]

References:
 - The reserved/non-reserved SQL keywords in the ANSI SQL standards: 
https://developer.mimer.com/wp-content/uploads/2018/05/Standard-SQL-Reserved-Words-Summary.pdf
 - SQL Key Words in PostgreSQL: 
https://www.postgresql.org/docs/current/sql-keywords-appendix.html

## How was this patch tested?
Added tests in `TableIdentifierParserSuite`.

Closes #23259 from maropu/SPARK-26215-WIP.

Authored-by: Takeshi Yamamuro 
Signed-off-by: Takeshi Yamamuro 
---
 docs/_data/menu-sql.yaml   |   2 +
 docs/sql-reserved-and-non-reserved-keywords.md | 574 +
 .../apache/spark/sql/catalyst/parser/SqlBase.g4| 127 +++--
 .../spark/sql/catalyst/parser/ParseDriver.scala|   2 +
 .../org/apache/spark/sql/internal/SQLConf.scala|   8 +
 5 files changed, 675 insertions(+), 38 deletions(-)

diff --git a/docs/_data/menu-sql.yaml b/docs/_data/menu-sql.yaml
index cd065ea..9bbb115 100644
--- a/docs/_data/menu-sql.yaml
+++ b/docs/_data/menu-sql.yaml
@@ -70,6 +70,8 @@
   url: sql-migration-guide-upgrade.html
 - text: Compatibility with Apache Hive
   url: sql-migration-guide-hive-compatibility.html
+- text: SQL Reserved/Non-Reserved Keywords
+  url: sql-reserved-and-non-reserved-keywords.html
 - text: Reference
   url: sql-reference.html
   subitems:
diff --git a/docs/sql-reserved-and-non-reserved-keywords.md 
b/docs/sql-reserved-and-non-reserved-keywords.md
new file mode 100644
index 000..321fb3f
--- /dev/null
+++ b/docs/sql-reserved-and-non-reserved-keywords.md
@@ -0,0 +1,574 @@
+---
+layout: global
+title: SQL Reserved/Non-Reserved Keywords
+displayTitle: SQL Reserved/Non-Reserved Keywords
+---
+
+In Spark SQL, there are 2 kinds of keywords: non-reserved and reserved. 
Non-reserved keywords have a
+special meaning only in particular contexts and can be used as identifiers 
(e.g., table names, view names,
+column names, column aliases, table aliases) in other contexts. Reserved 
keywords can't be used as
+table alias, but can be used as other identifiers.
+
+The list of reserved and non-reserved keywords can change according to the 
config
+`spark.sql.parser.ansi.enabled`, which is false by default.
+
+
+  KeywordSpark SQLSQL-2011
+  ANSI modedefault mode
+  
ABSnon-reservednon-reservedreserved
+  
ABSOLUTEnon-reservednon-reservednon-reserved
+  
ACOSnon-reservednon-reservednon-reserved
+  
ACTIONnon-reservednon-reservednon-reserved
+  
ADDnon-reservednon-reservednon-reserved
+  
AFTERnon-reservednon-reservednon-reserved
+  ALLreservednon-reservedreserved
+  
ALLOCATEnon-reservednon-reservedreserved
+  
ALTERnon-reservednon-reservedreserved
+  
ANALYZEnon-reservednon-reservednon-reserved
+  ANDreservednon-reservedreserved
+  ANTIreservedreservednon-reserved
+  ANYreservednon-reservedreserved
+  
AREnon-reservednon-reservedreserved
+  
ARCHIVEnon-reservednon-reservednon-reserved
+  
ARRAYnon-reservednon-reservedreserved
+  
ARRAY_AGGnon-reservednon-reservedreserved
+  
ARRAY_MAX_CARDINALITYnon-reservednon-reservedreserved
+  ASreservednon-reservedreserved
+  
ASCnon-reservednon-reservednon-reserved
+  
ASENSITIVEnon-reservednon-reservedreserved
+  
ASINnon-reservednon-reservedreserved
+  
ASSERTIONnon-reservednon-reservednon-reserved
+  
ASYMMETRICnon-reservednon-reservedreserved
+  
ATnon-reservednon-reservedreserved
+  
ATANnon-reservednon-reservednon-reserved
+  
ATOMICnon-reserved