osipovartem opened a new pull request, #24971: URL: https://github.com/apache/datafusion/pull/24971
## Which issue does this PR close? - Closes #24970. ## Rationale for this change `INSERT` currently aligns source expressions with target columns by storage `DataType` only. 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 `Cast` representation to enforce the target metadata. Existing casts are replaced rather than nested. The regression uses an unannotated `FixedSizeBinary(16)` source and an `arrow.uuid` target 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? - Added `plan_insert_preserves_target_extension_metadata`. - Ran all 575 `datafusion-sql` integration tests. - Ran `cargo clippy -p datafusion-sql --all-targets --all-features -- -D warnings`. - Ran `cargo fmt --all -- --check`. ## Are there any user-facing changes? Yes. SQL `INSERT` plans now preserve target Arrow field metadata, including extension metadata. There are no public API 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
