@devrev/meerkat-node 0.0.95 → 0.0.97

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 CHANGED
@@ -1,11 +1,67 @@
1
- # meerkat-node
1
+ # @devrev/meerkat-node
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
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
- ## Building
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
- Run `nx build meerkat-node` to build the library.
7
+ ## Key Features
8
8
 
9
- ## Running unit tests
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
- Run `nx test meerkat-node` to execute the unit tests via [Jest](https://jestjs.io).
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
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "convertCubeStringToTableSchema", {
6
6
  }
7
7
  });
8
8
  const _export_star = require("@swc/helpers/_/_export_star");
9
+ _export_star._(require("./cube-to-sql-with-resolution/cube-to-sql-with-resolution"), exports);
9
10
  _export_star._(require("./cube-to-sql/cube-to-sql"), exports);
10
11
  _export_star._(require("./duckdb-singleton"), exports);
11
12
  _export_star._(require("./node-sql-to-serialization"), exports);
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../meerkat-node/src/index.ts"],"sourcesContent":["export * from './cube-to-sql/cube-to-sql';\nexport * from './duckdb-singleton';\nexport * from './node-sql-to-serialization';\nexport { convertCubeStringToTableSchema };\nimport { convertCubeStringToTableSchema } from '@devrev/meerkat-core';\nexport * from './duckdb-manager/duckdb-manager';\nexport * from './file-manager/file-manager';\n"],"names":["convertCubeStringToTableSchema"],"mappings":";+BAGSA;;;eAAAA,2CAA8B;;;;uBAHzB;uBACA;uBACA;6BAEiC;uBACjC;uBACA"}
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-singleton';\nexport * from './node-sql-to-serialization';\nexport { convertCubeStringToTableSchema };\nimport { convertCubeStringToTableSchema } from '@devrev/meerkat-core';\nexport * from './duckdb-manager/duckdb-manager';\nexport * from './file-manager/file-manager';\n"],"names":["convertCubeStringToTableSchema"],"mappings":";+BAISA;;;eAAAA,2CAA8B;;;;uBAJzB;uBACA;uBACA;uBACA;6BAEiC;uBACjC;uBACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/meerkat-node",
3
- "version": "0.0.95",
3
+ "version": "0.0.97",
4
4
  "dependencies": {
5
5
  "@swc/helpers": "~0.5.0",
6
6
  "@devrev/meerkat-core": "*",
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './cube-to-sql-with-resolution/cube-to-sql-with-resolution';
1
2
  export * from './cube-to-sql/cube-to-sql';
2
3
  export * from './duckdb-singleton';
3
4
  export * from './node-sql-to-serialization';