You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/22 13:46:12 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #32296: [SPARK-35187][SQL] Failure on minimal interval literal

MaxGekk commented on a change in pull request #32296:
URL: https://github.com/apache/spark/pull/32296#discussion_r618415910



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -2395,13 +2395,22 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with SQLConfHelper with Logg
    */
   override def visitUnitToUnitInterval(ctx: UnitToUnitIntervalContext): CalendarInterval = {
     withOrigin(ctx) {
-      val value = Option(ctx.intervalValue.STRING).map(string).getOrElse {
+      val value = Option(ctx.intervalValue.STRING).map(string).map { interval =>
+        val sign = interval.startsWith("-")
+        val minus = ctx.intervalValue().MINUS() != null
+        (sign, minus) match {
+          case (true, true) => interval.replaceFirst("-", "")
+          case (false, true) => s"-$interval"
+          case (_, false) => interval
+        }
+      }.getOrElse {
         throw QueryParsingErrors.invalidFromToUnitValueError(ctx.intervalValue)
       }
+      println(value)

Review comment:
       Could you remove println




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



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