You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "ryzhyk (via GitHub)" <gi...@apache.org> on 2026/08/30 08:03:09 UTC
[PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
ryzhyk opened a new pull request, #24790:
URL: https://github.com/apache/datafusion/pull/24790
## Which issue does this PR close?
- Closes #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?
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew merged PR #24790:
URL: https://github.com/apache/datafusion/pull/24790
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "ryzhyk (via GitHub)" <gi...@apache.org>.
ryzhyk commented on PR #24790:
URL: https://github.com/apache/datafusion/pull/24790#issuecomment-5557567833
@kosiew , I pushed a stronger test. I am not really familiar with the code base and relied on claude. The fix looks reasonable to me though. I hope this is in a good enough shape to merge. Thanks for your feedback.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "ryzhyk (via GitHub)" <gi...@apache.org>.
ryzhyk commented on code in PR #24790:
URL: https://github.com/apache/datafusion/pull/24790#discussion_r3943143179
##########
datafusion/datasource-parquet/src/schema_coercion.rs:
##########
@@ -728,4 +732,53 @@ mod tests {
assert_eq!(result, expected_schema);
}
+
+ #[test]
+ fn coerce_int96_to_resolution_preserves_field_metadata() {
+ // Spark and Delta Lake stamp a field id on every field. Coercion must
+ // carry that metadata across on nested fields as well as leaves:
+ // formats that identify a column by id rather than by name, such as
+ // Delta Lake column mapping, cannot resolve a column that loses it.
+ let spark_schema = "
+ message spark_schema {
+ REQUIRED INT64 c0 = 1;
+ OPTIONAL group c1 = 2 {
+ OPTIONAL INT96 c2 = 3;
+ }
+ OPTIONAL group c3 (LIST) = 4 {
+ REPEATED group list {
+ OPTIONAL INT96 element = 5;
+ }
+ }
+ }
+ ";
+
+ let schema = parse_message_type(spark_schema).expect("should parse schema");
+ let descr = SchemaDescriptor::new(Arc::new(schema));
+ let arrow_schema = parquet_to_arrow_schema(&descr, None).unwrap();
+
+ let result = Int96Coercer::new(&descr, &arrow_schema, &TimeUnit::Microsecond)
+ .coerce()
+ .unwrap();
+
+ for (original, coerced) in arrow_schema.fields().iter().zip(result.fields()) {
Review Comment:
Sorry, missed your feedback. Will push an updated test in a bit.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24790:
URL: https://github.com/apache/datafusion/pull/24790#issuecomment-5467629820
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/24790?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 `96.96970%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 81.53%. Comparing base ([`4ada0dc`](https://app.codecov.io/gh/apache/datafusion/commit/4ada0dcabbf502f751a7c21cf6cb642154637af9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8bb2406`](https://app.codecov.io/gh/apache/datafusion/commit/8bb2406c8575547499b61e00b1f4424ac5f6661a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/24790?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...tafusion/datasource-parquet/src/schema\_coercion.rs](https://app.codecov.io/gh/apache/datafusion/pull/24790?src=pr&el=tree&filepath=datafusion%2Fdatasource-parquet%2Fsrc%2Fschema_coercion.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9kYXRhc291cmNlLXBhcnF1ZXQvc3JjL3NjaGVtYV9jb2VyY2lvbi5ycw==) | 96.96% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/24790?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #24790 +/- ##
==========================================
- Coverage 81.53% 81.53% -0.01%
==========================================
Files 1123 1123
Lines 406041 406074 +33
Branches 406041 406074 +33
==========================================
+ Hits 331049 331073 +24
- Misses 55631 55636 +5
- Partials 19361 19365 +4
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/24790?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew commented on code in PR #24790:
URL: https://github.com/apache/datafusion/pull/24790#discussion_r3912594407
##########
datafusion/datasource-parquet/src/schema_coercion.rs:
##########
@@ -728,4 +732,53 @@ mod tests {
assert_eq!(result, expected_schema);
}
+
+ #[test]
+ fn coerce_int96_to_resolution_preserves_field_metadata() {
+ // Spark and Delta Lake stamp a field id on every field. Coercion must
+ // carry that metadata across on nested fields as well as leaves:
+ // formats that identify a column by id rather than by name, such as
+ // Delta Lake column mapping, cannot resolve a column that loses it.
+ let spark_schema = "
+ message spark_schema {
+ REQUIRED INT64 c0 = 1;
+ OPTIONAL group c1 = 2 {
+ OPTIONAL INT96 c2 = 3;
+ }
+ OPTIONAL group c3 (LIST) = 4 {
+ REPEATED group list {
+ OPTIONAL INT96 element = 5;
+ }
+ }
+ }
+ ";
+
+ let schema = parse_message_type(spark_schema).expect("should parse schema");
+ let descr = SchemaDescriptor::new(Arc::new(schema));
+ let arrow_schema = parquet_to_arrow_schema(&descr, None).unwrap();
+
+ let result = Int96Coercer::new(&descr, &arrow_schema, &TimeUnit::Microsecond)
+ .coerce()
+ .unwrap();
+
+ for (original, coerced) in arrow_schema.fields().iter().zip(result.fields()) {
Review Comment:
Could we make this regression test a little stronger by adding a map containing an INT96 field and recursively comparing the metadata of nested fields?
Right now the assertion compares only the top-level fields, while the test comment says metadata should be preserved on nested fields as well. A recursive comparison covering struct, list, and map children would also exercise the rebuilt map and entry struct paths and protect arbitrary nested metadata, rather than only the outer Parquet field IDs.
This is non-blocking, but I think it would make the regression coverage match the intent of the fix more closely.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Preserve field metadata when coercing INT96 timestamps [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew commented on PR #24790:
URL: https://github.com/apache/datafusion/pull/24790#issuecomment-5565829419
🚀
@ryzhyk
Thank you for your contribution.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org