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_r258858073
 
 

 ##########
 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:
   In the master, these keywords (ANTI, CROSS, ...) are reserved only for 
[tableAlias(strictIdentifier)](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4#L529),
 so `sql("select * from (select 1) as anti")` fails, but `sql("select 1 as anti 
from (select 1)")` passes.
   
   In `sql-reserved-and-non-reserved-key-words.md`, since `strictIdentifier` is 
only used in `tableAlias` and `identifier` is used in all the other cases, I 
just list up the reserved/non-reserved keywords for not `strictIdentifier` but 
`identifier`. 

----------------------------------------------------------------
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