claudevdm opened a new pull request, #41960:
URL: https://github.com/apache/beam/pull/41960

   A CDC read (`IcebergIO.readRows(...).withCdc()` or Managed `ICEBERG_CDC`) of 
a table whose primary key has a `string` column 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`, `DELETE` or `MERGE` 
(Spark's default), and an upsert written as an equality delete plus the new row 
(Flink upsert tables).
   
   **Cause.** `ChangelogScanner` decodes the key columns' file bounds with 
`Conversions.fromByteBuffer`, which returns a `CharBuffer` for a string. The 
overlap bounds go into the changelog descriptor's Beam Row unchanged, and the 
Row's `String` coder 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 `String` in `createRecId`, where 
it is decoded. Iceberg's string comparator accepts any `CharSequence`, so the 
overlap checks are unchanged.


-- 
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]

Reply via email to