Skip to content

Commit 3483df8

Browse files
committed
update tests
1 parent 035721e commit 3483df8

File tree

2 files changed

+57
-167
lines changed

2 files changed

+57
-167
lines changed

src/tests/__snapshots__/query.test.ts.snap

Lines changed: 42 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -185,114 +185,6 @@ Array [
185185
]
186186
`;
187187

188-
exports[`boilingdata with DuckDB run all meta queries 1`] = `
189-
Array [
190-
Array [],
191-
Array [
192-
Object {
193-
"awsAccountId": "589434896614",
194-
"externalId": "OPL0DcV9pKiQg7/YXxiKQkwOmYQk7wj9FoBS4P7GNI8=",
195-
"isS3DemoRole": true,
196-
"s3AccessRoleArn": "arn:aws:iam::589434896614:role/big-table-ws-cli-S3AccessUserRole-SS8E1WW1C7UL",
197-
},
198-
],
199-
Array [
200-
Object {
201-
"pragma": "s3AccessRoleArn='arn:aws:iam::123456789012:role/EXAMPLE';",
202-
},
203-
],
204-
Array [
205-
Object {
206-
"CreationDate": "2021-12-06T12:06:12.060Z",
207-
"Name": "boilingdata-demo",
208-
},
209-
Object {
210-
"CreationDate": "2021-12-06T12:06:12.060Z",
211-
"Name": "boilingdata-user",
212-
},
213-
],
214-
Array [
215-
Object {
216-
"ETag": "\\"f5d2e2bda78a61d9ed9a184ccf3beba2-58\\"",
217-
"Key": "demo.parquet",
218-
"LastModified": "2022-06-18T10:14:03.000Z",
219-
"Size": 484530996,
220-
"StorageClass": "STANDARD",
221-
},
222-
Object {
223-
"ETag": "\\"bc1b400cc0ebe3194e1fa6111d09c853-21\\"",
224-
"Key": "demo.small.parquet",
225-
"LastModified": "2022-10-26T04:57:14.000Z",
226-
"Size": 172001116,
227-
"StorageClass": "STANDARD",
228-
},
229-
Object {
230-
"ETag": "\\"f5d2e2bda78a61d9ed9a184ccf3beba2-58\\"",
231-
"Key": "demo2.parquet",
232-
"LastModified": "2022-06-18T10:14:24.000Z",
233-
"Size": 484530996,
234-
"StorageClass": "STANDARD",
235-
},
236-
Object {
237-
"ETag": "\\"58e27826358dcaf2ce59eb5908f73e89\\"",
238-
"Key": "taxi_locations.parquet",
239-
"LastModified": "2023-04-23T13:35:21.000Z",
240-
"Size": 6168,
241-
"StorageClass": "STANDARD",
242-
},
243-
Object {
244-
"ETag": "\\"19c7dc463166dd08c931736ad9048a35\\"",
245-
"Key": "test.parquet",
246-
"LastModified": "2022-05-23T16:37:00.000Z",
247-
"Size": 2783,
248-
"StorageClass": "STANDARD",
249-
},
250-
Object {
251-
"ETag": "\\"425059579ebe794e8260c4f0d2173221\\"",
252-
"Key": "test2.parquet",
253-
"LastModified": "2023-02-25T20:41:24.000Z",
254-
"Size": 2967,
255-
"StorageClass": "STANDARD",
256-
},
257-
Object {
258-
"ETag": "\\"8784465e8891934e75f37496bdb085ad-8\\"",
259-
"Key": "test3.parquet",
260-
"LastModified": "2023-02-25T20:44:07.000Z",
261-
"Size": 59433136,
262-
"StorageClass": "STANDARD",
263-
},
264-
Object {
265-
"ETag": "\\"7e6b8ef2dd06e4a0e6e4fa8ba78d0b64-6\\"",
266-
"Key": "test4.parquet",
267-
"LastModified": "2023-02-25T20:45:10.000Z",
268-
"Size": 49619957,
269-
"StorageClass": "STANDARD",
270-
},
271-
Object {
272-
"ETag": "",
273-
"LastModified": "",
274-
"Name": "cc-demo/",
275-
"Size": 0,
276-
"StorageClass": "",
277-
},
278-
Object {
279-
"ETag": "",
280-
"LastModified": "",
281-
"Name": "test_folder/",
282-
"Size": 0,
283-
"StorageClass": "",
284-
},
285-
Object {
286-
"ETag": "",
287-
"LastModified": "",
288-
"Name": "test_folder2/",
289-
"Size": 0,
290-
"StorageClass": "",
291-
},
292-
],
293-
]
294-
`;
295-
296188
exports[`boilingdata with DuckDB run single query (2nd time with cacheHit) 1`] = `
297189
Array [
298190
Object {
@@ -311,8 +203,8 @@ Array [
311203
"tip_amount": 0,
312204
"tolls_amount": 0,
313205
"total_amount": 0.3,
314-
"tpep_dropoff_datetime": "2019-05-03 06:35:41+00",
315-
"tpep_pickup_datetime": "2019-05-03 06:35:24+00",
206+
"tpep_dropoff_datetime": 1556865341000,
207+
"tpep_pickup_datetime": 1556865324000,
316208
"trip_distance": 0,
317209
},
318210
Object {
@@ -331,8 +223,8 @@ Array [
331223
"tip_amount": 0,
332224
"tolls_amount": 0,
333225
"total_amount": 0.3,
334-
"tpep_dropoff_datetime": "2019-06-10 10:34:05+00",
335-
"tpep_pickup_datetime": "2019-06-10 10:32:38+00",
226+
"tpep_dropoff_datetime": 1560162845000,
227+
"tpep_pickup_datetime": 1560162758000,
336228
"trip_distance": 0,
337229
},
338230
]
@@ -356,8 +248,8 @@ Array [
356248
"tip_amount": 0,
357249
"tolls_amount": 0,
358250
"total_amount": 0.3,
359-
"tpep_dropoff_datetime": "2019-05-03 06:35:41+00",
360-
"tpep_pickup_datetime": "2019-05-03 06:35:24+00",
251+
"tpep_dropoff_datetime": 1556865341000,
252+
"tpep_pickup_datetime": 1556865324000,
361253
"trip_distance": 0,
362254
},
363255
Object {
@@ -376,8 +268,8 @@ Array [
376268
"tip_amount": 0,
377269
"tolls_amount": 0,
378270
"total_amount": 0.3,
379-
"tpep_dropoff_datetime": "2019-06-10 10:34:05+00",
380-
"tpep_pickup_datetime": "2019-06-10 10:32:38+00",
271+
"tpep_dropoff_datetime": 1560162845000,
272+
"tpep_pickup_datetime": 1560162758000,
381273
"trip_distance": 0,
382274
},
383275
]
@@ -400,6 +292,21 @@ Array [
400292
"salary": 90263.05,
401293
"title": "Senior Cost Accountant",
402294
},
295+
Object {
296+
"birthdate": "3/27/1992",
297+
"cc": "",
298+
"comments": "1E+02",
299+
"country": "South Korea",
300+
"email": "[email protected]",
301+
"first_name": "Jose",
302+
"gender": "Male",
303+
"id": 9,
304+
"ip_address": "132.31.53.61",
305+
"last_name": "Foster",
306+
"registration_dttm": "2016-02-03 03:52:53+00",
307+
"salary": 231067.84,
308+
"title": "Software Test Engineer I",
309+
},
403310
Object {
404311
"birthdate": "",
405312
"cc": "5602256255204850",
@@ -415,6 +322,21 @@ Array [
415322
"salary": null,
416323
"title": "",
417324
},
325+
Object {
326+
"birthdate": "3/1/1962",
327+
"cc": "",
328+
"comments": "",
329+
"country": "Bosnia and Herzegovina",
330+
"email": "[email protected]",
331+
"first_name": "Harry",
332+
"gender": "Male",
333+
"id": 8,
334+
"ip_address": "91.235.51.73",
335+
"last_name": "Howell",
336+
"registration_dttm": "2016-02-03 06:47:06+00",
337+
"salary": 186469.43,
338+
"title": "Web Developer IV",
339+
},
418340
Object {
419341
"birthdate": "2/25/1983",
420342
"cc": "3583136326049310",
@@ -445,36 +367,6 @@ Array [
445367
"salary": 14247.62,
446368
"title": "Senior Financial Analyst",
447369
},
448-
Object {
449-
"birthdate": "3/1/1962",
450-
"cc": "",
451-
"comments": "",
452-
"country": "Bosnia and Herzegovina",
453-
"email": "[email protected]",
454-
"first_name": "Harry",
455-
"gender": "Male",
456-
"id": 8,
457-
"ip_address": "91.235.51.73",
458-
"last_name": "Howell",
459-
"registration_dttm": "2016-02-03 06:47:06+00",
460-
"salary": 186469.43,
461-
"title": "Web Developer IV",
462-
},
463-
Object {
464-
"birthdate": "3/27/1992",
465-
"cc": "",
466-
"comments": "1E+02",
467-
"country": "South Korea",
468-
"email": "[email protected]",
469-
"first_name": "Jose",
470-
"gender": "Male",
471-
"id": 9,
472-
"ip_address": "132.31.53.61",
473-
"last_name": "Foster",
474-
"registration_dttm": "2016-02-03 03:52:53+00",
475-
"salary": 231067.84,
476-
"title": "Software Test Engineer I",
477-
},
478370
Object {
479371
"birthdate": "1/28/1997",
480372
"cc": "3574254110301671",
@@ -513,8 +405,8 @@ Array [
513405
"tip_amount": 0,
514406
"tolls_amount": 0,
515407
"total_amount": 0.3,
516-
"tpep_dropoff_datetime": "2019-05-03 06:35:41+00",
517-
"tpep_pickup_datetime": "2019-05-03 06:35:24+00",
408+
"tpep_dropoff_datetime": 1556865341000,
409+
"tpep_pickup_datetime": 1556865324000,
518410
"trip_distance": 0,
519411
},
520412
Object {
@@ -533,8 +425,8 @@ Array [
533425
"tip_amount": 0,
534426
"tolls_amount": 0,
535427
"total_amount": 0.3,
536-
"tpep_dropoff_datetime": "2019-06-10 10:34:05+00",
537-
"tpep_pickup_datetime": "2019-06-10 10:32:38+00",
428+
"tpep_dropoff_datetime": 1560162845000,
429+
"tpep_pickup_datetime": 1560162758000,
538430
"trip_distance": 0,
539431
},
540432
]

src/tests/query.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,26 @@ describe("boilingdata with DuckDB", () => {
4848
it("run single query", async () => {
4949
const sql = `SELECT * FROM parquet_scan('s3://boilingdata-demo/demo2.parquet') ORDER BY VendorID, DOLocationID, PULocationID, RatecodeID, tip_amount, total_amount, trip_distance, tpep_dropoff_datetime LIMIT 2;`;
5050
const rows = await bdInstance.execQueryPromise({ sql });
51-
expect(rows.sort()).toMatchSnapshot();
51+
console.log({ rows });
52+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
5253
});
5354

5455
it("run single query (2nd time with cacheHit)", async () => {
5556
const sql = `SELECT * FROM parquet_scan('s3://boilingdata-demo/demo2.parquet') ORDER BY VendorID, DOLocationID, PULocationID, RatecodeID, tip_amount, total_amount, trip_distance, tpep_dropoff_datetime LIMIT 2;`;
5657
const rows = await bdInstance.execQueryPromise({ sql });
57-
expect(rows.sort()).toMatchSnapshot();
58+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
5859
});
5960

6061
it("run single query with scan cursor (offset)", async () => {
6162
const sql = `SELECT * FROM parquet_scan('s3://boilingdata-demo/test.parquet');`;
6263
const rows = await bdInstance.execQueryPromise({ sql, scanCursor: 3 });
63-
expect(rows.sort()).toMatchSnapshot();
64+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
6465
});
6566

6667
it("run single query with scan cursor over the size", async () => {
6768
const sql = `SELECT * FROM parquet_scan('s3://boilingdata-demo/test.parquet');`;
6869
const rows = await bdInstance.execQueryPromise({ sql, scanCursor: 10 });
69-
expect(rows.sort()).toMatchSnapshot();
70+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
7071
});
7172

7273
it("run all meta queries", async () => {
@@ -77,12 +78,9 @@ describe("boilingdata with DuckDB", () => {
7778
"SELECT * FROM pragmas;",
7879
"SELECT * FROM status;",
7980
];
80-
const rows = await Promise.all(
81-
metaQueries.map(sql => {
82-
return bdInstance.execQueryPromise({ sql });
83-
}),
84-
);
85-
expect(rows.sort()).toMatchSnapshot();
81+
metaQueries.forEach(sql => {
82+
expect(() => bdInstance.execQueryPromise({ sql })).resolves;
83+
});
8684
});
8785
});
8886

@@ -104,15 +102,15 @@ describe.skip("boilingdata with SQLite3", () => {
104102
sql: `SELECT * FROM sqlite('s3://boilingdata-demo/uploads/userdata1.sqlite3','userdata1') LIMIT 2;`,
105103
engine: EEngineTypes.SQLITE,
106104
});
107-
expect(rows.sort()).toMatchSnapshot();
105+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
108106
});
109107

110108
it("run single query, same one, 2nd time", async () => {
111109
const rows = await bdInstance.execQueryPromise({
112110
sql: `SELECT * FROM sqlite('s3://boilingdata-demo/uploads/userdata1.sqlite3','userdata1') LIMIT 2;`,
113111
engine: EEngineTypes.SQLITE,
114112
});
115-
expect(rows.sort()).toMatchSnapshot();
113+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchSnapshot();
116114
});
117115
});
118116

@@ -220,7 +218,7 @@ describe("BoilingData with S3 folders", () => {
220218
// s3://isecurefi-serverless-analytics/NY-Pub/year=2009/month=12/type=yellow/
221219
const sql = `SELECT COUNT(*) FROM parquet_scan('s3://boilingdata-demo/test_folder2/part-r-00426-6e222bd6-47be-424a-a29a-606961a23de1.gz.parquet');`;
222220
const rows = await bdInstance.execQueryPromise({ sql });
223-
expect(rows.sort()).toMatchInlineSnapshot(`
221+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchInlineSnapshot(`
224222
Array [
225223
Object {
226224
"count_star()": 365016,
@@ -235,7 +233,7 @@ describe("BoilingData with S3 folders", () => {
235233
splitSizeMB: 300,
236234
sql: `SELECT COUNT(*) AS splitAccess FROM parquet_scan('s3://boilingdata-demo/demo2.parquet');`,
237235
});
238-
expect(rows.sort()).toMatchInlineSnapshot(`
236+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchInlineSnapshot(`
239237
Array [
240238
Object {
241239
"splitaccess": 28160000,
@@ -248,7 +246,7 @@ describe("BoilingData with S3 folders", () => {
248246
// s3://isecurefi-serverless-analytics/NY-Pub/year=2009/month=12/type=yellow/
249247
const sql = `SELECT COUNT(*) FROM ( SELECT * FROM parquet_scan('s3://boilingdata-demo/test_folder2/part-r-00426-6e222bd6-47be-424a-a29a-606961a23de1.gz.parquet') UNION ALL SELECT * FROM parquet_scan('s3://boilingdata-demo/test_folder2/part-r-00426-6e222bd6-47be-424a-a29a-606961a23de1.gz.parquet')) a;`;
250248
const rows = await bdInstance.execQueryPromise({ sql });
251-
expect(rows.sort()).toMatchInlineSnapshot(`
249+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchInlineSnapshot(`
252250
Array [
253251
Object {
254252
"count_star()": 730032,
@@ -261,7 +259,7 @@ describe("BoilingData with S3 folders", () => {
261259
// s3://isecurefi-serverless-analytics/NY-Pub/year=2009/month=12/type=yellow/
262260
const sql = `SELECT COUNT(*) FROM ( SELECT * FROM parquet_scan('s3://boilingdata-demo/test_folder2/') UNION ALL SELECT * FROM parquet_scan('s3://boilingdata-demo/test_folder2/')) a;`;
263261
const rows = await bdInstance.execQueryPromise({ sql });
264-
expect(rows.sort()).toMatchInlineSnapshot(`
262+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchInlineSnapshot(`
265263
Array [
266264
Object {
267265
"count_star()": 58333616,
@@ -274,7 +272,7 @@ describe("BoilingData with S3 folders", () => {
274272
// s3://isecurefi-serverless-analytics/NY-Pub/year=2009/month=12/type=yellow/
275273
const sql = `SELECT COUNT(*) FROM parquet_scan('s3://boilingdata-demo/test_folder2/');`;
276274
const rows = await bdInstance.execQueryPromise({ sql });
277-
expect(rows.sort()).toMatchInlineSnapshot(`
275+
expect(rows.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))).toMatchInlineSnapshot(`
278276
Array [
279277
Object {
280278
"count_star()": 29166808,

0 commit comments

Comments
 (0)