maropu commented on a change in pull request #23259: [SPARK-26215][SQL] Define 
reserved/non-reserved keywords based on the ANSI SQL standard
URL: https://github.com/apache/spark/pull/23259#discussion_r258854353
 
 

 ##########
 File path: docs/sql-reserved-and-non-reserved-key-words.md
 ##########
 @@ -0,0 +1,570 @@
+---
+layout: global
+title: SQL Reserved/Non-Reserved Key Words
+displayTitle: SQL Reserved/Non-Reserved Key Words
+---
+
+When `spark.sql.parser.ansi.enabled` is set to true (false by default), some 
keywords are reserved for Spark SQL.
+These reserved key words in this ANSI mode basically follow the ANSI SQL-2011 
standard, but it is slightly different between each other.
+A full list of reserved/non-reserved key words is as follows:
+
+<table class="table">
+  <tr><th rowspan="2" style="vertical-align: middle;"><b>Key Word</b></th><th 
colspan="2"><b>Spark SQL</b></th><th rowspan="2" style="vertical-align: 
middle;"><b>SQL-2011</b></th></tr>
+  <tr><th><b>ANSI mode</b></th><th><b>default mode</b></th></tr>
+  
<tr><td>ABS</td><td>non-reserved</td><td>non-reserved</td><td>reserved</td></tr>
+  
<tr><td>ABSOLUTE</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  
<tr><td>ACOS</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  
<tr><td>ACTION</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  
<tr><td>ADD</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  
<tr><td>AFTER</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  <tr><td>ALL</td><td>reserved</td><td>non-reserved</td><td>reserved</td></tr>
+  
<tr><td>ALLOCATE</td><td>non-reserved</td><td>non-reserved</td><td>reserved</td></tr>
+  
<tr><td>ALTER</td><td>non-reserved</td><td>non-reserved</td><td>reserved</td></tr>
+  
<tr><td>ANALYZE</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
+  <tr><td>AND</td><td>reserved</td><td>non-reserved</td><td>reserved</td></tr>
+  
<tr><td>ANTI</td><td>non-reserved</td><td>non-reserved</td><td>non-reserved</td></tr>
 
 Review comment:
   Yea, I noticed that... It seems we cannot move these keywords (`ANTI | FULL 
| INNER | LEFT | SEMI | RIGHT | NATURAL | JOIN | CROSS | ON | UNION | INTERSECT 
| EXCEPT | SETMINUS`) into `strictIdentifier` because  we need to parse some 
SQL texts, e.g., SELECT * FROM t1 CROSS JOIN t2. So, I just left the comment 
there: 
https://github.com/apache/spark/pull/23259/files#diff-8c1cb2af4aa1109e08481dae79052cc3R728
   
   To parse these SQL texts, `ansiReserved` and `ansiNonReserved` also cannot 
include these keywords, so I removed them in the latest fix.
   
   In short, IIUC we hold a rule below;
   ```
   //  All the ANTLR tokens except for some keywords (ANTI, FULL, INNER, LEFT, 
SEMI, RIGHT, NATURAL, JOIN, CROSS, ON,
   //          UNION, INTERSECT, EXCEPT, and SETMINUS)
   //      = UNION(`ansiReserved`, `ansiNonReserved`)
   //      = `nonReserved`
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to