1fanwang commented on code in PR #7741:
URL: https://github.com/apache/datafusion-comet/pull/7741#discussion_r4700711902


##########
native/spark-expr/src/conditional_funcs/lazy_logical.rs:
##########
@@ -147,7 +148,11 @@ pub fn lazy_in_list(
             )?
         });
     }
-    let chain = balanced_or(&terms, schema)?;
+    let mut chain = balanced_or(&terms, schema)?;
+    if value.nullable(schema)? {
+        let value_is_set: Arc<dyn PhysicalExpr> = 
Arc::new(IsNotNullExpr::new(Arc::clone(value)));
+        chain = Arc::new(CaseWhenExpr::try_new(vec![(value_is_set, chain)], 
None)?);
+    }

Review Comment:
   Scoped the value down to cheap expressions rather than the full 
materialize-once restructuring, fixed in 
cc5dfaf2b16cf18b1c0156f3fc8433faf7cdd6c4:
   
   
https://github.com/apache/datafusion-comet/blob/cc5dfaf2b16cf18b1c0156f3fc8433faf7cdd6c4/native/spark-expr/src/conditional_funcs/lazy_logical.rs#L218-L234
   
   The reasoning for not attempting the restructuring now is in the details 
block below, since it does not fit here.
   
   <details>
   <summary>Why scoped down instead of restructured, and what changed</summary>
   
   evaluate_projected and project are reusable for the value itself, but the 
chain also needs every column the candidates read, re-indexed into whatever 
batch carries the materialized value, and the existing CaseWhenExpr null guard 
and balanced_or/LazyLogical nesting would all need to read that materialized 
column instead of the original value expression. That is a second stateful 
PhysicalExpr roughly the size of NullShortCircuit, not a small change, and I 
judged it too large to take on safely in this pass alongside the other four 
findings and their own test fallout (see the nested-float regression in the 
reply on the skip(1) thread). I did not measure the restructuring's benefit 
against its risk beyond that read.
   
   The new is_cheap check accepts a column, a struct field, a literal, or 
arithmetic over them, matching what you suggested, and keeps CheckedBinaryExpr 
so the existing v + 1 IN (...) case still takes the lazy chain. A Cast that 
parses a string or a scalar function as the value now declines the chain 
instead of paying the once-per-term cost, falling back to the eager InListExpr 
exactly as before this PR. Added a unit test for each side of that boundary.
   </details>



##########
native/spark-expr/src/conditional_funcs/lazy_logical.rs:
##########
@@ -485,6 +490,39 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn in_list_skips_candidates_for_a_null_value() -> Result<()> {

Review Comment:
   Both confirmed and applied in cc5dfaf2b16cf18b1c0156f3fc8433faf7cdd6c4:
   
   
https://github.com/apache/datafusion-comet/blob/cc5dfaf2b16cf18b1c0156f3fc8433faf7cdd6c4/native/spark-expr/src/conditional_funcs/lazy_logical.rs#L502-L543
   
   I kept this reply scoped to the two edits proposed here. Tests added for the 
other three findings sit elsewhere in the same file, not folded into this 
consolidation. Details, including one honesty note on how I checked the dropped 
test's replacement, are below.
   
   <details>
   <summary>What else changed near here, and a verification gap</summary>
   
   Beyond the two confirmed edits, I added a struct-field-value test, a test 
for a Cast value falling back to the eager list, and a unit test for is_cheap's 
boundary, all adjacent to these two in the same file, since the other three 
findings needed their own coverage.
   
   I could not run logical_lazy_ansi.sql's JVM suite in this environment: 
Maven's spotless and scalatest plugins both hit a JDK 27 incompatibility 
(NoSuchMethodError, then Subject.getSubject UnsupportedOperationException) 
unrelated to this change, so I verified the (v + 1) query's six rows by hand 
against Spark's documented In.eval and And.eval null rules instead of an actual 
run. Worth a real CI pass confirming it before treating the drop as fully 
closed.
   </details>



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