@malloydata/db-trino 0.0.235-dev250207190835 → 0.0.235-dev250207191238

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, Dialect, FieldDef } from '@malloydata/malloy';
1
+ import { ConnectionConfig, MalloyQueryData, PersistSQLResults, QueryData, QueryOptionsReader, QueryRunStats, RunSQLOptions, TrinoDialect, StructDef, TableSourceDef, SQLSourceDef, AtomicTypeDef, Dialect, FieldDef, TestableConnection } from '@malloydata/malloy';
2
2
  import { BaseConnection } from '@malloydata/malloy/connection';
3
3
  export interface TrinoManagerOptions {
4
4
  credentials?: {
@@ -29,7 +29,7 @@ export interface BaseRunner {
29
29
  error?: string;
30
30
  }>;
31
31
  }
32
- export declare abstract class TrinoPrestoConnection extends BaseConnection implements Connection, PersistSQLResults {
32
+ export declare abstract class TrinoPrestoConnection extends BaseConnection implements TestableConnection, PersistSQLResults {
33
33
  name: string;
34
34
  private client;
35
35
  private queryOptions?;
@@ -65,6 +65,7 @@ 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
+ get dialectName(): string;
68
69
  static schemaFromExplain(explainResult: MalloyQueryData, structDef: StructDef, dialect: Dialect): void;
69
70
  protected fillStructDefForSqlBlockSchema(sql: string, structDef: StructDef): Promise<void>;
70
71
  unpackArray(_fields: FieldDef[], data: unknown): unknown[];
@@ -72,5 +73,6 @@ export declare class PrestoConnection extends TrinoPrestoConnection {
72
73
  export declare class TrinoConnection extends TrinoPrestoConnection {
73
74
  constructor(name: string, queryOptions?: QueryOptionsReader, config?: TrinoConnectionConfiguration);
74
75
  constructor(option: TrinoConnectionOptions, queryOptions?: QueryOptionsReader);
76
+ get dialectName(): string;
75
77
  protected fillStructDefForSqlBlockSchema(sql: string, structDef: StructDef): Promise<void>;
76
78
  }
@@ -30,7 +30,7 @@ const crypto_1 = require("crypto");
30
30
  const trino_client_1 = require("trino-client");
31
31
  class PrestoRunner {
32
32
  constructor(config) {
33
- this.client = new presto_js_client_1.PrestoClient({
33
+ const prestoClientConfig = {
34
34
  catalog: config.catalog,
35
35
  host: config.server,
36
36
  port: config.port,
@@ -38,7 +38,14 @@ class PrestoRunner {
38
38
  timezone: 'America/Costa_Rica',
39
39
  user: config.user || 'anyone',
40
40
  extraHeaders: { 'X-Presto-Session': 'legacy_unnest=true' },
41
- });
41
+ };
42
+ if (config.user && config.password) {
43
+ prestoClientConfig.basicAuthentication = {
44
+ user: config.user,
45
+ password: config.password,
46
+ };
47
+ }
48
+ this.client = new presto_js_client_1.PrestoClient(prestoClientConfig);
42
49
  }
43
50
  async runSQL(sql, limit, _abortSignal) {
44
51
  let ret = undefined;
@@ -296,7 +303,7 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
296
303
  throw new Error('Not implemented 7');
297
304
  }
298
305
  async test() {
299
- // await this.dryRunSQLQuery('SELECT 1');
306
+ await this.runSQL('SELECT 1');
300
307
  }
301
308
  async close() {
302
309
  return;
@@ -310,6 +317,9 @@ class PrestoConnection extends TrinoPrestoConnection {
310
317
  constructor(arg, queryOptions, config = {}) {
311
318
  super(typeof arg === 'string' ? arg : arg.name, new PrestoRunner(config), queryOptions);
312
319
  }
320
+ get dialectName() {
321
+ return 'presto';
322
+ }
313
323
  static schemaFromExplain(explainResult, structDef, dialect) {
314
324
  if (explainResult.rows.length === 0) {
315
325
  throw new Error('Received empty explain result when trying to fetch schema.');
@@ -339,6 +349,9 @@ class TrinoConnection extends TrinoPrestoConnection {
339
349
  constructor(arg, queryOptions, config = {}) {
340
350
  super(typeof arg === 'string' ? arg : arg.name, new TrinoRunner(config), queryOptions);
341
351
  }
352
+ get dialectName() {
353
+ return 'trino';
354
+ }
342
355
  async fillStructDefForSqlBlockSchema(sql, structDef) {
343
356
  const tmpQueryName = `myMalloyQuery${(0, crypto_1.randomUUID)().replace(/-/g, '')}`;
344
357
  await this.executeAndWait(`PREPARE ${tmpQueryName} FROM ${sql}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-trino",
3
- "version": "0.0.235-dev250207190835",
3
+ "version": "0.0.235-dev250207191238",
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.235-dev250207190835",
25
+ "@malloydata/malloy": "^0.0.235-dev250207191238",
26
26
  "@prestodb/presto-js-client": "^1.0.0",
27
27
  "gaxios": "^4.2.0",
28
28
  "trino-client": "^0.2.2"