Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-11 Thread via GitHub


hudi-agent commented on code in PR #19900:
URL: https://github.com/apache/hudi/pull/19900#discussion_r3991469855


##
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieAvroRecord.java:
##
@@ -104,7 +106,58 @@ public T getData() {
 
   @Override
   public Comparable doGetOrderingValue(HoodieSchema recordSchema, 
Properties props, String[] orderingFields) {
-return this.getData().getOrderingValue();
+Comparable payloadOrderingValue = getData().getOrderingValue();
+if (!canReadOrderingFieldsFromRecord(payloadOrderingValue, recordSchema, 
props, orderingFields)) {
+  return payloadOrderingValue;
+}
+// The payload carries no ordering value: payloads constructed from the 
record alone
+// (HoodieRecordUtils#loadPayload(String, GenericRecord)) default to 
OrderingValues#getDefault,
+// an Integer. Read the ordering fields off the record instead, the way
+// HoodieAvroIndexedRecord#doGetOrderingValue does, so that both Avro 
record representations
+// yield an ordering value of the type the ordering field declares. This 
is best effort: any
+// record we cannot read leaves the payload's value in place, which is 
what callers saw before.
+try {
+  Option avroData = 
getData().getIndexedRecord(recordSchema.toAvroSchema(), props);
+  if (!avroData.isPresent()) {
+return payloadOrderingValue;
+  }
+  boolean consistentLogicalTimestampEnabled = 
Boolean.parseBoolean(props.getProperty(
+  
KeyGeneratorOptions.KEYGENERATOR_CONSISTENT_LOGICAL_TIMESTAMP_ENABLED.key(),
+  
KeyGeneratorOptions.KEYGENERATOR_CONSISTENT_LOGICAL_TIMESTAMP_ENABLED.defaultValue()));
+  Comparable recordOrderingValue = OrderingValues.create(
+  orderingFields,
+  field -> (Comparable) HoodieAvroUtils.getNestedFieldVal(
+  (GenericRecord) avroData.get(), field, true, 
consistentLogicalTimestampEnabled));
+  // A nullable ordering field holding null reads back as null, which no 
caller expects here.
+  return recordOrderingValue == null ? payloadOrderingValue : 
recordOrderingValue;
+} catch (Exception e) {
+  // Reading the record is an optimization over the payload's default, 
never a new failure
+  // mode: a schema the payload cannot decode, or props an exotic payload 
requires and does
+  // not get here, must not turn an ordering value lookup into a write 
failure.
+  return payloadOrderingValue;
+}
+  }
+
+  /**
+   * Whether the ordering value is worth reading off the record rather than 
taking the payload's.
+   * Only when the payload has none, the table declares ordering fields, and 
the record is not a
+   * delete: BufferedRecord#isCommitTimeOrderingDelete treats a delete 
carrying the default

Review Comment:
   πŸ€– Keeping deletes at the default is a deliberate choice here, but it leaves 
the two representations disagreeing for deletes: a `_hoodie_is_deleted=true` 
record with `ts=100` is an event-time delete (loses to an existing `ts=200`) as 
`HoodieAvroIndexedRecord`, yet a commit-time delete (always wins via 
`isCommitTimeOrderingDelete`) as `HoodieAvroRecord`. Is that the intended 
long-term contract, or should this be tracked as a follow-up? @nsivabalan would 
be good to get your read on which delete semantics is the desired one for 
payload-based records.
   
   ⚠️ AI-generated; verify before applying. React πŸ‘/πŸ‘Ž to flag 
quality.



##
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieAvroRecord.java:
##
@@ -104,7 +106,58 @@ public T getData() {
 
   @Override
   public Comparable doGetOrderingValue(HoodieSchema recordSchema, 
Properties props, String[] orderingFields) {
-return this.getData().getOrderingValue();
+Comparable payloadOrderingValue = getData().getOrderingValue();
+if (!canReadOrderingFieldsFromRecord(payloadOrderingValue, recordSchema, 
props, orderingFields)) {
+  return payloadOrderingValue;
+}
+// The payload carries no ordering value: payloads constructed from the 
record alone
+// (HoodieRecordUtils#loadPayload(String, GenericRecord)) default to 
OrderingValues#getDefault,
+// an Integer. Read the ordering fields off the record instead, the way
+// HoodieAvroIndexedRecord#doGetOrderingValue does, so that both Avro 
record representations
+// yield an ordering value of the type the ordering field declares. This 
is best effort: any
+// record we cannot read leaves the payload's value in place, which is 
what callers saw before.
+try {
+  Option avroData = 
getData().getIndexedRecord(recordSchema.toAvroSchema(), props);
+  if (!avroData.isPresent()) {
+return payloadOrderingValue;
+  }
+  boolean consistentLogicalTimestampEnabled = 
Boolean.parseBoolean(props.getProperty(
+  
KeyGeneratorOptions.KEYGENERATOR_CONSISTENT_LOGICAL_TIMESTAMP_ENABLED.key(),
+  

Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-11 Thread via GitHub


hudi-bot commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5637660684

   
   ## CI report:
   
   * 4197bc02ce122def00bee7f6981be062922c4371 Azure: 
[SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16998)
 
   * 24d06462bb35b84a2768811d126218fd72af UNKNOWN
   
   
   Bot commands
 @hudi-bot supports the following commands:
   
- `@hudi-bot run azure` re-run the last Azure build
   


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-11 Thread via GitHub


linliu-code closed pull request #19900: fix(core): derive HoodieAvroRecord's 
ordering value from the record when the payload has none
URL: https://github.com/apache/hudi/pull/19900


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-11 Thread via GitHub


linliu-code commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5638278806

   Closing in favour of fixing the generation sites instead.
   
   This PR made `HoodieAvroRecord` derive its own ordering value when the 
payload has none. That is a fallback: it fires on 
`OrderingValues.isDefault(...)`, which cannot distinguish "the payload has no 
ordering value" from "its ordering value is genuinely 0", and making that 
inference safe required four guards (the default check, a delete gate, a null 
gate, and a catch-all around the decode). Needing four guards to make a guess 
safe is the signal that the guess is the wrong move.
   
   The record should instead be born with its ordering value. There are exactly 
two generation sites that build one without:
   
   - `HoodieCreateRecordUtils` (Spark SQL / DataSource) β€” fixed separately
   - `HoodieStreamerUtils` (Hudi Streamer) β€” fixed separately
   
   Fixing those addresses the cause rather than surviving it. Tracked with the 
design issue apache/hudi#19901, which proposes going one level further and 
making "no ordering value" unrepresentable rather than encoded as an untyped 0.


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-11 Thread via GitHub


hudi-bot commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5637728167

   
   ## CI report:
   
   * 4197bc02ce122def00bee7f6981be062922c4371 Azure: 
[SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16998)
 
   * 24d06462bb35b84a2768811d126218fd72af Azure: 
[PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17020)
 
   
   
   Bot commands
 @hudi-bot supports the following commands:
   
- `@hudi-bot run azure` re-run the last Azure build
   


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-10 Thread via GitHub


codecov-commenter commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5626055763

   ## 
[Codecov](https://app.codecov.io/gh/apache/hudi/pull/19900?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `13.04348%` with `20 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 80.19%. Comparing base 
([`648996f`](https://app.codecov.io/gh/apache/hudi/commit/648996f002c3c9e24a1e2bf53f97fe03e8bc4c81?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`4197bc0`](https://app.codecov.io/gh/apache/hudi/commit/4197bc02ce122def00bee7f6981be062922c4371?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/hudi/pull/19900?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[...org/apache/hudi/common/model/HoodieAvroRecord.java](https://app.codecov.io/gh/apache/hudi/pull/19900?src=pr&el=tree&filepath=hudi-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhudi%2Fcommon%2Fmodel%2FHoodieAvroRecord.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkvY29tbW9uL21vZGVsL0hvb2RpZUF2cm9SZWNvcmQuamF2YQ==)
 | 13.04% | [18 Missing and 2 partials :warning: 
](https://app.codecov.io/gh/apache/hudi/pull/19900?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   Additional details and impacted files
   
   
   
   ```diff
   @@ Coverage Diff  @@
   ## master   #19900  +/-   ##
   
   - Coverage 80.20%   80.19%   -0.02% 
   - Complexity3466134663   +2 
   
 Files  2546 2546  
 Lines142452   142474  +22 
 Branches  1733017337   +7 
   
   + Hits 114260   114262   +2 
   - Misses2028120299  +18 
   - Partials   7911 7913   +2 
   ```
   
   | 
[Components](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Ξ” | |
   |---|---|---|
   | 
[hudi-common](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `83.79% <13.04%> (-0.05%)` | :arrow_down: |
   | 
[hudi-client](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `83.28% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `85.57% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `73.28% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `78.17% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `69.99% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `70.81% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `75.99% <ΓΈ> (ΓΈ)` | |
   | 
[hudi-io](https://app.codecov.io/gh/apache/hudi/pull/19900/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | `81.61% <ΓΈ> (ΓΈ)` | |
   | 

Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-10 Thread via GitHub


hudi-bot commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5627251001

   
   ## CI report:
   
   * 4197bc02ce122def00bee7f6981be062922c4371 Azure: 
[SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16998)
 
   
   
   Bot commands
 @hudi-bot supports the following commands:
   
- `@hudi-bot run azure` re-run the last Azure build
   


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-10 Thread via GitHub


hudi-bot commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5626118677

   
   ## CI report:
   
   * 4197bc02ce122def00bee7f6981be062922c4371 UNKNOWN
   
   
   Bot commands
 @hudi-bot supports the following commands:
   
- `@hudi-bot run azure` re-run the last Azure build
   


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



Re: [PR] fix(core): derive HoodieAvroRecord's ordering value from the record when the payload has none [hudi]

2026-09-10 Thread via GitHub


hudi-bot commented on PR #19900:
URL: https://github.com/apache/hudi/pull/19900#issuecomment-5626179841

   
   ## CI report:
   
   * 4197bc02ce122def00bee7f6981be062922c4371 Azure: 
[PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16998)
 
   
   
   Bot commands
 @hudi-bot supports the following commands:
   
- `@hudi-bot run azure` re-run the last Azure build
   


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