viirya commented on a change in pull request #26881: [SPARK-30252][SQL] Disallow negative scale of Decimal under ansi mode URL: https://github.com/apache/spark/pull/26881#discussion_r365484693
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala ########## @@ -63,9 +63,12 @@ object Literal { case s: String => Literal(UTF8String.fromString(s), StringType) case c: Char => Literal(UTF8String.fromString(c.toString), StringType) case b: Boolean => Literal(b, BooleanType) - case d: BigDecimal => Literal(Decimal(d), DecimalType.fromBigDecimal(d)) + case d: BigDecimal => + val decimal = Decimal(d) + Literal(decimal, DecimalType.fromDecimal(decimal)) case d: JavaBigDecimal => - Literal(Decimal(d), DecimalType(Math.max(d.precision, d.scale), d.scale())) + val decimal = Decimal(d) + Literal(decimal, DecimalType.fromDecimal(decimal)) Review comment: Two cases seems can be combined now. ---------------------------------------------------------------- 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