rich7420 commented on code in PR #7322:
URL: https://github.com/apache/datafusion-comet/pull/7322#discussion_r4484268842


##########
native/spark-expr/src/conditional_funcs/null_short_circuit.rs:
##########
@@ -290,27 +289,46 @@ pub(super) fn evaluate_projected(
 }
 
 /// The input columns that `expr` reads, and `expr` reading them from a batch 
of just those columns.
+///
+/// A [`LambdaVariable`] reads a column of the batch its lambda is evaluated 
on exactly as a
+/// [`Column`] does, so it is projected and re-indexed the same way.
 pub(super) fn project(expr: &Arc<dyn PhysicalExpr>) -> Result<(Vec<usize>, 
Arc<dyn PhysicalExpr>)> {
-    let mut projection = collect_columns(expr)
-        .iter()
-        .map(Column::index)
-        .collect::<Vec<_>>();
+    let mut projection = vec![];
+    expr.apply(|e| {
+        if let Some(column) = e.downcast_ref::<Column>() {
+            projection.push(column.index());
+        } else if let Some(variable) = e.downcast_ref::<LambdaVariable>() {
+            projection.push(variable.index());

Review Comment:
   For `array_contains(a, size(filter(b, x -> x > 1)))`, this adds the inner 
lambda parameter to the outer projection, causing an out-of-bounds error. 
Preserve lambda scope when collecting and remapping columns.



-- 
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]

Reply via email to