Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 6 min read How-to mediumAdept

An Introduction to Data Formats in ClickHouse

ClickHouse can import and export a wide range of formats through the FORMAT clause and related settings. Covered here: CSV and TSV with custom delimiters, CustomSeparated for broken CSVs, JSONEachRow for NDJSON, Regexp and Template for custom text, Native and RowBinary for efficient transfer between servers, Parquet and other Apache formats, and SQLInsert/MySQLDump for SQL dumps. Two practical tricks: the Null format benchmarks queries without printing output, and Pretty* variants control how CLI results are displayed. clickhouse-local with the file() function lets you inspect local files before loading them.

Assumes: SQL basicscommand-line usage

Related posts

  • Extracting, Converting, and Querying Data in Local Files using clickhouse-local

    ClickHouse mediumAdept

    clickhouse-local runs ClickHouse's SQL engine as a standalone CLI, so you can query, transform and convert local, piped, HTTP, S3, MySQL or Postgres data without deploying a server. Worked examples cover querying CSVs with or without headers via the file() function, schema inference with DESCRIBE, and writing results with INTO OUTFILE in formats such as SQLInsert and Parquet. They also show globbing and joining multiple files, the virtual _file/_path columns, and stdin piping with --structure. Compressed multi-gigabyte files are handled with automatic compression detection, and a 826K CSV shrinks to 432K as Parquet.

  • A Deep Dive into Apache Parquet with ClickHouse - Part 1

    ClickHouse mediumAdept

    ClickHouse can read and write Apache Parquet through its file and s3 table functions, using the same Parquet code in ClickHouse Local and ClickHouse Server. Examples on a 28M-row UK house price dataset show schema inspection with DESCRIBE and aggregation queries over local files, S3 objects and glob-matched file sets. Writes can go through INSERT INTO FUNCTION, INTO OUTFILE or FORMAT Parquet redirection, and PARTITION BY splits output into one file per year. INSERT INTO FUNCTION produces smaller files (243MB vs 291MB) than the client-side approaches, so it is recommended where possible.

  • ClickHouse Input format matchup: Which is fastest & most efficient

    ClickHouse mediumAdept

    FastFormats is a benchmark that measures ClickHouse server-side ingestion time and hardware efficiency across roughly 60 input formats, crossed with batch size, pre-sorting and compression, using the ClickBench web analytics dataset over the HTTP interface. With 10k-row batches and LZ4 compression, the Native format was fastest: 131s for 2.55 GiB. That beat ArrowStream by 10%, RowBinary by 18%, TSV and Parquet by about 31–32%, CSV by 36%, and JSONEachRow by 51%, because its columnar layout closely matches MergeTree. Format choice has the biggest impact, followed by compression, while pre-sorting helps only in specific cases. Native is recommended unless the table DDL uses format-specific MATERIALIZED/DEFAULT expressions.

  • Getting Data Into ClickHouse - Part 1

    ClickHouse mediumAdept

    ClickHouse can load a 28.7M-row, 4.6GB gzipped Hacker News CSV with a single command, using schema inference via clickhouse-local's file() and the url() table function. Inferred schemas are best-effort, with Nullable Float64 and String types everywhere. Defining explicit types (UInt32, Enum, LowCardinality, DateTime) with ORDER BY id improves the result: loading from a local file with INFILE took about 94s versus 204s streaming from the URL. Sample analytical queries then scan the full table in under 2 seconds, even with ILIKE text filters.

  • Analyzing Hugging Face datasets with ClickHouse

    ClickHouse mediumAdept

    Hugging Face's Datasets Server automatically converts every dataset to Parquet and exposes the file URLs through a REST endpoint, so clickhouse-local can query any dataset with plain SQL via the url function and URL table engine. The walkthrough uses a Spotify tracks dataset to show aggregations, varPop checks, and bar-function histograms, then moves to ClickHouse's statistical functions and a reusable UDF that queries a dataset by name alone. Practical gotchas include setting max_http_get_redirects = 1 to follow the CDN redirect and enable_url_encoding = 0 to preserve escaped paths. Slow reads caused by small Parquet row groups, each triggering a separate HTTP request, were fixed in ClickHouse issue 53069.

The quest for software engineering knowledge.

Look:
Layout: