Repository navigation
Conversation
Collaborator
Author
|
R: @ahmedabu98 |
Contributor
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
A CDC read of a table whose primary key has a string column failed with "ClassCastException: java.nio.HeapCharBuffer cannot be cast to java.lang.String" as soon as one snapshot deleted and added rows in overlapping key ranges, as an upsert or a copy-on-write update or delete does. Iceberg decodes a string column's file bound as a CharBuffer, and the overlap bounds went into the changelog descriptor's Beam Row unchanged, where the String coder failed. Turn a decoded string bound into a String. A string bound may be truncated, to 16 characters by default, but both ends stay conservative, so the overlap check still holds; the OverlapRange comment now says so. The new tests resolve an upsert and a copy-on-write overwrite on a string key alone and on a string and a long, through both the local and the CoGroupByKey resolve paths, and an upsert on keys whose stored bounds are truncated. ChangelogScannerTest no longer hides the CharBuffer behind toString() and round-trips the overlap bounds through the descriptor's coder.
claudevdm
force-pushed
the
iceberg-fix-cdc-string-key
branch
from
December 5, 2026 16:15
1449e99 to
4a78a83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A CDC read (
IcebergIO.readRows(...).withCdc()or ManagedICEBERG_CDC) of a table whose primary key has astringcolumn fails whenever a snapshot removes and adds rows whose key ranges overlap:java.lang.ClassCastException: class java.nio.HeapCharBuffer cannot be cast to class java.lang.String
at org.apache.beam.sdk.coders.StringUtf8Coder.encode(StringUtf8Coder.java:37)
...
at org.apache.beam.sdk.io.iceberg.cdc.ChangelogScanner.routeBidirectional(ChangelogScanner.java:704)
That covers ordinary changes: a copy-on-write
UPDATE,DELETEorMERGE(Spark's default), and an upsert written as an equality delete plus the new row (Flink upsert tables).Cause.
ChangelogScannerdecodes the key columns' file bounds withConversions.fromByteBuffer, which returns aCharBufferfor a string. The overlap bounds go into the changelog descriptor's Beam Row unchanged, and the Row'sStringcoder fails on them. #41583 fixed the same kind of mismatch for date, time, timestamp and fixed keys; strings weren't covered.Fix. Turn a decoded string bound into a
StringincreateRecId, where it is decoded. Iceberg's string comparator accepts anyCharSequence, so the overlap checks are unchanged.