Zachgille opened a new pull request, #27862:
URL: https://github.com/apache/datafusion/pull/27862

   ## Which issue does this PR close?
   
   - Closes #27861.
   
   ## Rationale for this change
   
   A `CAST` or `TRY_CAST` to the source's own type keeps 
`ARROW:extension:metadata` when the source has that key but no 
`ARROW:extension:name`. The logical plan reports the key as stripped. The stale 
extension parameter therefore shows up in query results, and in tables created 
from a folded constant.
   
   ## What changes are included in this PR?
   
   `cast_with_target_field` and `try_cast_with_target_field` now skip a 
same-type, type-only cast only when the source has neither 
`ARROW:extension:name` nor `ARROW:extension:metadata`. The logical cast and 
physical type-only return_field paths already strip both keys.
   
   ## What is the testing strategy for this PR?
   
   - Unit tests: `same_type_type_only_cast_strips_orphan_extension_metadata` in 
`cast.rs` and `same_type_type_only_try_cast_strips_orphan_extension_metadata` 
in `try_cast.rs`.
   - `cast_extension_type_metadata.slt`: constant-folded and table-backed 
`CAST` and `TRY_CAST` over a source tagged only with `ARROW:extension:metadata`.
   
   All of these fail without the change.
   
   ## Are there any user-facing changes?
   
   A bug fix only. `ARROW:extension:metadata` no longer survives a same-type 
`CAST` or `TRY_CAST` when the source has no `ARROW:extension:name`. There are 
no API changes.
   
   AI assistance disclosure: I used AI coding tools to help write and test this 
change. I reviewed the change and the test results myself.


-- 
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]

Reply via email to