v.24.1New Feature
Implement Experimental Variant Data Type in ClickHouse
Implement Variant data type that represents a union of other data types. TypeVariant(T1, T2, ..., TN)means that each row of this type has a value of either typeT1orT2or ... orTNor none of them (NULLvalue). Variant type is available under a settingallow_experimental_variant_type. Reference: #54864. #58047 (Kruglov Pavel).
Why it matters
This feature addresses the need to store heterogeneous data within a single column by supporting multiple types under one unified data type. It enables more flexible schema designs and simplifies handling of mixed data without separate columns for each type.How to use it
Enable the feature by setting the experimental settingallow_experimental_variant_type to 1. Then define columns using Variant(T1, T2, ..., TN) syntax, where T1, T2, ..., TN are the allowed data types.