From ad2d6c505f8004ea32398cab98ec98af6bb2ae26 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 4 Feb 2021 12:01:34 +0100 Subject: [PATCH 1/4] Use driver @posthog/clickhouse instead of clickhouse --- package.json | 2 +- src/db.ts | 27 +++++----- src/ingestion/process-event.ts | 2 +- src/server.ts | 16 +++--- src/types.ts | 2 +- tests/helpers/clickhouse.ts | 6 +-- yarn.lock | 99 ++++------------------------------ 7 files changed, 39 insertions(+), 115 deletions(-) diff --git a/package.json b/package.json index f3d6d735..2e1aa6ad 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ "license": "MIT", "dependencies": { "@google-cloud/bigquery": "^5.5.0", + "@posthog/clickhouse": "^1.7.0", "@sentry/node": "^5.29.0", "@sentry/tracing": "^5.29.0", "adm-zip": "^0.4.16", - "clickhouse": "^2.2.1", "fastify": "^3.8.0", "hot-shots": "^8.2.1", "ioredis": "^4.19.2", diff --git a/src/db.ts b/src/db.ts index 98f635dc..88a9f755 100644 --- a/src/db.ts +++ b/src/db.ts @@ -1,9 +1,8 @@ import { Properties } from '@posthog/plugin-scaffold' -import { ClickHouse, QueryCursor } from 'clickhouse' +import ClickHouse from '@posthog/clickhouse' import { Producer } from 'kafkajs' import { DateTime } from 'luxon' import { Pool, QueryConfig, QueryResult, QueryResultRow } from 'pg' -import { string } from 'yargs' import { KAFKA_PERSON, KAFKA_PERSON_UNIQUE_ID } from './ingestion/topics' import { chainToElements, hashElements, unparsePersonPartial } from './ingestion/utils' import { @@ -41,14 +40,17 @@ export class DB { queryTextOrConfig: string | QueryConfig, values?: I ): Promise> { - return this.postgres.query(queryTextOrConfig, values) + return await this.postgres.query(queryTextOrConfig, values) } - public async clickhouseQuery(query: string, reqParams?: Record): Promise> { + public async clickhouseQuery( + query: string, + options?: ClickHouse.QueryOptions + ): Promise>> { if (!this.clickhouse) { throw new Error('ClickHouse connection has not been provided to this DB instance!') } - return this.clickhouse.query(query, reqParams).toPromise() + return await this.clickhouse.querying(query, options) } // Person @@ -205,7 +207,7 @@ export class DB { public async fetchEvents(): Promise { if (this.kafkaProducer) { - const events = (await this.clickhouseQuery(`SELECT * FROM events`)) as ClickHouseEvent[] + const events = (await this.clickhouseQuery(`SELECT * FROM events`)).data as ClickHouseEvent[] return ( events?.map( (event) => @@ -228,9 +230,8 @@ export class DB { public async fetchSessionRecordingEvents(): Promise { if (this.kafkaProducer) { - const events = ((await this.clickhouseQuery( - `SELECT * FROM session_recording_events` - )) as SessionRecordingEvent[]).map((event) => { + const events = ((await this.clickhouseQuery(`SELECT * FROM session_recording_events`)) + .data as SessionRecordingEvent[]).map((event) => { return { ...event, snapshot_data: event.snapshot_data ? JSON.parse(event.snapshot_data) : null, @@ -247,9 +248,11 @@ export class DB { public async fetchElements(event?: Event): Promise { if (this.kafkaProducer) { - const events = (await this.clickhouseQuery( - `SELECT elements_chain FROM events WHERE uuid='${sanitizeSqlIdentifier((event as any).uuid)}'` - )) as ClickHouseEvent[] + const events = ( + await this.clickhouseQuery( + `SELECT elements_chain FROM events WHERE uuid='${sanitizeSqlIdentifier((event as any).uuid)}'` + ) + ).data as ClickHouseEvent[] const chain = events?.[0]?.elements_chain return chainToElements(chain) } else { diff --git a/src/ingestion/process-event.ts b/src/ingestion/process-event.ts index 304fd9d2..13c83576 100644 --- a/src/ingestion/process-event.ts +++ b/src/ingestion/process-event.ts @@ -16,7 +16,7 @@ import { Event as EventProto, IEvent } from '../idl/protos' import { Producer } from 'kafkajs' import { KAFKA_EVENTS, KAFKA_SESSION_RECORDING_EVENTS } from './topics' import { elementsToString, sanitizeEventName } from './utils' -import { ClickHouse } from 'clickhouse' +import ClickHouse from '@posthog/clickhouse' import { DB } from '../db' import { status } from '../status' import * as Sentry from '@sentry/node' diff --git a/src/server.ts b/src/server.ts index 9442ce31..5f7d831b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5,7 +5,7 @@ import { Kafka, logLevel, Producer } from 'kafkajs' import { FastifyInstance } from 'fastify' import { PluginsServer, PluginsServerConfig, Queue } from './types' import { startQueue } from './worker/queue' -import { ClickHouse } from 'clickhouse' +import ClickHouse from '@posthog/clickhouse' import { startFastifyInstance, stopFastifyInstance } from './web/server' import { version } from '../package.json' import { PluginEvent } from '@posthog/plugin-scaffold' @@ -20,6 +20,7 @@ import { startSchedule } from './services/schedule' import { ConnectionOptions } from 'tls' import { DB } from './db' import { DateTime } from 'luxon' +import * as fs from 'fs' import { KAFKA_EVENTS_INGESTION_HANDOFF, KAFKA_EVENTS_WAL } from './ingestion/topics' export async function createServer( @@ -71,15 +72,16 @@ export async function createServer( throw new Error('You must set KAFKA_HOSTS to process events from Kafka!') } clickhouse = new ClickHouse({ - url: `http${serverConfig.CLICKHOUSE_SECURE ? 's' : ''}://$${serverConfig.CLICKHOUSE_HOST}`, + host: serverConfig.CLICKHOUSE_HOST, port: serverConfig.CLICKHOUSE_SECURE ? 8443 : 8123, - basicAuth: { - username: serverConfig.CLICKHOUSE_USER, - password: serverConfig.CLICKHOUSE_PASSWORD, - }, - config: { + protocol: serverConfig.CLICKHOUSE_SECURE ? 'https:' : 'http:', + user: serverConfig.CLICKHOUSE_USER, + password: serverConfig.CLICKHOUSE_PASSWORD || undefined, + format: 'JSON', + queryOptions: { database: serverConfig.CLICKHOUSE_DATABASE, }, + ca: serverConfig.CLICKHOUSE_CA ? fs.readFileSync(serverConfig.CLICKHOUSE_CA).toString() : undefined, }) await clickhouse.query('SELECT 1') // test that the connection works diff --git a/src/types.ts b/src/types.ts index 5e644da9..7caf4f9d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,7 +6,7 @@ import { VM } from 'vm2' import { DateTime } from 'luxon' import { StatsD } from 'hot-shots' import { EventsProcessor } from 'ingestion/process-event' -import { ClickHouse } from 'clickhouse' +import ClickHouse from '@posthog/clickhouse' import { DB } from './db' export enum LogLevel { diff --git a/tests/helpers/clickhouse.ts b/tests/helpers/clickhouse.ts index 9a006dd2..caf1e37d 100644 --- a/tests/helpers/clickhouse.ts +++ b/tests/helpers/clickhouse.ts @@ -1,13 +1,13 @@ import { defaultConfig } from '../../src/config' -import { ClickHouse } from 'clickhouse' +import ClickHouse from '@posthog/clickhouse' import { PluginsServerConfig } from '../../src/types' export async function resetTestDatabaseClickhouse(extraServerConfig: Partial): Promise { const config = { ...defaultConfig, ...extraServerConfig } const clickhouse = new ClickHouse({ - url: `http://$${config.CLICKHOUSE_HOST}`, + host: config.CLICKHOUSE_HOST, port: 8123, - config: { + queryOptions: { database: config.CLICKHOUSE_DATABASE, }, }) diff --git a/yarn.lock b/yarn.lock index a5470402..6e0c2e38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1179,6 +1179,11 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" +"@posthog/clickhouse@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@posthog/clickhouse/-/clickhouse-1.7.0.tgz#21fa1e8cfa0637b688f91964e0efeedbf4cf7a3c" + integrity sha512-B8hZ8Dh2EoJoDb7Gx38ylBQM92oON/X2IxXCb7BfYStk3m17nStcAyaCsc2zbvxC0fFfTMU8lFRiFSEJmijkyg== + "@posthog/plugin-scaffold@0.2.8": version "0.2.8" resolved "https://registry.yarnpkg.com/@posthog/plugin-scaffold/-/plugin-scaffold-0.2.8.tgz#14ee85afa9a91625bbae4e223ce03d215a22e8d7" @@ -1620,14 +1625,6 @@ "@typescript-eslint/types" "4.14.0" eslint-visitor-keys "^2.0.0" -JSONStream@1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.4.tgz#615bb2adb0cd34c8f4c447b5f6512fa1d8f16a2e" - integrity sha512-Y7vfi3I5oMOYIr+WxV8NZxDSwcbNgzdKYsTNInmycOq9bUYwGg9ryu57Wg5NLmCjqdFPNUmpMBo3kSJN9tCbXg== - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - abab@^2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a" @@ -2289,20 +2286,6 @@ cli-truncate@^2.1.0: slice-ansi "^3.0.0" string-width "^4.2.0" -clickhouse@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/clickhouse/-/clickhouse-2.2.1.tgz#dc7c6c24a54a829ed2e7c4d5495852afe15ded1e" - integrity sha512-NcqKA1Uc353QKs1MepTSZZrv3gF4v5ScoobAoDxcC+37VKV1QusG/hkaZHTupJ28oppuRFpdWKSIoN54qkD2vg== - dependencies: - JSONStream "1.3.4" - lodash "4.17.19" - querystring "0.2.0" - request "2.88.0" - stream2asynciter "1.0.1" - through "2.3.8" - tsv "0.2.0" - uuid "3.4.0" - cliui@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1" @@ -3671,7 +3654,7 @@ har-schema@^2.0.0: resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= -har-validator@~5.1.0, har-validator@~5.1.3: +har-validator@~5.1.3: version "5.1.5" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== @@ -4733,11 +4716,6 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= - jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -4935,11 +4913,6 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= -lodash@4.17.19: - version "4.17.19" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" - integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== - lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" @@ -5884,7 +5857,7 @@ proxy-addr@^2.0.5: forwarded "~0.1.2" ipaddr.js "1.9.1" -psl@^1.1.24, psl@^1.1.28: +psl@^1.1.28: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== @@ -5897,11 +5870,6 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" -punycode@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= - punycode@^2.1.0, punycode@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" @@ -5917,11 +5885,6 @@ qs@~6.5.2: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= - queue-microtask@^1.1.2: version "1.2.2" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.2.tgz#abf64491e6ecf0f38a6502403d4cda04f372dfd3" @@ -6177,32 +6140,6 @@ request-promise-native@^1.0.8: stealthy-require "^1.1.1" tough-cookie "^2.3.3" -request@2.88.0: - version "2.88.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" - integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.0" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.4.3" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - request@^2.88.2: version "2.88.2" resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" @@ -6712,11 +6649,6 @@ stream-shift@^1.0.0: resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== -stream2asynciter@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/stream2asynciter/-/stream2asynciter-1.0.1.tgz#9f35c8fff36d89c02030b72e36702b61b6224d10" - integrity sha512-HseDrFlR3YhQEnZ4MAoQmW8poOkUeVfRiuv6t3+Wwb2ehNs4SSgzENcZoYEQdCgp/OFkt1IL2DpyvG9VctQXjg== - string-argv@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" @@ -6963,7 +6895,7 @@ throat@^5.0.0: resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA== -through@2.3.8, "through@>=2.2.7 <3", through@^2.3.8: +through@^2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -7039,14 +6971,6 @@ tough-cookie@^3.0.1: psl "^1.1.28" punycode "^2.1.1" -tough-cookie@~2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" - integrity sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ== - dependencies: - psl "^1.1.24" - punycode "^1.4.1" - tr46@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479" @@ -7142,11 +7066,6 @@ tsutils@^3.17.1: dependencies: tslib "^1.8.1" -tsv@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/tsv/-/tsv-0.2.0.tgz#92869a3cb5f50332f3dc90fca82be667db6f72d6" - integrity sha1-koaaPLX1AzLz3JD8qCvmZ9tvctY= - tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -7291,7 +7210,7 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= -uuid@3.4.0, uuid@^3.3.2: +uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== From 76e4c0b9c25752cc6295dd1a982a243259af836e Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 4 Feb 2021 12:45:01 +0100 Subject: [PATCH 2/4] Update CH querying --- src/server.ts | 2 +- tests/helpers/clickhouse.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/server.ts b/src/server.ts index 5f7d831b..083ef1e9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -83,7 +83,7 @@ export async function createServer( }, ca: serverConfig.CLICKHOUSE_CA ? fs.readFileSync(serverConfig.CLICKHOUSE_CA).toString() : undefined, }) - await clickhouse.query('SELECT 1') // test that the connection works + await clickhouse.querying('SELECT 1') // test that the connection works if (!serverConfig.KAFKA_CONSUMPTION_TOPIC) { // When ingesting events, listen to the "INGESTION_HANDOFF" topic, otherwise listen to the "WAL" and discard diff --git a/tests/helpers/clickhouse.ts b/tests/helpers/clickhouse.ts index caf1e37d..5ada34d6 100644 --- a/tests/helpers/clickhouse.ts +++ b/tests/helpers/clickhouse.ts @@ -11,12 +11,12 @@ export async function resetTestDatabaseClickhouse(extraServerConfig: Partial Date: Thu, 4 Feb 2021 13:36:47 +0100 Subject: [PATCH 3/4] Fix clickhouseQuery usage --- src/db.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/db.ts b/src/db.ts index c4fd07d6..f80abfa7 100644 --- a/src/db.ts +++ b/src/db.ts @@ -63,7 +63,7 @@ export class DB { public async fetchPersons(database: Database.ClickHouse): Promise public async fetchPersons(database: Database = Database.Postgres): Promise { if (database === Database.ClickHouse) { - return (await this.clickhouseQuery('SELECT * FROM person')) as ClickHousePerson[] + return (await this.clickhouseQuery('SELECT * FROM person')).data as ClickHousePerson[] } else if (database === Database.Postgres) { return ((await this.postgresQuery('SELECT * FROM posthog_person')).rows as RawPerson[]).map( (rawPerson: RawPerson) => @@ -188,11 +188,13 @@ export class DB { database: Database = Database.Postgres ): Promise { if (database === Database.ClickHouse) { - return (await this.clickhouseQuery( - `SELECT * FROM person_distinct_id WHERE person_id='${escapeClickHouseString( - person.uuid - )}' and team_id='${person.team_id}' ORDER BY id` - )) as ClickHousePersonDistinctId[] + return ( + await this.clickhouseQuery( + `SELECT * FROM person_distinct_id WHERE person_id='${escapeClickHouseString( + person.uuid + )}' and team_id='${person.team_id}' ORDER BY id` + ) + ).data as ClickHousePersonDistinctId[] } else if (database === Database.Postgres) { const result = await this.postgresQuery( 'SELECT * FROM posthog_persondistinctid WHERE person_id=$1 and team_id=$2 ORDER BY id', From 41f3fc5dd270adf715a0882933a2c7fd89064c24 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 4 Feb 2021 14:19:30 +0100 Subject: [PATCH 4/4] Don't quote 64-bit ints in JSON from CH --- src/server.ts | 3 ++- tests/helpers/clickhouse.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index 083ef1e9..0fe1eb80 100644 --- a/src/server.ts +++ b/src/server.ts @@ -77,9 +77,10 @@ export async function createServer( protocol: serverConfig.CLICKHOUSE_SECURE ? 'https:' : 'http:', user: serverConfig.CLICKHOUSE_USER, password: serverConfig.CLICKHOUSE_PASSWORD || undefined, - format: 'JSON', + dataObjects: true, queryOptions: { database: serverConfig.CLICKHOUSE_DATABASE, + output_format_json_quote_64bit_integers: false, }, ca: serverConfig.CLICKHOUSE_CA ? fs.readFileSync(serverConfig.CLICKHOUSE_CA).toString() : undefined, }) diff --git a/tests/helpers/clickhouse.ts b/tests/helpers/clickhouse.ts index 5ada34d6..caa09f22 100644 --- a/tests/helpers/clickhouse.ts +++ b/tests/helpers/clickhouse.ts @@ -7,8 +7,10 @@ export async function resetTestDatabaseClickhouse(extraServerConfig: Partial