distinctJSONPaths
Introduit dans : v24.9.0
Calcule une liste des chemins distincts stockés dans une colonne JSON.
Syntaxe
distinctJSONPaths(json)Arguments
json— colonne JSON.JSON
Valeur renvoyée
Renvoie la liste triée des chemins. Array(String)
Exemples
Utilisation de base avec un JSON imbriqué
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;┌─distinctJSONPaths(json)───┐
│ ['a','b','c.d.e','c.d.f'] │
└───────────────────────────┘Avec des chemins JSON définis
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;┌─distinctJSONPaths(json)───┐
│ ['a','b','c.d.e','c.d.f'] │
└───────────────────────────┘