lipzhu commented on a change in pull request #24802: [SPARK-27949][SQL]Support 
ANSI SQL grammar `substring(string_expression from n1 [for n2])`
URL: https://github.com/apache/spark/pull/24802#discussion_r291038686
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -1333,6 +1333,20 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
     }
   }
 
+  /**
+   * Create a Substring/Substr expression.
+   */
+  override def visitSubstring(ctx: SubstringContext): Expression = 
withOrigin(ctx) {
+    val field = ctx.field
+    val pos = ctx.pos
+    val len = ctx.len
+    if (len != null) {
+      Substring(expression(field), expression(pos), expression(len))
+    } else {
+      new Substring(expression(field), expression(pos))
 
 Review comment:
   Add a default value for the case class and delete the verbose constructor 
may affect `Right` expression. Do we really to do this change in this PR?

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