@malloydata/db-trino 0.0.138-dev240402185231 → 0.0.138-dev240402220928
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.
|
@@ -59,6 +59,7 @@ export declare class TrinoConnection implements Connection, PersistSQLResults {
|
|
|
59
59
|
}>;
|
|
60
60
|
private structDefFromSqlBlock;
|
|
61
61
|
private executeAndWait;
|
|
62
|
+
private splitColumns;
|
|
62
63
|
malloyTypeFromTrinoType(name: string, trinoType: string): FieldAtomicTypeDef | StructDef;
|
|
63
64
|
structDefFromSchema(rows: string[][], structDef: StructDef): void;
|
|
64
65
|
private loadSchemaForSqlBlock;
|
package/dist/trino_connection.js
CHANGED
|
@@ -340,6 +340,37 @@ class TrinoConnection {
|
|
|
340
340
|
while (!(await result.next()).done)
|
|
341
341
|
;
|
|
342
342
|
}
|
|
343
|
+
splitColumns(s) {
|
|
344
|
+
const columns = [];
|
|
345
|
+
let parens = 0;
|
|
346
|
+
let column = '';
|
|
347
|
+
let eatSpaces = true;
|
|
348
|
+
for (let idx = 0; idx < s.length; idx++) {
|
|
349
|
+
const c = s.charAt(idx);
|
|
350
|
+
if (eatSpaces && c === ' ') {
|
|
351
|
+
// Eat space
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
eatSpaces = false;
|
|
355
|
+
if (!parens && c === ',') {
|
|
356
|
+
columns.push(column);
|
|
357
|
+
column = '';
|
|
358
|
+
eatSpaces = true;
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
column += c;
|
|
362
|
+
}
|
|
363
|
+
if (c === '(') {
|
|
364
|
+
parens += 1;
|
|
365
|
+
}
|
|
366
|
+
else if (c === ')') {
|
|
367
|
+
parens -= 1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
columns.push(column);
|
|
372
|
+
return columns;
|
|
373
|
+
}
|
|
343
374
|
malloyTypeFromTrinoType(name, trinoType) {
|
|
344
375
|
var _a;
|
|
345
376
|
let malloyType;
|
|
@@ -377,7 +408,7 @@ class TrinoConnection {
|
|
|
377
408
|
// TODO: Trino doesn't quote or escape commas in field names,
|
|
378
409
|
// so some magic is going to need to be applied before we get here
|
|
379
410
|
// to avoid confusion if a field name contains a comma
|
|
380
|
-
const innerTypes = structMatch[1]
|
|
411
|
+
const innerTypes = this.splitColumns(structMatch[1]);
|
|
381
412
|
malloyType = {
|
|
382
413
|
type: 'struct',
|
|
383
414
|
name,
|