@clickhouse/client 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +11 -11
  2. package/dist/client.d.ts +6 -6
  3. package/dist/client.js.map +1 -1
  4. package/dist/config.d.ts +6 -6
  5. package/dist/config.js +6 -5
  6. package/dist/config.js.map +1 -1
  7. package/dist/connection/compression.d.ts +4 -4
  8. package/dist/connection/compression.js +3 -3
  9. package/dist/connection/compression.js.map +1 -1
  10. package/dist/connection/create_connection.d.ts +6 -6
  11. package/dist/connection/create_connection.js +3 -3
  12. package/dist/connection/create_connection.js.map +1 -1
  13. package/dist/connection/index.d.ts +4 -4
  14. package/dist/connection/index.js.map +1 -1
  15. package/dist/connection/node_base_connection.d.ts +11 -11
  16. package/dist/connection/node_base_connection.js +75 -42
  17. package/dist/connection/node_base_connection.js.map +1 -1
  18. package/dist/connection/node_custom_agent_connection.d.ts +4 -4
  19. package/dist/connection/node_custom_agent_connection.js +2 -2
  20. package/dist/connection/node_custom_agent_connection.js.map +1 -1
  21. package/dist/connection/node_http_connection.d.ts +4 -4
  22. package/dist/connection/node_http_connection.js.map +1 -1
  23. package/dist/connection/node_https_connection.d.ts +5 -5
  24. package/dist/connection/node_https_connection.js +11 -11
  25. package/dist/connection/node_https_connection.js.map +1 -1
  26. package/dist/connection/socket_pool.d.ts +9 -9
  27. package/dist/connection/socket_pool.js +33 -32
  28. package/dist/connection/socket_pool.js.map +1 -1
  29. package/dist/connection/stream.d.ts +2 -2
  30. package/dist/connection/stream.js +18 -18
  31. package/dist/connection/stream.js.map +1 -1
  32. package/dist/index.d.ts +41 -8
  33. package/dist/index.js +4 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/result_set.d.ts +31 -20
  36. package/dist/result_set.js +83 -13
  37. package/dist/result_set.js.map +1 -1
  38. package/dist/utils/encoder.d.ts +2 -2
  39. package/dist/utils/encoder.js +3 -3
  40. package/dist/utils/encoder.js.map +1 -1
  41. package/dist/utils/index.d.ts +4 -4
  42. package/dist/utils/index.js.map +1 -1
  43. package/dist/utils/process.js.map +1 -1
  44. package/dist/utils/runtime.js.map +1 -1
  45. package/dist/utils/stream.d.ts +1 -1
  46. package/dist/utils/stream.js +8 -8
  47. package/dist/utils/stream.js.map +1 -1
  48. package/dist/utils/user_agent.js.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/dist/version.js.map +1 -1
  52. package/package.json +2 -2
  53. package/skills/clickhouse-js-node-coding/reference/async-insert.md +12 -12
  54. package/skills/clickhouse-js-node-coding/reference/client-configuration.md +16 -16
  55. package/skills/clickhouse-js-node-coding/reference/custom-json.md +31 -31
  56. package/skills/clickhouse-js-node-coding/reference/data-types.md +65 -65
  57. package/skills/clickhouse-js-node-coding/reference/insert-columns.md +23 -23
  58. package/skills/clickhouse-js-node-coding/reference/insert-formats.md +30 -30
  59. package/skills/clickhouse-js-node-coding/reference/insert-values.md +35 -35
  60. package/skills/clickhouse-js-node-coding/reference/ping.md +24 -24
  61. package/skills/clickhouse-js-node-coding/reference/query-parameters.md +27 -27
  62. package/skills/clickhouse-js-node-coding/reference/select-formats.md +21 -21
  63. package/skills/clickhouse-js-node-coding/reference/sessions.md +27 -27
  64. package/skills/clickhouse-js-node-troubleshooting/reference/compression.md +2 -2
  65. package/skills/clickhouse-js-node-troubleshooting/reference/data-types.md +24 -24
  66. package/skills/clickhouse-js-node-troubleshooting/reference/logging.md +5 -5
  67. package/skills/clickhouse-js-node-troubleshooting/reference/proxy-pathname.md +7 -7
  68. package/skills/clickhouse-js-node-troubleshooting/reference/query-format-clause.md +6 -6
  69. package/skills/clickhouse-js-node-troubleshooting/reference/query-params.md +30 -30
  70. package/skills/clickhouse-js-node-troubleshooting/reference/readonly-users.md +4 -4
  71. package/skills/clickhouse-js-node-troubleshooting/reference/socket-hangup.md +20 -20
  72. package/skills/clickhouse-js-node-troubleshooting/reference/tls.md +24 -24
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { NodeClickHouseClient as ClickHouseClient, type QueryResult, } from './client';
2
- export { createClient } from './client';
3
- export { type NodeClickHouseClientConfigOptions as ClickHouseClientConfigOptions } from './config';
4
- export { ResultSet, type StreamReadable } from './result_set';
5
- export { drainStream } from './connection/stream';
1
+ export { NodeClickHouseClient as ClickHouseClient, type QueryResult, } from "./client";
2
+ export { createClient } from "./client";
3
+ export { type NodeClickHouseClientConfigOptions as ClickHouseClientConfigOptions } from "./config";
4
+ export { ResultSet, type StreamReadable } from "./result_set";
5
+ export { drainStream } from "./connection/stream";
6
6
  /** Re-export @clickhouse/client-common types */
7
- export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, type ResponseHeaders, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, type ProgressRow, type RowOrProgress, type ClickHouseAuth, type ClickHouseJWTAuth, type ClickHouseCredentialsAuth, } from '@clickhouse/client-common';
7
+ export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, type ResponseHeaders, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, type ProgressRow, type RowOrProgress, type ClickHouseAuth, type ClickHouseJWTAuth, type ClickHouseCredentialsAuth, type ClickHouseTracer, type ClickHouseSpan, type ClickHouseSpanOptions, type ClickHouseSpanAttributes, type ClickHouseSpanStatus, type ClickHouseSpanName, } from "@clickhouse/client-common";
8
8
  /**
9
9
  * Re-export @clickhouse/client-common runtime values.
10
10
  *
@@ -13,11 +13,24 @@ export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type Quer
13
13
  * applied to them in `@clickhouse/client-common` are NOT propagated to consumers of this package.
14
14
  * Importing these values from `@clickhouse/client` is the recommended, non-deprecated path.
15
15
  */
16
- import { ClickHouseError as ClickHouseError_, parseError as parseError_, ClickHouseLogLevel as ClickHouseLogLevel_, SettingsMap as SettingsMap_, parseColumnType as parseColumnType_, isProgressRow as isProgressRow_, isRow as isRow_, isException as isException_, TupleParam as TupleParam_ } from '@clickhouse/client-common';
16
+ import { ClickHouseError as ClickHouseError_, parseError as parseError_, ClickHouseLogLevel as ClickHouseLogLevel_, SettingsMap as SettingsMap_, parseColumnType as parseColumnType_, isProgressRow as isProgressRow_, isRow as isRow_, isException as isException_, TupleParam as TupleParam_ } from "@clickhouse/client-common";
17
17
  export declare const ClickHouseError: typeof ClickHouseError_;
18
18
  export type ClickHouseError = ClickHouseError_;
19
19
  export declare const parseError: typeof parseError_;
20
- export declare const ClickHouseLogLevel: typeof ClickHouseLogLevel_;
20
+ export declare const ClickHouseLogLevel: {
21
+ readonly TRACE: 0;
22
+ readonly DEBUG: 1;
23
+ readonly INFO: 2;
24
+ readonly WARN: 3;
25
+ readonly ERROR: 4;
26
+ readonly OFF: 127;
27
+ readonly 0: "TRACE";
28
+ readonly 1: "DEBUG";
29
+ readonly 2: "INFO";
30
+ readonly 3: "WARN";
31
+ readonly 4: "ERROR";
32
+ readonly 127: "OFF";
33
+ };
21
34
  export type ClickHouseLogLevel = ClickHouseLogLevel_;
22
35
  export declare const SettingsMap: typeof SettingsMap_;
23
36
  export type SettingsMap = SettingsMap_;
@@ -34,4 +47,24 @@ export declare const isRow: typeof isRow_;
34
47
  export declare const isException: typeof isException_;
35
48
  export declare const TupleParam: typeof TupleParam_;
36
49
  export type TupleParam = TupleParam_;
50
+ export declare const ClickHouseSpanNames: {
51
+ readonly query: "clickhouse.query";
52
+ readonly query_stream: "clickhouse.query.stream";
53
+ readonly command: "clickhouse.command";
54
+ readonly exec: "clickhouse.exec";
55
+ readonly insert: "clickhouse.insert";
56
+ readonly ping: "clickhouse.ping";
57
+ };
58
+ export declare const ClickHouseSpanStatusCode: {
59
+ readonly UNSET: 0;
60
+ readonly OK: 1;
61
+ readonly ERROR: 2;
62
+ };
63
+ export declare const ClickHouseSpanKind: {
64
+ readonly INTERNAL: 0;
65
+ readonly SERVER: 1;
66
+ readonly CLIENT: 2;
67
+ readonly PRODUCER: 3;
68
+ readonly CONSUMER: 4;
69
+ };
37
70
  export declare const defaultJSONHandling: import("@clickhouse/client-common").JSONHandling;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultJSONHandling = exports.TupleParam = exports.isException = exports.isRow = exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.RecordsJSONFormats = exports.SingleDocumentJSONFormats = exports.StreamableJSONFormats = exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.SettingsMap = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.drainStream = exports.ResultSet = exports.createClient = exports.ClickHouseClient = void 0;
3
+ exports.defaultJSONHandling = exports.ClickHouseSpanKind = exports.ClickHouseSpanStatusCode = exports.ClickHouseSpanNames = exports.TupleParam = exports.isException = exports.isRow = exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.RecordsJSONFormats = exports.SingleDocumentJSONFormats = exports.StreamableJSONFormats = exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.SettingsMap = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.drainStream = exports.ResultSet = exports.createClient = exports.ClickHouseClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_1.NodeClickHouseClient; } });
6
6
  var client_2 = require("./client");
@@ -34,5 +34,8 @@ exports.isProgressRow = client_common_1.isProgressRow;
34
34
  exports.isRow = client_common_1.isRow;
35
35
  exports.isException = client_common_1.isException;
36
36
  exports.TupleParam = client_common_1.TupleParam;
37
+ exports.ClickHouseSpanNames = client_common_1.ClickHouseSpanNames;
38
+ exports.ClickHouseSpanStatusCode = client_common_1.ClickHouseSpanStatusCode;
39
+ exports.ClickHouseSpanKind = client_common_1.ClickHouseSpanKind;
37
40
  exports.defaultJSONHandling = client_common_1.defaultJSONHandling;
38
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAGiB;AAFf,0GAAA,oBAAoB,OAAoB;AAG1C,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AAErB,2CAA6D;AAApD,uGAAA,SAAS,OAAA;AAClB,8CAAiD;AAAxC,qGAAA,WAAW,OAAA;AAoDpB;;;;;;;GAOG;AACH,6DAkBkC;AAErB,QAAA,eAAe,GAAG,+BAAgB,CAAA;AAElC,QAAA,UAAU,GAAG,0BAAW,CAAA;AACxB,QAAA,kBAAkB,GAAG,kCAAmB,CAAA;AAExC,QAAA,W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A,eAAe,GAAG,+BAAgB,CAAC;AACnC,QAAA,iBAAiB,GAAG,iCAAkB,CAAC;AACvC,QAAA,aAAa,GAAG,6BAAc,CAAC;AAC/B,QAAA,KAAK,GAAG,qBAAM,CAAC;AACf,QAAA,WAAW,GAAG,2BAAY,CAAC;AAC3B,QAAA,UAAU,GAAG,0BAAW,CAAC;AAEzB,QAAA,mBAAmB,GAAG,mCAAoB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,wCAAyB,CAAC;AACrD,QAAA,kBAAkB,GAAG,kCAAmB,CAAC;AACzC,QAAA,mBAAmB,GAAG,mCAAoB,CAAC"}
@@ -1,14 +1,14 @@
1
- import type { BaseResultSet, DataFormat, JSONHandling, ResponseHeaders, ResultJSONType, ResultStream, Row } from '@clickhouse/client-common';
2
- import type { Readable } from 'stream';
3
- import Stream from 'stream';
1
+ import type { BaseResultSet, ClickHouseSpan, DataFormat, JSONHandling, ResponseHeaders, ResultJSONType, ResultStream, Row } from "@clickhouse/client-common";
2
+ import type { Readable } from "stream";
3
+ import Stream from "stream";
4
4
  /** {@link Stream.Readable} with additional types for the `on(data)` method and the async iterator.
5
5
  * Everything else is an exact copy from stream.d.ts */
6
- export type StreamReadable<T> = Omit<Stream.Readable, 'on'> & {
6
+ export type StreamReadable<T> = Omit<Stream.Readable, "on"> & {
7
7
  [Symbol.asyncIterator](): NodeJS.AsyncIterator<T>;
8
- on(event: 'data', listener: (chunk: T) => void): Stream.Readable;
9
- on(event: 'close' | 'drain' | 'end' | 'finish' | 'pause' | 'readable' | 'resume' | 'unpipe', listener: () => void): Stream.Readable;
10
- on(event: 'error', listener: (err: Error) => void): Stream.Readable;
11
- on(event: 'pipe', listener: (src: Readable) => void): Stream.Readable;
8
+ on(event: "data", listener: (chunk: T) => void): Stream.Readable;
9
+ on(event: "close" | "drain" | "end" | "finish" | "pause" | "readable" | "resume" | "unpipe", listener: () => void): Stream.Readable;
10
+ on(event: "error", listener: (err: Error) => void): Stream.Readable;
11
+ on(event: "pipe", listener: (src: Readable) => void): Stream.Readable;
12
12
  on(event: string | symbol, listener: (...args: any[]) => void): Stream.Readable;
13
13
  };
14
14
  export interface ResultSetOptions<Format extends DataFormat> {
@@ -18,31 +18,42 @@ export interface ResultSetOptions<Format extends DataFormat> {
18
18
  log_error: (error: Error) => void;
19
19
  response_headers: ResponseHeaders;
20
20
  jsonHandling?: JSONHandling;
21
+ span?: ClickHouseSpan;
21
22
  }
22
23
  export declare class ResultSet<Format extends DataFormat | unknown> implements BaseResultSet<Stream.Readable, Format> {
23
- /**
24
- * The stream of the response body.
25
- *
26
- * It is expected that the stream is passed directly from the response of the HTTP request
27
- * and has not been consumed or altered yet.
28
- */
29
- private _stream;
30
- private readonly format;
31
- readonly query_id: string;
32
24
  readonly response_headers: ResponseHeaders;
33
25
  private readonly exceptionTag;
34
26
  private readonly log_error;
35
27
  private readonly jsonHandling;
36
28
  private _consumed;
37
- constructor(
38
29
  /**
39
30
  * The stream of the response body.
40
31
  *
41
32
  * It is expected that the stream is passed directly from the response of the HTTP request
42
33
  * and has not been consumed or altered yet.
43
34
  */
44
- _stream: Stream.Readable, format: Format, query_id: string, log_error?: (error: Error) => void, _response_headers?: ResponseHeaders, jsonHandling?: JSONHandling);
35
+ private _stream;
36
+ private readonly format;
37
+ /** The `clickhouse.query.stream` span owned by this result set (if the
38
+ * client was configured with a tracer); it ends via {@link finishSpan}
39
+ * when the response stream is fully consumed, closed, or fails. */
40
+ private readonly span;
41
+ /** Decoded (decompressed) bytes received from the server so far. */
42
+ private span_bytes;
43
+ /** Rows decoded from the response stream so far. */
44
+ private span_rows;
45
+ private span_rows_counted;
46
+ private span_finished;
47
+ readonly query_id: string;
48
+ constructor(_stream: Stream.Readable, format: Format, query_id: string, log_error?: (error: Error) => void, _response_headers?: ResponseHeaders, jsonHandling?: JSONHandling, span?: ClickHouseSpan);
45
49
  private consume;
50
+ /** Add the number of rows decoded from the response stream. */
51
+ private addSpanRows;
52
+ /** Record the final response metrics (`clickhouse.response.decoded_bytes`
53
+ * and, when rows were counted, `db.response.returned_rows`) and the error
54
+ * (if any) on the span, and end it. Safe to call multiple times - only
55
+ * the first call wins. */
56
+ private finishSpan;
46
57
  /** See {@link BaseResultSet.text}. */
47
58
  text(): Promise<string>;
48
59
  /** See {@link BaseResultSet.json}. */
@@ -59,5 +70,5 @@ export declare class ResultSet<Format extends DataFormat | unknown> implements B
59
70
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using
60
71
  */
61
72
  [Symbol.dispose](): void;
62
- static instance<Format extends DataFormat>({ stream, format, query_id, log_error, response_headers, jsonHandling, }: ResultSetOptions<Format>): ResultSet<Format>;
73
+ static instance<Format extends DataFormat>({ stream, format, query_id, log_error, response_headers, jsonHandling, span, }: ResultSetOptions<Format>): ResultSet<Format>;
63
74
  }
@@ -41,25 +41,35 @@ const stream_1 = __importStar(require("stream"));
41
41
  const utils_1 = require("./utils");
42
42
  const NEWLINE = 0x0a;
43
43
  class ResultSet {
44
- _stream;
45
- format;
46
- query_id;
47
44
  response_headers = {};
48
45
  exceptionTag = undefined;
49
46
  log_error;
50
47
  jsonHandling;
51
48
  _consumed = false;
52
- constructor(
53
49
  /**
54
50
  * The stream of the response body.
55
51
  *
56
52
  * It is expected that the stream is passed directly from the response of the HTTP request
57
53
  * and has not been consumed or altered yet.
58
54
  */
59
- _stream, format, query_id, log_error, _response_headers, jsonHandling) {
55
+ _stream;
56
+ format;
57
+ /** The `clickhouse.query.stream` span owned by this result set (if the
58
+ * client was configured with a tracer); it ends via {@link finishSpan}
59
+ * when the response stream is fully consumed, closed, or fails. */
60
+ span;
61
+ /** Decoded (decompressed) bytes received from the server so far. */
62
+ span_bytes = 0;
63
+ /** Rows decoded from the response stream so far. */
64
+ span_rows = 0;
65
+ span_rows_counted = false;
66
+ span_finished = false;
67
+ query_id;
68
+ constructor(_stream, format, query_id, log_error, _response_headers, jsonHandling, span) {
60
69
  this._stream = _stream;
61
70
  this.format = format;
62
71
  this.query_id = query_id;
72
+ this.span = span;
63
73
  this.jsonHandling = {
64
74
  ...client_common_1.defaultJSONHandling,
65
75
  ...jsonHandling,
@@ -78,9 +88,45 @@ class ResultSet {
78
88
  this._consumed = true;
79
89
  return this._stream;
80
90
  }
91
+ /** Add the number of rows decoded from the response stream. */
92
+ addSpanRows(count) {
93
+ this.span_rows_counted = true;
94
+ this.span_rows += count;
95
+ }
96
+ /** Record the final response metrics (`clickhouse.response.decoded_bytes`
97
+ * and, when rows were counted, `db.response.returned_rows`) and the error
98
+ * (if any) on the span, and end it. Safe to call multiple times - only
99
+ * the first call wins. */
100
+ finishSpan(err) {
101
+ if (!this.span || this.span_finished) {
102
+ return;
103
+ }
104
+ this.span_finished = true;
105
+ const attributes = {
106
+ "clickhouse.response.decoded_bytes": this.span_bytes,
107
+ };
108
+ if (this.span_rows_counted) {
109
+ attributes["db.response.returned_rows"] = this.span_rows;
110
+ }
111
+ this.span.setAttributes(attributes);
112
+ if (err) {
113
+ (0, client_common_1.recordSpanError)(this.span, err);
114
+ }
115
+ this.span.end();
116
+ }
81
117
  /** See {@link BaseResultSet.text}. */
82
118
  async text() {
83
- return await (0, utils_1.getAsText)(this.consume());
119
+ const stream = this.consume();
120
+ try {
121
+ const text = await (0, utils_1.getAsText)(stream);
122
+ this.span_bytes += buffer_1.Buffer.byteLength(text);
123
+ this.finishSpan();
124
+ return text;
125
+ }
126
+ catch (err) {
127
+ this.finishSpan(err);
128
+ throw err;
129
+ }
84
130
  }
85
131
  /** See {@link BaseResultSet.json}. */
86
132
  async json() {
@@ -89,6 +135,7 @@ class ResultSet {
89
135
  const result = [];
90
136
  // Using the stream() instead of _stream directly to leverage the existing logic
91
137
  // for handling incomplete chunks and exception tags.
138
+ // The span progress is updated and the span is finished by the stream() pipeline.
92
139
  // TODO: consider using stream() for all formats to unify the logic and error handling.
93
140
  const stream = this.stream();
94
141
  for await (const rows of stream) {
@@ -100,8 +147,17 @@ class ResultSet {
100
147
  }
101
148
  // JSON, JSONObjectEachRow, etc.
102
149
  if ((0, client_common_2.isNotStreamableJSONFamily)(this.format)) {
103
- const text = await (0, utils_1.getAsText)(this.consume());
104
- return this.jsonHandling.parse(text);
150
+ const stream = this.consume();
151
+ try {
152
+ const text = await (0, utils_1.getAsText)(stream);
153
+ this.span_bytes += buffer_1.Buffer.byteLength(text);
154
+ this.finishSpan();
155
+ return this.jsonHandling.parse(text);
156
+ }
157
+ catch (err) {
158
+ this.finishSpan(err);
159
+ throw err;
160
+ }
105
161
  }
106
162
  // should not be called for CSV, etc.
107
163
  throw new Error(`Cannot decode ${this.format} as JSON`);
@@ -113,8 +169,11 @@ class ResultSet {
113
169
  const logError = this.log_error;
114
170
  const exceptionTag = this.exceptionTag;
115
171
  const jsonHandling = this.jsonHandling;
172
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
173
+ const resultSet = this;
116
174
  const toRows = new stream_1.Transform({
117
175
  transform(chunk, _encoding, callback) {
176
+ resultSet.span_bytes += chunk.length;
118
177
  const rows = [];
119
178
  let lastIdx = 0;
120
179
  let currentChunkPart;
@@ -125,6 +184,7 @@ class ResultSet {
125
184
  if (idx === -1) {
126
185
  incompleteChunks.push(chunk.subarray(lastIdx));
127
186
  if (rows.length > 0) {
187
+ resultSet.addSpanRows(rows.length);
128
188
  this.push(rows);
129
189
  }
130
190
  break;
@@ -163,16 +223,26 @@ class ResultSet {
163
223
  });
164
224
  const pipeline = stream_1.default.pipeline(this.consume(), toRows, function pipelineCb(err) {
165
225
  if (err &&
166
- err.name !== 'AbortError' &&
226
+ err.name !== "AbortError" &&
167
227
  err.message !== resultSetClosedMessage) {
168
228
  logError(err);
229
+ resultSet.finishSpan(err);
230
+ }
231
+ else {
232
+ resultSet.finishSpan();
169
233
  }
170
234
  });
171
235
  return pipeline;
172
236
  }
173
237
  /** See {@link BaseResultSet.close}. */
174
238
  close() {
239
+ // NB: _consumed is intentionally NOT set here. The stream is destroyed
240
+ // (not read to completion), so marking it as "consumed" would produce the
241
+ // misleading "Stream has been already consumed" error on any subsequent
242
+ // call. Downstream code will instead receive a "ResultSet has been closed"
243
+ // error from the destroyed stream, which accurately describes what happened.
175
244
  this._stream.destroy(new Error(resultSetClosedMessage));
245
+ this.finishSpan();
176
246
  }
177
247
  /**
178
248
  * Closes the `ResultSet`.
@@ -184,11 +254,11 @@ class ResultSet {
184
254
  [Symbol.dispose]() {
185
255
  this.close();
186
256
  }
187
- static instance({ stream, format, query_id, log_error, response_headers, jsonHandling, }) {
188
- return new ResultSet(stream, format, query_id, log_error, response_headers, jsonHandling);
257
+ static instance({ stream, format, query_id, log_error, response_headers, jsonHandling, span, }) {
258
+ return new ResultSet(stream, format, query_id, log_error, response_headers, jsonHandling, span);
189
259
  }
190
260
  }
191
261
  exports.ResultSet = ResultSet;
192
- const streamAlreadyConsumedMessage = 'Stream has been already consumed';
193
- const resultSetClosedMessage = 'ResultSet has been closed';
262
+ const streamAlreadyConsumedMessage = "Stream has been already consumed";
263
+ const resultSetClosedMessage = "ResultSet has been closed";
194
264
  //# sourceMappingURL=result_set.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"result_set.js","sourceRoot":"","sources":["../src/result_set.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,6DAKkC;AAClC,6DAIkC;AAClC,mCAA+B;AAE/B,iDAA0C;AAC1C,mCAAmC;AAEnC,MAAM,OAAO,GAAG,IAAa,CAAA;AAoC7B,MAAa,SAAS;IAiBV;IACS;IACD;IAhBF,gBAAgB,GAAoB,EAAE,CAAA;IAErC,YAAY,GAAuB,SAAS,CAAA;IAC5C,SAAS,CAAwB;IACjC,YAAY,CAAc;IACnC,SAAS,GAAG,KAAK,CAAA;IAEzB;IACE;;;;;OAKG;IACK,OAAwB,EACf,MAAc,EACf,QAAgB,EAChC,SAAkC,EAClC,iBAAmC,EACnC,YAA2B;QALnB,YAAO,GAAP,OAAO,CAAiB;QACf,WAAM,GAAN,MAAM,CAAQ;QACf,aAAQ,GAAR,QA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M,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,MAAM,CAAC,QAAQ,CAA4B,EACzC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,IAAI,GACqB;QACzB,OAAO,IAAI,SAAS,CAClB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AA9QD,8BA8QC;AAED,MAAM,4BAA4B,GAAG,kCAAkC,CAAC;AACxE,MAAM,sBAAsB,GAAG,2BAA2B,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { DataFormat, InsertValues, JSONHandling, ValuesEncoder } from '@clickhouse/client-common';
2
- import Stream from 'stream';
1
+ import type { DataFormat, InsertValues, JSONHandling, ValuesEncoder } from "@clickhouse/client-common";
2
+ import Stream from "stream";
3
3
  export declare class NodeValuesEncoder implements ValuesEncoder<Stream.Readable> {
4
4
  private readonly json;
5
5
  constructor(customJSONConfig: JSONHandling);
@@ -25,10 +25,10 @@ class NodeValuesEncoder {
25
25
  if (Array.isArray(values)) {
26
26
  return values
27
27
  .map((value) => (0, client_common_1.encodeJSON)(value, format, this.json.stringify))
28
- .join('');
28
+ .join("");
29
29
  }
30
30
  // JSON & JSONObjectEachRow format input
31
- if (typeof values === 'object') {
31
+ if (typeof values === "object") {
32
32
  return (0, client_common_1.encodeJSON)(values, format, this.json.stringify);
33
33
  }
34
34
  throw new Error(`Cannot encode values of type ${typeof values} with ${format} format`);
@@ -36,7 +36,7 @@ class NodeValuesEncoder {
36
36
  validateInsertValues(values, format) {
37
37
  if (!Array.isArray(values) &&
38
38
  !(0, stream_2.isStream)(values) &&
39
- typeof values !== 'object') {
39
+ typeof values !== "object") {
40
40
  throw new Error('Insert expected "values" to be an array, a stream of values or a JSON object, ' +
41
41
  `got: ${typeof values}`);
42
42
  }
@@ -1 +1 @@
1
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AAM,IAAI,KAAK,CACb,cAAc,MAAM,sDAAsD,CAC3E,CAAC;gBACJ,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,qDAAqD,CAC1E,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAnED,8CAmEC;AAED,SAAS,UAAU,CAAC,GAAiC;IACnD,IAAI,GAAG,EAAE,CAAC;QACR,4BAA4B;QAC5B,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- export * from './stream';
2
- export * from './encoder';
3
- export * from './process';
4
- export * from './user_agent';
1
+ export * from "./stream";
2
+ export * from "./encoder";
3
+ export * from "./process";
4
+ export * from "./user_agent";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,4CAAyB;AACzB,4CAAyB;AACzB,+CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";;AACA,8CAEC;AAHD,gCAAgC;AAChC,SAAgB,iBAAiB;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAA;AACxB,CAAC"}
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";;AACA,8CAEC;AAHD,gCAAgC;AAChC,SAAgB,iBAAiB;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAC;AACzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6B;AAC7B,yDAAuC;AAEvC,iGAAiG;AACjG,kEAAkE;AAClE,MAAa,OAAO;IAClB,MAAM,CAAC,OAAO,GAAG,iBAAc,CAAA;IAC/B,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAA;IAC7B,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;;AAH3B,0BAIC"}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,yDAAwC;AAExC,iGAAiG;AACjG,kEAAkE;AAClE,MAAa,OAAO;IAClB,MAAM,CAAC,OAAO,GAAG,iBAAc,CAAC;IAChC,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;;AAH5B,0BAIC"}
@@ -1,4 +1,4 @@
1
- import Stream from 'stream';
1
+ import Stream from "stream";
2
2
  export declare function isStream(obj: unknown): obj is Stream.Readable;
3
3
  export declare function getAsText(stream: Stream.Readable): Promise<string>;
4
4
  export declare function mapStream(mapper: (input: unknown) => string): Stream.Transform;
@@ -10,16 +10,16 @@ const stream_1 = __importDefault(require("stream"));
10
10
  const buffer_1 = require("buffer");
11
11
  const { MAX_STRING_LENGTH } = buffer_1.constants;
12
12
  function isStream(obj) {
13
- return (typeof obj === 'object' &&
13
+ return (typeof obj === "object" &&
14
14
  obj !== null &&
15
- 'pipe' in obj &&
16
- typeof obj.pipe === 'function' &&
17
- 'on' in obj &&
18
- typeof obj.on === 'function');
15
+ "pipe" in obj &&
16
+ typeof obj.pipe === "function" &&
17
+ "on" in obj &&
18
+ typeof obj.on === "function");
19
19
  }
20
20
  async function getAsText(stream) {
21
21
  try {
22
- let text = '';
22
+ let text = "";
23
23
  const textDecoder = new TextDecoder();
24
24
  for await (const chunk of stream) {
25
25
  text += textDecoder.decode(chunk, { stream: true });
@@ -33,8 +33,8 @@ async function getAsText(stream) {
33
33
  // string grows past MAX_STRING_LENGTH; JavaScriptCore (Bun) throws a
34
34
  // RangeError with "Out of memory" in the same situation.
35
35
  if (err instanceof RangeError &&
36
- (err.message.includes('Invalid string length') ||
37
- err.message.includes('Out of memory'))) {
36
+ (err.message.includes("Invalid string length") ||
37
+ err.message.includes("Out of memory"))) {
38
38
  throw new Error(`The response length exceeds the maximum allowed size of a string: ${MAX_STRING_LENGTH} characters.`, { cause: err });
39
39
  }
40
40
  throw err;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;;;;AAKA,4BASC;AAED,8BA6BC;AAED,8BASC;AAxDD,oDAA2B;AAC3B,mCAAkC;AAElC,MAAM,EAAE,iBAAiB,EAAE,GAAG,kBAAS,CAAA;AAEvC,SAAgB,QAAQ,CAAC,GAAY;IACnC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,MAAM,IAAI,GAAG;QACb,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU;QAC9B,IAAI,IAAI,GAAG;QACX,OAAO,GAAG,CAAC,EAAE,KAAK,UAAU,CAC7B,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,SAAS,CAAC,MAAuB;IACrD,IAAI,CAAC;QACH,IAAI,IAAI,GAAG,EAAE,CAAA;QAEb,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAA;QACrC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAA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B,GAAG,iBAAiB,iBAAO,CAAC,OAAO,eACvD,iBAAO,CAAC,IACV,QAAQ,iBAAO,CAAC,EAAE,GAAG,CAAA;IACrB,OAAO,cAAc;QACnB,CAAC,CAAC,GAAG,cAAc,IAAI,gBAAgB,EAAE;QACzC,CAAC,CAAC,gBAAgB,CAAA;AACtB,CAAC"}
1
+ {"version":3,"file":"user_agent.js","sourceRoot":"","sources":["../../src/utils/user_agent.ts"],"names":[],"mappings":";;AAYA,oCAOC;AAnBD,uCAAoC;AAEpC;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAC,cAAuB;IAClD,MAAM,gBAAgB,GAAG,iBAAiB,iBAAO,CAAC,OAAO,eACvD,iBAAO,CAAC,IACV,QAAQ,iBAAO,CAAC,EAAE,GAAG,CAAC;IACtB,OAAO,cAAc;QACnB,CAAC,CAAC,GAAG,cAAc,IAAI,gBAAgB,EAAE;QACzC,CAAC,CAAC,gBAAgB,CAAC;AACvB,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.20.0";
1
+ declare const _default: "1.21.0";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.20.0';
3
+ exports.default = "1.21.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@clickhouse/client",
3
3
  "description": "Official JS client for ClickHouse DB - Node.js implementation",
4
4
  "homepage": "https://clickhouse.com",
5
- "version": "1.20.0",
5
+ "version": "1.21.0",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "clickhouse",
@@ -44,7 +44,7 @@
44
44
  "build": "rm -rf dist; tsc"
45
45
  },
46
46
  "dependencies": {
47
- "@clickhouse/client-common": "1.20.0"
47
+ "@clickhouse/client-common": "1.21.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "simdjson": "^0.9.2"
@@ -17,7 +17,7 @@
17
17
  Enable on the client level or per-request via `clickhouse_settings`:
18
18
 
19
19
  ```ts
20
- import { createClient, ClickHouseError } from '@clickhouse/client'
20
+ import { createClient, ClickHouseError } from "@clickhouse/client";
21
21
 
22
22
  const client = createClient({
23
23
  url: process.env.CLICKHOUSE_URL,
@@ -26,10 +26,10 @@ const client = createClient({
26
26
  clickhouse_settings: {
27
27
  async_insert: 1,
28
28
  wait_for_async_insert: 1, // wait for ack from server
29
- async_insert_max_data_size: '1000000',
29
+ async_insert_max_data_size: "1000000",
30
30
  async_insert_busy_timeout_ms: 1000,
31
31
  },
32
- })
32
+ });
33
33
  ```
34
34
 
35
35
  ## Concurrent small inserts
@@ -42,21 +42,21 @@ const promises = [...new Array(10)].map(async () => {
42
42
  const values = [...new Array(1000).keys()].map(() => ({
43
43
  id: Math.floor(Math.random() * 100_000) + 1,
44
44
  data: Math.random().toString(36).slice(2),
45
- }))
45
+ }));
46
46
 
47
47
  await client
48
- .insert({ table: 'async_insert_example', values, format: 'JSONEachRow' })
48
+ .insert({ table: "async_insert_example", values, format: "JSONEachRow" })
49
49
  .catch((err) => {
50
50
  if (err instanceof ClickHouseError) {
51
51
  // err.code matches a row in system.errors
52
- console.error(`ClickHouse error ${err.code}:`, err)
53
- return
52
+ console.error(`ClickHouse error ${err.code}:`, err);
53
+ return;
54
54
  }
55
- console.error('Insert failed:', err)
56
- })
57
- })
55
+ console.error("Insert failed:", err);
56
+ });
57
+ });
58
58
 
59
- await Promise.all(promises)
59
+ await Promise.all(promises);
60
60
  ```
61
61
 
62
62
  ## `wait_for_async_insert` — fire-and-forget vs ack
@@ -82,7 +82,7 @@ await client.command({
82
82
  ENGINE MergeTree ORDER BY id
83
83
  `,
84
84
  clickhouse_settings: { wait_end_of_query: 1 },
85
- })
85
+ });
86
86
  ```
87
87
 
88
88
  Even better is to create a specialized client for inserts with the appropriate async