luis4a0 commented on code in PR #13103: URL: https://github.com/apache/gluten/pull/13103#discussion_r4536979319
########## 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="" +UPSTREAM_VELOX_PR_ID="19141" Review Comment: Resolved on the current head: the normal `dft-2026_11_06` dependency contains the native implementation, `UPSTREAM_VELOX_PR_ID` is empty, and `get-velox.sh` is unchanged from main. ########## gluten-ut/common/src/test/scala/org/apache/spark/sql/GlutenDecimalRoundSuiteBase.scala: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql + +import org.apache.gluten.config.GlutenConfig +import org.apache.gluten.execution.ProjectExecTransformer + +import org.apache.spark.sql.catalyst.expressions.{Literal, Round} +import org.apache.spark.sql.catalyst.optimizer.{ConstantFolding, NullPropagation} +import org.apache.spark.sql.internal.SQLConf +import org.apache.spark.sql.types._ + +import scala.collection.JavaConverters._ Review Comment: This common test source is compiled by Spark 3.4/3.5 with Scala 2.12 as well as Spark 4.x with Scala 2.13. `scala.jdk.CollectionConverters` is unavailable on the Scala 2.12 profiles, so retaining `JavaConverters` is required for cross-version source compatibility. ########## 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="" +UPSTREAM_VELOX_PR_ID="19141" Review Comment: Resolved on the current head. Gluten main now pins `dft-2026_11_06`, which contains the landed native ROUND implementation, and this PR no longer changes `ep/build-velox/src/get-velox.sh`; the developer hook is empty exactly as on main. ########## backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxValidatorApi.scala: ########## @@ -38,12 +39,32 @@ import io.substrait.proto.SimpleExtensionDeclaration import scala.collection.JavaConverters._ import scala.collection.mutable.ArrayBuffer -class VeloxValidatorApi extends ValidatorApi { +class VeloxValidatorApi extends ValidatorApi with Logging { import VeloxValidatorApi._ - /** For velox backend, key validation is on native side. */ - override def doExprValidate(substraitExprName: String, expr: Expression): Boolean = - true + /** + * Enforce decimal ROUND scale compatibility on the JVM independently of optional native plan + * validation. + */ + override def doExprValidate(substraitExprName: String, expr: Expression): Boolean = expr match { + case round: Round if round.child.dataType.isInstanceOf[DecimalType] => + val scale = round.scale + val supported = + if (scale.dataType != IntegerType || !scale.foldable) { + false + } else { + scale.eval(EmptyRow) match { + case null => true + case value: Int => value >= -400 && value <= 400 + case _ => false + } + } Review Comment: This code is no longer present. The decimal-specific Scala eligibility policy was removed, so `VeloxValidatorApi` no longer evaluates the scale. Normal compatibility eligibility is owned by native Substrait validation, following Rui’s guidance. ########## cpp/velox/substrait/SubstraitToVeloxPlanValidator.h: ########## @@ -148,8 +148,11 @@ class SubstraitToVeloxPlanValidator { /// Validate aggregate rel. bool validateAggRelFunctionType(const ::substrait::AggregateRel& substraitAgg); - /// Validate the round scalar function. - bool validateRound(const ::substrait::Expression::ScalarFunction& scalarFunction, const RowTypePtr& inputType); + /// Validate the round scalar function using its already-converted arguments. + /// The caller supplies one non-null expression for each Substrait argument. Review Comment: The split is intentional: the converted value expression supplies the effective input type, including casts and other nontrivial expressions, while the scale policy checks the final serialized Substrait literal contract (`i32` or typed `null.i32`). This avoids coupling constant eligibility to Velox expression subclasses. The focused tests cover cast inputs, typed NULL, foldable arithmetic, and nonliteral fallback. ########## backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxValidatorApi.scala: ########## @@ -38,12 +39,32 @@ import io.substrait.proto.SimpleExtensionDeclaration import scala.collection.JavaConverters._ import scala.collection.mutable.ArrayBuffer -class VeloxValidatorApi extends ValidatorApi { +class VeloxValidatorApi extends ValidatorApi with Logging { import VeloxValidatorApi._ - /** For velox backend, key validation is on native side. */ - override def doExprValidate(substraitExprName: String, expr: Expression): Boolean = - true + /** + * Enforce decimal ROUND scale compatibility on the JVM independently of optional native plan + * validation. + */ + override def doExprValidate(substraitExprName: String, expr: Expression): Boolean = expr match { + case round: Round if round.child.dataType.isInstanceOf[DecimalType] => + val scale = round.scale + val supported = + if (scale.dataType != IntegerType || !scale.foldable) { + false + } else { + scale.eval(EmptyRow) match { + case null => true + case value: Int => value >= -400 && value <= 400 + case _ => false + } + } Review Comment: This validation code was removed. Scala no longer evaluates the decimal ROUND scale in `VeloxValidatorApi`; the native Substrait validator owns normal compatibility eligibility, while validation-disabled mode is explicitly a debugging bypass. -- 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]
