> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Calcula a lista de caminhos distintos e seus tipos presentes no JSON

# distinctJSONPathsAndTypes

<div id="distinctJSONPathsAndTypes">
  ## distinctJSONPathsAndTypes
</div>

Introduzido em: v24.9.0

Calcula a lista de caminhos distintos e seus tipos armazenados na coluna [JSON](/pt-BR/reference/data-types/newjson).

<Note>
  Se a declaração JSON contiver caminhos com tipos especificados, esses caminhos sempre serão incluídos no resultado das funções `distinctJSONPaths/distinctJSONPathsAndTypes`, mesmo que os dados de entrada não contenham valores para esses caminhos.
</Note>

**Sintaxe**

```sql theme={null}
distinctJSONPathsAndTypes(json)
```

**Argumentos**

* `json` — coluna JSON. [`JSON`](/pt-BR/reference/data-types/newjson)

**Valor retornado**

Retorna o mapa ordenado de caminhos e tipos. [`Map(String, Array(String))`](/pt-BR/reference/data-types/map)

**Exemplos**

**Uso básico com tipos mistos**

```sql title=Query theme={null}
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;
```

```response title=Response theme={null}
┌─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))']} │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

**Com caminhos JSON declarados**

```sql title=Query theme={null}
DROP TABLE IF EXISTS test_json;
CREATE TABLE test_json(json JSON(a UInt32)) ENGINE = Memory;
INSERT INTO test_json VALUES ('{"b" : "Hello"}'), ('{"b" : "World", "c" : [1, 2, 3]}');

SELECT distinctJSONPathsAndTypes(json) FROM test_json;
```

```response title=Response theme={null}
┌─distinctJSONPathsAndTypes(json)────────────────────────────────┐
│ {'a':['UInt32'],'b':['String'],'c':['Array(Nullable(Int64))']} │
└────────────────────────────────────────────────────────────────┘
```
