You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/03/29 05:56:27 UTC

[GitHub] [spark] MaxGekk commented on a diff in pull request #40565: [SPARK-42873][SQL] Define Spark SQL types as keywords

MaxGekk commented on code in PR #40565:
URL: https://github.com/apache/spark/pull/40565#discussion_r1151426255


##########
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4:
##########
@@ -993,14 +993,34 @@ colPosition
     : position=FIRST | position=AFTER afterCol=errorCapturingIdentifier
     ;
 
+type
+    : BOOLEAN
+    | TINYINT | BYTE
+    | SMALLINT | SHORT
+    | INT | INTEGER
+    | BIGINT | LONG
+    | FLOAT | REAL
+    | DOUBLE
+    | DATE
+    | TIMESTAMP | TIMESTAMP_NTZ | TIMESTAMP_LTZ
+    | STRING
+    | CHARACTER | CHAR
+    | VARCHAR
+    | BINARY
+    | DECIMAL | DEC | NUMERIC
+    | VOID
+    | INTERVAL
+    | ARRAY | STRUCT | MAP
+    ;

Review Comment:
   `identifier` doesn't catch any bad input as it is defined:
   ```
   IDENTIFIER
       : (LETTER | DIGIT | '_')+
       ;
   ```
   
   Even on Spark 3.3, sometimes we get `Syntax error`:
   ```sql
   Welcome to
         ____              __
        / __/__  ___ _____/ /__
       _\ \/ _ \/ _ `/ __/  '_/
      /___/ .__/\_,_/_/ /_/\_\   version 3.3.2
         /_/
   
   scala> sql("CREATE TABLE tbl(a #abc)")
   org.apache.spark.sql.catalyst.parser.ParseException:
   Syntax error at or near '#': extra input '#'(line 1, pos 19)
   
   == SQL ==
   CREATE TABLE tbl(a #abc)
   -------------------^^^
   ```
   or sometimes:
   ```sql
   scala> sql("CREATE TABLE tbl(a 1abc)")
   org.apache.spark.sql.catalyst.parser.ParseException:
   DataType 1abc is not supported.(line 1, pos 19)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org