Snowflake’s JSON support lets you store, parse, and query semi-structured data with the VARIANT type, PARSE_JSON, dot notation, and FLATTEN.
JSON handling allows you to keep semi-structured data in its raw form while still filtering, joining, and aggregating it with regular SQL. No complex ETL is needed.
Create tables with a VARIANT column. Insert raw JSON strings directly; Snowflake auto-casts them to VARIANT.
Wrap incoming text with PARSE_JSON() when Snowflake cannot infer the type automatically or when loading from staged files.
Use : and [] to traverse objects and arrays. Cast the result to the desired scalar type for filtering or math.
FLATTEN iterates array elements and key–value pairs. Join its output to the base table with , LATERAL or CROSS JOIN.
Store only needed keys, add clustered keys on frequently filtered elements, and avoid SELECT * on large VARIANT columns.
The example below parses an order_meta
JSON column, joins it to Orders
, and explodes a items
array into rows for reporting.
Snowflake has no traditional indexes, but adding a clustered key on an expression like order_meta:shipping.state
improves pruning.
VARIANT is stored in compressed columnar format. Expect ~2× raw size compression, so cost is usually marginal.
Use OBJECT_INSERT
, OBJECT_DELETE
, or :
path replacement inside an UPDATE statement.