@malloydata/db-duckdb 0.0.49-dev230626172855 → 0.0.49-dev230626201111

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.
@@ -48,7 +48,7 @@ export declare abstract class DuckDBCommon implements TestableConnection, Persis
48
48
  error: string;
49
49
  structDef?: undefined;
50
50
  }>;
51
- fetchSchemaForTables(tables: string[]): Promise<{
51
+ fetchSchemaForTables(tables: Record<string, string>): Promise<{
52
52
  schemas: Record<string, StructDef>;
53
53
  errors: Record<string, string>;
54
54
  }>;
@@ -23,7 +23,6 @@
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.DuckDBCommon = void 0;
26
- const malloy_1 = require("@malloydata/malloy");
27
26
  const duckDBToMalloyTypes = {
28
27
  'BIGINT': 'number',
29
28
  'INTEGER': 'number',
@@ -266,33 +265,33 @@ class DuckDBCommon {
266
265
  async fetchSchemaForTables(tables) {
267
266
  const schemas = {};
268
267
  const errors = {};
269
- for (const tableURL of tables) {
270
- let inCache = this.schemaCache.get(tableURL);
268
+ for (const tableKey in tables) {
269
+ let inCache = this.schemaCache.get(tableKey);
271
270
  if (!inCache) {
271
+ const tablePath = tables[tableKey];
272
272
  try {
273
273
  inCache = {
274
- schema: await this.getTableSchema(tableURL),
274
+ schema: await this.getTableSchema(tableKey, tablePath),
275
275
  };
276
- this.schemaCache.set(tableURL, inCache);
276
+ this.schemaCache.set(tableKey, inCache);
277
277
  }
278
278
  catch (error) {
279
279
  inCache = { error: error.message };
280
280
  }
281
281
  }
282
282
  if (inCache.schema !== undefined) {
283
- schemas[tableURL] = inCache.schema;
283
+ schemas[tableKey] = inCache.schema;
284
284
  }
285
285
  else {
286
- errors[tableURL] = inCache.error || 'Unknown schema fetch error';
286
+ errors[tableKey] = inCache.error || 'Unknown schema fetch error';
287
287
  }
288
288
  }
289
289
  return { schemas, errors };
290
290
  }
291
- async getTableSchema(tableURL) {
292
- const { tablePath } = (0, malloy_1.parseTableURI)(tableURL);
291
+ async getTableSchema(tableKey, tablePath) {
293
292
  const structDef = {
294
293
  type: 'struct',
295
- name: tablePath,
294
+ name: tableKey,
296
295
  dialect: 'duckdb',
297
296
  structSource: { type: 'table', tablePath },
298
297
  structRelationship: {
@@ -33,7 +33,7 @@ export declare abstract class DuckDBWASMConnection extends DuckDBCommon {
33
33
  error: string;
34
34
  structDef?: undefined;
35
35
  }>;
36
- fetchSchemaForTables(tableUris: string[]): Promise<{
36
+ fetchSchemaForTables(missing: Record<string, string>): Promise<{
37
37
  schemas: Record<string, StructDef>;
38
38
  errors: Record<string, string>;
39
39
  }>;
@@ -51,7 +51,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
51
51
  exports.DuckDBWASMConnection = void 0;
52
52
  const duckdb = __importStar(require("@malloydata/duckdb-wasm"));
53
53
  const web_worker_1 = __importDefault(require("web-worker"));
54
- const malloy_1 = require("@malloydata/malloy");
55
54
  const apache_arrow_1 = require("apache-arrow");
56
55
  const duckdb_common_1 = require("./duckdb_common");
57
56
  const TABLE_MATCH = /FROM\s*('([^']*)'|"([^"]*)")/gi;
@@ -267,13 +266,10 @@ class DuckDBWASMConnection extends duckdb_common_1.DuckDBCommon {
267
266
  await this.findTables(tables);
268
267
  return super.fetchSchemaForSQLBlock(sqlRef);
269
268
  }
270
- async fetchSchemaForTables(tableUris) {
271
- const tables = tableUris.map(tableUri => {
272
- const { tablePath } = (0, malloy_1.parseTableURI)(tableUri);
273
- return tablePath;
274
- });
269
+ async fetchSchemaForTables(missing) {
270
+ const tables = Object.values(missing);
275
271
  await this.findTables(tables);
276
- return super.fetchSchemaForTables(tableUris);
272
+ return super.fetchSchemaForTables(missing);
277
273
  }
278
274
  async close() {
279
275
  if (this._connection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.49-dev230626172855",
3
+ "version": "0.0.49-dev230626201111",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@malloydata/duckdb-wasm": "0.0.2",
44
- "@malloydata/malloy": "^0.0.49-dev230626172855",
44
+ "@malloydata/malloy": "^0.0.49-dev230626201111",
45
45
  "apache-arrow": "^11.0.0",
46
46
  "duckdb": "0.8.1",
47
47
  "web-worker": "^1.2.0"