clickhouse-client --format: Output Formats in CI
clickhouse-client --format (or a trailing FORMAT clause) sets the output encoding, so CI steps can read TabSeparated or JSON instead of the human Pretty table.
The interactive default, PrettyCompact, draws a box-drawing table that scripts cannot parse. In CI you choose an explicit machine format.
What it does
ClickHouse supports many input and output formats. The output format is set globally with --format or per query with a FORMAT clause. TabSeparated and CSV suit shell parsing; JSON and JSONEachRow suit consumers that want structured data; TabSeparatedRaw drops quoting entirely.
Common usage
clickhouse-client --query "SELECT count() FROM app.events" --format TabSeparated
# per-query FORMAT clause
clickhouse-client --query "SELECT * FROM app.events FORMAT JSONEachRow"
# capture a single scalar cleanly
clickhouse-client --query "SELECT version()" --format TabSeparatedRawOptions
| Format | What it does |
|---|---|
| TabSeparated (TSV) | Tab-delimited rows, easy to cut/awk |
| CSV / CSVWithNames | Comma-separated, optionally with a header row |
| JSON | A full JSON object with data, meta, and statistics |
| JSONEachRow | One JSON object per line (newline-delimited) |
| TabSeparatedRaw | No escaping, good for a single scalar value |
| PrettyCompact | Human box table (the interactive default) |
In CI
When capturing a value into a variable, use TabSeparatedRaw or TabSeparated so there are no quotes or box characters to strip. JSONEachRow is the friendliest for feeding rows into another tool, since each line parses independently. Set the format explicitly; relying on the default Pretty table in a script is a common parsing bug.
Common errors in CI
"Code: 73. DB::Exception: Unknown format <name>" means a misspelled format (it is case-sensitive: JSONEachRow, not jsoneachrow). Garbled output piped to another tool usually means the Pretty table leaked through because no format was set. A FORMAT clause must be the last thing in the query, after any settings.