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

Abierto
#44 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@terbed ya está trabajando en esto.

Desde el 11/10/2026.

  • #59 de @terbed — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust, sql
Área
databases

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
30
Forks
30
Merge medio
3 d 19 h
PR fusionados (30 d)
15

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/datafusion-iceberg

Todos los issues de apache/datafusion-iceberg

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.