Closed movy closed 11 months ago
SET
and other session-level commands should work if you provide the session id to the client.
void (async () => {
const client = createClient({
session_id: crypto.randomUUID(),
})
for (const setting in [0, 1]) {
await client.command({
query: `SET output_format_json_quote_64bit_integers = ${setting}`,
clickhouse_settings: { wait_end_of_query: 1 }
})
const rows = await client.query({
query: `SELECT toInt64(${setting})`,
format: 'JSONEachRow'
})
console.log({ setting }, await rows.json())
}
await client.close()
})()
Prints:
{ setting: '0' } [ { 'toInt64(0)': 0 } ]
{ setting: '1' } [ { 'toInt64(1)': '1' } ]
Additionally, you can just use clickhouse_settings
for that:
void (async () => {
const client = createClient()
const rows1 = await client.query({
query: 'SELECT toInt64(0)',
format: 'JSONEachRow',
clickhouse_settings: {
output_format_json_quote_64bit_integers: 0,
}
})
console.log(await rows1.json())
const rows2 = await client.query({
query: 'SELECT toInt64(1)',
format: 'JSONEachRow',
clickhouse_settings: {
output_format_json_quote_64bit_integers: 1,
}
})
console.log(await rows2.json())
await client.close()
})()
yields the same
[ { 'toInt64(0)': 0 } ]
[ { 'toInt64(1)': '1' } ]
@movy, added an example based on your code: https://github.com/ClickHouse/clickhouse-js/blob/main/examples/session_level_commands.ts
Describe the bug
I am trying to change
output_format_json_quote_64bit_integers
viaSET
command and cannot get client to respect new setting: regardless of the setting, Int64 values are always quotedCode example
Output:
Environment
0.2.2
v20.5.1
Ubuntu 22.02
ClickHouse server
23.7.1.2470