@malloydata/db-trino 0.0.230-dev250116214420 → 0.0.230-dev250116221349

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, ConnectionConfig, MalloyQueryData, PersistSQLResults, QueryData, QueryOptionsReader, QueryRunStats, RunSQLOptions, TrinoDialect, StructDef, TableSourceDef, SQLSourceDef, AtomicTypeDef, FieldDef } from '@malloydata/malloy';
1
+ import { Connection, ConnectionConfig, MalloyQueryData, PersistSQLResults, QueryData, QueryOptionsReader, QueryRunStats, RunSQLOptions, TrinoDialect, StructDef, TableSourceDef, SQLSourceDef, AtomicTypeDef, Dialect, FieldDef } from '@malloydata/malloy';
2
2
  import { BaseConnection } from '@malloydata/malloy/connection';
3
3
  export interface TrinoManagerOptions {
4
4
  credentials?: {
@@ -65,8 +65,8 @@ export declare abstract class TrinoPrestoConnection extends BaseConnection imple
65
65
  export declare class PrestoConnection extends TrinoPrestoConnection {
66
66
  constructor(name: string, queryOptions?: QueryOptionsReader, config?: TrinoConnectionConfiguration);
67
67
  constructor(option: TrinoConnectionOptions, queryOptions?: QueryOptionsReader);
68
+ static schemaFromExplain(explainResult: MalloyQueryData, structDef: StructDef, dialect: Dialect): void;
68
69
  protected fillStructDefForSqlBlockSchema(sql: string, structDef: StructDef): Promise<void>;
69
- protected schemaFromExplain(explainResult: MalloyQueryData, structDef: StructDef): void;
70
70
  unpackArray(data: unknown): unknown[];
71
71
  }
72
72
  export declare class TrinoConnection extends TrinoPrestoConnection {
@@ -310,11 +310,7 @@ class PrestoConnection extends TrinoPrestoConnection {
310
310
  constructor(arg, queryOptions, config = {}) {
311
311
  super(typeof arg === 'string' ? arg : arg.name, new PrestoRunner(config), queryOptions);
312
312
  }
313
- async fillStructDefForSqlBlockSchema(sql, structDef) {
314
- const explainResult = await this.runSQL(`EXPLAIN ${sql}`, {});
315
- this.schemaFromExplain(explainResult, structDef);
316
- }
317
- schemaFromExplain(explainResult, structDef) {
313
+ static schemaFromExplain(explainResult, structDef, dialect) {
318
314
  if (explainResult.rows.length === 0) {
319
315
  throw new Error('Received empty explain result when trying to fetch schema.');
320
316
  }
@@ -327,9 +323,13 @@ class PrestoConnection extends TrinoPrestoConnection {
327
323
  if ((lines === null || lines === void 0 ? void 0 : lines.length) === 0) {
328
324
  throw new Error('Received invalid explain result when trying to fetch schema.');
329
325
  }
330
- const schemaDesc = new TrinoPrestoSchemaParser(lines[0], this.dialect);
326
+ const schemaDesc = new TrinoPrestoSchemaParser(lines[0], dialect);
331
327
  structDef.fields = schemaDesc.parseQueryPlan();
332
328
  }
329
+ async fillStructDefForSqlBlockSchema(sql, structDef) {
330
+ const explainResult = await this.runSQL(`EXPLAIN ${sql}`, {});
331
+ PrestoConnection.schemaFromExplain(explainResult, structDef, this.dialect);
332
+ }
333
333
  unpackArray(data) {
334
334
  return JSON.parse(data);
335
335
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-trino",
3
- "version": "0.0.230-dev250116214420",
3
+ "version": "0.0.230-dev250116221349",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "dependencies": {
25
- "@malloydata/malloy": "^0.0.230-dev250116214420",
25
+ "@malloydata/malloy": "^0.0.230-dev250116221349",
26
26
  "@prestodb/presto-js-client": "^1.0.0",
27
27
  "gaxios": "^4.2.0",
28
28
  "trino-client": "^0.2.2"