Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement ANSI support for Round #989

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Round.ansiEnabled to be added th protobuf as fail_on_error
raulcd committed Oct 2, 2024
commit 6d0b46c88452a90a380b6f78da6fa2f0045b17ef
1 change: 1 addition & 0 deletions native/proto/src/proto/expr.proto
Original file line number Diff line number Diff line change
@@ -404,6 +404,7 @@ message ScalarFunc {
string func = 1;
repeated Expr args = 2;
DataType return_type = 3;
bool fail_on_error = 4;
}

message BitwiseAnd {
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
@@ -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)