v.22.3Experimental Feature
New Object Data Type for Storing and Querying Semi-Structured Data
New data typeObject(<schema_format>), which supports storing of semi-structured data (for now JSON only). Data is written to such types as string. Then all paths are extracted according to format of semi-structured data and written as separate columns in most optimal types, that can store all their values. Those columns can be queried by names that match paths in source data. E.gdata.key1.key2or with cast operatordata.key1.key2::Int64.
Why it matters
This feature enables efficient storage and querying of semi-structured data within ClickHouse by automatically extracting nested fields into dedicated columns. It solves the problem of handling JSON-like data structures without sacrificing query performance or requiring complex parsing at query time.How to use it
Define a column with theObject('JSON') data type when creating a table. Insert JSON data as strings into this column. Access nested fields using dot notation, e.g., data.key1.key2, or cast them to specific types using data.key1.key2::Int64 in queries.