VARIANT stores semi-structured values using Parquet/Iceberg Variant encoding. Compared with JSONB, VARIANT can preserve supported leaf types such as integers with their width, decimals, timestamps, binary values, arrays, and nested objects.
Define a VARIANT type
Syntax:VARIANT
Example
Add values to a VARIANT column
You can populate aVARIANT column in two main ways:
- Parse a serialized value with
::VARIANT. - Convert an existing SQL value with
to_variant(...).
Examples
MAP values must share a common value type. Use a typed STRUCT when you need mixed leaf types in one object.
When casting from VARCHAR, RisingWave parses the string as a serialized Variant value. to_variant instead boxes the SQL value itself.
Access nested values
Usevariant_get(value, path) to access nested values and variant_typeof(value) to inspect the stored Variant type.
Example
NULL instead of an error, use try_variant_get(value, path).
Casts
RisingWave supports these casts forVARIANT:
Limitations
VARIANTcannot be used as a key type. This includes primary keys, index keys,GROUP BY,DISTINCT,ORDER BY, and join keys.- Of the set operations, only
UNION ALLis supported forVARIANTcolumns. VARIANTis not supported in non-SQL UDF signatures yet.