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

philo 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 49e1ca5a8c [GLUTEN-7807] Bind attr with name if its exprId is not 
found in transforming relation (#7819)
49e1ca5a8c is described below

commit 49e1ca5a8ce556f2e661038e487b5823823facb8
Author: Kaifei Yi <[email protected]>
AuthorDate: Wed Nov 6 15:04:50 2024 +0800

    [GLUTEN-7807] Bind attr with name if its exprId is not found in 
transforming relation (#7819)
---
 .../spark/sql/execution/ColumnarBuildSideRelation.scala   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala
 
b/backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala
index feaf72f64f..d5c848dd97 100644
--- 
a/backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala
+++ 
b/backends-velox/src/main/scala/org/apache/spark/sql/execution/ColumnarBuildSideRelation.scala
@@ -25,7 +25,7 @@ import org.apache.gluten.utils.ArrowAbiUtil
 import org.apache.gluten.vectorized.{ColumnarBatchSerializerJniWrapper, 
NativeColumnarToRowJniWrapper}
 
 import org.apache.spark.sql.catalyst.InternalRow
-import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression, 
UnsafeProjection, UnsafeRow}
+import org.apache.spark.sql.catalyst.expressions.{Attribute, 
AttributeReference, Expression, UnsafeProjection, UnsafeRow}
 import org.apache.spark.sql.execution.joins.BuildSideRelation
 import org.apache.spark.sql.internal.SQLConf
 import org.apache.spark.sql.utils.SparkArrowUtil
@@ -103,6 +103,18 @@ case class ColumnarBuildSideRelation(output: 
Seq[Attribute], batches: Array[Arra
 
     var closed = false
 
+    val exprIds = output.map(_.exprId)
+    val projExpr = key.transformDown {
+      case attr: AttributeReference if !exprIds.contains(attr.exprId) =>
+        val i = output.count(_.name == attr.name)
+        if (i != 1) {
+          throw new IllegalArgumentException(s"Only one attr with the same 
name is supported: $key")
+        } else {
+          output.find(_.name == attr.name).get
+        }
+    }
+    val proj = UnsafeProjection.create(Seq(projExpr), output)
+
     // Convert columnar to Row.
     val jniWrapper = NativeColumnarToRowJniWrapper.create(runtime)
     val c2rId = jniWrapper.nativeColumnarToRowInit()
@@ -141,7 +153,6 @@ case class ColumnarBuildSideRelation(output: 
Seq[Attribute], batches: Array[Arra
                 ColumnarBatches.getNativeHandle(batch),
                 0)
             batch.close()
-            val proj = UnsafeProjection.create(Seq(key), output)
 
             new Iterator[InternalRow] {
               var rowId = 0


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

Reply via email to