bucket(decimal) partition pruning silently drops rows when the query literal's scale differs from the column scale
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Java
- Stelle
- 9.4k
- Fork
- 3.7k
- Merge medio
- 2g 15h
- PR unite (30g)
- 169
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/iceberg
-
Spark: Test INSERT targets with computed IDENTIFIER expressionsForse già presa @shivadarshan-devadiga l’ha presa 7 giorni fa. Apertaimprovement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scanForse già presa @Ankitkj1999 l’ha presa 9 giorni fa. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Flink: JdbcLockFactory concurrent lock-table creation can fail with "table already exists" and restart the jobForse già presa @adiranjan25 l’ha presa 16 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/iceberg#18797 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tablesForse già presa @yusufyildiz34 l’ha presa 29 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/iceberg#18632 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListForse già presa @mohamed-elbrik l’ha presa 34 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/iceberg
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
speakeasy-api/speakeasy#2159 ·
I maintainer di solito rispondono entro 1 giorno
-
area: cli
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vitruv-tools/NeoJoin#415 ·
I maintainer di solito rispondono entro 1 giorno
-
Quick Installation step 2 installs from the plugin manager, but the plugin isn't published yetAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
I maintainer di solito rispondono entro 6 giorni
-
account assessment course feature lecture
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] 连接达梦时报错,agent 进程启动即退Apertabug db/dameng user-priority/P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno