@malloydata/malloy 0.0.149 → 0.0.150
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.
|
@@ -57,6 +57,7 @@ export declare abstract class Dialect {
|
|
|
57
57
|
supportsComplexFilteredSources: boolean;
|
|
58
58
|
supportsTempTables: boolean;
|
|
59
59
|
hasModOperator: boolean;
|
|
60
|
+
supportsLeftJoinUnnest: boolean;
|
|
60
61
|
abstract getGlobalFunctionDef(name: string): DialectFunctionOverloadDef[] | undefined;
|
|
61
62
|
abstract quoteTablePath(tablePath: string): string;
|
|
62
63
|
abstract sqlGroupSetTable(groupSetCount: number): string;
|
package/dist/dialect/dialect.js
CHANGED
|
@@ -79,6 +79,8 @@ class Dialect {
|
|
|
79
79
|
// can create temp tables
|
|
80
80
|
this.supportsTempTables = true;
|
|
81
81
|
this.hasModOperator = true;
|
|
82
|
+
// can LEFT JOIN UNNEST
|
|
83
|
+
this.supportsLeftJoinUnnest = true;
|
|
82
84
|
}
|
|
83
85
|
sqlFinalStage(_lastStageName, _fields) {
|
|
84
86
|
throw new Error('Dialect has no final Stage but called Anyway');
|
|
@@ -29,8 +29,8 @@ function fnLog() {
|
|
|
29
29
|
const base = (0, util_1.makeParam)('base', (0, util_1.anyExprType)('number'));
|
|
30
30
|
return [
|
|
31
31
|
(0, util_1.overload)((0, util_1.minScalar)('number'), [value.param, base.param],
|
|
32
|
-
//
|
|
33
|
-
(0, util_1.sql) `
|
|
32
|
+
// Trino has it but Presto doesn't
|
|
33
|
+
(0, util_1.sql) `(LN(${value.arg}) / LN(${base.arg}))`),
|
|
34
34
|
];
|
|
35
35
|
}
|
|
36
36
|
exports.fnLog = fnLog;
|
|
@@ -36,7 +36,7 @@ export declare class TrinoDialect extends Dialect {
|
|
|
36
36
|
sqlAnyValueTurtle(groupSet: number, fieldList: DialectFieldList): string;
|
|
37
37
|
sqlAnyValueLastTurtle(name: string, groupSet: number, sqlName: string): string;
|
|
38
38
|
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string;
|
|
39
|
-
sqlUnnestAlias(source: string, alias: string,
|
|
39
|
+
sqlUnnestAlias(source: string, alias: string, _fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, _isInNestedPipeline: boolean): string;
|
|
40
40
|
sqlSumDistinctHashedKey(sqlDistinctKey: string): string;
|
|
41
41
|
sqlGenerateUUID(): string;
|
|
42
42
|
sqlFieldReference(alias: string, fieldName: string, _fieldType: string, _isNested: boolean, _isArray: boolean): string;
|
|
@@ -70,5 +70,7 @@ export declare class TrinoDialect extends Dialect {
|
|
|
70
70
|
export declare class PrestoDialect extends TrinoDialect {
|
|
71
71
|
name: string;
|
|
72
72
|
supportsPipelinesInViews: boolean;
|
|
73
|
+
supportsLeftJoinUnnest: boolean;
|
|
73
74
|
sqlGenerateUUID(): string;
|
|
75
|
+
sqlUnnestAlias(source: string, alias: string, _fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, _isInNestedPipeline: boolean): string;
|
|
74
76
|
}
|
|
@@ -246,21 +246,21 @@ class TrinoDialect extends dialect_1.Dialect {
|
|
|
246
246
|
//
|
|
247
247
|
// BigQuery will allocate more resources if we use a CROSS JOIN so we do that instead.
|
|
248
248
|
//
|
|
249
|
-
sqlUnnestAlias(source, alias,
|
|
250
|
-
const fieldsNames = fieldList.map(f => this.sqlMaybeQuoteIdentifier(f.sqlOutputName));
|
|
249
|
+
sqlUnnestAlias(source, alias, _fieldList, needDistinctKey, isArray, _isInNestedPipeline) {
|
|
251
250
|
if (isArray) {
|
|
252
251
|
if (needDistinctKey) {
|
|
253
|
-
return `
|
|
252
|
+
// return `LEFT JOIN UNNEST(transform(${source}, x -> ROW(x) )) WITH ORDINALIITY as words_0(value,__row_id_from_${alias}) ON TRUE`;
|
|
253
|
+
return `LEFT JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) WITH ORDINALITY as ${alias}(value, ignore,__row_id_from_${alias}) ON TRUE`;
|
|
254
254
|
}
|
|
255
255
|
else {
|
|
256
|
-
return `
|
|
256
|
+
return `LEFT JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) as ${alias}(value, ignore) ON TRUE`;
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
else if (needDistinctKey) {
|
|
260
|
-
return `
|
|
260
|
+
return `LEFT JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) WITH ORDINALITY as ${alias}_outer(${alias}, ignore,__row_id_from_${alias}) ON TRUE`;
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
263
|
-
return `
|
|
263
|
+
return `LEFT JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore)))as ${alias}_outer(${alias},ignore) ON TRUE`;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
sqlSumDistinctHashedKey(sqlDistinctKey) {
|
|
@@ -499,10 +499,28 @@ class PrestoDialect extends TrinoDialect {
|
|
|
499
499
|
super(...arguments);
|
|
500
500
|
this.name = 'presto';
|
|
501
501
|
this.supportsPipelinesInViews = false; // what a drag...
|
|
502
|
+
this.supportsLeftJoinUnnest = false; // we need to fix this....
|
|
502
503
|
}
|
|
503
504
|
sqlGenerateUUID() {
|
|
504
505
|
return 'CAST(UUID() AS VARCHAR)';
|
|
505
506
|
}
|
|
507
|
+
sqlUnnestAlias(source, alias, _fieldList, needDistinctKey, isArray, _isInNestedPipeline) {
|
|
508
|
+
if (isArray) {
|
|
509
|
+
if (needDistinctKey) {
|
|
510
|
+
// return `LEFT JOIN UNNEST(transform(${source}, x -> ROW(x) )) WITH ORDINALIITY as words_0(value,__row_id_from_${alias}) ON TRUE`;
|
|
511
|
+
return `CROSS JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) WITH ORDINALITY as ${alias}(value, ignore,__row_id_from_${alias})`;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
return `CROSS JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) as ${alias}(value, ignore)`;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else if (needDistinctKey) {
|
|
518
|
+
return `CROSS JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore))) WITH ORDINALITY as ${alias}_outer(${alias}, ignore,__row_id_from_${alias})`;
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
return `CROSS JOIN UNNEST(zip_with(${source},array[],(r,ignore) -> (r, ignore)))as ${alias}_outer(${alias},ignore)`;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
506
524
|
}
|
|
507
525
|
exports.PrestoDialect = PrestoDialect;
|
|
508
526
|
//# sourceMappingURL=trino.js.map
|