@malloydata/db-duckdb 0.0.11-dev221129185945 → 0.0.11-dev221202180154

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, FetchSchemaAndRunSimultaneously, FetchSchemaAndRunStreamSimultaneously, MalloyQueryData, PersistSQLResults, PooledConnection, RunSQLOptions, SQLBlock, StreamingConnection, StructDef, QueryDataRow } from "@malloydata/malloy";
1
+ import { Connection, MalloyQueryData, PersistSQLResults, PooledConnection, RunSQLOptions, SQLBlock, StreamingConnection, StructDef, QueryDataRow } from "@malloydata/malloy";
2
2
  export interface DuckDBQueryOptions {
3
3
  rowLimit: number;
4
4
  }
@@ -23,10 +23,6 @@ export declare abstract class DuckDBCommon implements Connection, PersistSQLResu
23
23
  }>;
24
24
  runSQL(sql: string, options?: RunSQLOptions): Promise<MalloyQueryData>;
25
25
  abstract runSQLStream(sql: string, _options: RunSQLOptions): AsyncIterableIterator<QueryDataRow>;
26
- runSQLBlockAndFetchResultSchema(sqlBlock: SQLBlock): Promise<{
27
- data: MalloyQueryData;
28
- schema: StructDef;
29
- }>;
30
26
  private getSQLBlockSchema;
31
27
  /**
32
28
  * Split's a structs columns declaration into individual columns
@@ -42,18 +38,19 @@ export declare abstract class DuckDBCommon implements Connection, PersistSQLResu
42
38
  private stringToTypeMap;
43
39
  private fillStructDefFromTypeMap;
44
40
  private schemaFromQuery;
45
- fetchSchemaForSQLBlocks(sqlRefs: SQLBlock[]): Promise<{
46
- schemas: Record<string, StructDef>;
47
- errors: Record<string, string>;
41
+ fetchSchemaForSQLBlock(sqlRef: SQLBlock): Promise<{
42
+ structDef: StructDef;
43
+ error?: undefined;
44
+ } | {
45
+ error: string;
46
+ structDef?: undefined;
48
47
  }>;
49
48
  fetchSchemaForTables(tables: string[]): Promise<{
50
49
  schemas: Record<string, StructDef>;
51
50
  errors: Record<string, string>;
52
51
  }>;
53
52
  private getTableSchema;
54
- canFetchSchemaAndRunSimultaneously(): this is FetchSchemaAndRunSimultaneously;
55
53
  canStream(): this is StreamingConnection;
56
- canFetchSchemaAndRunStreamSimultaneously(): this is FetchSchemaAndRunStreamSimultaneously;
57
54
  test(): Promise<void>;
58
55
  protected abstract createHash(sqlCommand: string): Promise<string>;
59
56
  manifestTemporaryTable(sqlCommand: string): Promise<string>;
@@ -73,11 +73,6 @@ class DuckDBCommon {
73
73
  }
74
74
  return { rows: result, totalRows: result.length };
75
75
  }
76
- async runSQLBlockAndFetchResultSchema(sqlBlock) {
77
- const data = await this.runSQL(sqlBlock.select);
78
- const schema = (await this.fetchSchemaForSQLBlocks([sqlBlock])).schemas[sqlBlock.name];
79
- return { data, schema };
80
- }
81
76
  async getSQLBlockSchema(sqlRef) {
82
77
  const structDef = {
83
78
  type: "struct",
@@ -94,7 +89,7 @@ class DuckDBCommon {
94
89
  },
95
90
  fields: [],
96
91
  };
97
- await this.schemaFromQuery(`DESCRIBE SELECT * FROM (${sqlRef.select})`, structDef);
92
+ await this.schemaFromQuery(`DESCRIBE SELECT * FROM (${sqlRef.selectStr})`, structDef);
98
93
  return structDef;
99
94
  }
100
95
  /**
@@ -220,18 +215,13 @@ class DuckDBCommon {
220
215
  }
221
216
  this.fillStructDefFromTypeMap(structDef, typeMap);
222
217
  }
223
- async fetchSchemaForSQLBlocks(sqlRefs) {
224
- const schemas = {};
225
- const errors = {};
226
- for (const sqlRef of sqlRefs) {
227
- try {
228
- schemas[sqlRef.name] = await this.getSQLBlockSchema(sqlRef);
229
- }
230
- catch (error) {
231
- errors[sqlRef.name] = error;
232
- }
218
+ async fetchSchemaForSQLBlock(sqlRef) {
219
+ try {
220
+ return { structDef: await this.getSQLBlockSchema(sqlRef) };
221
+ }
222
+ catch (error) {
223
+ return { error: error.message };
233
224
  }
234
- return { schemas, errors };
235
225
  }
236
226
  async fetchSchemaForTables(tables) {
237
227
  const schemas = {};
@@ -266,15 +256,9 @@ class DuckDBCommon {
266
256
  await this.schemaFromQuery(infoQuery, structDef);
267
257
  return structDef;
268
258
  }
269
- canFetchSchemaAndRunSimultaneously() {
270
- return false;
271
- }
272
259
  canStream() {
273
260
  return true;
274
261
  }
275
- canFetchSchemaAndRunStreamSimultaneously() {
276
- return false;
277
- }
278
262
  async test() {
279
263
  await this.runRawSQL("SELECT 1");
280
264
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.11-dev221129185945",
3
+ "version": "0.0.11-dev221202180154",
4
4
  "license": "GPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@duckdb/duckdb-wasm": "^1.17.0",
22
- "@malloydata/malloy": "^0.0.11-dev221129185945",
22
+ "@malloydata/malloy": "^0.0.11-dev221202180154",
23
23
  "duckdb": "0.5.1"
24
24
  }
25
25
  }