Skip to main content
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 a VARIANT 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

Use variant_get(value, path) to access nested values and variant_typeof(value) to inspect the stored Variant type.

Example

If you want invalid paths to return NULL instead of an error, use try_variant_get(value, path).

Casts

RisingWave supports these casts for VARIANT:

Limitations

  • VARIANT cannot 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 ALL is supported for VARIANT columns.
  • VARIANT is not supported in non-SQL UDF signatures yet.