Core: Incremental partition stats are wrong after partition spec evolution
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start in core/src/main/java/org/apache/iceberg/PartitionStatsHandler.java at computeAndMergeStatsIncremental (around line 190), where previous stats rows are keyed by the unified partition type. Then read PartitionMap in core/src/main/java/org/apache/iceberg/util/PartitionMap.java (around line 181), which compares partitions in each spec's own type. Done when the issue's reproduction gives the same per-partition counts as a full computation, for format versions 2 and 3.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Apache Iceberg version
1.12.0 (latest release)
Query engine
Other
Please describe the bug 🐞
What happens. After partition spec evolution, the incremental computation of partition statistics writes a file that drops partitions and undercounts others. This is PartitionStatsHandler.computeAndWriteStatsFile when an ancestor snapshot already has a partition statistics file, which is also what Spark's compute_partition_stats runs. A full computation of the same snapshot is correct. Incremental computation was added in 1.10.0 (#12629), so 1.10.0 through 1.12.0 and main are affected.
Why. computeAndMergeStatsIncremental puts the rows of the previous statistics file into a PartitionMap keyed by their partition, which is in the unified partition type
(L190).
PartitionMap compares the partitions of a spec in that spec's own partition type
(L181).
When a spec's fields are not a prefix of the unified type, for example after removing a partition field that is not the last, the previous rows of that spec are read at the wrong positions. They collide, so only the last one is kept, and the newly computed statistics, keyed in the spec's type, never match them.
Reproduction (in-memory catalog, format version 2 or 3):
Schema schema = new Schema(optional(1, "id", IntegerType.get()), optional(2, "part", IntegerType.get()));
Table table = catalog.createTable(TableIdentifier.of("db", "t"), schema,
PartitionSpec.builderFor(schema).identity("part").build(), Map.of("format-version", "2"));
table.newAppend().appendFile(file(table.spec(), "part=1", 10)).appendFile(file(table.spec(), "part=2", 20)).commit();
computeAndCommit(table); // full
table.updateSpec().removeField("part").addField(Expressions.bucket("id", 4)).commit();
table.newAppend()
.appendFile(file(table.spec(), "id_bucket_4=0", 5))
.appendFile(file(table.spec(), "id_bucket_4=1", 7))
.appendFile(file(table.spec(), "id_bucket_4=2", 9))
.commit();
computeAndCommit(table); // incremental
table.newAppend().appendFile(file(table.spec(), "id_bucket_4=0", 3)).commit();
computeAndCommit(table); // incremental
where computeAndCommit runs PartitionStatsHandler.computeAndWriteStatsFile(table) and registers the result, and file builds a DataFile with the given partition path and record count.
| Partition of spec 1 | Incremental result | Full computation of the same snapshot |
|---|---|---|
id_bucket_4=0 |
3 records, 1 file | 8 records, 2 files |
id_bucket_4=1 |
missing | 7 records, 1 file |
id_bucket_4=2 |
9 records, 1 file | 9 records, 1 file |
Impact. Every later incremental computation starts from the wrong file, so the error persists. Tables that changed their partitioning in this way and use incrementally computed statistics files, for example from Spark's compute_partition_stats, may already have wrong files. Workaround: remove the table's partition statistics files and compute again, which is a full computation.
Fix: #18936
Willingness to contribute
- I can contribute a fix for this bug independently
- Lenguaje dominante
- Java
- Estrellas
- 9.4k
- Forks
- 3.7k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 169
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/iceberg
-
Spark: Test INSERT targets with computed IDENTIFIER expressionsPosiblemente ocupada @shivadarshan-devadiga la tomó hace 8 días. Abiertoimprovement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scanPosiblemente ocupada @Ankitkj1999 la tomó hace 10 días. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Flink: JdbcLockFactory concurrent lock-table creation can fail with "table already exists" and restart the jobPosiblemente ocupada @adiranjan25 la tomó hace 17 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/iceberg#18797 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tablesPosiblemente ocupada @yusufyildiz34 la tomó hace 29 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/iceberg#18632 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListPosiblemente ocupada @mohamed-elbrik la tomó hace 34 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
Todos los issues de apache/iceberg
Issues similares
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Handle TSP error code 212Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
bug module: hybrid priority: high
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bancolombia/bin-stash#92 ·
-
Pub/Sub nackSplit drops other splits' empty checkpoint entries and lowers pendingCheckpointsAbiertobug module:pubsub priority:P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
flink-gcp/flink-connector-gcp#2325 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
eclipse-dirigible/dirigible#8877 ·
Los mantenedores suelen responder en 1 día