This is an automated email from the ASF dual-hosted git repository.

changchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 5c9f5d50b1 [GLUTEN-11403][VL] Validate attribute existence before 
binding in ExpressionConverter (#11546)
5c9f5d50b1 is described below

commit 5c9f5d50b11a02c87006826ece1e5ec17248b1ae
Author: Chang Chen <[email protected]>
AuthorDate: Tue Feb 3 20:24:24 2026 +0800

    [GLUTEN-11403][VL] Validate attribute existence before binding in 
ExpressionConverter (#11546)
    
    * Spark: Validate attribute existence before binding in ExpressionConverter
    
    * Spark: Add GlutenDeprecatedDatasetAggregatorSuite for Spark 4.0
    
    * Spark: Add GlutenDeprecatedDatasetAggregatorSuite for Spark 4.1
    
    * fix style
---
 .../gluten/expression/ExpressionConverter.scala    | 24 +++++++++++-----------
 .../gluten/utils/velox/VeloxTestSettings.scala     |  1 +
 .../GlutenDeprecatedDatasetAggregatorSuite.scala   | 24 ++++++++++++++++++++++
 .../gluten/utils/velox/VeloxTestSettings.scala     |  1 +
 .../GlutenDeprecatedDatasetAggregatorSuite.scala   | 24 ++++++++++++++++++++++
 5 files changed, 62 insertions(+), 12 deletions(-)

diff --git 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala
 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala
index a810a4ef1d..cc8d204cd5 100644
--- 
a/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala
+++ 
b/gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala
@@ -358,20 +358,20 @@ object ExpressionConverter extends SQLConfHelper with 
Logging {
           a)
       case a: AttributeReference =>
         if (attributeSeq == null) {
-          throw new UnsupportedOperationException(s"attributeSeq should not be 
null.")
+          throw new UnsupportedOperationException("attributeSeq should not be 
null.")
         }
-        try {
-          val bindReference =
-            BindReferences.bindReference(expr, attributeSeq, allowFailures = 
false)
-          val b = bindReference.asInstanceOf[BoundReference]
-          AttributeReferenceTransformer(substraitExprName, a, b)
-        } catch {
-          case e: IllegalStateException =>
-            // This situation may need developers to fix, although we just 
throw the below
-            // exception to let the corresponding operator fall back.
-            throw new UnsupportedOperationException(
-              s"Failed to bind reference for $expr: ${e.getMessage}")
+        val input = AttributeSeq(attributeSeq)
+        if (input.indexOf(a.exprId) == -1) {
+          // This situation may need developers to fix, although we just throw 
the below
+          // exception to let the corresponding operator fall back.
+          throw new UnsupportedOperationException(
+            "Failed to bind reference: " +
+              s"couldn't find $a in ${input.attrs.mkString("[", ",", "]")}")
         }
+        val b = BindReferences
+          .bindReference(expr, input, allowFailures = false)
+          .asInstanceOf[BoundReference]
+        AttributeReferenceTransformer(substraitExprName, a, b)
       case b: BoundReference =>
         BoundReferenceTransformer(substraitExprName, b)
       case l: Literal =>
diff --git 
a/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
 
b/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
index e45b4b0b06..881f0dabb2 100644
--- 
a/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
+++ 
b/gluten-ut/spark40/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
@@ -817,6 +817,7 @@ class VeloxTestSettings extends BackendTestSettings {
   enableSuite[GlutenDataFrameTableValuedFunctionsSuite]
   enableSuite[GlutenDataFrameTransposeSuite]
   enableSuite[GlutenDefaultANSIValueSuite]
+  enableSuite[GlutenDeprecatedDatasetAggregatorSuite]
   // TODO: 4.x enableSuite[GlutenExplainSuite]  // 1 failure
   enableSuite[GlutenICUCollationsMapSuite]
   enableSuite[GlutenInlineTableParsingImprovementsSuite]
diff --git 
a/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
 
b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
new file mode 100644
index 0000000000..2b4cd01c34
--- /dev/null
+++ 
b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
@@ -0,0 +1,24 @@
+/*
+ * 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 scala.annotation.nowarn
+
+@nowarn("cat=deprecation")
+class GlutenDeprecatedDatasetAggregatorSuite
+  extends DeprecatedDatasetAggregatorSuite
+  with GlutenSQLTestsTrait {}
diff --git 
a/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
 
b/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
index 5598bbb1fd..10741f7fbc 100644
--- 
a/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
+++ 
b/gluten-ut/spark41/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala
@@ -782,6 +782,7 @@ class VeloxTestSettings extends BackendTestSettings {
   // TODO: 4.x enableSuite[GlutenDataFrameSubquerySuite]  // 1 failure
   enableSuite[GlutenDataFrameTableValuedFunctionsSuite]
   enableSuite[GlutenDataFrameTransposeSuite]
+  enableSuite[GlutenDeprecatedDatasetAggregatorSuite]
   // TODO: 4.x enableSuite[GlutenExplainSuite]  // 1 failure
   enableSuite[GlutenICUCollationsMapSuite]
   enableSuite[GlutenInlineTableParsingImprovementsSuite]
diff --git 
a/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
 
b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
new file mode 100644
index 0000000000..2b4cd01c34
--- /dev/null
+++ 
b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenDeprecatedDatasetAggregatorSuite.scala
@@ -0,0 +1,24 @@
+/*
+ * 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 scala.annotation.nowarn
+
+@nowarn("cat=deprecation")
+class GlutenDeprecatedDatasetAggregatorSuite
+  extends DeprecatedDatasetAggregatorSuite
+  with GlutenSQLTestsTrait {}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to