- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wednesday
By the time to_variant_object runs, that array has no VOID element left in it.
ARRAY(PAYMENT_DATE, TRANSACTION_DATE) resolves a common element type across its arguments, so the expression is already ARRAY<DATE>. The check walks array element types, map value types and struct field types against one accepted-type list that excludes the untyped NULL type, and a struct keeps each field's own declared type, so nothing promotes PAYMENT_DATE there.
-
Confirm the coercion:
TYPEOF(ARRAY(PAYMENT_DATE, TRANSACTION_DATE))returnsarray<date>, whileTYPEOF(ARRAY(PAYMENT_DATE))returnsarray<void>. -
Confirm the container is not what decides it:
TO_VARIANT_OBJECT(ARRAY(PAYMENT_DATE))andTO_VARIANT_OBJECT(MAP('k', PAYMENT_DATE))both fail with the sameDATATYPE_MISMATCH.CAST_WITHOUT_SUGGESTION, andTO_VARIANT_OBJECT(ARRAY(INTERVAL '1' SECOND))fails too, so VOID is not being singled out. -
Confirm what
SCHEMA_OF_VARIANTreports:SCHEMA_OF_VARIANT(TO_VARIANT_OBJECT(ARRAY(CAST(NULL AS DATE))))returnsARRAY<VOID>even though the input type wasARRAY<DATE>. VARIANT stores one untyped null for every null value, so your cast did apply and the field simply holds that null.
On whether it is deliberate, I can only speak to observed behavior: the exclusion applies uniformly to arrays, maps and structs, and I have not found anything public stating whether leaving the untyped NULL type out of the accepted list was a design decision.