RyanLin5967 opened a new issue, #919:
URL: https://github.com/apache/hudi-rs/issues/919
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Description of the bug
Currently, the merge looks up the ordering field only among top-level
columns, so a nested field such as `meta.ts` gives no ordering value and the
log record always replaces the base row. With a top-level `ts` and the same
values the read returns `x`.
### Steps To Reproduce
```python
import tempfile
from pyspark.sql import SparkSession
from hudi import HudiTableBuilder, HudiReadOptions
spark = (SparkSession.builder
.config("spark.jars.packages",
"org.apache.hudi:hudi-spark4.0-bundle_2.13:1.2.1")
.config("spark.serializer",
"org.apache.spark.serializer.KryoSerializer").getOrCreate())
path = tempfile.mkdtemp()
opts = {"hoodie.table.name": "t", "hoodie.datasource.write.table.type":
"MERGE_ON_READ",
"hoodie.datasource.write.recordkey.field": "id",
"hoodie.datasource.write.precombine.field": "meta.ts"}
for rows in ([("a", "x", (5,))], [("a", "y", (1,))]):
spark.createDataFrame(rows, "id STRING, v STRING, meta STRUCT<ts:
LONG>").write.format("hudi") \
.options(**opts).mode("append").save(path)
t = HudiTableBuilder.from_base_uri(path).build()
print([(r["id"], r["v"]) for b in t.read(HudiReadOptions()) for r in
b.to_pylist()])
# [('a', 'y')], should be [('a', 'x')]
# the second write has meta.ts 1, below the stored 5
print(spark.read.format("hudi").load(path).select("id", "v").collect())
# [Row(id='a', v='x')]
```
### Expected behavior
The read returns `[('a', 'x')]`, as Spark does, since the table's
`hoodie.record.merge.mode` is `EVENT_TIME_ORDERING` and `meta.ts` 5 is the
higher value.
### Screenshots / Logs
_No response_
### Software information
- Operating system: macOS 26.7.1, arm64 (Darwin 25.6.0)
- Rust version: none, the PyPI wheel on Python 3.12.16
- Project version: hudi 0.5.0, and main (its CI wheel, 0.6.0.dev0)
- Writer: Hudi 1.2.1 (`hudi-spark4.0-bundle_2.13`) on pyspark 4.0.5, Java
21.0.12.1
### Additional context
`RecordContext::ordering_accessor` resolves the field with
`batch.schema().index_of`, which matches only top-level columns.
--
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]