Repository navigation
chdb 4.5.1
Requires chdb-core>=26.11.1, unchanged from 4.5.0.
New
Direct PyArrow queries (#806): chdb.query_arrow() returns a pyarrow.Table, and chdb.query_arrow_batches() returns a closable iterator of record batches. Both read results through the Arrow C Data interface, so they skip the Arrow IPC encoding that query(sql, "ArrowTable") does.
import chdb
import pyarrow as pa
table = chdb.query_arrow("SELECT number, number * 2 AS doubled FROM numbers(5)")
with chdb.query_arrow_batches("SELECT number FROM numbers(1000000)") as batches:
for batch in batches:
...
events = pa.table({"id": [1, 2, 3]})
with chdb.arrow.connect() as session:
with session.register_arrow(events) as source:
session.query_arrow(f"SELECT sum(id) AS total FROM {source.sql_expr}")
session.execute("CREATE TABLE dst (id Int64) ENGINE=Memory")
session.insert_arrow("dst", events)chdb.arrow.connect(path, settings=...)opens a session.register_arrow()takes a PyArrow table, record batch, or anything with__arrow_c_stream__andschema, and returns a source you use in SQL throughsource.sql_expr.insert_arrow()writes one into an existing table.- A path that already has a query string, such as
"data.db?mode=ro", keeps it whensettingsare added. The connection stays read-only and rejects writes. - Only one module-level batch stream can run at a time. Starting another query while a stream is open raises
RuntimeError("Finish the active Arrow batch stream first")and does not block. A stream that is closed early or interrupted cancels its query and releases the engine. query(sql, "ArrowTable")is unchanged.
Fixed
- DataStore:
when(...).otherwise(...)with only integer literals returnsint64, as pandas does (np.where/np.select). It used to return ClickHouse'suint8, which wrapped around on later subtraction (#804).
Full Changelog: v4.5.0...v4.5.1