MaxGekk commented on a change in pull request #23541: [SPARK-26618][SQL] Make 
typed Timestamp/Date literals consistent to casting
URL: https://github.com/apache/spark/pull/23541#discussion_r248575220
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -1555,9 +1554,25 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
     try {
       valueType match {
         case "DATE" =>
-          Literal(Date.valueOf(value))
+          val castedValue = Cast(
+            Literal(value),
+            DateType,
+            Some(SQLConf.get.sessionLocalTimeZone)).eval()
+          if (castedValue == null) {
+            throw new ParseException(s"Cannot parse the date value: ${value}", 
ctx)
 
 Review comment:
   Replaced

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to