Skip to content

fix(asap-tools): batch ClickHouse JSON-lines bulk load instead of a single oversized INSERT - #542

Open
akanksha-akkihal wants to merge 3 commits into
mainfrom
541-fix-asap-tools-batch-clickhouse-json-lines-bulk-load
Open

fix(asap-tools): batch ClickHouse JSON-lines bulk load instead of a single oversized INSERT#542
akanksha-akkihal wants to merge 3 commits into
mainfrom
541-fix-asap-tools-batch-clickhouse-json-lines-bulk-load

Conversation

@akanksha-akkihal

@akanksha-akkihal akanksha-akkihal commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Bulk-loading JSON-lines datasets into ClickHouse previously piped the entire file through a single INSERT ... FORMAT JSONEachRow, which is unreliable for the multi-GB datasets used in the ClickHouse benchmark. This PR loads in bounded batches, waits for ClickHouse to be reachable before loading, and fails with an actionable message when input data is malformed.

Changes

  • Batched loader (experiment_utils/services/json/loader.py): streams the
    file and inserts in bounded batches (default 100k rows) via
    docker exec clickhouse-client, instead of one giant INSERT.
  • Readiness check: poll ClickHouse HTTP /ping until it returns Ok.
    before loading; on timeout, raise with the tail of the container logs.
  • Input validation: each line is checked for valid JSON and embedded null
    bytes, so malformed input fails with the offending line number and a preview.
  • MV-safe init: when init_sql_file is provided, it owns DROP/CREATE
    for its own objects — the standalone DROP TABLE no longer runs first and
    break schemas with dependent materialized views.
  • Both the ClickBench and custom JSON-lines paths share the batched loader.

akanksha-akkihal and others added 2 commits July 28, 2026 11:46
Bulk-loading a JSON-lines dataset piped the entire file through a single
INSERT ... FORMAT JSONEachRow, which is unreliable for the multi-GB datasets
the ClickHouse benchmark now uses. Load in bounded batches via a dedicated
loader script instead, poll ClickHouse HTTP until it is actually reachable
before loading, and validate each line so malformed input fails with the
offending line number rather than an opaque client error.

Also let init_sql_file own DROP/CREATE for its own objects, so a schema that
defines dependent materialized views is not broken by a standalone DROP TABLE.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(asap-tools): batch ClickHouse JSON-lines bulk load instead of a single oversized INSERT

1 participant