Skip to content

Commit c348fbd

Browse files
authored
Fix head version tests, add ClickHouseSummary. real_time_microseconds (#307)
1 parent 78816e6 commit c348fbd

File tree

4 files changed

+62
-33
lines changed

4 files changed

+62
-33
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Unreleased
2+
3+
## New features
4+
5+
- Added optional `real_time_microseconds` field to the `ClickHouseSummary` interface (see https://github.com/ClickHouse/ClickHouse/pull/69032)
6+
17
# 1.5.0 (Node.js)
28

39
## New features

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3.8'
1+
#version: '3.8'
22
services:
33
clickhouse:
44
image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-24.8-alpine}'

packages/client-common/src/clickhouse_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface ClickHouseSummary {
2727
result_rows: string
2828
result_bytes: string
2929
elapsed_ns: string
30+
/** Available only after ClickHouse 24.9 */
31+
real_time_microseconds?: string
3032
}
3133

3234
export type ResponseHeaders = Record<string, string | string[] | undefined>

packages/client-node/__tests__/integration/node_summary.test.ts

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,69 @@ whenOnEnv(
3030
values: jsonValues,
3131
format: 'JSONEachRow',
3232
})
33-
expect(insertSummary).toEqual({
34-
read_rows: '5',
35-
read_bytes: jasmine.any(String),
36-
written_rows: '5',
37-
written_bytes: jasmine.any(String),
38-
total_rows_to_read: '0',
39-
result_rows: '5',
40-
result_bytes: jasmine.any(String),
41-
elapsed_ns: jasmine.any(String),
42-
})
33+
expect(insertSummary).toEqual(
34+
jasmine.objectContaining({
35+
read_rows: '5',
36+
read_bytes: jasmine.any(String),
37+
written_rows: '5',
38+
written_bytes: jasmine.any(String),
39+
total_rows_to_read: '0',
40+
result_rows: '5',
41+
result_bytes: jasmine.any(String),
42+
elapsed_ns: jasmine.any(String),
43+
}),
44+
)
45+
assertRealTimeMicroseconds(insertSummary)
4346

4447
const { summary: execSummary } = await client.exec({
45-
query: `INSERT INTO ${tableName} SELECT * FROM ${tableName}`,
46-
})
47-
expect(execSummary).toEqual({
48-
read_rows: '5',
49-
read_bytes: jasmine.any(String),
50-
written_rows: '5',
51-
written_bytes: jasmine.any(String),
52-
total_rows_to_read: '5',
53-
result_rows: '5',
54-
result_bytes: jasmine.any(String),
55-
elapsed_ns: jasmine.any(String),
48+
query: `INSERT INTO ${tableName}
49+
SELECT *
50+
FROM ${tableName}`,
5651
})
52+
expect(execSummary).toEqual(
53+
jasmine.objectContaining({
54+
read_rows: '5',
55+
read_bytes: jasmine.any(String),
56+
written_rows: '5',
57+
written_bytes: jasmine.any(String),
58+
total_rows_to_read: '5',
59+
result_rows: '5',
60+
result_bytes: jasmine.any(String),
61+
elapsed_ns: jasmine.any(String),
62+
}),
63+
)
64+
assertRealTimeMicroseconds(execSummary)
5765
})
5866

5967
it('should provide summary for command', async () => {
6068
const { summary } = await client.command({
61-
query: `INSERT INTO ${tableName} VALUES (144, 'Hello', [2, 4]), (255, 'World', [3, 5])`,
69+
query: `INSERT INTO ${tableName}
70+
VALUES (144, 'Hello', [2, 4]),
71+
(255, 'World', [3, 5])`,
6272
clickhouse_settings: {
6373
wait_end_of_query: 1,
6474
},
6575
})
66-
expect(summary).toEqual({
67-
read_rows: '2',
68-
read_bytes: jasmine.any(String),
69-
written_rows: '2',
70-
written_bytes: jasmine.any(String),
71-
total_rows_to_read: '0',
72-
result_rows: '2',
73-
result_bytes: jasmine.any(String),
74-
elapsed_ns: jasmine.any(String),
75-
})
76+
expect(summary).toEqual(
77+
jasmine.objectContaining({
78+
read_rows: '2',
79+
read_bytes: jasmine.any(String),
80+
written_rows: '2',
81+
written_bytes: jasmine.any(String),
82+
total_rows_to_read: '0',
83+
result_rows: '2',
84+
result_bytes: jasmine.any(String),
85+
elapsed_ns: jasmine.any(String),
86+
}),
87+
)
88+
assertRealTimeMicroseconds(summary)
7689
})
90+
91+
function assertRealTimeMicroseconds(summary: any) {
92+
// FIXME: remove this condition after 24.9 is released
93+
if (process.env['CLICKHOUSE_VERSION'] === 'head') {
94+
expect(summary.real_time_microseconds).toBeDefined()
95+
expect(summary.real_time_microseconds).toMatch(/^\d+$/)
96+
}
97+
}
7798
})

0 commit comments

Comments
 (0)