The json Clickhouse command lets you parse, query, and generate JSON data natively inside ClickHouse tables.
json Clickhouse (a family of JSON functions) enables reading JSON strings, extracting fields, and writing structured JSON directly in SQL. You can store semi-structured events and report on them without ETL.
Use it when logs, click-streams, or API payloads arrive as JSON. Instead of flattening every key into columns, keep raw JSON, then query specific attributes only when needed.
Use JSONExtract()
to pull out a typed value. Supply the JSON column, path, and target type.
SELECT JSONExtract(orders.meta,'$.payment.method','String') AS pay_method FROM Orders;
Leverage JSONExtractArrayRaw()
or JSONExtractKeysAndValues()
to return arrays or key/value pairs for further processing with arrayJoin()
.
Yes. Combine groupArray()
or groupUniqArray()
with JSONExtract()
to build JSON-like results or use JSONAgg
to output JSON arrays.
ClickHouse stores JSON as String
; ingestion performance remains high. The cost appears at query time because extraction is executed on the fly.
Store raw JSON plus a few high-cardinality keys as materialized columns for filtering. Use MATERIALIZED
columns to pre-compute frequently queried JSON paths and index them with skip indexes
.
Create a materialized view to denormalize common JSON attributes into a wide table for dashboards while retaining raw data for ad-hoc analysis.
Add a MATERIALIZED column with the extracted value and create a skip index on that column for fast filtering.
No. JSON is stored as plain strings. Efficiency comes from columnar storage and late extraction, not a binary format.
You cannot partially update JSON strings; insert a new row or mutate the full string with ALTER TABLE UPDATE
.