cloud-fan commented on a change in pull request #23880: [SPARK-26976][SQL] 
Forbid reserved keywords as table identifiers when ANSI mode is on
URL: https://github.com/apache/spark/pull/23880#discussion_r259786314
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -1404,6 +1404,15 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
     }
   }
 
+  override def visitIdentifier(ctx: IdentifierContext): String = 
withOrigin(ctx) {
+    val keyword = ctx.getText
+    if (ctx.ansiReserved() != null) {
+      throw new ParseException(
+        s"'$keyword' is reserved and you cannot use this keyword as an 
identifier.", ctx)
 
 Review comment:
   ah good point!
   
   But if don't forbid CURRENT_TIMESTAMP as column name, `SELECT 
CURRENT_TIMESTAMP FROM t` is ambiguous.
   
   It looks to me that we should create an entry for `CURRENT_TIMESTAMP` 
directly in the antlr file, and return the corresponding function for it in 
`AstBuilder.scala`

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