Skip to content

Commit 7c3a846

Browse files
authored
chore: update meerkat node duckdb package (#130)
* update: duckddb manager * update: tests * fix: build * update: version * fix: test * fix: test
1 parent c866cdc commit 7c3a846

22 files changed

+367
-457
lines changed

meerkat-browser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devrev/meerkat-browser",
3-
"version": "0.0.89",
3+
"version": "0.0.90",
44
"dependencies": {
55
"@swc/helpers": "~0.5.0",
66
"@devrev/meerkat-core": "*",

meerkat-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devrev/meerkat-core",
3-
"version": "0.0.89",
3+
"version": "0.0.90",
44
"dependencies": {
55
"@swc/helpers": "~0.5.0"
66
},

meerkat-node/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@devrev/meerkat-node",
3-
"version": "0.0.89",
3+
"version": "0.0.90",
44
"dependencies": {
55
"@swc/helpers": "~0.5.0",
66
"@devrev/meerkat-core": "*",
7-
"@duckdb/node-api": "1.1.3-alpha.7",
87
"axios": "^1.6.0",
9-
"lodash": "^4.17.21"
8+
"lodash": "^4.17.21",
9+
"duckdb": "^1.0.0"
1010
},
1111
"scripts": {
1212
"release": "semantic-release"

meerkat-node/src/__tests__/cube-projection-filters.spec.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ describe('cube-to-sql', () => {
8080
console.info('SQL: ', sql);
8181
const output: any = await duckdbExec(sql);
8282
const expectQueryResult = [
83-
{ person__count_star: 2, person__other_dimension: 'dashboard_others' },
83+
{
84+
person__count_star: BigInt(2),
85+
person__other_dimension: 'dashboard_others',
86+
},
8487
];
8588
expect(output).toEqual(expectQueryResult);
8689
});
@@ -117,7 +120,10 @@ describe('cube-to-sql', () => {
117120
console.info('SQL: ', sql);
118121
const output: any = await duckdbExec(sql);
119122
const expectQueryResult = [
120-
{ person__count_star: 4, person__other_dimension: 'dashboard_others' },
123+
{
124+
person__count_star: BigInt(4),
125+
person__other_dimension: 'dashboard_others',
126+
},
121127
];
122128
expect(output).toEqual(expectQueryResult);
123129
});
@@ -159,7 +165,10 @@ describe('cube-to-sql', () => {
159165
console.info('SQL: ', sql);
160166
const output: any = await duckdbExec(sql);
161167
const expectQueryResult = [
162-
{ person__count_star: 3, person__other_dimension: 'dashboard_others' },
168+
{
169+
person__count_star: BigInt(3),
170+
person__other_dimension: 'dashboard_others',
171+
},
163172
];
164173
expect(output).toEqual(expectQueryResult);
165174
});

meerkat-node/src/__tests__/unnest-group-by.spec.ts

+33-33
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ describe('cube-to-sql', () => {
101101
const output = await duckdbExec(sql);
102102
expect(output).toEqual([
103103
{
104-
tickets__count: 3,
104+
tickets__count: BigInt(3),
105105
tickets__owners: ['b'],
106106
},
107107
{
108-
tickets__count: 2,
108+
tickets__count: BigInt(2),
109109
tickets__owners: ['d'],
110110
},
111111
{
112-
tickets__count: 2,
112+
tickets__count: BigInt(2),
113113
tickets__owners: ['c'],
114114
},
115115
{
116-
tickets__count: 2,
116+
tickets__count: BigInt(2),
117117
tickets__owners: ['a'],
118118
},
119119
{
120-
tickets__count: 1,
120+
tickets__count: BigInt(1),
121121
tickets__owners: ['e'],
122122
},
123123
]);
@@ -150,27 +150,27 @@ describe('cube-to-sql', () => {
150150
const output = await duckdbExec(sql);
151151
expect(output).toEqual([
152152
{
153-
tickets__count: 2,
153+
tickets__count: BigInt(2),
154154
tickets__owners: null,
155155
},
156156
{
157-
tickets__count: 1,
157+
tickets__count: BigInt(1),
158158
tickets__owners: ['e'],
159159
},
160160
{
161-
tickets__count: 1,
161+
tickets__count: BigInt(1),
162162
tickets__owners: ['b', 'c', 'd'],
163163
},
164164
{
165-
tickets__count: 1,
165+
tickets__count: BigInt(1),
166166
tickets__owners: ['b', 'c'],
167167
},
168168
{
169-
tickets__count: 1,
169+
tickets__count: BigInt(1),
170170
tickets__owners: ['a', 'd'],
171171
},
172172
{
173-
tickets__count: 1,
173+
tickets__count: BigInt(1),
174174
tickets__owners: ['a', 'b'],
175175
},
176176
]);
@@ -203,15 +203,15 @@ describe('cube-to-sql', () => {
203203
const output = await duckdbExec(sql);
204204
expect(output).toEqual([
205205
{
206-
tickets__count: 4,
206+
tickets__count: BigInt(4),
207207
tickets__created_by: 'z',
208208
},
209209
{
210-
tickets__count: 2,
210+
tickets__count: BigInt(2),
211211
tickets__created_by: 'x',
212212
},
213213
{
214-
tickets__count: 1,
214+
tickets__count: BigInt(1),
215215
tickets__created_by: 'y',
216216
},
217217
]);
@@ -244,15 +244,15 @@ describe('cube-to-sql', () => {
244244
const output = await duckdbExec(sql);
245245
expect(output).toEqual([
246246
{
247-
tickets__count: 4,
247+
tickets__count: BigInt(4),
248248
tickets__created_by: 'z',
249249
},
250250
{
251-
tickets__count: 2,
251+
tickets__count: BigInt(2),
252252
tickets__created_by: 'x',
253253
},
254254
{
255-
tickets__count: 1,
255+
tickets__count: BigInt(1),
256256
tickets__created_by: 'y',
257257
},
258258
]);
@@ -293,85 +293,85 @@ describe('cube-to-sql', () => {
293293
const output = await duckdbExec(sql);
294294
expect(output).toEqual([
295295
{
296-
tickets__count: 1,
296+
tickets__count: BigInt(1),
297297
tickets__created_by: 'z',
298298
tickets__owners: ['d'],
299299
tickets__tags: [null],
300300
},
301301
{
302-
tickets__count: 1,
302+
tickets__count: BigInt(1),
303303
tickets__created_by: 'z',
304304
tickets__owners: ['c'],
305305
tickets__tags: [null],
306306
},
307307
{
308-
tickets__count: 1,
308+
tickets__count: BigInt(1),
309309
tickets__created_by: 'z',
310310
tickets__owners: ['b'],
311311
tickets__tags: [null],
312312
},
313313
{
314-
tickets__count: 1,
314+
tickets__count: BigInt(1),
315315
tickets__created_by: 'z',
316316
tickets__owners: [null],
317317
tickets__tags: ['t5'],
318318
},
319319
{
320-
tickets__count: 1,
320+
tickets__count: BigInt(1),
321321
tickets__created_by: 'z',
322322
tickets__owners: [null],
323323
tickets__tags: ['t4'],
324324
},
325325
{
326-
tickets__count: 1,
326+
tickets__count: BigInt(1),
327327
tickets__created_by: 'z',
328328
tickets__owners: ['a'],
329329
tickets__tags: ['t4'],
330330
},
331331
{
332-
tickets__count: 1,
332+
tickets__count: BigInt(1),
333333
tickets__created_by: 'y',
334334
tickets__owners: [null],
335335
tickets__tags: ['t4'],
336336
},
337337
{
338-
tickets__count: 1,
338+
tickets__count: BigInt(1),
339339
tickets__created_by: 'y',
340340
tickets__owners: [null],
341341
tickets__tags: ['t3'],
342342
},
343343
{
344-
tickets__count: 1,
344+
tickets__count: BigInt(1),
345345
tickets__created_by: 'y',
346346
tickets__owners: ['e'],
347347
tickets__tags: ['t1'],
348348
},
349349
{
350-
tickets__count: 1,
350+
tickets__count: BigInt(1),
351351
tickets__created_by: 'x',
352352
tickets__owners: ['d'],
353353
tickets__tags: [null],
354354
},
355355
{
356-
tickets__count: 1,
356+
tickets__count: BigInt(1),
357357
tickets__created_by: 'x',
358358
tickets__owners: ['b'],
359359
tickets__tags: [null],
360360
},
361361
{
362-
tickets__count: 1,
362+
tickets__count: BigInt(1),
363363
tickets__created_by: 'x',
364364
tickets__owners: ['c'],
365365
tickets__tags: ['t3'],
366366
},
367367
{
368-
tickets__count: 1,
368+
tickets__count: BigInt(1),
369369
tickets__created_by: 'x',
370370
tickets__owners: ['b'],
371371
tickets__tags: ['t2'],
372372
},
373373
{
374-
tickets__count: 1,
374+
tickets__count: BigInt(1),
375375
tickets__created_by: 'x',
376376
tickets__owners: ['a'],
377377
tickets__tags: ['t1'],
@@ -424,11 +424,11 @@ describe('cube-to-sql', () => {
424424
const output = await duckdbExec(sql);
425425
expect(output).toEqual([
426426
{
427-
tickets__count: 1,
427+
tickets__count: BigInt(1),
428428
tickets__tags: ['t4'],
429429
},
430430
{
431-
tickets__count: 1,
431+
tickets__count: BigInt(1),
432432
tickets__tags: ['t1'],
433433
},
434434
]);

meerkat-node/src/duckdb-exec.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { DuckDBSingleton } from './duckdb-singleton';
2-
import { transformDuckDBQueryResult } from './utils/transform-duckdb-result';
32

4-
export const duckdbExec = async (
5-
query: string
6-
): Promise<Record<string, unknown>[]> => {
7-
const db = await DuckDBSingleton.getInstance();
8-
const connection = await db.connect();
9-
10-
const result = await connection.run(query);
11-
12-
const { data } = await transformDuckDBQueryResult(result);
13-
14-
return data;
3+
export const duckdbExec = <T = unknown>(query: string): Promise<T> => {
4+
const db = DuckDBSingleton.getInstance();
5+
return new Promise((resolve, reject) => {
6+
db.all(query, (err, res) => {
7+
if (err) {
8+
reject(err);
9+
}
10+
resolve(res as T);
11+
});
12+
});
1513
};

0 commit comments

Comments
 (0)