From 6d0b46c88452a90a380b6f78da6fa2f0045b17ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 2 Oct 2024 15:57:39 +0200 Subject: [PATCH] Add Round.ansiEnabled to be added th protobuf as fail_on_error --- native/proto/src/proto/expr.proto | 1 + .../apache/comet/serde/QueryPlanSerde.scala | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/native/proto/src/proto/expr.proto b/native/proto/src/proto/expr.proto index 88940f386..61656c0cc 100644 --- a/native/proto/src/proto/expr.proto +++ b/native/proto/src/proto/expr.proto @@ -404,6 +404,7 @@ message ScalarFunc { string func = 1; repeated Expr args = 2; DataType return_type = 3; + bool fail_on_error = 4; } message BitwiseAnd { diff --git a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala index 51b32b7df..b851a7e9a 100644 --- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala +++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala @@ -1924,7 +1924,12 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim // `scale` must be Int64 type in DataFusion val scaleExpr = exprToProtoInternal(Literal(_scale.toLong, LongType), inputs) val optExpr = - scalarExprToProtoWithReturnType("round", r.dataType, childExpr, scaleExpr) + scalarExprToProtoWithReturnTypeAnsi( + "round", + r.dataType, + r.ansiEnabled, + childExpr, + scaleExpr) optExprWithInfo(optExpr, expr, r.child) } @@ -2610,6 +2615,20 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim } } + def scalarExprToProtoWithReturnTypeAnsi( + funcName: String, + returnType: DataType, + failOnError: Boolean, + args: Option[Expr]*): Option[Expr] = { + val builder = ExprOuterClass.ScalarFunc.newBuilder() + builder.setFunc(funcName) + builder.setFailOnError(failOnError) + serializeDataType(returnType).flatMap { t => + builder.setReturnType(t) + scalarExprToProto0(builder, args: _*) + } + } + def scalarExprToProto(funcName: String, args: Option[Expr]*): Option[Expr] = { val builder = ExprOuterClass.ScalarFunc.newBuilder() builder.setFunc(funcName)