@malloydata/db-trino 0.0.424 → 0.0.426

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.
@@ -24,7 +24,7 @@ export interface TrinoConnectionConfiguration {
24
24
  }
25
25
  export type TrinoConnectionOptions = ConnectionConfig;
26
26
  export interface BaseRunner {
27
- runSQL(sql: string, options: RunSQLOptions): Promise<{
27
+ runSQL(sql: string, options: RunSQLOptions, queryMetadataComment?: string): Promise<{
28
28
  rows: unknown[][];
29
29
  columns: {
30
30
  name: string;
@@ -31,11 +31,12 @@ class PrestoRunner {
31
31
  }
32
32
  this.client = new presto_js_client_1.PrestoClient(prestoClientConfig);
33
33
  }
34
- async runSQL(sql, options = {}) {
34
+ async runSQL(sql, options = {}, queryMetadataComment = '') {
35
35
  let ret = undefined;
36
- const q = options.rowLimit
37
- ? `SELECT * FROM(${sql}) LIMIT ${options.rowLimit}`
38
- : sql;
36
+ const q = queryMetadataComment +
37
+ (options.rowLimit
38
+ ? `SELECT * FROM(${sql}) LIMIT ${options.rowLimit}`
39
+ : sql);
39
40
  let error = undefined;
40
41
  try {
41
42
  ret = (await this.client.query(q)) || [];
@@ -79,9 +80,9 @@ class TrinoRunner {
79
80
  auth: new trino_client_1.BasicAuth(config.user, config.password || ''),
80
81
  });
81
82
  }
82
- async runSQL(sql, options = {}) {
83
+ async runSQL(sql, options = {}, queryMetadataComment = '') {
83
84
  var _a;
84
- const result = await this.client.query(sql);
85
+ const result = await this.client.query(queryMetadataComment + sql);
85
86
  let queryResult = await result.next();
86
87
  if (queryResult.value.error) {
87
88
  return {
@@ -180,7 +181,7 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
180
181
  // TODO(figutierrez): Use.
181
182
  _rowIndex = 0) {
182
183
  await this.ensureSetup();
183
- const r = await this.client.runSQL(sqlCommand, options);
184
+ const r = await this.client.runSQL(sqlCommand, options, this.queryMetadataComment(options.queryMetadata));
184
185
  if (r.error) {
185
186
  throw new Error(r.error);
186
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-trino",
3
- "version": "0.0.424",
3
+ "version": "0.0.426",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "dependencies": {
26
- "@malloydata/malloy": "0.0.424",
26
+ "@malloydata/malloy": "0.0.426",
27
27
  "@prestodb/presto-js-client": "^1.1.0",
28
28
  "gaxios": "^4.2.0",
29
29
  "luxon": "^3.7.2",