lokeshj1703 opened a new issue, #19636:
URL: https://github.com/apache/hudi/issues/19636

   ## Problem
   
   When a table's ordering (precombine) field is a nullable column, a record 
whose ordering value is null triggers a `NullPointerException` in the file 
group reader's merge path.
   
   `OrderingValues.create` maps the field value through the key-generation / 
field-mapping function and, for the single-field case, returns whatever the 
function produced. When the underlying column value is null the function 
returns null, so `create` returns null and the resulting `BufferedRecord` 
carries a null ordering value.
   
   That null then reaches `BufferedRecordMergerFactory.shouldKeepNewerRecord`, 
which calls `getOrderingValue().compareTo(...)` without a null guard. During a 
partition-path update index merge 
(`HoodieIndexUtils.mergeForPartitionUpdatesAndDeletionsIfNeeded` -> 
`EventTimeRecordMerger.finalMerge` -> `shouldKeepNewerRecord`) this throws:
   
   ```
   java.lang.NullPointerException
        at 
org.apache.hudi.common.table.read.BufferedRecordMergerFactory.shouldKeepNewerRecord(...)
   ```
   
   A nullable ordering column is common in practice (for example a nullable 
BIGINT event-time column), so any MOR table with such a column can hit this on 
reads/merges.
   
   ## Secondary issue
   
   Coercing the null ordering value to the default 
(`HoodieRecord.DEFAULT_ORDERING_VALUE`, an `Integer 0`) is not sufficient on 
its own: `shouldKeepNewerRecord` and `EventTimePartialRecordMerger.finalMerge` 
then compare that `Integer 0` against a real `Long` ordering value and throw 
`ClassCastException: java.lang.Long cannot be cast to java.lang.Integer`. Both 
comparison sites need an `isSameClass` guard (as `deltaMergeDeleteRecord` 
already has) so a default/type-mismatched ordering value is treated as a tie 
rather than compared directly.
   
   ## Expected behavior
   
   A null ordering field value should not crash reads or merges. It should be 
treated as the default ordering value, and ordering comparisons should be 
skipped (record treated as a tie, newer kept) when either value is the default 
or the two values are of different types.
   
   ## Environment
   
   - Affects the 1.x line (file group reader / `BufferedRecordMergerFactory`).
   - Merge mode: `EVENT_TIME_ORDERING` (and the partial-update variant when 
`hoodie.partial.update.mode` is set).
   


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