Skip to content

Instantly share code, notes, and snippets.

@tom-clickhouse
Created October 18, 2024 07:43
Show Gist options
  • Save tom-clickhouse/c02b49fc5ec275aaa6e9d463311048ba to your computer and use it in GitHub Desktop.
Save tom-clickhouse/c02b49fc5ec275aaa6e9d463311048ba to your computer and use it in GitHub Desktop.
JSON type with max_dynamic_paths parameter
SET allow_experimental_json_type = 1;
CREATE OR REPLACE TABLE test
(
c JSON(a.b UInt32, a.c String, max_dynamic_paths=3)
)
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 }}'),
('{"a":{"b":70, "c":"str7", "f":{"g":"2020-01-01"} }}'),
('{"a":{"b":80, "c":"str8"}, "f":{"g":[100, 200]}, "h":"TRUE" }'),
('{"a":{"b":90, "c":"str9"}, "f":{"g":"2020-01-02"} }');
SELECT * FROM test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment