bucket(decimal) partition pruning silently drops rows when the query literal's scale differs from the column scale
Los mantenedores suelen responder en 1 día
@ViktorBystrov72 ya está trabajando en esto.
Desde el 16/11/2026.
- #18991 de @ViktorBystrov72 — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Read Literals.DecimalLiteral.to, StringLiteral.to, Binder, BucketUtil.hash, Bucket.project, ProjectionUtil.transformSet, and BoundSetPredicate.test; inspect the decimal bucket and IN predicate tests. Reproduce the scale mismatch for decimal(9,2), then verify numeric equality is handled consistently in bucket pruning and residual evaluation without changing hashes for stored values. Issue #18991 already has an open linked pull request.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Apache Iceberg version
None
Query engine
None
Please describe the bug 🐞
Description
With a decimal(9,2) column partitioned by bucket(value, 16), the query WHERE value = 100.0 silently misses rows holding 100.00, because the literal keeps its written scale when bound but the bucket hash is scale-sensitive.
Literals.DecimalLiteral.to(DECIMAL) and StringLiteral.to(DECIMAL) both say "do not change decimal scale" and return the literal unchanged, while IntegerLiteral/LongLiteral/FloatLiteral/DoubleLiteral.to(DECIMAL) all setScale(column scale, HALF_UP). Binder converts literals via Literal.to(type), so a decimal literal keeps its written scale. But BucketUtil.hash(BigDecimal) hashes the raw unscaled-value bytes, so numerically equal decimals at different scales hash differently.
The spec (format/spec.md) says hash results are "not dependent on decimal scale, which is part of the type, not the data value". That holds for stored data, where the column scale is fixed, but not for un-normalized query literals.
To Reproduce
Schema decimal(9,2), partition spec bucket(value, 16):
value = 100.00projects tovalue_bucket == 8value = 100.0projects tovalue_bucket == 0
A manifest whose stored partition value is 8 is then pruned by ManifestEvaluator.eq (lower == upper == 8 vs projected 0 returns ROWS_CANNOT_MATCH), so the rows are silently missing from WHERE value = 100.0. The same flaw reaches IN lists via Bucket.project -> ProjectionUtil.transformSet.
Same family at row level: binding IN(1.1, 2.2) on decimal(9,2), then BoundSetPredicate.test(1.100) returns false, because Evaluator.in / BoundSetPredicate.test use Set.contains on raw BigDecimals and BigDecimal.equals/hashCode are scale-sensitive (equals false, compareTo == 0, contains false). Residual evaluation drops matching rows.
Verified on current main (bc94d8e, 2026-11-16): calibration BucketUtil.hash(14.20) = -500754589 matches the spec example.
Expected behavior
Numerically equal decimal literals project to the same bucket regardless of written scale, and IN evaluation matches numerically equal decimals.
Possible fix
Normalize the decimal literal to the column scale at bind time (DecimalLiteral.to / StringLiteral.to), taking care that values with more fractional digits than the column scale must not be silently rounded for EQ; or scale-normalize inside the bucket projection. Changing BucketUtil.hash itself would break spec compatibility with existing data.
Notes
- Closest prior report is #7882 (closed, Hive-side trimming, identity partition); it did not fix this code path,
Set.containsis still in current main. - I can contribute a fix for this bug independently.
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- 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
-
hermes-queue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
chrisalunlloyd2-sudo/mindpalace#430 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
unitycatalog/unitycatalog#2363 ·
Los mantenedores suelen responder en 1 día
-
area: editor P3 type: feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
halisonworks/mod-codeling#290 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
CVE-2026-63402 i18nextAbiertoarea/dependencies area/dependencies/js backport/26.6 backport/26.8 kind/cve severity/medium source/scan-dependencies status/triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días