fix(asap-tools): batch ClickHouse JSON-lines bulk load instead of a single oversized INSERT - #542
Conversation
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>
|
Code review findings on this PR:
Will follow up with fixes for these. |
- Run the ClickHouse HTTP readiness wait before DROP/init-SQL execution instead of after, so it actually guards those calls. - Drop the target table for dataset_name="custom" with no init_sql_file, restoring clean-table-per-run behavior for that path. - Bound json/loader.py max_rows against a live total+len(batch) count instead of the post-flush total, so it stops reading at the requested row count instead of validating up to a full batch_size of lines first. - Dedupe the ClickHouse /ping readiness check into a shared _clickhouse_ping_ok() helper used by both ClickHouseService.is_healthy() and the new ClickHouseDataLoaderService.is_healthy(), and collapse _ensure_clickhouse_http_ready() onto the inherited wait_until_ready() while keeping its docker-logs-on-timeout diagnostic. - Use ClickHouseService.CONTAINER_NAME instead of a hardcoded container name in the readiness-timeout log fetch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
experiment_utils/services/json/loader.py): streams thefile and inserts in bounded batches (default 100k rows) via
docker exec clickhouse-client, instead of one giant INSERT./pinguntil it returnsOk.before loading; on timeout, raise with the tail of the container logs.
bytes, so malformed input fails with the offending line number and a preview.
init_sql_fileis provided, it ownsDROP/CREATEfor its own objects — the standalone
DROP TABLEno longer runs first andbreak schemas with dependent materialized views.