@clickhouse/client-common
Advanced tools
Changelog
1.6.0 (Common, Node.js, Web)
real_time_microseconds
field to the ClickHouseSummary
interface (see https://github.com/ClickHouse/ClickHouse/pull/69032)ResultSet.json
if the response data was not in fact a valid JSON. (#311)Changelog
1.4.1 (Node.js, Web)
ClickHouseClient
is now exported as a value from @clickhouse/client
and @clickhouse/client-web
packages, allowing for better integration in dependency injection frameworks that rely on IoC (e.g., Nest.js, tsyringe) (@mathieu-bour, #292).Changelog
1.4.0 (Node.js)
exec
method now accepts an optional values
parameter, which allows you to pass the request body as a Stream.Readable
. This can be useful in case of custom insert streaming with arbitrary ClickHouse data formats (which might not be explicitly supported and allowed by the client in the insert
method yet). NB: in this case, you are expected to serialize the data in the stream in the required input format yourself.Changelog
1.3.0 (Common, Node.js, Web)
It is now possible to get the entire response headers object from the query
/insert
/command
/exec
methods. With query
, you can access the ResultSet.response_headers
property; other methods (insert
/command
/exec
) return it as parts of their response objects as well.
For example:
const rs = await client.query({
query: 'SELECT * FROM system.numbers LIMIT 1',
format: 'JSONEachRow',
})
console.log(rs.response_headers['content-type'])
This will print: application/x-ndjson; charset=UTF-8
. It can be used in a similar way with the other methods.
Re-exported several constants from the @clickhouse/client-common
package for convenience:
SupportedJSONFormats
SupportedRawFormats
StreamableFormats
StreamableJSONFormats
SingleDocumentJSONFormats
RecordsJSONFormats
Changelog
1.2.0 (Node.js)
(Experimental) Added an option to provide a custom HTTP Agent in the client configuration via the http_agent
option (#283, related: #278). The following conditions apply if a custom HTTP Agent is provided:
max_open_connections
and tls
options will have no effect and will be ignored by the client, as it is a part of the underlying HTTP Agent configuration.keep_alive.enabled
will only regulate the default value of the Connection
header (true
-> Connection: keep-alive
, false
-> Connection: close
).keep_alive.idle_socket_ttl
value to 0
.(Experimental) Added a new client configuration option: set_basic_auth_header
, which disables the Authorization
header that is set by the client by default for every outgoing HTTP request. One of the possible scenarios when it is necessary to disable this header is when a custom HTTPS agent is used, and the server requires TLS authorization. For example:
const agent = new https.Agent({
ca: fs.readFileSync('./ca.crt'),
})
const client = createClient({
url: 'https://server.clickhouseconnect.test:8443',
http_agent: agent,
// With a custom HTTPS agent, the client won't use the default HTTPS connection implementation; the headers should be provided manually
http_headers: {
'X-ClickHouse-User': 'default',
'X-ClickHouse-Key': '',
},
// Authorization header conflicts with the TLS headers; disable it.
set_basic_auth_header: false,
})
NB: It is currently not possible to set the set_basic_auth_header
option via the URL params.
If you have feedback on these experimental features, please let us know by creating an issue in the repository.
Changelog
1.1.0 (Common, Node.js, Web)
query
/command
/exec
/insert
request via the BaseQueryParams.auth
setting; when set, the credentials will be taken from there instead of the username/password provided during the client instantiation (#278).session_id
for a particular query
/command
/exec
/insert
request via the BaseQueryParams.session_id
setting; when set, it will be used instead of the session id provided during the client instantiation (@holi0317, #271).ResponseJSON<T>.totals
TypeScript type. Now it correctly matches the shape of the data (T
, default = unknown
) instead of the former Record<string, number>
definition (#274).Changelog
1.0.2 (Common, Node.js, Web)
command
method now drains the response stream properly, as the previous implementation could cause the Keep-Alive
socket to close after each request.ResultSet.stream
method if the request was aborted or the result set was closed (#263).Changelog
1.0.0 (Common, Node.js, Web)
Formal stable release milestone with a lot of improvements and some breaking changes.
Major new features overview:
From now on, the client will follow the official semantic versioning guidelines.
The following configuration parameters are marked as deprecated:
host
configuration parameter is deprecated; use url
instead.additional_headers
configuration parameter is deprecated; use http_headers
instead.The client will log a warning if any of these parameters are used. However, it is still allowed to use host
instead of url
and additional_headers
instead of http_headers
for now; this deprecation is not supposed to break the existing code.
These parameters will be removed in the next major release (2.0.0).
See "New features" section for more details.