Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Jun 4, 2024
1 parent 60de09c commit 4d43485
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
}
}

val cometAnsiEnabled = CometConf.COMET_ANSI_MODE_ENABLED.get()
val ansiNotSupported = "ANSI mode not supported. " +
s"Set ${CometConf.COMET_ANSI_MODE_ENABLED.key}=true to enable it anyway."

expr match {
case a @ Alias(_, _) =>
val r = exprToProtoInternal(a.child, inputs)
Expand All @@ -699,28 +703,28 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
case c @ Cast(child, dt, timeZoneId, _) =>
handleCast(child, inputs, dt, timeZoneId, evalMode(c))

case expr: Add if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Add if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case expr: Subtract if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Subtract if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case expr: Multiply if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Multiply if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case expr: Divide if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Divide if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case expr: Remainder if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Remainder if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case expr: Pmod if evalMode(expr) == CometEvalMode.ANSI =>
withInfo(expr, "ANSI mode not supported")
case expr: Pmod if evalMode(expr) == CometEvalMode.ANSI && !cometAnsiEnabled =>
withInfo(expr, ansiNotSupported)
None

case add @ Add(left, right, _) if supportedDataType(left.dataType) =>
Expand Down Expand Up @@ -1616,7 +1620,7 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim

case r: Round =>
val cometEvalMode = evalMode(r)
if (cometEvalMode == CometEvalMode.ANSI && !CometConf.COMET_ANSI_MODE_ENABLED.get) {
if (cometEvalMode == CometEvalMode.ANSI && !cometAnsiEnabled) {
// https://github.com/apache/datafusion-comet/issues/466
withInfo(
r,
Expand Down

0 comments on commit 4d43485

Please sign in to comment.