You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2026/10/01 15:28:08 UTC
[I] `convert_filters_to_predicate` negates a weakened AND, producing a predicate that drops matching rows [datafusion-iceberg]
andygrove opened a new issue, #44:
URL: https://github.com/apache/datafusion-iceberg/issues/44
### Describe the bug
When one side of an `AND` can't be converted, `to_iceberg_and_predicate` keeps only the other side ([expr_to_predicate.rs#L370-L382](https://github.com/apache/datafusion-iceberg/blob/a2bc9427d0659591b5f8122b90fec710fe2f5de6/crates/datafusion/src/physical_plan/expr_to_predicate.rs#L370-L382)). On its own that is fine for `Inexact` pushdown, because the result is weaker than the filter. `Expr::Not` then negates whatever its child produced ([expr_to_predicate.rs#L89-L105](https://github.com/apache/datafusion-iceberg/blob/a2bc9427d0659591b5f8122b90fec710fe2f5de6/crates/datafusion/src/physical_plan/expr_to_predicate.rs#L89-L105)). Negating a weaker predicate gives a stronger one, which rejects rows the original filter accepts.
### To Reproduce
```rust
// schema: a INT, b STRING
let expr = SessionContext::new().parse_sql_expr("NOT (a = 1 AND upper(b) = 'X')", &df_schema)?;
let predicate = convert_filters_to_predicate(&[expr]);
// Some(NOT (a = 1)): drops a = 1, b = 'y', which the filter keeps
```
### Expected behavior
The result is `None`, or another predicate implied by the filter. One way is to track whether each converted sub-predicate is exact, and negate only exact ones.
### Additional context
SQL doesn't trigger this today with the default optimizer. DataFusion's simplifier rewrites `NOT (A AND B)` to `NOT A OR NOT B` before pushdown, so nothing is pushed for this filter. `convert_filters_to_predicate` is public, though, so other callers can hit it, as can any plan whose filters reach the scan without simplification. `NOT (flag AND a = 1)` on a boolean column has the same problem.
--
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: github-unsubscribe@datafusion.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org