linliu-code opened a new pull request, #19280:
URL: https://github.com/apache/hudi/pull/19280

   ### Describe the issue this Pull Request addresses
   
   On a Merge-on-Read table written with `PostgresDebeziumAvroPayload`, a 
snapshot read could return the raw sentinel string 
`__debezium_unavailable_value` for TOASTed columns (large STRING/BYTES columns 
Debezium could not capture in an UPDATE) instead of the real value. This 
affected pre-9 table versions (6 and 8); version 9 resolves toasted values 
through the `FILL_UNAVAILABLE` partial-update handler and was unaffected.
   
   Root cause: the payload fills toasted columns from the base value by 
mutating the incoming avro record in place and returning that same reference. 
`HoodieAvroRecordMerger` has an identity short-circuit — when the payload 
returns the same object it was handed, the merger returns the engine-backed 
`newer` record rather than rebuilding. Since `newer` is a separate avro 
conversion of the same row, the in-place fill was dropped and the sentinel 
survived into the merged result.
   
   ### Summary and Changelog
   
   Make the payload return a new record only when it actually fills a toasted 
column (a lazy shallow copy), leaving the record untouched otherwise. The 
merger's identity short-circuit then still fires for every normal merge, and 
only the toasted case falls through to rebuild, so the fill survives. 
`HoodieAvroRecordMerger` is unchanged.
   
   - `PostgresDebeziumAvroPayload.mergeToastedValuesIfPresent` now returns an 
`IndexedRecord` (a distinct shallow copy when it fills a toasted column, else 
the original) instead of mutating in place; both `combineAndGetUpdateValue` 
overloads return that record.
   - Adds `TestDebeziumToastedValue`, a parameterized functional test over 
table versions 6, 8 and 9.
   
   ### Impact
   
   Fixes wrong data (sentinel placeholder leaking into query results) for 
Postgres Debezium toasted columns on MOR snapshot reads for table versions 6 
and 8. No public API change. The common merge path is unchanged (the merger's 
zero-copy short-circuit still applies); only a toasted-column merge does one 
extra shallow record copy.
   
   ### Risk Level
   
   low
   
   The change is confined to `PostgresDebeziumAvroPayload`; the record merger 
is untouched. Covered by the new parameterized functional test across table 
versions 6, 8 and 9.
   
   ### 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]

Reply via email to