mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 18:32:29 +00:00
2.6 KiB
2.6 KiB
slug | sidebar_position |
---|---|
/en/sql-reference/aggregate-functions/reference/distinctjsonpaths | 216 |
distinctJSONPaths
Calculates the list of distinct paths stored in JSON column.
Syntax
distinctJSONPaths(json)
Arguments
json
— JSON column.
Returned Value
- The sorted list of paths Array(String).
Example
Query:
DROP TABLE IF EXISTS test_json;
CREATE TABLE test_json(json JSON) ENGINE = Memory;
INSERT INTO test_json VALUES ('{"a" : 42, "b" : "Hello"}'), ('{"b" : [1, 2, 3], "c" : {"d" : {"e" : "2020-01-01"}}}'), ('{"a" : 43, "c" : {"d" : {"f" : [{"g" : 42}]}}}')
SELECT distinctJSONPaths(json) FROM test_json;
Result:
┌─distinctJSONPaths(json)───┐
│ ['a','b','c.d.e','c.d.f'] │
└───────────────────────────┘
distinctJSONPathsAndTypes
Calculates the list of distinct paths and their types stored in JSON column.
Syntax
distinctJSONPathsAndTypes(json)
Arguments
json
— JSON column.
Returned Value
- The sorted map of paths and types Map(String, Array(String)).
Example
Query:
DROP TABLE IF EXISTS test_json;
CREATE TABLE test_json(json JSON) ENGINE = Memory;
INSERT INTO test_json VALUES ('{"a" : 42, "b" : "Hello"}'), ('{"b" : [1, 2, 3], "c" : {"d" : {"e" : "2020-01-01"}}}'), ('{"a" : 43, "c" : {"d" : {"f" : [{"g" : 42}]}}}')
SELECT distinctJSONPathsAndTypes(json) FROM test_json;
Result:
┌─distinctJSONPathsAndTypes(json)───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ {'a':['Int64'],'b':['Array(Nullable(Int64))','String'],'c.d.e':['Date'],'c.d.f':['Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))']} │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘