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

viirya pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new d095294b fix: Fallback to Spark when cannot resolve AttributeReference 
(#926)
d095294b is described below

commit d095294b76d118c5017fde693204037bf17fd7d2
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Mon Sep 9 07:10:07 2024 -0700

    fix: Fallback to Spark when cannot resolve AttributeReference (#926)
---
 .../scala/org/apache/comet/serde/QueryPlanSerde.scala    | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala 
b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
index d77fac47..dbc3a1d8 100644
--- a/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
+++ b/spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
@@ -1710,12 +1710,20 @@ object QueryPlanSerde extends Logging with 
ShimQueryPlanSerde with CometExprShim
 
           if (dataType.isDefined) {
             if (binding) {
-              val boundRef = BindReferences
-                .bindReference(attr, inputs, allowFailures = false)
-                .asInstanceOf[BoundReference]
+              // Spark may produce unresolvable attributes in some cases,
+              // for example 
https://github.com/apache/datafusion-comet/issues/925.
+              // So, we allow the binding to fail.
+              val boundRef: Any = BindReferences
+                .bindReference(attr, inputs, allowFailures = true)
+
+              if (boundRef.isInstanceOf[AttributeReference]) {
+                withInfo(attr, s"cannot resolve $attr among 
${inputs.mkString(", ")}")
+                return None
+              }
+
               val boundExpr = ExprOuterClass.BoundReference
                 .newBuilder()
-                .setIndex(boundRef.ordinal)
+                .setIndex(boundRef.asInstanceOf[BoundReference].ordinal)
                 .setDatatype(dataType.get)
                 .build()
 


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

Reply via email to