Copilot commented on code in PR #13103:
URL: https://github.com/apache/gluten/pull/13103#discussion_r4293197326
##########
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc:
##########
@@ -127,6 +127,19 @@ bool SubstraitToVeloxPlanValidator::validateRound(
return false;
}
+ const auto& valueType = params[0]->type();
Review Comment:
`validateRound` dereferences `params[0]` without checking `params.size()`.
If the caller ever passes an empty `params` vector (e.g., due to an upstream
conversion failure while `arguments` still exist), this will crash. Add a
`params.size() >= 1` (and ideally `params.size() >= 2` / `params.size() ==
arguments.size()`) guard before indexing.
##########
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:
Calling `scale.eval(EmptyRow)` during validation can throw (e.g., foldable
expressions involving casts/arithmetic overflow/div-by-zero under ANSI), which
would fail planning rather than cleanly falling back to Spark. Consider
wrapping the `eval` in a `try/catch` (e.g., `NonFatal`) and treating exceptions
as `supported = false` (optionally logging at debug). This keeps validation
side-effect free and avoids unexpected driver-side failures.
##########
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:
The PR description states `UPSTREAM_VELOX_PR_ID=19141` is a temporary
developer hook and should be replaced/removed before merging, but this change
hard-codes it as the default. Please revert this to an empty default (or gate
it behind an explicit opt-in env/flag) so normal builds don’t accidentally pin
to a PR.
##########
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:
`scala.collection.JavaConverters._` is deprecated on Scala 2.13+ in favor of
`scala.jdk.CollectionConverters._`. Since this test base is shared across Spark
versions, switching to the newer import (and corresponding `.asJava`
conversions) will reduce deprecation noise on Scala 2.13 builds.
--
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]