jin-won-park opened a new issue, #18922:
URL: https://github.com/apache/iceberg/issues/18922
### 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
```java
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 `startsWith` filter 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
- [x] 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
--
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]