Repository navigation
Description
Support CAST, TRY_CAST, and :: from stored or composed Variant values to SQL types, regardless of which expression produced the value. Casts directly around getter UDFs already work; casts from other Variant expressions still need the same conversion semantics.
Landed
- SQL type hints and getter cast rewrites — Support SQL type hints and casts for Variant getters #88.
- SQL
VARIANTregistration and Variant getter targets — feat: register SQL VARIANT and support Variant getter targets #89. - SQL casts to VARIANT and
to_variant_object, replacingcast_to_variant— Replace cast_to_variant with SQL casts and to_variant_object #105, merged 2026-10-27. Casts accept scalars and arrays; structs and string-keyed maps useto_variant_object. Strings are wrapped, not parsed as JSON. - Identity casts preserve existing Variant storage, including shredding and binary layouts. New conversions carry
arrow.parquet.variantmetadata; recursive planning validation and per-row try-cast NULL behavior have regression coverage in Replace cast_to_variant with SQL casts and to_variant_object #105.
Remaining conversion-kernel gaps and the temporary safe-cast null adjustment are tracked in #71. They are separate from the missing SQL cast dispatch here.
Remaining behavior
With functions and the type planner registered:
CREATE TABLE variant_values AS
SELECT parse_json('7') AS v;
-- All should return 7 as INT.
SELECT CAST(v AS INT), TRY_CAST(v AS INT), v::INT
FROM variant_values;
-- Composed expressions should work too.
SELECT CAST(parse_json('7') AS INT);Reuse Arrow's Variant extraction/conversion kernels and existing typed-getter semantics. Dispatch using source fields and extension metadata; an ordinary struct resembling Variant storage must not be treated as Variant. Assess DataFusion's existing planning/extension APIs before proposing an upstream hook.
Acceptance criteria
- Stored columns and composed Variant expressions use typed-getter conversion rules across projection and materialization boundaries.
- Strict casts error on failed conversions; try casts return SQL NULL. Preserve SQL NULL, Variant null, and missing-result semantics consistently with getters.
- Preserve explicit intermediate conversions, existing getter cast optimizations, and the casts to VARIANT added in Replace cast_to_variant with SQL casts and to_variant_object #105.
- Keep declared result fields consistent with kernel output. Accept valid binary layouts without converting buffers solely to prefer BinaryView.
- Add focused SLTs for expression/materialization boundaries, reusing the existing conversion and null fixtures.
Nested Variant getter targets and exposing DataFusion's SQL type-string resolver remain separate follow-ups. Related: #69, #71.
Activity
[-]Support general SQL casts to and from VARIANT[/-][+]Support general SQL casts from VARIANT[/+]