Skip to content

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

ClickHouse 11 min read How-to mediumAdept

A Deep Dive into Apache Parquet with ClickHouse - Part 1

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.

Assumes: SQL basicscolumnar storage conceptsAmazon S3

Related posts

  • Getting Data Into ClickHouse - Part 3 - Using S3

    ClickHouse mediumAdept

    ClickHouse can both query data in place on Amazon S3 and ingest it, shown here on an 11.5-billion-row, ~600GB forex tick dataset stored as zstd CSV and Parquet. The s3 table function supports glob patterns and schema inference for ad-hoc queries. A full-dataset aggregation over all 66 pairs took about 583s on one node, about 435s with max_download_threads=12, and about 226s when distributed across the cluster with s3Cluster (roughly 50M rows/s). The examples also use window functions to find the largest daily spread changes and note that Parquet files parse less parallelly than CSV.

  • 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 2

    ClickHouse mediumAdept

    Parquet files are organized into row groups, column chunks and pages, with dictionary, RLE/bit-packing and delta encodings plus footer metadata and min/max statistics that let readers push down projections and predicates. In ClickHouse, writing via INSERT INTO FUNCTION file/s3 gives predictable control over row group size through min_insert_block_size_bytes, min_insert_block_size_rows and output_format_parquet_row_group_size, whereas SELECT ... FORMAT Parquet tends to produce many small row groups that compress worse. The new ParquetMetadata input format exposes per-column encodings, compression and statistics. Benchmarks on the UK house price dataset show Parquet at 174–348 MB depending on codec, versus 3.5 GB for uncompressed CSV.

  • ClickHouse Release 23.8

    ClickHouse mediumAdept

    ClickHouse 23.8 makes file reads much faster by using Parquet row-group min/max statistics to skip data, answering count() from file metadata, and pruning files via the _file virtual column without reading them. On a 126GiB PyPI Parquet dataset in GCS, a count dropped from 26.5s to 11.4s, a time-range filter from 84s to 35s, and a 10% filename sample from 4.6s to 0.6s. The release also adds the S3Queue table engine for streaming ingestion from S3. It tracks processed files in ClickHouse Keeper using an unordered mode (with TTL and file-count limits) or an ordered mode keyed on filenames. Direct querying of zip, tar and 7z archives via the file function is also new.

  • Loading Parquet data into MySQL with ClickHouse

    ClickHouse mediumAdept

    MySQL has no native Parquet import, but clickhouse-local can read a Parquet file over HTTP with the `url` table function and write it straight into a MySQL table via `INSERT INTO FUNCTION mysql(...)`. In the walkthrough, 2.3M StackOverflow vote rows load in about 16.6 seconds using roughly 227 MiB of memory. The same `mysql` table function can query MySQL back. An inline subquery is written in ClickHouse SQL and rewritten into MySQL syntax, while the `query()` form is sent to MySQL verbatim, so ClickHouse-only functions like `tuple` fail there. Credentials can be kept in config-defined named collections instead of being passed on every call.

The quest for software engineering knowledge.

Look:
Layout: