andygrove opened a new pull request, #7834:
URL: https://github.com/apache/datafusion-comet/pull/7834

   ## Which issue does this PR close?
   
   Related to #7138, which #7712 fixed for filter pushdown. No separate issue: 
this is the equality-delete half, found while closing #7233.
   
   ## Rationale for this change
   
   A data file written before a column was promoted (such as `INT` to `BIGINT`) 
keeps the older type. iceberg-rust narrows each equality-delete value to the 
type the file stores, and a value that does not fit becomes NULL 
(apache/iceberg-rust#3122). When one delete file holds both a value that fits 
and one that does not, the native scan drops a row that no delete value matches.
   
   On main, with an `INT` key promoted to `BIGINT` and one delete file holding 
`2` and `3000000000`, Spark returns `[1,a] [3,c] [4,d]` and the native scan 
returns `[1,a] [4,d]`. The delete values are only 2 and 3000000000, yet the row 
with id 3 disappears. The delete values may be in either order. A delete file 
with a single value, with values that all fit, or with values that all do not 
fit matched Spark, as did `FLOAT` to `DOUBLE` and `DECIMAL` widening, so the 
result depends on the mix of values in the file.
   
   #7712 narrows the filter pushdown per file, but it does not cover equality 
deletes, which iceberg-rust applies by a different route.
   
   ## What changes are included in this PR?
   
   - `CometScanRule` falls back to Spark for an equality delete whose key 
column may be stored narrower than the table type. 
`IcebergReflection.promotedFieldIds` finds those columns by field id: columns 
whose type differs somewhere in the table's schema history, every column of a 
type a promotion can produce when the history has a gap (expired schemas), and, 
for a table with a `schema.name-mapping.default` property (set by `add_files`, 
`migrate` and `snapshot`), every column of `INT`, `BIGINT`, `DOUBLE`, `DECIMAL` 
or `TIMESTAMP_NTZ` type.
   - The user guide lists the new fallback.
   
   The name-mapping case follows from the same iceberg-rust behavior but I did 
not reproduce a row loss for an imported file. The cost of being wrong is a 
fallback to Spark on a table that has equality deletes and a name mapping, not 
a wrong result.
   
   This replaces the equality-delete part of #7233, which I closed. The 
residual-pushdown changes in #7233 came from #7156 and stay with that PR.
   
   ## How are these changes tested?
   
   `CometIcebergNativeSuite` gains a test that promotes an `INT` key to 
`BIGINT`, commits equality-delete files with `[3000000000]`, `[2, 3000000000]` 
and `[3000000000, 2]`, and checks that the scan falls back to Spark and returns 
Spark's rows. It fails on main. `CometIcebergNativeSuite`, 
`CometIcebergNativeScanSuite` and `CometFuzzIcebergSuite` pass on Spark 4.1 
(188 passed, 2 canceled).
   


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