Repository navigation
Releases
client-web-1.25.0
Migration Notes
query()now sends itsformatto the server as thedefault_formatsetting, instead of appendingFORMAT <format>to the SQL (see Improvements below). No code change is required, but check the following:- The query text recorded in
system.query_log, in logs and in traces no longer ends withFORMAT <format>. Adjust anything that matches on that suffix. - A
FORMATclause in the query itself is no longer a syntax error: the server uses it, and if it differs from theformatoption,query()throws an error that names both formats. With atracerconfigured, that error is recorded on theclickhouse.query.streamspan (#1103). Remove the clause, or useexec()if you need full control over the SQL. - A user whose profile locks
default_formatwith a<constraints>entry (possible on ClickHouse 26.x) fails everyquery()withSETTING_CONSTRAINT_VIOLATION. Allow changingdefault_formatfor that user. (#1085)
- The query text recorded in
Improvements
-
query()now sends the query as written and passes itsformatto the server as thedefault_formatsetting, instead of appendingFORMAT <format>to the SQL. This matches the Go, Rust and Java clients, and fixes queries that failed because of the appended clause:- a trailing semicolon followed by a comment, such as
SELECT 1; -- note, no longer fails withMulti-statements are not allowed(#973); FORMATis no longer placed after a trailingSETTINGSclause, which some older servers rejected (#970);- the short
SHOW ROW POLICIESsyntax works (#759).
The
formatoption overrides adefault_formatset inclickhouse_settings. AnX-ClickHouse-Formatrequest header set viahttp_headers(on the client or on the call) is not sent byquery(), as the server would prefer it overdefault_format; the other methods still send it. (#1085) - a trailing semicolon followed by a comment, such as
-
command()andexec()now also send the query as written, without removing trailing semicolons, as the server accepts them. The one exception isexec()withvalues: the server reads the data right after the statement and rejects a;before it, so trailing semicolons are still removed there. (#1085) -
When the server reports an error in a JSON output format (with
http_write_exception_in_output_formatenabled, the error that occurs while it writes the result comes back as{"exception": "..."}),ClickHouseError.messageno longer keeps the JSON escaping, for example\"instead of". (#1085)
Bug fixes
- (Web only)
ResultSet.close()now ends theclickhouse.query.streamtracing span when cancelling the response stream rejects (for example after a connection reset), instead of leaving the span open. (#1103)
client-1.25.0
Migration Notes
query()now sends itsformatto the server as thedefault_formatsetting, instead of appendingFORMAT <format>to the SQL (see Improvements below). No code change is required, but check the following:- The query text recorded in
system.query_log, in logs and in traces no longer ends withFORMAT <format>. Adjust anything that matches on that suffix. - A
FORMATclause in the query itself is no longer a syntax error: the server uses it, and if it differs from theformatoption,query()throws an error that names both formats. With atracerconfigured, that error is recorded on theclickhouse.query.streamspan (#1103). Remove the clause, or useexec()if you need full control over the SQL. - A user whose profile locks
default_formatwith a<constraints>entry (possible on ClickHouse 26.x) fails everyquery()withSETTING_CONSTRAINT_VIOLATION. Allow changingdefault_formatfor that user. (#1085)
- The query text recorded in
Improvements
-
query()now sends the query as written and passes itsformatto the server as thedefault_formatsetting, instead of appendingFORMAT <format>to the SQL. This matches the Go, Rust and Java clients, and fixes queries that failed because of the appended clause:- a trailing semicolon followed by a comment, such as
SELECT 1; -- note, no longer fails withMulti-statements are not allowed(#973); FORMATis no longer placed after a trailingSETTINGSclause, which some older servers rejected (#970);- the short
SHOW ROW POLICIESsyntax works (#759).
The
formatoption overrides adefault_formatset inclickhouse_settings. AnX-ClickHouse-Formatrequest header set viahttp_headers(on the client or on the call) is not sent byquery(), as the server would prefer it overdefault_format; the other methods still send it. (#1085) - a trailing semicolon followed by a comment, such as
-
command()andexec()now also send the query as written, without removing trailing semicolons, as the server accepts them. The one exception isexec()withvalues: the server reads the data right after the statement and rejects a;before it, so trailing semicolons are still removed there. (#1085) -
When the server reports an error in a JSON output format (with
http_write_exception_in_output_formatenabled, the error that occurs while it writes the result comes back as{"exception": "..."}),ClickHouseError.messageno longer keeps the JSON escaping, for example\"instead of". (#1085)
Bug fixes
- (Node.js only)
ResultSet.close()no longer throws an uncaughtResultSet has been closederror when theResultSetwraps a stream that has noerrorlistener. (#1087)
client-1.24.1
Bug fixes
- Fixed a
socket hang uperror on a request that took over a socket released by an earlier request, when another request queued for that socket was aborted in between. The orphaned idle-socket timer from the earlier release destroyed the socketidle_socket_ttllater, mid-request (Node.js only) (#1040). (#1041)
client-web-1.24.0
New features
- OpenTelemetry: richer, more actionable spans (requested by Langfuse, #948). (#950)
- The
X-ClickHouse-Summaryheader is now parsed on the Web client and attached to the operation spans (query/command/exec/insert), including the outerclickhouse.queryspan. Previously the Web client did not parse the summary header at all. - Every key present in the summary header is recorded as
clickhouse.summary.<key>(the set is not hardcoded). This surfacestotal_rows_to_readandmemory_usage(peak query memory, in bytes; sent by newer servers), and picks up future server-side additions (e.g.real_time_microseconds) automatically. db.response.returned_rowsis now recorded for non-streaming result consumption too (json()onJSON/JSONObjectEachRow/ the other single-document JSON formats), not just row-streaming paths.- Added a
span_attributesfield to the per-request query params (query/command/exec/insert/ping). Use it to enrich the operation span with application-level context — e.g. mirroring the tags you also send via thelog_commentsetting (route, tenant, surface, etc.). Caller-provided attributes never override the client's owndb.*/server.*/clickhouse.*attributes. - Added a
dangerously_log_query_textclient option (defaultfalse). When enabled, the raw SQL statement is attached to spans as the OpenTelemetrydb.query.textattribute. The query text may contain sensitive literals, which is why it is off by default; boundquery_paramsvalues and credentials are never traced regardless of this setting.
- The
Bug fixes
- Fixed
Array(Date)/Array(Date32)query-parameter binding (and other temporal element types nested in arrays, tuples, and maps). A JSDateinside a container was serialized as a bare Unix timestamp (e.g.[1683244800]), which the server'sArray(Date)element parser rejects (CANNOT_PARSE_INPUT_ASSERTION_FAILED). Container-nestedDatevalues are now emitted as a quoted UTC date string (e.g.['2023-05-05']), the one encoding every temporal element type accepts. Note: aDateused insideArray(DateTime)/Array(DateTime64)is now bound at day precision (the time-of-day is dropped), since date-only is the only formArray(Date)accepts; scalarDate/DateTimebinding is unchanged. (#947) - Export the
QueryParamsWithFormat,ClickHouseSummary,WithClickHouseSummary,ResultJSONType,RowJSONTypeandPingParamstypes from@clickhouse/client-web. They are used in the signatures of the public API (query,ping, the result types), but could not be imported from the package root (#997). (#1024)
client-1.24.0
New features
- OpenTelemetry: richer, more actionable spans (requested by Langfuse, #948). (#950)
- The
X-ClickHouse-Summarycounters are now attached to theclickhouse.queryspan as well (previously only oncommand/exec/insert), so the request-level metrics are visible on the outer client span. - Every key present in the summary header is now recorded as
clickhouse.summary.<key>(the set is no longer a hardcoded subset). This surfacestotal_rows_to_read(already typed but never recorded) andmemory_usage(peak query memory, in bytes; sent by newer servers), and picks up future server-side additions (e.g.real_time_microseconds) automatically. db.response.returned_rowsis now recorded for non-streaming result consumption too (json()onJSON/JSONObjectEachRow/ the other single-document JSON formats), not just row-streaming paths.- Added a
span_attributesfield to the per-request query params (query/command/exec/insert/ping). Use it to enrich the operation span with application-level context — e.g. mirroring the tags you also send via thelog_commentsetting (route, tenant, surface, etc.). Caller-provided attributes never override the client's owndb.*/server.*/clickhouse.*attributes. - Added a
dangerously_log_query_textclient option (defaultfalse). When enabled, the raw SQL statement is attached to spans as the OpenTelemetrydb.query.textattribute and included in theerror-level logs emitted for a failed request. The query text may contain sensitive literals, which is why it is off by default; boundquery_paramsvalues and credentials are never logged or traced regardless of this setting.
- The
Bug fixes
- Fixed
Array(Date)/Array(Date32)query-parameter binding (and other temporal element types nested in arrays, tuples, and maps). A JSDateinside a container was serialized as a bare Unix timestamp (e.g.[1683244800]), which the server'sArray(Date)element parser rejects (CANNOT_PARSE_INPUT_ASSERTION_FAILED). Container-nestedDatevalues are now emitted as a quoted UTC date string (e.g.['2023-05-05']), the one encoding every temporal element type accepts. Note: aDateused insideArray(DateTime)/Array(DateTime64)is now bound at day precision (the time-of-day is dropped), since date-only is the only formArray(Date)accepts; scalarDate/DateTimebinding is unchanged. (#947) - Export the
QueryParamsWithFormat,ClickHouseSummary,WithClickHouseSummary,ResultJSONType,RowJSONTypeandPingParamstypes from@clickhouse/client. They are used in the signatures of the public API (query,ping, the result types), but could not be imported from the package root (#997). (#1024)
client-web-1.23.1
Bug Fixes
- Re-export
EXCEPTION_TAG_HEADER_NAMEandextractErrorAtTheEndOfChunkfrom@clickhouse/client-web. Both are part of the (now deprecated)@clickhouse/client-commonpublic API but were missed when its surface was bundled into and re-exported from the client packages in 1.23.0 (#845). Reported downstream by Langfuse. (#935)
client-1.23.1
Bug Fixes
- Re-export
EXCEPTION_TAG_HEADER_NAMEandextractErrorAtTheEndOfChunkfrom@clickhouse/client. Both are part of the (now deprecated)@clickhouse/client-commonpublic API but were missed when its surface was bundled into and re-exported from the client packages in 1.23.0 (#845). Reported downstream by Langfuse. (#935)
rowbinary-v0.2.0
New features
-
Added the RowBinary writer — the encode mirror of the reader: type-specific
writeX(sink, value)building blocks and combinators that compose with no per-element closures, exported from@clickhouse/rowbinary/writer(or the per-type modules). (#911)writeRows(writeRow)drives anIterable<T>of rows into a plainRowBinarypayload. Note its shape: it is a streaming generator, not a one-shotWriter<readonly T[]>. It writes into a fixed-size buffer (bufferSize, default 64 KiB), yields each batch of whole rows when the buffer fills — rewinding so a half-written row never leaks — and starts a fresh buffer for the rest, so a result larger than the buffer (or an unbounded row source) streams out chunk by chunk. An oversized row grows the buffer (doubling) rather than failing, and per-buffer fill is published on the@clickhouse/rowbinary:writeRows.flushnode:diagnostics_channelfor buffer-utilization metrics. (#915)import { writeRows, writeTupleNamed, writeUInt64, writeString, } from "@clickhouse/rowbinary/writer"; const writeRow = writeTupleNamed({ id: writeUInt64, name: writeString }); for (const chunk of writeRows(writeRow)(rows, 64 * 1024)) send(chunk);
Writer edge-case hardening:
writeDate/writeDate32/writeDateTimefloor to the calendar day / whole second instead of rounding (so a non-midnightDateor sub-secondDateTimeno longer rounds up);parseIPv6rejects malformed hex groups instead of silently encoding0; andwriteGeometryvalidates the discriminant before writing its byte, so an out-of-range value can't leave a partial payload. (#916)
datatype-parser-v0.1.3
Migration Notes
- Node.js 18.x is no longer supported. The
engines.nodefloor was raised from>=18.0.0to>=20. Node.js 20.x, 22.x, 24.x, and 26.x are supported and exercised in CI. (#906)
client-web-1.23.0
Migration Notes
-
Node.js 26.x was added to the CI matrix, and Node.js 18.x is no longer supported. The
engines.nodefloor of@clickhouse/client(previously>=16) and@clickhouse/datatype-parser(previously>=18.0.0) was raised to>=20. Node.js 20.x, 22.x, 24.x, and 26.x are supported and exercised in CI. -
The
@clickhouse/client-commonpackage is deprecated.@clickhouse/client(Node.js) and@clickhouse/client-web(Web) no longer depend on it; the shared code is now bundled into each client package. Everything previously importable from@clickhouse/client-commonshould be imported from@clickhouse/clientor@clickhouse/client-webinstead. The@clickhouse/client-commonpackage itself will no longer receive updates. ([#845]) -
The
parseColumnTypefunction and itsSimpleColumnTypescompanion (exported from@clickhouse/client,@clickhouse/client-web, and@clickhouse/client-common) are deprecated and slated for removal in a future major version. They are superseded by the new standalone@clickhouse/datatype-parserpackage (parseDataTypeplus itsNodeAST), which parses the full ClickHouse data-type grammar and emits an AST that mirrors the server's. ([#893])
New features
-
(Node.js) Added a RowBinary reader library and agent skill under
skills/clickhouse-js-node-rowbinary-parser. It ships type-specific, monomorphizable building blocks for decodingRowBinary/RowBinaryWithNames/RowBinaryWithNamesAndTypesstreams (full-buffer and chunked), plus a skill that guides an agent to generate bespoke high-performance parsers from a query's column types. The skill is bundled into@clickhouse/client(registered inagents.skills) and is also published independently as the@clickhouse/rowbinarypackage. A matching RowBinary writer is planned. ([#864]) -
Published the
@clickhouse/datatype-parserpackage: a small, dependency-free standalone parser for ClickHouse data-type strings (the kind sent in the types row ofRowBinaryWithNamesAndTypes, e.g.Array(Nullable(UInt64)),Tuple(a UInt8, b String),Enum8('a' = 1)). It is a faithful port of the server'sParserDataTypeand emits a JSON AST that is byte-identical to the server'sEXPLAIN AST json = 1data-type subtree. It supersedes the deprecatedparseColumnType(see Migration Notes). ([#893]) -
(Node.js,
@experimental) Added an additiveconnection?: Connection<Stream.Readable>option tocreateClientthat lets a caller plug an externally-built backendConnection-like object in place of the default HTTP(S) factory. Only supposed to be used for testing thechDBintegration. ([#879]) -
Added
ClickHouseSettingsInterface, a package-neutral structural counterpart toClickHouseSettings, exported from@clickhouse/client,@clickhouse/client-web, and@clickhouse/client-common. It is identical toClickHouseSettingsexcept that its index signature omitsSettingsMap(a class with a private member, which TypeScript compares nominally). Because each client package now bundles its own copy of the common module, theirClickHouseSettingstypes are mutually unassignable;ClickHouseSettingsInterfaceis structurally identical across all three packages and assignable into each package'sClickHouseSettings, so a consumer that shares a single settings-producing helper across both the Node.js and Web clients can type it against this one type without casts. Values typed asSettingsMapcannot be carried through it — useClickHouseSettingsif you need them. ([#889])