fix: preserve target extension metadata in INSERT - #24971
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24971 +/- ##
==========================================
- Coverage 81.67% 81.67% -0.01%
==========================================
Files 1126 1126
Lines 414842 414855 +13
Branches 414842 414855 +13
==========================================
- Hits 338841 338838 -3
- Misses 56070 56080 +10
- Partials 19931 19937 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ryux1
left a comment
There was a problem hiding this comment.
Reviewed both paths of the field-aware coercion. When storage types already match, the added Cast::new_from_field supplies the target extension metadata; when cast_to already produced a cast, replacing that cast preserves its child and conversion while avoiding a redundant nested cast. The metadata-only and storage-type-conversion tests exercise those branches, and the final alias still enforces the target column name. This looks good to me.
602d867 to
2599861
Compare
ryux1
left a comment
There was a problem hiding this comment.
Thanks, Artem. I re-reviewed b5ae6ff: limiting the field-aware cast to actual extension types keeps the fix scoped and avoids promising propagation of arbitrary field metadata. I also ablated the new guard and confirmed the ordinary-metadata regression test fails without it, then restored the change and ran the focused INSERT tests successfully. The remaining hosted jobs are still pending, but the updated code and coverage look good to me.
Which issue does this PR close?
Rationale for this change
INSERTcurrently aligns source expressions with target columns by storageDataTypeonly. If both fields use the same storage type but the target is an Arrow extension type, the cast is skipped and the DML projection loses the target extension metadata. A table sink can then receive a schema that does not describe the target logical type.What changes are included in this PR?
After storage-type coercion, compare the resulting field metadata with the target table field. When they differ, use the existing field-aware
Castrepresentation to enforce the target metadata. Existing casts are replaced rather than nested.The regression uses an unannotated
FixedSizeBinary(16)source and anarrow.uuidtarget so the behavior is independent of any particular downstream consumer. Existing parameterized UUID INSERT snapshots are updated to show the target field-aware cast.What is the testing strategy for this PR?
plan_insert_preserves_target_extension_metadata.datafusion-sqlintegration tests.cargo clippy -p datafusion-sql --all-targets --all-features -- -D warnings.cargo fmt --all -- --check.Are there any user-facing changes?
Yes. SQL
INSERTplans now preserve target Arrow field metadata, including extension metadata. There are no public API changes.