andygrove commented on code in PR #7233:
URL: https://github.com/apache/datafusion-comet/pull/7233#discussion_r4760945504
##########
spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala:
##########
@@ -1184,6 +1184,18 @@ case class CometScanRule(session: SparkSession)
val topLevelIds = (metadata.tableSchema +: historicSchemas)
.flatMap(IcebergReflection.buildFieldIdMapping(_).values)
.toSet
+ // iceberg-rust turns each equality-delete row into a filter on
the key column and
+ // compares it with a file that still stores a narrower type
incorrectly, so a key
+ // that may have been promoted drops rows Spark keeps
(apache/iceberg-rust#3122). A
+ // dropped key exists only in the history, so every schema is
checked.
+ lazy val promotedKeyColumns = (Seq(metadata.tableSchema,
metadata.scanSchema) ++
Review Comment:
Done in 78f78f8954. `IcebergReflection.promotedFieldIds` makes one pass over
the table history plus the scan and table schemas and records the types seen
for each top-level field id. A field id counts as promoted if it has more than
one type, or if it has a promotable type and the history is incomplete or the
table has a name mapping. `promotedColumns` now uses it too, so there is one
list of promotable types and no `findField` call per column per schema.
`CometScanRule` computes the ids once, lazily, and checks
`promotedKeyIds.contains(fid)`. A dropped key still falls back, because its id
stays in the history. A new `id` (field 2, STRING) no longer falls back when an
older `id` (field 1) was promoted and dropped. I added a unit test for that
case, `a dropped column and a later one of the same name are told apart by
field id`, and an end-to-end test, `equality delete keyed on a column that
reuses the name of a promoted one is native`. I did not re-run your 128-schema
measurement.
--
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]