[branch-55] Align metadata propagation through Physical and Logical casts (#23169) - #24875
[branch-55] Align metadata propagation through Physical and Logical casts (#23169)#24875timsaucer wants to merge 3 commits into
Conversation
…#23169) - Closes apache#22079 - Closes apache#24724 The logical `Expr::Cast` and `Expr::TryCast` have a `FieldRef` target that was added in apache#18136 so that logical casts can express a cast to an extension type. In combination with a SQL type planner ( apache#20676 ) and an optimizer rule, this enabled casting to/from extension types with custom semantics to actually occur. The ability to do this was reverted by apache#20836 (which removed the original test) and I am not sure that ability ever made it into a release. When investigating this issue, it became clear the logical and physical cast behaviour had diverged with respect to the target field. This PR strips specific metadata keys (extension name and extension metadata) when propagating metadata from the source of a cast to the target (because doing so may result in an invalid destination field that consumers could reject), and propagates all metadata from the (logical) cast target field (e.g., so that a cast to an extension type represented by the cast target field will have a `to_field()` that communicates the extension type). For the physical cast, this behaviour is replicated exactly (I hope). Note that actually casting to an extension type can be implemented with an optimizer rule, planner, or by the mechanism I have in the works in apache#21071 . Yes It was in practice not common to create a `Expr::Cast` with field metadata internally and thus I don't think users will see metadata changes from the inclusion of metadata from the target field. I would be surprised if stripping the extension name/metadata from the source was disruptive (it was more likely to have caused errors). Superceeds an earlier but similar attempt ( apache#22162 ). --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> Co-authored-by: Tim Saucer <timsaucer@gmail.com> (cherry picked from commit 124291e)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## branch-55 #24875 +/- ##
=============================================
+ Coverage 81.19% 81.20% +0.01%
=============================================
Files 1110 1110
Lines 387713 388207 +494
Branches 387713 388207 +494
=============================================
+ Hits 314785 315251 +466
- Misses 54412 54418 +6
- Partials 18516 18538 +22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
I definitely can make it it's own commit. It's a very minor change, but if you want I'll remove it and add another PR. That one would need to land first to avoid breaking CI on this one. |
|
If you don't mind that'd be great to land as it's own prequel commit. I'll aprove that PR, hopefuly it's not much more work. |
This PR is a backport of #23169 onto
branch-55.I made two changes:
usestatement inplanner.rs.