NoahKusaba opened a new pull request, #164:
URL: https://github.com/apache/datafusion-iceberg/pull/164

   ## Which issue does this PR close?
   
   Closes #101.
   
   ## Rationale for this change
   
   Filters on float columns could return fewer rows than the same query on an 
in-memory table. DataFusion treats -0.0 as equal to 0.0, and NaN as equal to 
itself and greater than every number. Iceberg's file skipping orders -0.0 
before 0.0 and matches NaN only with `IS NAN`. So pushing `x > 2.0` or `x = 
0.0` down unchanged skipped files holding NaN or -0.0 rows that the filter 
keeps.
   
   ## What changes are included in this PR?
   
   Float comparisons and `IN` lists are converted to match DataFusion: compare 
the values other than NaN, with a zero literal matching both zeros, then add 
`OR x IS NAN` or `AND x IS NOT NAN`. For example:
   
   | Filter | Pushed predicate |
   |---|---|
   | `x > 2.0` | `(x > 2) OR (x IS NAN)` |
   | `x = 0.0` | `((x >= -0) AND (x <= 0)) AND (x IS NOT NAN)` |
   | `x = 'NaN'` | `x IS NAN` |
   
   The conversion is exact, so `NOT` around it is still pushed down. Other 
filters are unchanged.
   
   The NaN term still lets a file be skipped when its NaN count is zero, which 
iceberg-rust's writer records. Files without NaN counts, such as imported 
Parquet files, are no longer skipped for `>`, `>=` and `!=` on floats.
   
   ## Are these tested?
   
   - A unit snapshot of the pushed predicate for every comparison with a 
number, a zero and NaN, plus -0.0, `REAL`, a literal on the left, `IN`, `NOT 
IN` and `NOT`.
   - `float_predicate_pushdown.slt`: 25 queries over a table with NaN, -0.0, 
0.0 and `NULL` in separate files. Expected rows are what DataFusion returns for 
the same data in memory; 16 of the queries fail on `main`. One `EXPLAIN` checks 
that the NaN term reaches the scan.
   
   ## Are there any user-facing changes?
   
   Float filters return the right rows. `EXPLAIN` shows the added NaN and zero 
terms in the pushed predicate.
   


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