> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> JSONCompactEachRowWithProgress フォーマットに関するドキュメント

# JSONCompactEachRowWithProgress

| 入力 | 出力 | エイリアス |
| - | - | - |
| ✗ | ✔ | |

<h2 id="description">
  説明
</h2>

[`JSONCompactEachRow`](/docs/ja/reference/formats/JSON/JSONCompactEachRow) のコンパクトな行ごとの出力に、ストリーミングの進捗情報を組み合わせたフォーマットです。ClickHouse は各イベントを個別の JSON オブジェクトとしてストリーム出力し、カラム値はネイティブの JSON 型のまま保持されます。

関連する `JSONCompactStringsEachRowWithProgress` フォーマットも同じ種類のトップレベルオブジェクトを使用しますが、フィールド値は文字列としてシリアル化されます。

ストリームの契約 (`writesProgressConcurrently` / `finalizeImpl`) は [`JSONEachRowWithProgress`](/docs/ja/reference/formats/JSON/JSONEachRowWithProgress) と共通です。ただし、`row` / `totals` / `min` / `max` のペイロードは名前付きオブジェクトではなく、カラム順に並んだ値の **Array** になります。

<h2 id="stream-objects">
  ストリームオブジェクト
</h2>

レスポンスの各行は 1 つの JSON オブジェクトです。クライアントはトップレベルのキーに応じて処理を振り分けてください。

| トップレベルのキー | 出現するタイミング | 形状 |
| - | - | - |
| `meta` | 最初の `row` の前に 1 回 (`progress` オブジェクトがこれより先に出力される場合があります) | `{"meta":[{"name":...,"type":...}, ...]}` — カラム名と型 |
| `row` | 結果の行ごとに 1 回 | `{"row":[...]}` — ヘッダー順のカラム値 |
| `progress` | クエリ実行中に定期的に | `{"progress":{...}}` — `read_rows`、`read_bytes`、`total_rows_to_read` などのカウンター |
| `totals` | totals が存在する場合 | `{"totals":[...]}` — ヘッダー順の totals 行の値 |
| `min` / `max` | 極値が存在する場合 | `{"min":[...]}` / `{"max":[...]}` — ヘッダー順の極値行の値 |
| `rows_before_limit_at_least` | クエリに `LIMIT` が含まれる場合 | `{"rows_before_limit_at_least":N}` — `LIMIT` がなかった場合の行数の下限推定値 (行が除外されたことを示すものではありません) |
| `rows_before_aggregation` | クエリが集約を行い、かつ `rows_before_aggregation` カウンターが有効な場合 | `{"rows_before_aggregation":N}` |
| `exception` | HTTP 経由で `http_write_exception_in_output_format=1` が設定されている状態でクエリが失敗した場合 | `{"exception":"..."}` — エラーテキストは `row` の下にネストされず、**トップレベルの文字列**として出力されます |

`rows_before_limit_at_least` オブジェクトは、クエリに `LIMIT` が含まれていれば、実際には制限によって行が除外されなかった場合でも出力されます。これは `LIMIT` がなかった場合の行数の下限推定値です (意味は `JSON` の場合と同じです) 。クライアントは、これを行が除外された証拠として扱わないでください。

`meta` は最初の `row` の前に 1 回出力されますが、`progress` オブジェクトが `meta` より先に届くことがあります。トップレベルの `exception` オブジェクトは、HTTP 経由で `http_write_exception_in_output_format=1` が設定されている場合にのみ出力されます。それ以外の場合、エラーはトランスポート層を通じて通知されます。出力される場合は、`row` の下にネストされず、独立したトップレベルのオブジェクトとなります。

<h2 id="example-usage">
  使用例
</h2>

```sql title="Query" theme={null}
SELECT *
FROM generateRandom('a Array(Int8), d Decimal32(4), c Tuple(DateTime64(3), UUID)', 1, 10, 2)
LIMIT 5
FORMAT JSONCompactEachRowWithProgress
```

```response title="Response" theme={null}
{"meta":[{"name":"a","type":"Array(Int8)"},{"name":"d","type":"Decimal(9, 4)"},{"name":"c","type":"Tuple(DateTime64(3), UUID)"}]}
{"row":[[-8], 46848.5225, ["2064-06-11 14:00:36.578","b06f4fa1-22ff-f84f-a1b7-a5807d983ae6"]]}
{"row":[[-76], -85331.598, ["2038-06-16 04:10:27.271","2bb0de60-3a2c-ffc0-d7a7-a5c88ed8177c"]]}
{"row":[[-32], -31470.8994, ["2027-07-18 16:58:34.654","1cdbae4c-ceb2-1337-b954-b175f5efbef8"]]}
{"row":[[-116], 32104.097, ["1979-04-27 21:51:53.321","66903704-3c83-8f8a-648a-da4ac1ffa9fc"]]}
{"row":[[], 2427.6614, ["1980-04-24 11:30:35.487","fee19be8-0f46-149b-ed98-43e7455ce2b2"]]}
{"progress":{"read_rows":"5","read_bytes":"184","total_rows_to_read":"5","elapsed_ns":"335771"}}
{"rows_before_limit_at_least":5}
```

<h2 id="format-settings">
  フォーマット設定
</h2>
