The 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).
A very minimal example with CSV (from the tests, it does not make sense as CSV is supported via the normal insert, just an illustration):
const stream = Stream.Readable.from(['42,foobar,"[1,2]"'], {
objectMode: false,
})
const execResult = await client.exec({
query: `INSERT INTO ${tableName} FORMAT CSV`,
values: stream,
})
// the result stream contains nothing useful for an insert
// and should be immediately drained to release the socket
await drainStream(execResult.stream)
const rs = await client.query({
query: `SELECT * FROM ${tableName}`,
format: 'JSONEachRow',
})
expect(await rs.json()).toEqual([
{
id: '42',
name: 'foobar',
sku: [1, 2],
},
])
Checklist
[x] Unit and integration tests covering the common scenarios were added
[x] A human-readable description of the changes was provided to include in CHANGELOG
Summary
The
exec
method now accepts an optionalvalues
parameter, which allows you to pass the request body as aStream.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 theinsert
method yet).A very minimal example with CSV (from the tests, it does not make sense as CSV is supported via the normal
insert
, just an illustration):Checklist