Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Last active October 18, 2024 07:38
Show Gist options
  • Save tom-clickhouse/c52ab757aca15723427032f305c73656 to your computer and use it in GitHub Desktop.
Save tom-clickhouse/c52ab757aca15723427032f305c73656 to your computer and use it in GitHub Desktop.
JSON type
SET allow_experimental_json_type = 1;
CREATE OR REPLACE TABLE test
(
c JSON(a.b UInt32, a.c String)
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS
min_bytes_for_wide_part = 1,
min_rows_for_wide_part = 1;
INSERT INTO test VALUES
('{"a":{"b":10, "c":"str1", "d":42 }}'),
('{"a":{"b":20, "c":"str2", "d":43 }}'),
('{"a":{"b":30, "c":"str3", "e":44 }}'),
('{"a":{"b":40, "c":"str4", "d":"foo", "e":"baz"}}'),
('{"a":{"b":50, "c":"str5", "d":[23, 24] }}'),
('{"a":{"b":60, "c":"str6", "d":{"e":"bar"}, "e":45 }}');
SELECT * FROM test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment