sunchao commented on code in PR #7811:
URL: https://github.com/apache/datafusion-comet/pull/7811#discussion_r4805089348


##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -1782,6 +1782,28 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
     }
   }
 
+  test("decimal addition and subtraction align extreme negative scales 
natively") {
+    withSQLConf(
+      "spark.sql.legacy.allowNegativeScaleOfDecimal" -> "true",
+      SQLConf.ANSI_ENABLED.key -> "true",
+      CometConf.COMET_SCALA_UDF_CODEGEN_ENABLED.key -> "false") {
+      withTable("decimal_align") {
+        sql("CREATE TABLE decimal_align(flag BOOLEAN, n INT) USING parquet")
+        sql("INSERT INTO decimal_align VALUES (true, 7), (false, 7), (false, 
NULL)")
+        val coarseType = DecimalType(19, -128)
+        val nonzero = lit(new java.math.BigDecimal("1E+128")).cast(coarseType)
+        val coarse = when(col("flag"), 
nonzero).otherwise(lit(0).cast(coarseType))
+        val fine = col("n").cast(DecimalType(3, 0))
+        val input = spark.table("decimal_align")
+        val query = input.select(try_add(coarse, fine), try_subtract(fine, 
coarse))
+        checkSparkAnswerAndOperator(query, Seq(classOf[CometProjectExec]))
+        checkCometAnswer(
+          query,
+          Seq(Row(null, null), Row(BigDecimal(7), BigDecimal(7)), Row(null, 
null)))

Review Comment:
   Removed the hard-coded rows in 
[092eb7f](https://github.com/apache/datafusion-comet/commit/092eb7f5db4dabd4e5d8d18703174370d5446ed2).
 `checkSparkAnswerAndOperator` already compares all three rows with Spark and 
checks that the projection runs in Comet.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to