yihua opened a new pull request, #20844: URL: https://github.com/apache/hudi/pull/20844
### Describe the issue this Pull Request addresses closes #20837 On a merge-on-read table, and for a partition move on either table type, a global index merges each matched record of a Spark SQL `MERGE INTO` with its current version while tagging it, and the result is a final row in the table schema with the table's payload class. When those records land in a small file group that also takes inserts, they go to the merge handle, where `StreamingFileGroupRecordBufferLoader` decoded every incoming record with the `ExpressionPayload` record schema and the `ExpressionPayload` merger evaluated the MERGE clauses on them again. The table got unreadable rows, or kept the old rows under event-time ordering. ### Summary and Changelog The merge handle now writes the rows a global index already merged as they are. - `StreamingFileGroupRecordBufferLoader` buffers an incoming record that is not an `ExpressionPayload` record in the table schema (the reader schema without meta fields) instead of the `ExpressionPayload` record schema. - `ExpressionPayloadRecordMerger#finalMerge` keeps a newer record in that schema rather than evaluating the MERGE clauses on it, and `PayloadUpdateProcessor` skips the `ExpressionPayload` insert evaluation for it. The two schemas never collide, since the `ExpressionPayload` record schema is named `record`. - `HoodieIndexUtils` notes that the index merge must keep buffering its incoming `ExpressionPayload` records with meta fields, so that they never take that path. - `TestMergeIntoTable` runs a MERGE with an assignment that reads the source (`price = s.price + 1`, which also catches a second evaluation) into a MOR small file group under `GLOBAL_SIMPLE` and `GLOBAL_BLOOM` and both orderings, with a stale event-time update, and a partition move into a small file group on COW and MOR. Without the fix they fail with `but got Array([1,,1.0,0], [1,a,1.0,0], [1,,1.0,0], [4,a4,40.0,2000])` and `but got Array([1,,5.149096449E-314,0,p2], ...)`. `LsmFileGroupRecordIterator` decodes incoming records the same way; it is left unchanged since I have not reproduced the bug on the LSM layout. ### Impact MERGE INTO with `GLOBAL_SIMPLE` or `GLOBAL_BLOOM` writes the rows the index merged into small file groups correctly, on MOR and for partition moves on COW. No API or config change. ### Risk Level medium. The change is limited to writes with `ExpressionPayload` through the merge handle; records of other payloads are buffered and merged as before. ### Documentation Update none ### Contributor's checklist - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [ ] Enough context is provided in the sections above - [ ] 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]
