Skip to content

Commit

Permalink
Fix JSONEachRowWithProgress tests with latest ClickHouse version
Browse files Browse the repository at this point in the history
  • Loading branch information
slvrtrn committed Jan 8, 2025
1 parent 9f3e31e commit 891b3eb
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,18 @@ describe('[Node.js] stream JSON formats', () => {
describe('JSONEachRowWithProgress', () => {
it('should work', async () => {
const limit = 2
const expectedProgressRowsCount = 4
/*
The layout after 25.1 for two rows with max_block_size=1 looks like:
[
{"progress":{"read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"}},
{"progress":{"read_rows":"1","read_bytes":"8","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"}},
{"row":{"number":"0"}},
{"progress":{"read_rows":"2","read_bytes":"16","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"}},
{"row":{"number":"1"}}
]
See also: https://github.com/ClickHouse/ClickHouse/pull/73834
*/
const expectedProgressRowsCount = 3
const rs = await client.query({
query: `SELECT number FROM system.numbers LIMIT ${limit}`,
format: 'JSONEachRowWithProgress',
Expand All @@ -243,7 +254,14 @@ describe('[Node.js] stream JSON formats', () => {
},
})
const rows = await rs.json<{ number: 'string' }>()
expect(rows.length).toEqual(limit + expectedProgressRowsCount)
// 25.1+
expect(rows.length).toBeGreaterThanOrEqual(
limit + expectedProgressRowsCount,
)
// 24.12 (had one more progress row emitted)
expect(rows.length).toBeLessThanOrEqual(
limit + expectedProgressRowsCount + 1,
)
expect(rows.filter((r) => !isProgressRow(r)) as unknown[]).toEqual([
{ row: { number: '0' } },
{ row: { number: '1' } },
Expand Down

0 comments on commit 891b3eb

Please sign in to comment.