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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to