@malloydata/db-trino 0.0.322 → 0.0.324
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.
- package/dist/test.nonspec.js +1 -1
- package/dist/trino_connection.js +21 -3
- package/package.json +6 -2
package/dist/test.nonspec.js
CHANGED
package/dist/trino_connection.js
CHANGED
|
@@ -28,6 +28,7 @@ const connection_1 = require("@malloydata/malloy/connection");
|
|
|
28
28
|
const presto_js_client_1 = require("@prestodb/presto-js-client");
|
|
29
29
|
const crypto_1 = require("crypto");
|
|
30
30
|
const trino_client_1 = require("trino-client");
|
|
31
|
+
const luxon_1 = require("luxon");
|
|
31
32
|
class PrestoRunner {
|
|
32
33
|
constructor(config) {
|
|
33
34
|
const prestoClientConfig = {
|
|
@@ -35,7 +36,7 @@ class PrestoRunner {
|
|
|
35
36
|
host: config.server,
|
|
36
37
|
port: config.port,
|
|
37
38
|
schema: config.schema,
|
|
38
|
-
timezone: '
|
|
39
|
+
timezone: 'UTC',
|
|
39
40
|
user: config.user || 'anyone',
|
|
40
41
|
extraHeaders: { 'X-Presto-Session': 'legacy_unnest=true' },
|
|
41
42
|
};
|
|
@@ -224,9 +225,24 @@ class TrinoPrestoConnection extends connection_1.BaseConnection {
|
|
|
224
225
|
// decimal numbers come back as strings
|
|
225
226
|
return Number(rawRow);
|
|
226
227
|
}
|
|
227
|
-
else if (colSchema.type === 'timestamp'
|
|
228
|
+
else if ((colSchema.type === 'timestamp' || colSchema.type === 'timestamptz') &&
|
|
229
|
+
typeof rawRow === 'string') {
|
|
228
230
|
// timestamps come back as strings
|
|
229
|
-
|
|
231
|
+
if (colSchema.type === 'timestamptz') {
|
|
232
|
+
// TIMESTAMP WITH TIME ZONE format: "2020-02-20 00:00:00 America/Mexico_City"
|
|
233
|
+
const trinoTzPattern = /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)?) (.+)$/;
|
|
234
|
+
const match = rawRow.match(trinoTzPattern);
|
|
235
|
+
if (match) {
|
|
236
|
+
const [, dateTimePart, tzName] = match;
|
|
237
|
+
// Use Luxon to parse with timezone awareness
|
|
238
|
+
const dt = luxon_1.DateTime.fromSQL(dateTimePart, { zone: tzName });
|
|
239
|
+
if (dt.isValid) {
|
|
240
|
+
return dt.toJSDate();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// For plain timestamps, Trino returns UTC values - append 'Z' to parse as UTC
|
|
245
|
+
return new Date(rawRow + 'Z');
|
|
230
246
|
}
|
|
231
247
|
else {
|
|
232
248
|
return rawRow;
|
|
@@ -492,7 +508,9 @@ class TrinoPrestoSchemaParser extends malloy_1.TinyParser {
|
|
|
492
508
|
}
|
|
493
509
|
if (this.peek().text === 'with') {
|
|
494
510
|
this.nextText('with', 'time', 'zone');
|
|
511
|
+
return { type: 'timestamptz' };
|
|
495
512
|
}
|
|
513
|
+
return { type: 'timestamp' };
|
|
496
514
|
}
|
|
497
515
|
const typeDef = this.dialect.sqlTypeToMalloyType(sqlType);
|
|
498
516
|
if (typeDef.type === 'number' && sqlType === 'decimal') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-trino",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.324",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,11 +22,15 @@
|
|
|
22
22
|
"prepublishOnly": "npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@malloydata/malloy": "0.0.
|
|
25
|
+
"@malloydata/malloy": "0.0.324",
|
|
26
26
|
"@prestodb/presto-js-client": "^1.0.0",
|
|
27
27
|
"gaxios": "^4.2.0",
|
|
28
|
+
"luxon": "^3.5.0",
|
|
28
29
|
"trino-client": "^0.2.2"
|
|
29
30
|
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/luxon": "^3.5.0"
|
|
33
|
+
},
|
|
30
34
|
"description": "Malloy is a modern open source language for describing data relationships and transformations. It is both a semantic modeling language and a querying language that runs queries against a relational database. Malloy currently connects to BigQuery and Postgres, and natively supports DuckDB. We've built a Visual Studio Code extension to facilitate building Malloy data models, querying and transforming data, and creating simple visualizations and dashboards.",
|
|
31
35
|
"bugs": {
|
|
32
36
|
"url": "https://github.com/malloydata/malloy/issues"
|