@malloydata/db-duckdb 0.0.22-dev230207180844 → 0.0.22-dev230207183024

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.
@@ -1,4 +1,4 @@
1
- import { Connection, MalloyQueryData, PersistSQLResults, PooledConnection, RunSQLOptions, SQLBlock, StreamingConnection, StructDef, QueryDataRow } from "@malloydata/malloy";
1
+ import { Connection, MalloyQueryData, PersistSQLResults, PooledConnection, QueryDataRow, RunSQLOptions, SQLBlock, StreamingConnection, StructDef } from "@malloydata/malloy";
2
2
  export interface DuckDBQueryOptions {
3
3
  rowLimit: number;
4
4
  }
@@ -25,15 +25,15 @@ exports.DuckDBCommon = void 0;
25
25
  */
26
26
  const malloy_1 = require("@malloydata/malloy");
27
27
  const duckDBToMalloyTypes = {
28
- BIGINT: "number",
29
- DOUBLE: "number",
30
- VARCHAR: "string",
31
- DATE: "date",
32
- TIMESTAMP: "timestamp",
33
- TIME: "string",
34
- DECIMAL: "number",
35
- BOOLEAN: "boolean",
36
- INTEGER: "number",
28
+ "BIGINT": "number",
29
+ "DOUBLE": "number",
30
+ "VARCHAR": "string",
31
+ "DATE": "date",
32
+ "TIMESTAMP": "timestamp",
33
+ "TIME": "string",
34
+ "DECIMAL": "number",
35
+ "BOOLEAN": "boolean",
36
+ "INTEGER": "number"
37
37
  };
38
38
  class DuckDBCommon {
39
39
  constructor(queryOptions) {
@@ -83,23 +83,23 @@ class DuckDBCommon {
83
83
  if (result.length > rowLimit) {
84
84
  result = result.slice(0, rowLimit);
85
85
  }
86
- return { rows: result, totalRows: result.length };
86
+ return { "rows": result, "totalRows": result.length };
87
87
  }
88
88
  async getSQLBlockSchema(sqlRef) {
89
89
  const structDef = {
90
- type: "struct",
91
- dialect: "duckdb",
92
- name: sqlRef.name,
93
- structSource: {
94
- type: "sql",
95
- method: "subquery",
96
- sqlBlock: sqlRef,
90
+ "type": "struct",
91
+ "dialect": "duckdb",
92
+ "name": sqlRef.name,
93
+ "structSource": {
94
+ "type": "sql",
95
+ "method": "subquery",
96
+ "sqlBlock": sqlRef
97
97
  },
98
- structRelationship: {
99
- type: "basetable",
100
- connectionName: this.name,
98
+ "structRelationship": {
99
+ "type": "basetable",
100
+ "connectionName": this.name
101
101
  },
102
- fields: [],
102
+ "fields": []
103
103
  };
104
104
  await this.schemaFromQuery(`DESCRIBE SELECT * FROM (${sqlRef.selectStr})`, structDef);
105
105
  return structDef;
@@ -174,16 +174,16 @@ class DuckDBCommon {
174
174
  if (structMatch && structMatch.groups) {
175
175
  const newTypeMap = this.stringToTypeMap(structMatch.groups["fields"]);
176
176
  const innerStructDef = {
177
- type: "struct",
177
+ "type": "struct",
178
178
  name,
179
- dialect: this.dialectName,
180
- structSource: { type: arrayMatch ? "nested" : "inline" },
181
- structRelationship: {
182
- type: arrayMatch ? "nested" : "inline",
183
- field: name,
184
- isArray: false,
179
+ "dialect": this.dialectName,
180
+ "structSource": { "type": arrayMatch ? "nested" : "inline" },
181
+ "structRelationship": {
182
+ "type": arrayMatch ? "nested" : "inline",
183
+ "field": name,
184
+ "isArray": false
185
185
  },
186
- fields: [],
186
+ "fields": []
187
187
  };
188
188
  this.fillStructDefFromTypeMap(innerStructDef, newTypeMap);
189
189
  structDef.fields.push(innerStructDef);
@@ -192,27 +192,31 @@ class DuckDBCommon {
192
192
  if (arrayMatch) {
193
193
  malloyType = duckDBToMalloyTypes[duckDBType];
194
194
  const innerStructDef = {
195
- type: "struct",
195
+ "type": "struct",
196
196
  name,
197
- dialect: this.dialectName,
198
- structSource: { type: "nested" },
199
- structRelationship: { type: "nested", field: name, isArray: true },
200
- fields: [{ type: malloyType, name: "value" }],
197
+ "dialect": this.dialectName,
198
+ "structSource": { "type": "nested" },
199
+ "structRelationship": {
200
+ "type": "nested",
201
+ "field": name,
202
+ "isArray": true
203
+ },
204
+ "fields": [{ "type": malloyType, "name": "value" }]
201
205
  };
202
206
  structDef.fields.push(innerStructDef);
203
207
  }
204
208
  else {
205
209
  if (malloyType !== undefined) {
206
210
  structDef.fields.push({
207
- type: malloyType,
208
- name,
211
+ "type": malloyType,
212
+ name
209
213
  });
210
214
  }
211
215
  else {
212
216
  structDef.fields.push({
213
217
  name,
214
- type: "string",
215
- e: [`'DuckDB type "${duckDBType}" not supported by Malloy'`],
218
+ "type": "string",
219
+ "e": [`'DuckDB type "${duckDBType}" not supported by Malloy'`]
216
220
  });
217
221
  }
218
222
  }
@@ -233,11 +237,11 @@ class DuckDBCommon {
233
237
  if (!inCache) {
234
238
  try {
235
239
  inCache = {
236
- structDef: await this.getSQLBlockSchema(sqlRef),
240
+ "structDef": await this.getSQLBlockSchema(sqlRef)
237
241
  };
238
242
  }
239
243
  catch (error) {
240
- inCache = { error: error.message };
244
+ inCache = { "error": error.message };
241
245
  }
242
246
  this.sqlSchemaCache.set(key, inCache);
243
247
  }
@@ -251,12 +255,12 @@ class DuckDBCommon {
251
255
  if (!inCache) {
252
256
  try {
253
257
  inCache = {
254
- schema: await this.getTableSchema(tableURL),
258
+ "schema": await this.getTableSchema(tableURL)
255
259
  };
256
260
  this.schemaCache.set(tableURL, inCache);
257
261
  }
258
262
  catch (error) {
259
- inCache = { error: error.message };
263
+ inCache = { "error": error.message };
260
264
  }
261
265
  }
262
266
  if (inCache.schema !== undefined) {
@@ -271,15 +275,15 @@ class DuckDBCommon {
271
275
  async getTableSchema(tableURL) {
272
276
  const { tablePath } = (0, malloy_1.parseTableURI)(tableURL);
273
277
  const structDef = {
274
- type: "struct",
275
- name: tablePath,
276
- dialect: "duckdb",
277
- structSource: { type: "table", tablePath },
278
- structRelationship: {
279
- type: "basetable",
280
- connectionName: this.name,
278
+ "type": "struct",
279
+ "name": tablePath,
280
+ "dialect": "duckdb",
281
+ "structSource": { "type": "table", tablePath },
282
+ "structRelationship": {
283
+ "type": "basetable",
284
+ "connectionName": this.name
281
285
  },
282
- fields: [],
286
+ "fields": []
283
287
  };
284
288
  const quotedTablePath = tablePath.match(/[:*/]/)
285
289
  ? `'${tablePath}'`
@@ -305,6 +309,6 @@ class DuckDBCommon {
305
309
  }
306
310
  exports.DuckDBCommon = DuckDBCommon;
307
311
  DuckDBCommon.DEFAULT_QUERY_OPTIONS = {
308
- rowLimit: 10,
312
+ "rowLimit": 10
309
313
  };
310
314
  //# sourceMappingURL=duckdb_common.js.map
@@ -89,7 +89,7 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
89
89
  else {
90
90
  resolve({
91
91
  rows,
92
- totalRows: rows.length,
92
+ "totalRows": rows.length
93
93
  });
94
94
  }
95
95
  });
@@ -135,7 +135,7 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
135
135
  const workerUrl = isNode()
136
136
  ? bundle.mainWorker
137
137
  : URL.createObjectURL(new Blob([`importScripts("${bundle.mainWorker}");`], {
138
- type: "text/javascript",
138
+ "type": "text/javascript"
139
139
  }));
140
140
  // Instantiate the asynchronous version of DuckDB-wasm
141
141
  this.worker = new web_worker_1.default(workerUrl);
@@ -144,7 +144,7 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
144
144
  await this._database.instantiate(bundle.mainModule, bundle.pthreadWorker);
145
145
  if (this.databasePath) {
146
146
  await this._database.open({
147
- path: this.databasePath,
147
+ "path": this.databasePath
148
148
  });
149
149
  }
150
150
  URL.revokeObjectURL(workerUrl);
@@ -172,7 +172,7 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
172
172
  return {
173
173
  // Normalize the data from its default proxied form
174
174
  rows,
175
- totalRows: table.numRows,
175
+ "totalRows": table.numRows
176
176
  };
177
177
  }
178
178
  else {
@@ -40,14 +40,14 @@ class DuckDBWASMConnection extends duckdb_wasm_connection_1.DuckDBWASMConnection
40
40
  }
41
41
  const dist = distMatch[0];
42
42
  return {
43
- mvp: {
44
- mainModule: `${dist}/duckdb-mvp.wasm`,
45
- mainWorker: `${dist}/duckdb-node-mvp.worker.cjs`,
46
- },
47
- eh: {
48
- mainModule: `${dist}/duckdb-eh.wasm`,
49
- mainWorker: `${dist}/duckdb-node-eh.worker.cjs`,
43
+ "mvp": {
44
+ "mainModule": `${dist}/duckdb-mvp.wasm`,
45
+ "mainWorker": `${dist}/duckdb-node-mvp.worker.cjs`
50
46
  },
47
+ "eh": {
48
+ "mainModule": `${dist}/duckdb-eh.wasm`,
49
+ "mainWorker": `${dist}/duckdb-node-eh.worker.cjs`
50
+ }
51
51
  };
52
52
  }
53
53
  async createHash(sqlCommand) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.22-dev230207180844",
3
+ "version": "0.0.22-dev230207183024",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@duckdb/duckdb-wasm": "^1.20.0",
41
- "@malloydata/malloy": "^0.0.22-dev230207180844",
41
+ "@malloydata/malloy": "^0.0.22-dev230207183024",
42
42
  "duckdb": "0.6.1",
43
43
  "web-worker": "^1.2.0"
44
44
  }