clickhouse 0.2.0
clickhouse: ^0.2.0 copied to clipboard
A fast, native Dart driver for ClickHouse over the TCP binary protocol — queries, batch inserts, connection pooling, LZ4/LZ4HC/ZSTD compression, and full column-type support.
Changelog #
All notable changes to this project are documented here. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.2.0 #
Feature-parity release with the official Go driver on the native transport, validated against ClickHouse 26.6 (plus 24.3 / 25.1). Test coverage 94.7%.
Added #
- Native ZSTD compression — a pure-Dart ZSTD codec is now built in for
CompressionMethod.zstdin both directions (decodes real libzstd frames, encodes valid frames). AregisterCodec(CompressionMethod.zstd, …)still overrides the built-in (e.g. an FFI libzstd). - Per-query OpenTelemetry span —
traceId/spanId/traceState/traceFlagsonquery()/exec(), overriding the connection-level span. - Per-query timezone —
timezone:onquery()/queryRow()/selectAll()decodesDateTime/DateTime64results in a chosen IANA zone. - External query cancellation — a
cancelTriggerfuture onquery()/exec()aborts an in-flight operation withQueryCancelledException. Batch.appendRows(Rows, {flushEvery})— client-sideINSERT … SELECT, piping a query result straight into a batch.- Custom-type marshaling —
ClickHouseValuer(write, unwrapped on append) andClickHouseScannable+Rows.scanInto/scanIntoByName(read). DialContext/dialStrategy— a richer dialer receiving the connection id, resolved address, and options (takes precedence overdial).ColumnType.scanType— the DartTypeeach column decodes to.ErrAcquireConnNoAddress— sentinel thrown when no usable address is configured.- Language + OS metadata (
lv:dart/…,os:…) in the client-info string, sosystem.query_logrecords the client runtime.
Changed #
- LZ4HC now runs a real high-compression (hash-chain) encoder instead of
aliasing plain LZ4;
compressLevelscales the search depth. maxCompressionBufferis now honored — a large insert block is split across multiple compressed frames (flushed between chunks) to bound memory.
Fixed #
- Timezone-safe
DateTimebinding — boundDateTime/DateTime64literals now carry an explicitUTCzone, fixing misreads when the server session timezone is not UTC. - Multi-row
VALUESbinding — aList<GroupSet>renders as comma-joined tuples ((…), (…)) instead of an array, forINSERT … VALUES (?,?),(?,?).
0.1.0 #
Initial release. A pure-Dart ClickHouse driver speaking the native TCP binary protocol (port 9000). Validated against ClickHouse 24.3, 25.1, and 26.6.
Connection & pooling #
ClickHouseConnection— TCP dial, handshake, protocol-revision negotiation.ClickHousePool— bounded pool withmaxOpen/maxIdle, lifetime and idle eviction, wait timeout, health checks, andPoolStats.- Multiple addresses with
ConnOpenStrategy(in-order / round-robin / random). - TLS (
secure,skipVerify,tlsServerName) and a customdialhook for SSH tunnels, unix sockets, proxies, or instrumentation. - JWT authentication via a
getJwtcallback. - DSN parsing:
ClickHouseOptions.fromDsn('clickhouse://user@host:9000/db?...').
Queries & inserts #
query(),exec(),asyncInsert(), and streamingRows(next,valueAt,valueByName,scan,toMap,scanStruct,columnTypes,totals).- Batch inserts:
prepareBatch()→addRow/appendFromMap/appendStruct/ columnarcolumn(i).append*, withsend,flush,abort,close. - Batch pool options:
releaseConnection(free the connection untilsend()) andcloseOnFlush. - Per-query
queryId,quotaKey,settings(withImportantSetting/CustomSetting), server-side{name:Type}parameters, and a full-lifecycletimeoutthat cancels the query. - Client-side binding:
bind()with positional?, numeric$N, and named@nameplaceholders (backtick / comment / string-literal aware). - External (temporary) tables alongside a query.
Column types #
String, FixedString, Int8/16/32/64/128/256, UInt8/16/32/64/128/256,
Float32/64, BFloat16, Bool, Date, Date32, DateTime, DateTime64 (timezone-aware,
DST-correct via package:timezone), Time, Time64, UUID, Decimal(32/64/128/256),
IPv4, IPv6, Enum8/16 (name-mapped), Array, Tuple, Map, Nested, Nullable,
LowCardinality, Variant, Dynamic (v1 + v3), JSON (string + object modes),
SimpleAggregateFunction, Nothing, all Interval kinds, and the geo types
(Point, Ring, LineString, MultiLineString, Polygon, MultiPolygon).
Compression #
- LZ4 and LZ4HC with ClickHouse CityHash128 frame checksums.
- Pluggable
Codecinterface (registerCodec) for ZSTD and others.
Observability #
- Callbacks for progress, profile info, profile events, and server logs.
- Structured
loggerhook and OpenTelemetry trace-context propagation. - Structured errors:
ClickHouseExceptionwithClickHouseErrorCode, plusOpError,ColumnConverterError,BlockError, andErr*sentinels.
Notes #
- Native TCP transport only (no HTTP). ZSTD ships as a pluggable codec seam
rather than a bundled dependency. Struct mapping uses closures
(
appendStruct/scanStruct) instead of runtime reflection.