adriangb opened a new pull request, #21390: URL: https://github.com/apache/datafusion/pull/21390
## Which issue does this PR close? N/A — discovered while investigating metadata propagation through cast expressions. ## Rationale for this change `Expr::Cast` preserves the source field's metadata through a dedicated `to_field` handler in `expr_schema.rs`, but `Expr::TryCast` fell through to the default case which creates a `Field::new(...)` without any metadata. This caused source column metadata to be silently dropped when using `TRY_CAST`. ## What changes are included in this PR? - Added a dedicated `to_field` handler for `Expr::TryCast` in `expr_schema.rs` that preserves source field metadata (matching `Expr::Cast` behavior), while keeping TryCast's always-nullable semantics. - Added SLT tests in `metadata.slt` verifying metadata preservation through `TRY_CAST` on both timestamp and integer columns. ## Are these changes tested? Yes — new sqllogictest cases in `metadata.slt` using `arrow_metadata()` to verify metadata is preserved through `TRY_CAST`. ## Are there any user-facing changes? `TRY_CAST` now preserves source field metadata, consistent with `CAST` behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
