Repository navigation
Commit d939afc
committed
fix: arrow_cast must not elide a metadata-changing cast
`ArrowCastFunc::simplify` short-circuited whenever the argument's data type
already equalled the requested one and returned the argument untouched. That
was sound while a same-type cast could not change anything, but a cast
target's metadata is authoritative, and `arrow_cast` names a storage type and
nothing else - its declared return field (`return_field_from_args`) never
carries metadata.
So casting an extension-typed value back to its own storage type is not a
no-op, it strips the extension metadata, and the short circuit swallowed it:
SELECT arrow_metadata(arrow_cast(uuid_val, 'FixedSizeBinary(16)'),
'ARROW:extension:name')
-- 'arrow.uuid' before, NULL after
which is an `arrow.uuid` value that escaped a cast back to plain
`FixedSizeBinary(16)` (apache#22079).
Elide the cast only when the argument carries no metadata for it to strip.
Checking metadata emptiness rather than just `ARROW:extension:name` follows
from the rule itself: the target field carries no metadata at all, so any
metadata on the argument is metadata the cast removes.1 parent 0bb24a2 commit d939afc
2 files changed
Lines changed: 60 additions & 4 deletions
File tree
- datafusion
- functions/src/core
- sqllogictest/test_files
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
166 | 183 | | |
167 | 184 | | |
168 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
0 commit comments