rdtr commented on code in PR #13351:
URL: https://github.com/apache/gluten/pull/13351#discussion_r4544374184
##########
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxSparkPlanExecApi.scala:
##########
@@ -189,6 +189,59 @@ class VeloxSparkPlanExecApi extends SparkPlanExecApi with
Logging {
else { name }
}
+ override def genDecimalArithmeticTransformer(
+ substraitExprName: String,
+ left: ExpressionTransformer,
+ right: ExpressionTransformer,
+ original: BinaryArithmetic): ExpressionTransformer = {
+ original match {
+ case p: Pmod =>
+ if (p.evalMode != EvalMode.ANSI && p.evalMode != EvalMode.LEGACY) {
+ throw new GlutenNotSupportException(
+ s"Decimal pmod with evaluation mode ${p.evalMode} is not
supported.")
+ }
+ // Spark evaluates the divisor first and can skip the dividend for a
null/zero divisor.
+ // An eager native function is equivalent only when neither child can
raise an error.
+ // Restrict this initial implementation to values whose evaluation
cannot throw.
+ if (
+ !p.children.forall {
+ case _: AttributeReference | _: BoundReference | _: Literal => true
+ case _ => false
+ }
+ ) {
+ throw new GlutenNotSupportException(
+ "Decimal pmod with computed operands is not supported.")
+ }
+ // Checked decimal pmod is not present in older Velox builds.
Validation must resolve its
+ // signature before offloading; otherwise preserve Spark execution
even when validation
+ // was explicitly disabled.
+ if (!GlutenConfig.get.enableNativeValidation) {
+ throw new GlutenNotSupportException("Decimal pmod requires native
validation.")
+ }
+ // Use Spark's resolved decimal type, including the precision check
needed after
+ // adjusting a negative remainder. The checked function has fixed ANSI
semantics,
+ // preserving the expression's captured mode even if the session
changes after planning.
+ val checked = DecimalArithmeticExpressionTransformer(
+ "checked_" + substraitExprName,
Review Comment:
With the config-reading `pmod` from facebookincubator/velox#19522, this
becomes `substraitExprName` for both modes, without the `try` wrapper at line
234.
##########
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxSparkPlanExecApi.scala:
##########
@@ -189,6 +189,59 @@ class VeloxSparkPlanExecApi extends SparkPlanExecApi with
Logging {
else { name }
}
+ override def genDecimalArithmeticTransformer(
+ substraitExprName: String,
+ left: ExpressionTransformer,
+ right: ExpressionTransformer,
+ original: BinaryArithmetic): ExpressionTransformer = {
+ original match {
+ case p: Pmod =>
+ if (p.evalMode != EvalMode.ANSI && p.evalMode != EvalMode.LEGACY) {
+ throw new GlutenNotSupportException(
+ s"Decimal pmod with evaluation mode ${p.evalMode} is not
supported.")
+ }
+ // Spark evaluates the divisor first and can skip the dividend for a
null/zero divisor.
+ // An eager native function is equivalent only when neither child can
raise an error.
+ // Restrict this initial implementation to values whose evaluation
cannot throw.
+ if (
+ !p.children.forall {
+ case _: AttributeReference | _: BoundReference | _: Literal => true
+ case _ => false
+ }
+ ) {
+ throw new GlutenNotSupportException(
+ "Decimal pmod with computed operands is not supported.")
+ }
+ // Checked decimal pmod is not present in older Velox builds.
Validation must resolve its
+ // signature before offloading; otherwise preserve Spark execution
even when validation
+ // was explicitly disabled.
+ if (!GlutenConfig.get.enableNativeValidation) {
Review Comment:
This check exists because `checked_pmod` may be missing from older Velox
builds. Once the pin includes the decimal `pmod`, the regular signature check
covers it.
##########
ep/build-velox/src/get-velox.sh:
##########
@@ -25,7 +25,7 @@ RUN_SETUP_SCRIPT=ON
ENABLE_ENHANCED_FEATURES=OFF
# Developer use only for testing Velox PR.
-UPSTREAM_VELOX_PR_ID=""
Review Comment:
Shouldn't you revert this to `""` before merging this PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]