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

> JSON に格納されている重複しないパスとその型の一覧を計算します

# distinctJSONPathsAndTypes

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

導入バージョン: v24.9.0

[JSON](/ja/reference/data-types/newjson) カラムに格納されている、重複のないパスとその型の一覧を計算します。

<Note>
  JSON 宣言に型が指定されたパスが含まれている場合、入力データにそれらのパスの値がなくても、これらのパスは `distinctJSONPaths/distinctJSONPathsAndTypes` 関数の結果に常に含まれます。
</Note>

**構文**

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

**引数**

* `json` — JSONカラム。[`JSON`](/ja/reference/data-types/newjson)

**戻り値**

パスと型をソートしたマップを返します。[`Map(String, Array(String))`](/ja/reference/data-types/map)

**例**

**型が混在する場合の基本的な使い方**

```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))']} │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

**宣言済みの JSON パスを使用する場合**

```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))']} │
└────────────────────────────────────────────────────────────────┘
```
