Repository navigation
Description
Is your feature request related to a problem or challenge?
This came up while implementing SQL casts to Variant in datafusion-variant.
cast_to_variant and cast_to_variant_with_options cannot distinguish an Arrow UUID column from ordinary FixedSizeBinary(16). The arrow.uuid annotation belongs to the input Field, but these APIs accept only &dyn Array.
The conversion dispatches on the storage data type and converts fixed-size binary values to Variant::Binary. A caller implementing CAST(uuid_column AS VARIANT) therefore cannot preserve UUID semantics through this kernel, even when it has the correctly annotated input field.
This follows from the implementation in Arrow 60.0.0 and remains the case on current main: the fixed-size binary path receives no extension metadata.
Describe the solution you'd like
Allow callers to supply input field information, for example through a conversion entry point accepting &Field and &dyn Array. Use the canonical arrow.uuid annotation to distinguish UUID from ordinary binary:
| Input | Expected Variant value |
|---|---|
FixedSizeBinary(16) annotated with arrow.uuid |
Variant::Uuid |
Unannotated FixedSizeBinary(16) |
Variant::Binary |
| Arrow null | Arrow null |
Honor UUID annotations on nested fields in lists, structs, and maps as well. Existing array-only callers should retain their binary conversion behavior. The exact API shape is open for discussion.
Additional context
Related work addressed UUID metadata in shredded Variant storage:
- #10015: merged UUID metadata preservation for shredded fields and Parquet writing.
In #10015's discussion, the justification was that a shredded FixedSizeBinary(16) field can only represent UUID: Arrow uses dedicated decimal types, and the shredding specification stores binary as BYTE_ARRAY. The merged change therefore attaches UUID metadata when constructing or canonicalizing those shredded fields.
That inference relies on the input already being shredded Variant storage. Ordinary Arrow inputs to cast_to_variant need their field metadata to distinguish UUID from binary.
Activity
codewarnab commentedon Nov 1, 2026
take
codewarnab commentedon Nov 1, 2026
Before I start, would these two new functions work?
They would accept the input
Fieldalong with the array, so the conversion can read the UUID annotation.arrow.uuidfield becomesVariant::Uuid.FixedSizeBinary(16)staysVariant::Binary.The existing functions would stay unchanged. The first new function would use the same defaults as
cast_to_variant.Does this look okay, or would you prefer a different API?
sdf-jkl commentedon Nov 2, 2026
It had so been inconvenient throughout the Variant work to pass
Fieldeverywhere just to to pass the extension type around 😢I can see no other way without changing the way we propagate the
ExtensionType. Though I'd be very interested in proposing such a change.codewarnab commentedon Nov 2, 2026
I see what you mean. I read the discussion in #8730 about the problems and the possible approaches.
Should I hold off on this issue until there is an agreement on #8730, or should I proceed with the
Field-accepting API for now? 🙂sdf-jkl commentedon Nov 2, 2026
#8370 haven't been touched in a long time. Getting some attention to it is a good thing and would help us avoid introducing new APIs just to carry
Fieldto the input.codewarnab commentedon Nov 3, 2026
Okay, I’ll dig deeper into #8730 as soon as I have time and share any ideas /plans /questions there.
You mentioned #8370. Did you mean #8730? I’m assuming it was a typo.
sdf-jkl commentedon Nov 27, 2026
#12211 fixed the nested children part of the issue for Variant values
codewarnab commentedon Nov 27, 2026
I'm going to unassign myself from this one.
The main question is how the
arrow.uuidtag should reachcast_to_variant. One option is new functions that take aField. The other is the bigger extension type change discussed in #8730. I shared a prototype and some questions on #8730 on Nov 3 but haven't heard back, so I don't have a clear direction to build on.#12211 already handles the nested part, so what's left mostly depends on that decision. Someone else is welcome to pick it up, or I can come back to it once the approach is agreed.
codewarnab commentedon Nov 27, 2026
untake