cloud-fan commented on a change in pull request #29064:
URL: https://github.com/apache/spark/pull/29064#discussion_r453518043



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala
##########
@@ -90,6 +93,51 @@ class SparkSqlAstBuilder(conf: SQLConf) extends 
AstBuilder(conf) {
     ResetCommand
   }
 
+  /**
+   * Create a [[SetCommand]] logical plan to set 
[[SQLConf.SESSION_LOCAL_TIMEZONE]]
+   * Example SQL :
+   * {{{
+   *   SET TIME ZONE LOCAL;
+   *   SET TIME ZONE 'Asia/Shanghai';
+   *   SET TIME ZONE INTERVAL 10 HOURS;
+   * }}}
+   */
+  override def visitSetTimeZone(ctx: SetTimeZoneContext): LogicalPlan = 
withOrigin(ctx) {
+    val key = SQLConf.SESSION_LOCAL_TIMEZONE.key
+    if (ctx.interval != null) {
+      val interval = parseIntervalLiteral(ctx.interval)
+      if (interval.months != 0 || interval.days != 0 ||
+        math.abs(interval.microseconds) > 18 * 
DateTimeConstants.MICROS_PER_HOUR) {
+        throw new ParseException("The interval value must be in the range of 
[-18, +18] hours",

Review comment:
       shall we also fail for things like `INTERVAL 1 MICROSECOND`?




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



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

Reply via email to