ShashidharM0118 commented on PR #19434: URL: https://github.com/apache/datafusion/pull/19434#issuecomment-3678860994
> @ShashidharM0118 see [#19092 (comment)](https://github.com/apache/datafusion/issues/19092#issuecomment-3678747013). I'm wondering why the existing const evaluation isn't already simplifying this. It doesn't seem like it should require `is (not) null` specific code. If I understand correctly, The existing `simplify_const_expr` already handles `IS NULL(literal)` and `IS NOT NULL(literal)` through `IsNullExpr::evaluate()` and `IsNotNullExpr::evaluate()`, which correctly evaluate literals. The issue was that simplification was conditional. In the original code at lines 469-480 in `pruning_predicate.rs`: ``` if tf.transformed { // ... comments ... let simplifier = PhysicalExprSimplifier::new(&schema); expr = simplifier.simplify(tf.data)?; } else { expr = tf.data; // Line 479: simplifier skipped here } ``` When `tf.transformed == false` (e.g., for regular expressions like `or(is_not_null(lit(NULL)), col("a").eq(lit(24)))` without `DynamicFilterPhysicalExpr`), the simplifier was skipped entirely at line 479. As a result, expressions like `IS NOT NULL(NULL literal)` reached `build_predicate_expression` unsimplified, causing pruning to be skipped (the expression incorrectly simplified to `true` via `unhandled_hook`, making `true OR (pruning_expr) = true`, which prevents pruning). -- 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]
