comphead commented on code in PR #7233: URL: https://github.com/apache/datafusion-comet/pull/7233#discussion_r4744465695
########## docs/source/user-guide/latest/iceberg.md: ########## @@ -1000,6 +1017,14 @@ Which entries apply depends on which native paths are enabled: returns a struct of NULL fields, and an empty list for a list of structs, where the native scan returns the list with each element's fields NULL ([#6794](https://github.com/apache/datafusion-comet/issues/6794)). +- **Data files that store a narrower type than their column.** Files written before a type + promotion, such as `INT` to `BIGINT`, keep the older type, and files imported by `add_files`, + `migrate` or `snapshot` can store any narrower type. iceberg-rust compares such a file with a + filter literal incorrectly, so comparisons other than `=` pushed to the native scan can drop + matching rows. Comet avoids this for promotions that the schema history records and for tables + with a name mapping, which the import procedures set, but not for promotions made before + Iceberg 0.12 or for files imported into a table without a name mapping + ([#7138](https://github.com/apache/datafusion-comet/issues/7138)). Review Comment: Equality deletes go through the same comparison, and neither guard covers them. At the pin, iceberg-rust turns each delete row into `col IS NULL OR col != v`, binds it to the task schema (`crates/iceberg/src/arrow/caching_delete_file_loader.rs:617-629`, `delete_filter.rs:231`), and ANDs it into the same row filter (`reader/pipeline.rs:478-544`). There `not_eq` calls `try_cast_literal` (`predicate_visitor.rs:520-533`). Take an equality delete written after an `INT` to `BIGINT` promotion with a value above `i32::MAX`. When it applies to an older `INT` file, `v` becomes NULL and every non-NULL row of that file is dropped. A `DOUBLE` delete value such as `0.1` rounds to the `FLOAT` `0.1` and removes a row that Spark keeps. `CometScanRule` checks equality-delete keys only for nesting and type (`CometScanRule.scala:1214-1257`). Could this bullet list equality deletes keyed on such a column, or could `CometScanRule` fall back when a key is in `promotedColumns`? https://github.com/apache/ datafusion-comet/pull/7712 also lists this as not covered. I found this by reading the code and did not run it. ########## spark/src/main/scala/org/apache/comet/serde/operator/CometIcebergNativeScan.scala: ########## @@ -1301,6 +1380,23 @@ object CometIcebergNativeScan extends CometOperatorSerde[CometBatchScanExec] wit // schema so a filter column projected out of the scan output is still recognized. val pageIndexUnsupportedColumns = IcebergReflection.pageIndexUnsupportedColumns(metadata.tableSchema) + // Columns whose type changed over the table's history, or whose files may store a narrower + // type; residual predicates comparing them with a literal are dropped, except equality. + // iceberg-rust casts the literal to the file's type for the row filter, so a value that does + // not fit becomes NULL, and the page index skips the pages of a file whose type it cannot + // compare with the literal (apache/iceberg-rust#3122). add_files, migrate and snapshot import + // files without checking their types against the schema, so the history records nothing for + // them, but they set a name mapping, so a table that has one is treated as if its files could + // be narrower. The scan schema covers VERSION AS OF reads, where a name can still mean a + // column the table has since replaced with a new one. + // + // This workaround can go once the pin includes the iceberg-rust fixes for the row filter + // (#3540) and the page index (#3507). Until then, IN lookups on BIGINT keys of migrated tables + // lose row group pruning in the native scan. Review Comment: Both fixes are merged now. https://github.com/apache/iceberg-rust/pull/3507 landed as `58af4edf51` on 2026-11-16, and https://github.com/apache/iceberg-rust/pull/3540 landed as `90e454aa51` on 2026-11-23. Both come after iceberg-rust's Arrow 60 bump (https://github.com/apache/iceberg-rust/pull/3257), so the current pin (Arrow 59.2) cannot take them. The iceberg-rust pin in https://github.com/apache/datafusion-comet/pull/7618 (`6c97391`) is older than both as well. https://github.com/apache/iceberg-rust/pull/3540 converts the filter columns to the table schema for each file, and it covers `INT(8)`, `UINT_32` and `date` to `timestamp` files. Once the pin reaches `90e454aa51`, this guard, the schema-history guard and the two gaps that `iceberg.md` lists can all be removed. Could the comment name that commit and the Arrow 60 dependency, so the next pin bump knows what to remove? Also, https://github.com/apache/datafusion-comet/pull/7712 works around the same bug by checking each file' s footer, so only one of the two workarounds should land. -- 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]
