@malloydata/db-trino 0.0.273 → 0.0.274

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.
@@ -22,7 +22,7 @@ export interface TrinoConnectionConfiguration {
22
22
  }
23
23
  export type TrinoConnectionOptions = ConnectionConfig;
24
24
  export interface BaseRunner {
25
- runSQL(sql: string, limit: number | undefined, abortSignal?: AbortSignal): Promise<{
25
+ runSQL(sql: string, options: RunSQLOptions): Promise<{
26
26
  rows: unknown[][];
27
27
  columns: {
28
28
  name: string;
@@ -47,9 +47,11 @@ class PrestoRunner {
47
47
  }
48
48
  this.client = new presto_js_client_1.PrestoClient(prestoClientConfig);
49
49
  }
50
- async runSQL(sql, limit, _abortSignal) {
50
+ async runSQL(sql, options = {}) {
51
51
  let ret = undefined;
52
- const q = limit ? `SELECT * FROM(${sql}) LIMIT ${limit}` : sql;
52
+ const q = options.rowLimit
53
+ ? `SELECT * FROM(${sql}) LIMIT ${options.rowLimit}`
54
+ : sql;
53
55
  let error = undefined;
54
56
  try {
55
57
  ret = (await this.client.query(q)) || [];
@@ -78,7 +80,7 @@ class TrinoRunner {
78
80
  auth: new trino_client_1.BasicAuth(config.user, config.password || ''),
79
81
  });
80
82
  }
81
- async runSQL(sql, limit, _abortSignal) {
83
+ async runSQL(sql, options = {}) {
82
84
  var _a;
83
85
  const result = await this.client.query(sql);
84
86
  let queryResult = await result.next();
@@ -91,10 +93,11 @@ class TrinoRunner {
91
93
  }
92
94
  const columns = queryResult.value.columns;
93
95
  const outputRows = [];
94
- while (queryResult !== null && (!limit || outputRows.length < limit)) {
96
+ while (queryResult !== null &&
97
+ (!options.rowLimit || outputRows.length < options.rowLimit)) {
95
98
  const rows = (_a = queryResult.value.data) !== null && _a !== void 0 ? _a : [];
96
99
  for (const row of rows) {
97
- if (!limit || outputRows.length < limit) {
100
+ if (!options.rowLimit || outputRows.length < options.rowLimit) {
98
101
  outputRows.push(row);
99
102
  }
100
103
  }
@@ -184,7 +187,7 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
184
187
  async runSQL(sqlCommand, options = {},
185
188
  // TODO(figutierrez): Use.
186
189
  _rowIndex = 0) {
187
- const r = await this.client.runSQL(sqlCommand, options.rowLimit, options.abortSignal);
190
+ const r = await this.client.runSQL(sqlCommand, options);
188
191
  if (r.error) {
189
192
  throw new Error(r.error);
190
193
  }
@@ -258,7 +261,7 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
258
261
  return structDef;
259
262
  }
260
263
  async executeAndWait(sqlBlock) {
261
- await this.client.runSQL(sqlBlock, undefined);
264
+ await this.client.runSQL(sqlBlock, {});
262
265
  // TODO: make sure failure is handled correctly.
263
266
  //while (!(await result.next()).done);
264
267
  }
@@ -277,7 +280,7 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
277
280
  async loadSchemaForSqlBlock(sqlBlock, structDef, element) {
278
281
  var _a;
279
282
  try {
280
- const queryResult = await this.client.runSQL(sqlBlock, undefined);
283
+ const queryResult = await this.client.runSQL(sqlBlock, {});
281
284
  if (queryResult.error) {
282
285
  // TODO: handle.
283
286
  throw new Error(queryResult.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-trino",
3
- "version": "0.0.273",
3
+ "version": "0.0.274",
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.273",
25
+ "@malloydata/malloy": "0.0.274",
26
26
  "@prestodb/presto-js-client": "^1.0.0",
27
27
  "gaxios": "^4.2.0",
28
28
  "trino-client": "^0.2.2"