kazuyukitanimura commented on code in PR #1512:
URL: https://github.com/apache/datafusion-comet/pull/1512#discussion_r1991925624


##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -655,8 +655,23 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde with CometExprShim
           (builder, mathExpr) => builder.setIntegralDivide(mathExpr))
 
         if (divideExpr.isDefined) {
+          val childExpr = if (dataType.isInstanceOf[DecimalType]) {
+            // check overflow for decimal type
+            val builder = ExprOuterClass.CheckOverflow.newBuilder()
+            builder.setChild(divideExpr.get)
+            builder.setFailOnError(false)

Review Comment:
   Is it always `false` even for ANSI mode?



##########
spark/src/test/scala/org/apache/comet/CometExpressionSuite.scala:
##########
@@ -2734,4 +2734,18 @@ class CometExpressionSuite extends CometTestBase with 
AdaptiveSparkPlanHelper {
     }
   }
 
+  test("test integral divide overflow for decimal") {

Review Comment:
   would you mind testing both ANSI and non-ANSI?



##########
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala:
##########
@@ -655,8 +655,23 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde with CometExprShim
           (builder, mathExpr) => builder.setIntegralDivide(mathExpr))
 
         if (divideExpr.isDefined) {
+          val childExpr = if (dataType.isInstanceOf[DecimalType]) {
+            // check overflow for decimal type
+            val builder = ExprOuterClass.CheckOverflow.newBuilder()
+            builder.setChild(divideExpr.get)
+            builder.setFailOnError(false)
+            builder.setDatatype(serializeDataType(dataType).get)
+            Some(
+              ExprOuterClass.Expr
+                .newBuilder()
+                .setCheckOverflow(builder)
+                .build())
+          } else {
+            divideExpr
+          }
+
           // cast result to long
-          castToProto(expr, None, LongType, divideExpr.get, 
CometEvalMode.LEGACY)
+          castToProto(expr, None, LongType, childExpr.get, 
CometEvalMode.LEGACY)

Review Comment:
   Could be just naming issue but why it is `child`?



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to