vinishjail97 opened a new pull request, #19769:
URL: https://github.com/apache/hudi/pull/19769

   ### Change Logs
   
   `OrderingValues#create` coerces a null ordering-field value to 
`HoodieRecord.DEFAULT_ORDERING_VALUE`, which is declared `int`. A record whose 
ordering column is `null` therefore holds `Integer(0)` while its counterpart in 
the same file group holds the column's real value, e.g. a `Long`. 
`BufferedRecordMergerFactory.shouldKeepNewerRecord` compared the two with a raw 
`Comparable#compareTo`, throwing `ClassCastException: java.lang.Integer cannot 
be cast to java.lang.Long`, which the write path wraps as 
`HoodieUpsertException`.
   
   The comment above that comparison already notes the hazard, but the guard it 
annotates applies only to DELETE records, so a non-delete record holding the 
sentinel was unguarded.
   
   This applies the guard `deltaMergeDeleteRecord` already uses in the same 
file (also used by `HoodieMergedLogRecordScanner` and 
`PartialUpdateAvroPayload`): skip the comparison when the incoming ordering 
value is the default sentinel or the two classes differ, falling back to 
natural order.
   
   For same-class, non-default ordering values the result is unchanged: `!(old 
> new)` is `new >= old`. Only the inputs that previously threw behave 
differently.
   
   ### Impact
   
   No API, config, or default change. Tables whose ordering field is nullable 
no longer fail merges.
   
   ### Risk level
   
   low
   
   Added two cases to `TestBufferedRecordMergerFactory` covering both 
mixed-class directions, `deltaMerge` and `finalMerge`, and same-class 
event-time ordering. They fail with `ClassCastException` against the unfixed 
method and pass with the fix (`Tests run: 3, Failures: 0, Errors: 0` in 
`hudi-common`).
   
   ### Documentation Update
   
   None.
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Change Logs and Impact were stated clearly
   - [x] Adequate tests were added if applicable
   - [ ] CI passed
   


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