Skip to content

Releases

client-web-1.25.0

Choose a tag to compare

@ccoltx ccoltx released this 04 Nov 18:30
a5b9c61

Migration Notes

  • query() now sends its format to the server as the default_format setting, instead of appending FORMAT <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 with FORMAT <format>. Adjust anything that matches on that suffix.
    • A FORMAT clause in the query itself is no longer a syntax error: the server uses it, and if it differs from the format option, query() throws an error that names both formats. With a tracer configured, that error is recorded on the clickhouse.query.stream span (#1103). Remove the clause, or use exec() if you need full control over the SQL.
    • A user whose profile locks default_format with a <constraints> entry (possible on ClickHouse 26.x) fails every query() with SETTING_CONSTRAINT_VIOLATION. Allow changing default_format for that user. (#1085)

Improvements

  • query() now sends the query as written and passes its format to the server as the default_format setting, instead of appending FORMAT <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 with Multi-statements are not allowed (#973);
    • FORMAT is no longer placed after a trailing SETTINGS clause, which some older servers rejected (#970);
    • the short SHOW ROW POLICIES syntax works (#759).

    The format option overrides a default_format set in clickhouse_settings. An X-ClickHouse-Format request header set via http_headers (on the client or on the call) is not sent by query(), as the server would prefer it over default_format; the other methods still send it. (#1085)

  • command() and exec() now also send the query as written, without removing trailing semicolons, as the server accepts them. The one exception is exec() with values: 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_format enabled, the error that occurs while it writes the result comes back as {"exception": "..."}), ClickHouseError.message no longer keeps the JSON escaping, for example \" instead of ". (#1085)

Bug fixes

  • (Web only) ResultSet.close() now ends the clickhouse.query.stream tracing span when cancelling the response stream rejects (for example after a connection reset), instead of leaving the span open. (#1103)

client-1.25.0

Choose a tag to compare

@ccoltx ccoltx released this 04 Nov 14:39
bfd729c

Migration Notes

  • query() now sends its format to the server as the default_format setting, instead of appending FORMAT <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 with FORMAT <format>. Adjust anything that matches on that suffix.
    • A FORMAT clause in the query itself is no longer a syntax error: the server uses it, and if it differs from the format option, query() throws an error that names both formats. With a tracer configured, that error is recorded on the clickhouse.query.stream span (#1103). Remove the clause, or use exec() if you need full control over the SQL.
    • A user whose profile locks default_format with a <constraints> entry (possible on ClickHouse 26.x) fails every query() with SETTING_CONSTRAINT_VIOLATION. Allow changing default_format for that user. (#1085)

Improvements

  • query() now sends the query as written and passes its format to the server as the default_format setting, instead of appending FORMAT <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 with Multi-statements are not allowed (#973);
    • FORMAT is no longer placed after a trailing SETTINGS clause, which some older servers rejected (#970);
    • the short SHOW ROW POLICIES syntax works (#759).

    The format option overrides a default_format set in clickhouse_settings. An X-ClickHouse-Format request header set via http_headers (on the client or on the call) is not sent by query(), as the server would prefer it over default_format; the other methods still send it. (#1085)

  • command() and exec() now also send the query as written, without removing trailing semicolons, as the server accepts them. The one exception is exec() with values: 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_format enabled, the error that occurs while it writes the result comes back as {"exception": "..."}), ClickHouseError.message no longer keeps the JSON escaping, for example \" instead of ". (#1085)

Bug fixes

  • (Node.js only) ResultSet.close() no longer throws an uncaught ResultSet has been closed error when the ResultSet wraps a stream that has no error listener. (#1087)

client-1.24.1

Choose a tag to compare

@ccoltx ccoltx released this 13 Oct 15:01
6a265d2

Bug fixes

  • Fixed a socket hang up error 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 socket idle_socket_ttl later, mid-request (Node.js only) (#1040). (#1041)

client-web-1.24.0

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 05 Oct 17:40
710aea5

New features

  • OpenTelemetry: richer, more actionable spans (requested by Langfuse, #948). (#950)
    • The X-ClickHouse-Summary header is now parsed on the Web client and attached to the operation spans (query / command / exec / insert), including the outer clickhouse.query span. 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 surfaces total_rows_to_read and memory_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_rows is now recorded for non-streaming result consumption too (json() on JSON / JSONObjectEachRow / the other single-document JSON formats), not just row-streaming paths.
    • Added a span_attributes field 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 the log_comment setting (route, tenant, surface, etc.). Caller-provided attributes never override the client's own db.* / server.* / clickhouse.* attributes.
    • Added a dangerously_log_query_text client option (default false). When enabled, the raw SQL statement is attached to spans as the OpenTelemetry db.query.text attribute. The query text may contain sensitive literals, which is why it is off by default; bound query_params values and credentials are never traced regardless of this setting.

Bug fixes

  • Fixed Array(Date) / Array(Date32) query-parameter binding (and other temporal element types nested in arrays, tuples, and maps). A JS Date inside a container was serialized as a bare Unix timestamp (e.g. [1683244800]), which the server's Array(Date) element parser rejects (CANNOT_PARSE_INPUT_ASSERTION_FAILED). Container-nested Date values are now emitted as a quoted UTC date string (e.g. ['2023-05-05']), the one encoding every temporal element type accepts. Note: a Date used inside Array(DateTime) / Array(DateTime64) is now bound at day precision (the time-of-day is dropped), since date-only is the only form Array(Date) accepts; scalar Date / DateTime binding is unchanged. (#947)
  • Export the QueryParamsWithFormat, ClickHouseSummary, WithClickHouseSummary, ResultJSONType, RowJSONType and PingParams types 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

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 05 Oct 17:40
710aea5

New features

  • OpenTelemetry: richer, more actionable spans (requested by Langfuse, #948). (#950)
    • The X-ClickHouse-Summary counters are now attached to the clickhouse.query span as well (previously only on command / 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 surfaces total_rows_to_read (already typed but never recorded) and memory_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_rows is now recorded for non-streaming result consumption too (json() on JSON / JSONObjectEachRow / the other single-document JSON formats), not just row-streaming paths.
    • Added a span_attributes field 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 the log_comment setting (route, tenant, surface, etc.). Caller-provided attributes never override the client's own db.* / server.* / clickhouse.* attributes.
    • Added a dangerously_log_query_text client option (default false). When enabled, the raw SQL statement is attached to spans as the OpenTelemetry db.query.text attribute and included in the error-level logs emitted for a failed request. The query text may contain sensitive literals, which is why it is off by default; bound query_params values and credentials are never logged or traced regardless of this setting.

Bug fixes

  • Fixed Array(Date) / Array(Date32) query-parameter binding (and other temporal element types nested in arrays, tuples, and maps). A JS Date inside a container was serialized as a bare Unix timestamp (e.g. [1683244800]), which the server's Array(Date) element parser rejects (CANNOT_PARSE_INPUT_ASSERTION_FAILED). Container-nested Date values are now emitted as a quoted UTC date string (e.g. ['2023-05-05']), the one encoding every temporal element type accepts. Note: a Date used inside Array(DateTime) / Array(DateTime64) is now bound at day precision (the time-of-day is dropped), since date-only is the only form Array(Date) accepts; scalar Date / DateTime binding is unchanged. (#947)
  • Export the QueryParamsWithFormat, ClickHouseSummary, WithClickHouseSummary, ResultJSONType, RowJSONType and PingParams types 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

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 07 Jul 09:37
f67717b

Bug Fixes

  • Re-export EXCEPTION_TAG_HEADER_NAME and extractErrorAtTheEndOfChunk from @clickhouse/client-web. Both are part of the (now deprecated) @clickhouse/client-common public 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

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 07 Jul 09:37
f67717b

Bug Fixes

  • Re-export EXCEPTION_TAG_HEADER_NAME and extractErrorAtTheEndOfChunk from @clickhouse/client. Both are part of the (now deprecated) @clickhouse/client-common public 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

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 29 Jun 20:21
cd69570

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 an Iterable<T> of rows into a plain RowBinary payload. Note its shape: it is a streaming generator, not a one-shot Writer<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.flush node:diagnostics_channel for 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/writeDateTime floor to the calendar day / whole second instead of rounding (so a non-midnight Date or sub-second DateTime no longer rounds up); parseIPv6 rejects malformed hex groups instead of silently encoding 0; and writeGeometry validates the discriminant before writing its byte, so an out-of-range value can't leave a partial payload. (#916)

datatype-parser-v0.1.3

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 29 Jun 20:42
1d6fcbe

Migration Notes

  • Node.js 18.x is no longer supported. The engines.node floor was raised from >=18.0.0 to >=20. Node.js 20.x, 22.x, 24.x, and 26.x are supported and exercised in CI. (#906)

client-web-1.23.0

Choose a tag to compare

@peter-leonov-ch peter-leonov-ch released this 29 Jun 21:45
70ad405

Migration Notes

  • Node.js 26.x was added to the CI matrix, and Node.js 18.x is no longer supported. The engines.node floor 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-common package 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-common should be imported from @clickhouse/client or @clickhouse/client-web instead. The @clickhouse/client-common package itself will no longer receive updates. ([#845])

  • The parseColumnType function and its SimpleColumnTypes companion (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-parser package (parseDataType plus its Node AST), 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 decoding RowBinary / RowBinaryWithNames / RowBinaryWithNamesAndTypes streams (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 in agents.skills) and is also published independently as the @clickhouse/rowbinary package. A matching RowBinary writer is planned. ([#864])

  • Published the @clickhouse/datatype-parser package: a small, dependency-free standalone parser for ClickHouse data-type strings (the kind sent in the types row of RowBinaryWithNamesAndTypes, e.g. Array(Nullable(UInt64)), Tuple(a UInt8, b String), Enum8('a' = 1)). It is a faithful port of the server's ParserDataType and emits a JSON AST that is byte-identical to the server's EXPLAIN AST json = 1 data-type subtree. It supersedes the deprecated parseColumnType (see Migration Notes). ([#893])

  • (Node.js, @experimental) Added an additive connection?: Connection<Stream.Readable> option to createClient that lets a caller plug an externally-built backend Connection-like object in place of the default HTTP(S) factory. Only supposed to be used for testing the chDB integration. ([#879])

  • Added ClickHouseSettingsInterface, a package-neutral structural counterpart to ClickHouseSettings, exported from @clickhouse/client, @clickhouse/client-web, and @clickhouse/client-common. It is identical to ClickHouseSettings except that its index signature omits SettingsMap (a class with a private member, which TypeScript compares nominally). Because each client package now bundles its own copy of the common module, their ClickHouseSettings types are mutually unassignable; ClickHouseSettingsInterface is structurally identical across all three packages and assignable into each package's ClickHouseSettings, 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 as SettingsMap cannot be carried through it — use ClickHouseSettings if you need them. ([#889])