Skip to content

Commit

Permalink
Add Round.ansiEnabled to be added th protobuf as fail_on_error
Browse files Browse the repository at this point in the history
  • Loading branch information
raulcd committed Oct 2, 2024
1 parent ce34e93 commit 6d0b46c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions native/proto/src/proto/expr.proto
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ message ScalarFunc {
string func = 1;
repeated Expr args = 2;
DataType return_type = 3;
bool fail_on_error = 4;
}

message BitwiseAnd {
Expand Down
21 changes: 20 additions & 1 deletion spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6d0b46c

Please sign in to comment.