@malloydata/db-trino 0.0.165-dev240813192511 → 0.0.165-dev240813215510
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,5 @@
|
|
|
1
|
-
import { Connection, ConnectionConfig, FetchSchemaOptions, MalloyQueryData, FieldAtomicTypeDef, PersistSQLResults,
|
|
1
|
+
import { Connection, ConnectionConfig, FetchSchemaOptions, MalloyQueryData, FieldAtomicTypeDef, PersistSQLResults, QueryData, QueryOptionsReader, QueryRunStats, RunSQLOptions, SQLBlock, StructDef } from '@malloydata/malloy';
|
|
2
|
+
import { BaseConnection } from '@malloydata/malloy/connection';
|
|
2
3
|
export interface TrinoManagerOptions {
|
|
3
4
|
credentials?: {
|
|
4
5
|
clientId: string;
|
|
@@ -17,7 +18,7 @@ export interface TrinoConnectionConfiguration {
|
|
|
17
18
|
password?: string;
|
|
18
19
|
}
|
|
19
20
|
export type TrinoConnectionOptions = ConnectionConfig;
|
|
20
|
-
export interface
|
|
21
|
+
export interface BaseRunner {
|
|
21
22
|
runSQL(sql: string, limit: number | undefined): Promise<{
|
|
22
23
|
rows: unknown[][];
|
|
23
24
|
columns: {
|
|
@@ -28,7 +29,7 @@ export interface BaseConnection {
|
|
|
28
29
|
error?: string;
|
|
29
30
|
}>;
|
|
30
31
|
}
|
|
31
|
-
export declare abstract class TrinoPrestoConnection implements Connection, PersistSQLResults {
|
|
32
|
+
export declare abstract class TrinoPrestoConnection extends BaseConnection implements Connection, PersistSQLResults {
|
|
32
33
|
trinoToMalloyTypes: {
|
|
33
34
|
[key: string]: FieldAtomicTypeDef;
|
|
34
35
|
};
|
|
@@ -43,9 +44,7 @@ export declare abstract class TrinoPrestoConnection implements Connection, Persi
|
|
|
43
44
|
constructor(name: string, queryOptions?: QueryOptionsReader, pConfig?: TrinoConnectionConfiguration);
|
|
44
45
|
get dialectName(): string;
|
|
45
46
|
private readQueryOptions;
|
|
46
|
-
isPool(): this is PooledConnection;
|
|
47
47
|
canPersist(): this is PersistSQLResults;
|
|
48
|
-
canStream(): this is StreamingConnection;
|
|
49
48
|
get supportsNesting(): boolean;
|
|
50
49
|
manifestTemporaryTable(_sqlCommand: string): Promise<string>;
|
|
51
50
|
unpackArray(data: unknown): unknown[];
|
package/dist/trino_connection.js
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.TrinoConnection = exports.PrestoConnection = exports.TrinoPrestoConnection = void 0;
|
|
26
26
|
const malloy_1 = require("@malloydata/malloy");
|
|
27
|
+
const connection_1 = require("@malloydata/malloy/connection");
|
|
27
28
|
const presto_js_client_1 = require("@prestodb/presto-js-client");
|
|
28
29
|
const crypto_1 = require("crypto");
|
|
29
30
|
const trino_client_1 = require("trino-client");
|
|
30
|
-
class
|
|
31
|
+
class PrestoRunner {
|
|
31
32
|
constructor(config) {
|
|
32
33
|
this.client = new presto_js_client_1.PrestoClient({
|
|
33
34
|
catalog: config.catalog,
|
|
@@ -60,7 +61,7 @@ class PrestoBase {
|
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
class
|
|
64
|
+
class TrinoRunner {
|
|
64
65
|
constructor(config) {
|
|
65
66
|
this.client = trino_client_1.Trino.create({
|
|
66
67
|
catalog: config.catalog,
|
|
@@ -102,7 +103,7 @@ class TrinooBase {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
// manage access to BQ, control costs, enforce global data/API limits
|
|
105
|
-
class TrinoPrestoConnection {
|
|
106
|
+
class TrinoPrestoConnection extends connection_1.BaseConnection {
|
|
106
107
|
sqlToMalloyType(sqlType) {
|
|
107
108
|
var _a, _b;
|
|
108
109
|
const baseSqlType = (_b = (_a = sqlType.match(/^(\w+)/)) === null || _a === void 0 ? void 0 : _a.at(0)) !== null && _b !== void 0 ? _b : sqlType;
|
|
@@ -112,6 +113,7 @@ class TrinoPrestoConnection {
|
|
|
112
113
|
return undefined;
|
|
113
114
|
}
|
|
114
115
|
constructor(name, queryOptions, pConfig) {
|
|
116
|
+
super();
|
|
115
117
|
this.trinoToMalloyTypes = {
|
|
116
118
|
'varchar': { type: 'string' },
|
|
117
119
|
'integer': { type: 'number', numberType: 'integer' },
|
|
@@ -144,10 +146,10 @@ class TrinoPrestoConnection {
|
|
|
144
146
|
const config = pConfig || {};
|
|
145
147
|
this.name = name;
|
|
146
148
|
if (name === 'trino') {
|
|
147
|
-
this.client = new
|
|
149
|
+
this.client = new TrinoRunner(config);
|
|
148
150
|
}
|
|
149
151
|
else {
|
|
150
|
-
this.client = new
|
|
152
|
+
this.client = new PrestoRunner(config);
|
|
151
153
|
}
|
|
152
154
|
this.queryOptions = queryOptions;
|
|
153
155
|
//this.config = config;
|
|
@@ -169,15 +171,9 @@ class TrinoPrestoConnection {
|
|
|
169
171
|
return options;
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
|
-
isPool() {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
174
|
canPersist() {
|
|
176
175
|
return true;
|
|
177
176
|
}
|
|
178
|
-
canStream() {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
177
|
get supportsNesting() {
|
|
182
178
|
return true;
|
|
183
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-trino",
|
|
3
|
-
"version": "0.0.165-
|
|
3
|
+
"version": "0.0.165-dev240813215510",
|
|
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.165-
|
|
25
|
+
"@malloydata/malloy": "^0.0.165-dev240813215510",
|
|
26
26
|
"@prestodb/presto-js-client": "^1.0.0",
|
|
27
27
|
"gaxios": "^4.2.0",
|
|
28
28
|
"trino-client": "^0.2.2"
|