yihua opened a new pull request, #19564:
URL: https://github.com/apache/hudi/pull/19564
### Describe the issue this Pull Request addresses
closes #19563
`PostgresDebeziumAvroPayload` casts to the concrete class
`GenericData.Record` in `mergeToastedValuesIfPresent` and
`containsBytesToastedValues`. Since #13987 ("perf: Lazy deserialization of Avro
indexed record"), `BaseAvroPayload.getRecord` returns a
`SerializableIndexedRecord` whenever the payload's record does not already
carry the exact `Schema` instance being merged with, which is the ordinary case
in production and after any Kryo round trip. `SerializableIndexedRecord`
implements `GenericRecord` but does not extend `GenericData.Record`, so any
TOAST check on a non-null `BYTES` column throws `ClassCastException`. The
sibling `containsStringToastedValues` was already converted to the interface,
which is why only `BYTES` columns are affected.
### Summary and Changelog
Debezium Postgres ingestion of tables with a `BYTES` column no longer fails
when the incoming event wins the LSN comparison.
* `PostgresDebeziumAvroPayload`: cast to the `GenericRecord` interface
instead of the `GenericData.Record` implementation, in
`mergeToastedValuesIfPresent` (the record already in storage) and in both reads
inside `containsBytesToastedValues`.
* `TestPostgresDebeziumAvroPayload#testMergeWithToastedValues`: turned into
a parameterized test over two independent dimensions, whether the incoming
record is lazily deserialized (built on an equal but distinct `Schema`
instance, which forces the round trip) and whether the record already in
storage is a `SerializableIndexedRecord`. An added assertion pins that the lazy
path is actually taken, so the parameterization cannot quietly degrade into
four copies of the original case. Reverting the payload change fails 3 of the 4
cases with the reported `ClassCastException`; the pre-existing case is the one
that passed before.
### Impact
None beyond fixing the crash. The interface cast accepts everything the
implementation cast accepted.
### Risk Level
low
Covered by the parameterized regression test above, verified to fail without
the payload change.
### Documentation Update
none
### Contributor's checklist
- [x] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable
--
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]