cloud-fan commented on a change in pull request #26190: [SPARK-29532][SQL] 
simplify interval string parsing
URL: https://github.com/apache/spark/pull/26190#discussion_r336943077
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -100,6 +101,15 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
     withOrigin(ctx)(StructType(visitColTypeList(ctx.colTypeList)))
   }
 
+  override def visitSingleInterval(ctx: SingleIntervalContext): 
CalendarInterval = {
+    withOrigin(ctx) {
+      val intervals = ctx.intervalField.asScala.map(visitIntervalField)
+      validate(intervals.nonEmpty,
+        "at least one time unit should be given for interval literal", ctx)
+      intervals.reduce(_.add(_))
 
 Review comment:
   This is how it was done in the parser. It's indeed different from 
`CalendarInterval.fromCaseInsensitiveString`. Let me see how to follow 
`CalendarInterval` and make the parser more efficient.

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