LOAD 'chdb_hook'; \set parquet_file file:///tmp/big.tmp/big.parquet CREATE TYPE http_method AS ENUM( 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH', 'QUERY' ); \set ECHO errors CREATE TABLE logs ( req_id BIGINT, start_at TIMESTAMP, duration INTEGER, resource TEXT, method http_method, node_id BIGINT, response INTEGER ); -- Fill the table with ca 100MB of records. INSERT INTO logs SELECT random(0, +9223372036854775807), concat('2025-12-19 10:42:00.', floor(random(0, 999999)))::timestamp - (random(1, 86400 * 14) || 's')::interval, random(1, 500) AS duration, (ARRAY['/profile', '/users', '/users/1321945', '/users/283434', '/users/802683', '/users/1739238', '/users/7392323', '/widgets', '/search', '/search', '/search', '/widgets/omnis', '/widgets/natus', '/widgets/voluptatem', '/widgets/totam', '/widgets/aperiam'])[random(1, 15)], (WITH x(a) AS (select random(x-x+1, 100)) SELECT CASE WHEN a < 91 THEN 'GET' WHEN a < 97 THEN 'POST' WHEN a < 99 THEN 'PUT' ELSE (ARRAY['HEAD', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH', 'QUERY'])[random(x-x+1, 7)] END FROM x)::http_method, random(1, 8) AS node_id, (WITH x(a) AS (select random(x-x+1, 100)) SELECT CASE WHEN a < 95 THEN 200 WHEN a < 97 THEN 201 WHEN a < 99 THEN 204 ELSE (ARRAY[308, 400, 401, 403, 500])[random(x-x+1, 5)] END FROM x) -- FROM generate_series(1, 1000) x; FROM generate_series(1, 1260000) x; SELECT pg_size_pretty(pg_total_relation_size('logs')); pg_size_pretty ---------------- 100 MB (1 row) -- Copy out the data COPY logs TO :'parquet_file' (structure $$ req_id UInt64, start_at DateTime64(6, 'UTC'), duration UInt16, resource String, method String, node_id UInt32, response UInt16 $$); -- Load it back in. CREATE TABLE imported_logs (LIKE logs INCLUDING ALL); COPY imported_logs FROM :'parquet_file'; -- They should be the same WITH x AS ( SELECT * FROM logs EXCEPT ALL SELECT * FROM imported_logs ) SELECT * FROM x LIMIT 10; req_id | start_at | duration | resource | method | node_id | response --------+----------+----------+----------+--------+---------+---------- (0 rows) \set ECHO errors