Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/clickhouse-client-forward-compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@hyperdx/common-utils": patch
"@hyperdx/cli": patch
---

Import ClickHouse client types from the platform packages
(`@clickhouse/client` / `@clickhouse/client-web`) instead of the deprecated
`@clickhouse/client-common`. This makes the packages forward-compatible with
`@clickhouse/client*` 1.23 (where `client-common` is deprecated and each
platform package bundles and re-exports its own copy of the shared types)
without bumping the pinned version. No runtime behavior changes.
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
"devDependencies": {
"@clickhouse/client": "^1.12.1",
"@clickhouse/client-common": "^1.12.1",
"@hyperdx/common-utils": "^0.20.0",
"@jest/globals": "^30.2.0",
"@types/crypto-js": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
BaseResultSet,
ClickHouseSettings,
DataFormat,
} from '@clickhouse/client-common';
} from '@clickhouse/client';

import {
BaseClickhouseClient,
Expand Down
2 changes: 1 addition & 1 deletion packages/common-utils/src/__tests__/clickhouse.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResponseJSON } from '@clickhouse/client-common';
import { ResponseJSON } from '@clickhouse/client';

import {
ChSql,
Expand Down
2 changes: 1 addition & 1 deletion packages/common-utils/src/__tests__/metadata.int.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createClient } from '@clickhouse/client';
import { ClickHouseClient } from '@clickhouse/client-common';
import { ClickHouseClient } from '@clickhouse/client';

import { ClickhouseClient as HdxClickhouseClient } from '@/clickhouse/node';
import { Metadata, MetadataCache } from '@/core/metadata';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createClient } from '@clickhouse/client';
import { ClickHouseClient } from '@clickhouse/client-common';
import { ClickHouseClient } from '@clickhouse/client';

import { ClickhouseClient as HdxClickhouseClient } from '@/clickhouse/node';
import { Metadata, MetadataCache } from '@/core/metadata';
Expand Down
16 changes: 13 additions & 3 deletions packages/common-utils/src/clickhouse/browser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {
BaseResultSet,
ClickHouseClient as WebClickHouseClient,
ClickHouseSettings,
DataFormat,
} from '@clickhouse/client-common';
} from '@clickhouse/client-web';
import { createClient } from '@clickhouse/client-web';

import {
Expand Down Expand Up @@ -72,6 +73,13 @@ export class ClickhouseClient extends BaseClickhouseClient {
super(options);
}

// This subclass always builds a web client, so narrow the base class's
// platform-agnostic client type to the web-specific one.
protected getClient(): WebClickHouseClient {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- subclass always builds a web client
return super.getClient() as WebClickHouseClient;
}

private buildClient() {
let url = this.host!;
let myFetch: typeof fetch;
Expand Down Expand Up @@ -125,10 +133,12 @@ export class ClickhouseClient extends BaseClickhouseClient {
let clickhouseSettings: ClickHouseSettings | undefined;
// If this is the settings query, we must not process the clickhouse settings, or else we will infinitely recurse
if (!shouldSkipApplySettings) {
clickhouseSettings = await this.processClickhouseSettings({
// The shared base class produces a platform-neutral settings object; the
// web client expects its own (now self-bundled) ClickHouseSettings type.
clickhouseSettings = (await this.processClickhouseSettings({
connectionId,
externalClickhouseSettings,
});
})) as ClickHouseSettings;
Comment on lines +138 to +141
}

const httpHeaders: { [header: string]: string } = {
Expand Down
18 changes: 14 additions & 4 deletions packages/common-utils/src/clickhouse/node.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createClient } from '@clickhouse/client';
import type {
BaseResultSet,
ClickHouseClient as NodeClickHouseClient,
ClickHouseSettings,
DataFormat,
} from '@clickhouse/client-common';
} from '@clickhouse/client';
import { createClient } from '@clickhouse/client';

import {
BaseClickhouseClient,
Expand All @@ -27,6 +28,13 @@ export class ClickhouseClient extends BaseClickhouseClient {
});
}

// This subclass always builds a node client, so narrow the base class's
// platform-agnostic client type to the node-specific one.
protected getClient(): NodeClickHouseClient {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- subclass always builds a node client
return super.getClient() as NodeClickHouseClient;
}

protected async __query<Format extends DataFormat>({
query,
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- default generic value
Expand All @@ -43,10 +51,12 @@ export class ClickhouseClient extends BaseClickhouseClient {
let clickhouseSettings: ClickHouseSettings | undefined;
// If this is the settings query, we must not process the clickhouse settings, or else we will infinitely recurse
if (!shouldSkipApplySettings) {
clickhouseSettings = await this.processClickhouseSettings({
// The shared base class produces a platform-neutral settings object; the
// node client expects its own (now self-bundled) ClickHouseSettings type.
clickhouseSettings = (await this.processClickhouseSettings({
externalClickhouseSettings,
connectionId,
});
})) as ClickHouseSettings;
Comment on lines +56 to +59
}

// TODO: Custom error handling
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4575,7 +4575,6 @@ __metadata:
resolution: "@hyperdx/cli@workspace:packages/cli"
dependencies:
"@clickhouse/client": "npm:^1.12.1"
"@clickhouse/client-common": "npm:^1.12.1"
"@hyperdx/common-utils": "npm:^0.20.0"
"@jest/globals": "npm:^30.2.0"
"@types/crypto-js": "npm:^4.2.2"
Expand Down
Loading