[branch-55] Preserve field metadata when coercing INT96 timestamps (#24790) - #25895
Conversation
## Which issue does this PR close? - Closes apache#24786. ## Rationale for this change `Int96Coercer` rebuilds every struct, list and map field with `Field::new_struct`, `Field::new_list` and `Field::new`, which start from empty metadata. Leaf fields go through `field_with_new_type`, which clones the field, so only container fields are affected, and only when the file holds an INT96 column: the same file read without `coerce_int96` keeps its metadata. ## What changes are included in this PR? Carry `current_field.metadata()` across in the three constructors. ## Are these changes tested? yes ## Are there any user-facing changes? --------- Signed-off-by: Leonid Ryzhyk <ryzhyk@gmail.com> (cherry picked from commit cc29ea1)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## branch-55 #25895 +/- ##
===========================================
Coverage 81.21% 81.21%
===========================================
Files 1110 1110
Lines 388506 388606 +100
Branches 388506 388606 +100
===========================================
+ Hits 315527 315611 +84
- Misses 54430 54448 +18
+ Partials 18549 18547 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
comphead
left a comment
There was a problem hiding this comment.
Thanks @dwsmith1983 this backport makes sense to me. Would you mind adding more information how critical is not having this fix in the patchset? For backports we usually trying to merge the critical things.
Without it the query returns wrong results and raises no error. With The fix is three |
alamb
left a comment
There was a problem hiding this comment.
Tahnks @dwsmith1983 -- looks good to me
Which issue does this PR close?
branch-55, for the 55.2.0 patch release (Release DataFusion55.2.0(patch) Release (Oct 2026) #25758).Int96Coercerdrops the metadata of struct, list and map fields. #24786 onbranch-55.Rationale for this change
With
datafusion.execution.parquet.coerce_int96set, a file with an INT96 column comes back with the metadata of every struct, list and map field emptied, while leaf fields keep theirs. Readers that match fields by Parquet field id lose the id of any container whose id sits only on the container. Apache DataFusion Comet always enables the coercion, so with Spark's field id reads on it null fills such a container where Spark reads it (apache/datafusion-comet#6131).What changes are included in this PR?
A clean cherry-pick of #24790 (with
-x): the three container constructors inschema_coercion.rskeep the original field's metadata, plus that PR's tests.What is the testing strategy for this PR?
The tests from #24790 come with the cherry-pick. The
datafusion-datasource-parquetcrate's tests,cargo fmtandcargo clippypass on this branch.Are there any user-facing changes?
Struct, list and map fields read from files with INT96 columns keep their field metadata when
coerce_int96is set. No API changes.