API: Truncate projection of startsWith/notStartsWith miscounts surrogate pairs
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start with the string truncate transform: the TruncateString project and projectStrict methods, which compare the prefix's String.length() with the width, and UnicodeUtil.truncateString, which counts code points. Run the reproduction from the issue (startsWith and notStartsWith on "😀" with truncate width 2) to see the wrong projections. Done means both methods compare code point counts, and tests cover surrogate-pair prefixes while ASCII and BMP cases still pass.
索引モデルが issue の本文から書いたものです。
説明
Apache Iceberg version
main (development)
Query engine
None
Please describe the bug 🐞
Problem
truncate[W] on strings truncates to W code points (UnicodeUtil.truncateString), but TruncateString.project and projectStrict decide how to project startsWith/notStartsWith by comparing the prefix's String.length() (UTF-16 chars) with W.
A prefix with supplementary characters such as emoji can have length() == W and still have fewer than W code points. The projection then treats it as a full partition value and turns it into an equality, while the partition values of matching rows are longer.
Reproduce
Schema schema = new Schema(Types.NestedField.optional(1, "s", Types.StringType.get()));
PartitionSpec spec = PartitionSpec.builderFor(schema).truncate("s", 2).build();
// "😀" is 1 code point but 2 chars. A row "😀abc" lands in partition s_trunc = "😀a".
Projections.inclusive(spec).project(Expressions.startsWith("s", "😀"));
// actual: ref(name="s_trunc") == "😀" -> partition "😀a" is pruned
// expected: ref(name="s_trunc") startsWith "😀"
Projections.strict(spec).project(Expressions.notStartsWith("s", "😀"));
// actual: ref(name="s_trunc") != "😀" -> partition "😀a" is treated as all-matching
// expected: ref(name="s_trunc") notStartsWith "😀"
Impact
- Inclusive projection prunes partitions that contain matching rows, so scans with such a
startsWithfilter silently return fewer rows. - Strict projection reports partitions as fully matching when none of their rows match, which affects residuals and partition-level decisions such as metadata-only deletes.
It only happens for string truncate partitions when the prefix's UTF-16 length equals the width but its code point count is smaller. ASCII and BMP-only prefixes are unaffected.
Proposed fix
Compare the prefix's code point count with the width in both methods. I have a fix with tests and can open a PR.
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
- 主要言語
- Java
- スター
- 9.4k
- フォーク
- 3.7k
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 169
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iceberg のほかの issue
-
Spark: Test INSERT targets with computed IDENTIFIER expressions対応中かも @shivadarshan-devadiga が 7 日前に担当しました。 オープンimprovement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Core] TestAvroPartitionStatsHandler fails on Windows due to unclosed partition statistics scan対応中かも @Ankitkj1999 が 10 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Flink: JdbcLockFactory concurrent lock-table creation can fail with "table already exists" and restart the job対応中かも @adiranjan25 が 16 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/iceberg#18797 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Core: TableMetadata.Builder allows adding encryption keys to v1/v2 tables対応中かも @yusufyildiz34 が 29 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/iceberg#18632 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToList対応中かも @mohamed-elbrik が 34 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
bug module: hybrid priority: high
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bancolombia/bin-stash#92 ·
-
bug module:pubsub priority:P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
flink-gcp/flink-connector-gcp#2325 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eclipse-dirigible/dirigible#8877 ·
メンテナーはふだん 1 日以内に返信