Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSONEachRowWithProgress tests with latest ClickHouse version #373

Closed
wants to merge 1 commit into from
Closed
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
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
Loading