[GitHub] [spark] cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception
cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception URL: https://github.com/apache/spark/pull/26479#discussion_r345086978 ## File path: sql/core/src/test/resources/sql-tests/inputs/literals.sql ## @@ -153,3 +153,12 @@ select interval '1' year to second; select '1' year to second; select interval 1 year '2-1' year to month; select 1 year '2-1' year to month; +SET spark.sql.ansi.enabled=false; Review comment: not related to this PR, but it's really annoying to duplicate the test cases with ansi mode on and off. I'm wondering if we can introduce a `-- import abc.sql` directive so that we can easily import test cases in `ansi/interval.sql`, with several ansi specific test cases. cc @maropu 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 With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception
cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception URL: https://github.com/apache/spark/pull/26479#discussion_r345044456 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala ## @@ -1860,16 +1860,19 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging override def visitTypeConstructor(ctx: TypeConstructorContext): Literal = withOrigin(ctx) { val value = string(ctx.STRING) val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT) +val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("") +val isNegative = if (negativeSign == "-") true else false Review comment: do we really need to check `ctx.negativeSign.getText`? the parser rule is `MINUS? ...` 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 With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception
cloud-fan commented on a change in pull request #26479: [SPARK-29855][SQL] typed literals with negative sign with proper result or exception URL: https://github.com/apache/spark/pull/26479#discussion_r345040238 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala ## @@ -1860,16 +1860,19 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging override def visitTypeConstructor(ctx: TypeConstructorContext): Literal = withOrigin(ctx) { val value = string(ctx.STRING) val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT) +val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("") +val isNegative = if (negativeSign == "-") true else false Review comment: is it simply `val isNegative = ctx.negativeSign != null`? 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 With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org