-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createClient } from '@clickhouse/client' // or '@clickhouse/client-web' | ||
import * as crypto from 'crypto' // required for Node.js only | ||
|
||
void (async () => { | ||
const client = createClient({ | ||
// with session_id defined, SET and other session commands | ||
// will affect all the consecutive queries | ||
session_id: crypto.randomUUID(), | ||
}) | ||
|
||
await client.command({ | ||
query: `SET output_format_json_quote_64bit_integers = 0`, | ||
clickhouse_settings: { wait_end_of_query: 1 }, | ||
}) | ||
|
||
// this query uses output_format_json_quote_64bit_integers = 0 | ||
const rows1 = await client.query({ | ||
query: `SELECT toInt64(42)`, | ||
format: 'JSONEachRow', | ||
}) | ||
console.log(await rows1.json()) | ||
|
||
await client.command({ | ||
query: `SET output_format_json_quote_64bit_integers = 1`, | ||
clickhouse_settings: { wait_end_of_query: 1 }, | ||
}) | ||
|
||
// this query uses output_format_json_quote_64bit_integers = 1 | ||
const rows2 = await client.query({ | ||
query: `SELECT toInt64(144)`, | ||
format: 'JSONEachRow', | ||
}) | ||
console.log(await rows2.json()) | ||
|
||
await client.close() | ||
})() |