Pular para o conteúdo principal

distinctJSONPaths

Introduzido em: v24.9.0 Calcula uma lista de caminhos distintos armazenados em uma coluna JSON. Sintaxe
distinctJSONPaths(json)
Argumentos
  • json — coluna JSON. JSON
Valor retornado Retorna a lista ordenada de paths. Array(String) Exemplos Uso básico com JSON aninhado
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;
Response
┌─distinctJSONPaths(json)───┐
│ ['a','b','c.d.e','c.d.f'] │
└───────────────────────────┘
Com JSON paths declarados
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;
Response
┌─distinctJSONPaths(json)─┐
│ ['a','b','c']           │
└─────────────────────────┘
Última modificação em 10 de junho de 2026