andygrove commented on code in PR #7233:
URL: https://github.com/apache/datafusion-comet/pull/7233#discussion_r4744882535


##########
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:
   Done in 6f7677caf0. The comment now names `90e454aa51` for the row filter 
(#3540) and `58af4edf51` for the page index (#3507), and says both come after 
iceberg-rust's Arrow 60 bump (#3257), so the pin needs that dependency first. 
On #7712, I agree that only one of the two workarounds should land. I'd like to 
settle that with its author before either merges.
   



##########
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:
   Thanks, I confirmed this against the code and chose the fallback. 
`CometScanRule` now declines the native scan when an equality-delete key is in 
the promoted-column set. That set covers the current, scan and historic schemas 
with the name-mapping widening, so a dropped key is covered too. The new test 
`equality delete keyed on a promoted column falls back to Spark` promotes `INT` 
to `BIGINT` and commits a delete of `3000000000`. It matches Spark and fails 
with the fallback disabled. The fallback is listed under "Current limitations" 
in `iceberg.md` (28006e6255).
   



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