`convert_filters_to_predicate` negates a weakened AND, producing a predicate that drops matching rows

Aperta
#44 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@terbed ci sta già lavorando.

Dal 11/10/2026.

  • #59 di @terbed — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, sql
Ambito
databases

Direzione di ricerca

Start in crates/datafusion/src/physical_plan/expr_to_predicate.rs, especially the AND handling at lines 370-382 and Expr::Not at lines 89-105. Reproduce the issue with the provided NOT (a = 1 AND upper(b) = 'X') expression, then verify that conversion returns None or only a predicate implied by the original filter.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
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). 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). Negating a weaker predicate gives a stronger one, which rejects rows the original filter accepts.

To Reproduce
// 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.

Lingua principale
Rust
Stelle
30
Fork
30
Merge medio
3g 19h
PR unite (30g)
15

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/datafusion-iceberg

Tutte le issue di apache/datafusion-iceberg

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.