The "DB::Exception: Unknown format" error in ClickHouse occurs when a query specifies a data format that the server does not recognize. The UNKNOWN_FORMAT error is raised when the format name provided in a FORMAT clause, INSERT ... FORMAT, or in a table function like file() or s3() does not match any of ClickHouse's built-in or registered formats.
Impact
The query that references the unknown format will fail immediately. No data is read, written, or modified. This is a client-side configuration error that has no impact on existing data or other running queries.
Common Causes
- Typo in the format name (e.g.,
Parqetinstead ofParquet,JSOMinstead ofJSON) - Using a format name from another database system that ClickHouse does not support
- The ClickHouse version does not include support for the requested format (some formats were added in newer releases)
- Case sensitivity issues -- ClickHouse format names are case-sensitive
- Using an abbreviated or unofficial format name instead of the full ClickHouse format name
- Copy-pasting queries from documentation written for a different ClickHouse version
Troubleshooting and Resolution Steps
Check the format name spelling. Commonly used formats in ClickHouse include:
TabSeparated,CSV,JSONEachRow,JSON,Parquet,ORC,Avro,Arrow,Native,RowBinary,Values,TSV,JSONCompactEachRow,Protobuf,MsgPack,TSKV
List all supported formats on your ClickHouse instance:
SELECT * FROM system.formats ORDER BY name;Verify case sensitivity. Format names are case-sensitive:
-- Correct SELECT * FROM your_table FORMAT JSONEachRow; -- Incorrect SELECT * FROM your_table FORMAT jsoneachrow;Check your ClickHouse version for format availability:
SELECT version();Some formats (e.g.,
One,Prometheus,SQLInsert) were added in more recent versions.Use the closest available format if the one you need is not supported. For example:
- Instead of a generic
JSONarray format, useJSONEachRowfor line-delimited JSON - Instead of
TSV, useTabSeparated(thoughTSVis a valid alias)
- Instead of a generic
For table functions, ensure the format parameter is correctly placed:
-- Correct SELECT * FROM file('data.csv', 'CSV', 'col1 UInt32, col2 String'); -- Incorrect format parameter SELECT * FROM file('data.csv', 'csv_format', 'col1 UInt32, col2 String');
Best Practices
- Refer to the
system.formatstable when unsure about available formats on your specific ClickHouse version. - Use consistent format names across your codebase and document your preferred formats.
- When writing client applications, validate format names against the target ClickHouse version's supported list.
- Prefer widely supported formats like
JSONEachRow,CSV, andTabSeparatedfor maximum compatibility across versions.
Frequently Asked Questions
Q: Are format names case-sensitive in ClickHouse?
A: Yes. You must use the exact casing as documented. For example, JSONEachRow is correct, while jsoneachrow or JSONEACHROW will trigger the UNKNOWN_FORMAT error.
Q: Can I add custom formats to ClickHouse?
A: ClickHouse does not support user-defined data formats at runtime. All formats must be compiled into the binary. However, ClickHouse provides a very large number of built-in formats that cover most use cases.
Q: Is TSV the same as TabSeparated?
A: Yes, TSV is an alias for TabSeparated in ClickHouse. Similarly, TSKV is the key-value variant. Both forms are accepted.