@devrev/meerkat-node 0.0.96 → 0.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -6
- package/index.js +2 -9
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +2 -4
package/README.md
CHANGED
|
@@ -1,11 +1,67 @@
|
|
|
1
|
-
# meerkat-node
|
|
1
|
+
# @devrev/meerkat-node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@devrev/meerkat-node` is a library for converting cube queries into SQL and executing them in a Node.js environment using [DuckDB](https://duckdb.org/). It serves as a server-side query engine within the Meerkat ecosystem.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package uses `@devrev/meerkat-core` to generate a DuckDB-compatible AST and `duckdb` to execute the resulting query against local data files like Parquet or CSV.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Key Features
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- **Cube to SQL Execution**: Translates cube queries into SQL and executes them.
|
|
10
|
+
- **Node.js Optimized**: Built to work seamlessly with `duckdb`.
|
|
11
|
+
- **Simplified API**: Provides a `duckdbExec` utility for easy query execution.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @devrev/meerkat-node @devrev/meerkat-core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
Here's a basic example of how to convert a cube query into SQL and execute it.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { cubeQueryToSQL, duckdbExec } from '@devrev/meerkat-node';
|
|
25
|
+
import { Query, TableSchema } from '@devrev/meerkat-core';
|
|
26
|
+
|
|
27
|
+
async function main() {
|
|
28
|
+
// 1. Define your table schema. In Node.js, the SQL typically points to a data file.
|
|
29
|
+
const tableSchema: TableSchema = {
|
|
30
|
+
name: 'users',
|
|
31
|
+
sql: `SELECT * FROM 'users.parquet'`,
|
|
32
|
+
columns: [
|
|
33
|
+
{ name: 'id', type: 'INTEGER' },
|
|
34
|
+
{ name: 'name', type: 'VARCHAR' },
|
|
35
|
+
{ name: 'city', type: 'VARCHAR' },
|
|
36
|
+
{ name: 'signed_up_at', type: 'TIMESTAMP' },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// 2. Define your Cube query.
|
|
41
|
+
const query: Query = {
|
|
42
|
+
measures: ['users.count'],
|
|
43
|
+
dimensions: ['users.city'],
|
|
44
|
+
filters: [
|
|
45
|
+
{
|
|
46
|
+
member: 'users.city',
|
|
47
|
+
operator: 'equals',
|
|
48
|
+
values: ['New York'],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
limit: 100,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// 3. Convert the query to SQL.
|
|
55
|
+
const sql = await cubeQueryToSQL({
|
|
56
|
+
query,
|
|
57
|
+
tableSchemas: [tableSchema],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// 4. Execute the query using DuckDB.
|
|
61
|
+
const results = await duckdbExec(sql);
|
|
62
|
+
|
|
63
|
+
console.log('Query Results:', results);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main();
|
|
67
|
+
```
|
package/index.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "convertCubeStringToTableSchema", {
|
|
3
|
-
enumerable: true,
|
|
4
|
-
get: function() {
|
|
5
|
-
return _meerkatcore.convertCubeStringToTableSchema;
|
|
6
|
-
}
|
|
7
|
-
});
|
|
8
2
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
9
3
|
_export_star._(require("./cube-to-sql-with-resolution/cube-to-sql-with-resolution"), exports);
|
|
10
4
|
_export_star._(require("./cube-to-sql/cube-to-sql"), exports);
|
|
11
|
-
_export_star._(require("./duckdb-singleton"), exports);
|
|
12
|
-
_export_star._(require("./node-sql-to-serialization"), exports);
|
|
13
|
-
const _meerkatcore = require("@devrev/meerkat-core");
|
|
14
5
|
_export_star._(require("./duckdb-manager/duckdb-manager"), exports);
|
|
6
|
+
_export_star._(require("./duckdb-singleton"), exports);
|
|
15
7
|
_export_star._(require("./file-manager/file-manager"), exports);
|
|
8
|
+
_export_star._(require("./node-sql-to-serialization"), exports);
|
|
16
9
|
|
|
17
10
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../meerkat-node/src/index.ts"],"sourcesContent":["export * from './cube-to-sql-with-resolution/cube-to-sql-with-resolution';\nexport * from './cube-to-sql/cube-to-sql';\nexport * from './duckdb-
|
|
1
|
+
{"version":3,"sources":["../../meerkat-node/src/index.ts"],"sourcesContent":["export * from './cube-to-sql-with-resolution/cube-to-sql-with-resolution';\nexport * from './cube-to-sql/cube-to-sql';\nexport * from './duckdb-manager/duckdb-manager';\nexport * from './duckdb-singleton';\nexport * from './file-manager/file-manager';\nexport * from './node-sql-to-serialization';\n"],"names":[],"mappings":";;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA"}
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './cube-to-sql-with-resolution/cube-to-sql-with-resolution';
|
|
2
2
|
export * from './cube-to-sql/cube-to-sql';
|
|
3
|
-
export * from './duckdb-singleton';
|
|
4
|
-
export * from './node-sql-to-serialization';
|
|
5
|
-
export { convertCubeStringToTableSchema };
|
|
6
|
-
import { convertCubeStringToTableSchema } from '@devrev/meerkat-core';
|
|
7
3
|
export * from './duckdb-manager/duckdb-manager';
|
|
4
|
+
export * from './duckdb-singleton';
|
|
8
5
|
export * from './file-manager/file-manager';
|
|
6
|
+
export * from './node-sql-to-serialization';
|