AngersZhuuuu commented on a change in pull request #30421:
URL: https://github.com/apache/spark/pull/30421#discussion_r584844133
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -509,10 +509,16 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with
SQLConfHelper with Logg
protected def visitStringConstant(
ctx: ConstantContext,
legacyNullAsString: Boolean): String = withOrigin(ctx) {
- ctx match {
- case _: NullLiteralContext if !legacyNullAsString => null
- case s: StringLiteralContext => createString(s)
- case o => o.getText
+ expression(ctx) match {
+ case Literal(null, _) if !legacyNullAsString => null
+ case l @ Literal(null, _) => l.toString
+ case l: Literal =>
+ // TODO For v2 commands, we will cast the string back to its actual
value,
+ // which is a waste and can be improved in the future.
+ Cast(l, StringType,
Some(SQLConf.get.sessionLocalTimeZone)).eval().toString
+ case _ =>
+ throw new IllegalArgumentException("Only support convert Literal to
string when visit" +
Review comment:
Done
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]