@malloydata/render 0.0.133-dev240318205756 → 0.0.133-dev240320200749
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/bundle/bundled_renderer.js +469 -1
- package/dist/bundle/bundled_renderer.min.js +256 -146
- package/package.json +2 -2
|
@@ -5414,6 +5414,468 @@ ${(0, utils_1.indent)(sql)}
|
|
|
5414
5414
|
}
|
|
5415
5415
|
});
|
|
5416
5416
|
|
|
5417
|
+
// ../malloy/dist/dialect/trino/functions/trino_functions.js
|
|
5418
|
+
var require_trino_functions = __commonJS({
|
|
5419
|
+
"../malloy/dist/dialect/trino/functions/trino_functions.js"(exports) {
|
|
5420
|
+
"use strict";
|
|
5421
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5422
|
+
exports.TRINO_FUNCTIONS = void 0;
|
|
5423
|
+
var functions_1 = require_functions();
|
|
5424
|
+
exports.TRINO_FUNCTIONS = functions_1.FUNCTIONS.clone();
|
|
5425
|
+
exports.TRINO_FUNCTIONS.seal();
|
|
5426
|
+
}
|
|
5427
|
+
});
|
|
5428
|
+
|
|
5429
|
+
// ../malloy/dist/dialect/trino/functions/index.js
|
|
5430
|
+
var require_functions6 = __commonJS({
|
|
5431
|
+
"../malloy/dist/dialect/trino/functions/index.js"(exports) {
|
|
5432
|
+
"use strict";
|
|
5433
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5434
|
+
exports.TRINO_FUNCTIONS = void 0;
|
|
5435
|
+
var trino_functions_1 = require_trino_functions();
|
|
5436
|
+
Object.defineProperty(exports, "TRINO_FUNCTIONS", { enumerable: true, get: function() {
|
|
5437
|
+
return trino_functions_1.TRINO_FUNCTIONS;
|
|
5438
|
+
} });
|
|
5439
|
+
}
|
|
5440
|
+
});
|
|
5441
|
+
|
|
5442
|
+
// ../malloy/dist/dialect/trino/trino.js
|
|
5443
|
+
var require_trino = __commonJS({
|
|
5444
|
+
"../malloy/dist/dialect/trino/trino.js"(exports) {
|
|
5445
|
+
"use strict";
|
|
5446
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5447
|
+
exports.TrinoDialect = void 0;
|
|
5448
|
+
var utils_1 = require_utils();
|
|
5449
|
+
var malloy_types_1 = require_malloy_types();
|
|
5450
|
+
var functions_1 = require_functions6();
|
|
5451
|
+
var dialect_1 = require_dialect();
|
|
5452
|
+
function timestampMeasureable(units) {
|
|
5453
|
+
return [
|
|
5454
|
+
"microsecond",
|
|
5455
|
+
"millisecond",
|
|
5456
|
+
"second",
|
|
5457
|
+
"minute",
|
|
5458
|
+
"hour",
|
|
5459
|
+
"day"
|
|
5460
|
+
].includes(units);
|
|
5461
|
+
}
|
|
5462
|
+
function dateMeasureable(units) {
|
|
5463
|
+
return ["day", "week", "month", "quarter", "year"].includes(units);
|
|
5464
|
+
}
|
|
5465
|
+
var extractMap = {
|
|
5466
|
+
"day_of_week": "dayofweek",
|
|
5467
|
+
"day_of_year": "dayofyear"
|
|
5468
|
+
};
|
|
5469
|
+
function qtz(qi) {
|
|
5470
|
+
const tz = qi.queryTimezone;
|
|
5471
|
+
if (tz && tz !== "UTC") {
|
|
5472
|
+
return tz;
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
var TrinoDialect = class extends dialect_1.Dialect {
|
|
5476
|
+
constructor() {
|
|
5477
|
+
super(...arguments);
|
|
5478
|
+
this.name = "trino";
|
|
5479
|
+
this.defaultNumberType = "FLOAT64";
|
|
5480
|
+
this.defaultDecimalType = "NUMERIC";
|
|
5481
|
+
this.udfPrefix = "__udf";
|
|
5482
|
+
this.hasFinalStage = false;
|
|
5483
|
+
this.divisionIsInteger = false;
|
|
5484
|
+
this.supportsSumDistinctFunction = false;
|
|
5485
|
+
this.unnestWithNumbers = false;
|
|
5486
|
+
this.defaultSampling = { enable: false };
|
|
5487
|
+
this.supportUnnestArrayAgg = false;
|
|
5488
|
+
this.supportsAggDistinct = false;
|
|
5489
|
+
this.supportsCTEinCoorelatedSubQueries = false;
|
|
5490
|
+
this.dontUnionIndex = true;
|
|
5491
|
+
this.supportsQualify = true;
|
|
5492
|
+
this.supportsSafeCast = true;
|
|
5493
|
+
this.supportsNesting = true;
|
|
5494
|
+
this.cantPartitionWindowFunctionsOnExpressions = true;
|
|
5495
|
+
this.keywords = `
|
|
5496
|
+
ALL
|
|
5497
|
+
AND
|
|
5498
|
+
ANY
|
|
5499
|
+
ARRAY
|
|
5500
|
+
AS
|
|
5501
|
+
ASC
|
|
5502
|
+
ASSERT_ROWS_MODIFIED
|
|
5503
|
+
AT
|
|
5504
|
+
BETWEEN
|
|
5505
|
+
BY
|
|
5506
|
+
CASE
|
|
5507
|
+
CAST
|
|
5508
|
+
COLLATE
|
|
5509
|
+
CONTAINS
|
|
5510
|
+
CREATE
|
|
5511
|
+
CROSS
|
|
5512
|
+
CUBE
|
|
5513
|
+
CURRENT
|
|
5514
|
+
DEFAULT
|
|
5515
|
+
DEFINE
|
|
5516
|
+
DESC
|
|
5517
|
+
DISTINCT
|
|
5518
|
+
ELSE
|
|
5519
|
+
END
|
|
5520
|
+
ENUM
|
|
5521
|
+
ESCAPE
|
|
5522
|
+
EXCEPT
|
|
5523
|
+
EXCLUDE
|
|
5524
|
+
EXISTS
|
|
5525
|
+
EXTRACT
|
|
5526
|
+
FALSE
|
|
5527
|
+
FETCH
|
|
5528
|
+
FOLLOWING
|
|
5529
|
+
FOR
|
|
5530
|
+
FROM
|
|
5531
|
+
FULL
|
|
5532
|
+
GROUP
|
|
5533
|
+
GROUPING
|
|
5534
|
+
GROUPS
|
|
5535
|
+
HASH
|
|
5536
|
+
HAVING
|
|
5537
|
+
IF
|
|
5538
|
+
IGNORE
|
|
5539
|
+
IN
|
|
5540
|
+
INNER
|
|
5541
|
+
INTERSECT
|
|
5542
|
+
INTERVAL
|
|
5543
|
+
INTO
|
|
5544
|
+
IS
|
|
5545
|
+
JOIN
|
|
5546
|
+
LATERAL
|
|
5547
|
+
LEFT
|
|
5548
|
+
LIKE
|
|
5549
|
+
LIMIT
|
|
5550
|
+
LOOKUP
|
|
5551
|
+
MERGE
|
|
5552
|
+
NATURAL
|
|
5553
|
+
NEW
|
|
5554
|
+
NO
|
|
5555
|
+
NOT
|
|
5556
|
+
NULL
|
|
5557
|
+
NULLS
|
|
5558
|
+
OF
|
|
5559
|
+
ON
|
|
5560
|
+
OR
|
|
5561
|
+
ORDER
|
|
5562
|
+
OUTER
|
|
5563
|
+
OVER
|
|
5564
|
+
PARTITION
|
|
5565
|
+
PRECEDING
|
|
5566
|
+
PROTO
|
|
5567
|
+
RANGE
|
|
5568
|
+
RECURSIVE
|
|
5569
|
+
RESPECT
|
|
5570
|
+
RIGHT
|
|
5571
|
+
ROLLUP
|
|
5572
|
+
ROWS
|
|
5573
|
+
SELECT
|
|
5574
|
+
SET
|
|
5575
|
+
SOME
|
|
5576
|
+
STRUCT
|
|
5577
|
+
TABLESAMPLE
|
|
5578
|
+
THEN
|
|
5579
|
+
TO
|
|
5580
|
+
TREAT
|
|
5581
|
+
TRUE
|
|
5582
|
+
UNBOUNDED
|
|
5583
|
+
UNION
|
|
5584
|
+
UNNEST
|
|
5585
|
+
USING
|
|
5586
|
+
WHEN
|
|
5587
|
+
WHERE
|
|
5588
|
+
WINDOW
|
|
5589
|
+
WITH
|
|
5590
|
+
WITHIN`.split(/\s/);
|
|
5591
|
+
}
|
|
5592
|
+
quoteTablePath(tablePath) {
|
|
5593
|
+
return `${tablePath.replace(/malloytest/g, "malloy_demo.faa")}`;
|
|
5594
|
+
}
|
|
5595
|
+
sqlGroupSetTable(groupSetCount) {
|
|
5596
|
+
return `CROSS JOIN (SELECT row_number() OVER() -1 group_set FROM UNNEST(SEQUENCE(0,${groupSetCount})))`;
|
|
5597
|
+
}
|
|
5598
|
+
sqlAnyValue(groupSet, fieldName) {
|
|
5599
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN ${fieldName} END)`;
|
|
5600
|
+
}
|
|
5601
|
+
// can array agg or any_value a struct...
|
|
5602
|
+
sqlAggregateTurtle(groupSet, fieldList, orderBy, limit) {
|
|
5603
|
+
let tail = "";
|
|
5604
|
+
if (limit !== void 0) {
|
|
5605
|
+
tail += ` LIMIT ${limit}`;
|
|
5606
|
+
}
|
|
5607
|
+
const fields = fieldList.map((f4) => `
|
|
5608
|
+
'${f4.sqlOutputName}' VALUE ${f4.sqlExpression}`).join(", ");
|
|
5609
|
+
return `cast(COALESCE(SLICE(COALESCE(ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN JSON_PARSE(JSON_OBJECT(${fields})) END
|
|
5610
|
+
${orderBy} -- ${tail}
|
|
5611
|
+
), ARRAY[]), 1, ${limit}), ARRAY[]) as json)`;
|
|
5612
|
+
}
|
|
5613
|
+
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
5614
|
+
const fields = fieldList.map((f4) => `
|
|
5615
|
+
'${f4.sqlOutputName}' VALUE ${f4.sqlExpression}`).join(", ");
|
|
5616
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN JSON_OBJECT(${fields}))`;
|
|
5617
|
+
}
|
|
5618
|
+
sqlAnyValueLastTurtle(name, groupSet, sqlName) {
|
|
5619
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN ${name} END) as ${sqlName}`;
|
|
5620
|
+
}
|
|
5621
|
+
sqlCoaleseMeasuresInline(groupSet, fieldList) {
|
|
5622
|
+
const fields = fieldList.map((f4) => `${f4.sqlExpression} as ${f4.sqlOutputName}`).join(", ");
|
|
5623
|
+
const nullValues = fieldList.map((f4) => `NULL as ${f4.sqlOutputName}`).join(", ");
|
|
5624
|
+
return `COALESCE(ANY_VALUE(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}) END), STRUCT(${nullValues}))`;
|
|
5625
|
+
}
|
|
5626
|
+
//
|
|
5627
|
+
// this code used to be:
|
|
5628
|
+
//
|
|
5629
|
+
// from += `JOIN UNNEST(GENERATE_ARRAY(0,${this.maxGroupSet},1)) as group_set\n`;
|
|
5630
|
+
//
|
|
5631
|
+
// BigQuery will allocate more resources if we use a CROSS JOIN so we do that instead.
|
|
5632
|
+
//
|
|
5633
|
+
sqlUnnestAlias(source3, alias, fieldList, needDistinctKey, isArray2, _isInNestedPipeline) {
|
|
5634
|
+
if (isArray2) {
|
|
5635
|
+
if (needDistinctKey) {
|
|
5636
|
+
return `LEFT JOIN UNNEST(ARRAY(( SELECT AS STRUCT row_number() over() as __row_id, value FROM UNNEST(${source3}) value))) as ${alias}`;
|
|
5637
|
+
} else {
|
|
5638
|
+
return `LEFT JOIN UNNEST(ARRAY((SELECT AS STRUCT value FROM unnest(${source3}) value))) as ${alias}`;
|
|
5639
|
+
}
|
|
5640
|
+
} else if (needDistinctKey) {
|
|
5641
|
+
return `LEFT JOIN UNNEST(ARRAY(( SELECT AS STRUCT row_number() over() as __row_id, * FROM UNNEST(${source3})))) as ${alias}`;
|
|
5642
|
+
} else {
|
|
5643
|
+
return `LEFT JOIN UNNEST(${source3}) as ${alias}`;
|
|
5644
|
+
}
|
|
5645
|
+
}
|
|
5646
|
+
sqlSumDistinctHashedKey(sqlDistinctKey) {
|
|
5647
|
+
sqlDistinctKey = `CAST(${sqlDistinctKey} AS STRING)`;
|
|
5648
|
+
const upperPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 1, 15)) as int64) as numeric) * 4294967296`;
|
|
5649
|
+
const lowerPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 16, 8)) as int64) as numeric)`;
|
|
5650
|
+
const precisionShiftMultiplier = "0.000000001";
|
|
5651
|
+
return `(${upperPart} + ${lowerPart}) * ${precisionShiftMultiplier}`;
|
|
5652
|
+
}
|
|
5653
|
+
sqlGenerateUUID() {
|
|
5654
|
+
return "GENERATE_UUID()";
|
|
5655
|
+
}
|
|
5656
|
+
sqlFieldReference(alias, fieldName, _fieldType, _isNested, _isArray) {
|
|
5657
|
+
return `${alias}.${fieldName}`;
|
|
5658
|
+
}
|
|
5659
|
+
sqlUnnestPipelineHead(isSingleton, sourceSQLExpression) {
|
|
5660
|
+
let p3 = sourceSQLExpression;
|
|
5661
|
+
if (isSingleton) {
|
|
5662
|
+
p3 = `[${p3}]`;
|
|
5663
|
+
}
|
|
5664
|
+
return `UNNEST(${p3})`;
|
|
5665
|
+
}
|
|
5666
|
+
sqlCreateFunction(id2, funcText) {
|
|
5667
|
+
return `CREATE TEMPORARY FUNCTION ${id2}(__param ANY TYPE) AS ((
|
|
5668
|
+
${(0, utils_1.indent)(funcText)}));
|
|
5669
|
+
`;
|
|
5670
|
+
}
|
|
5671
|
+
sqlCreateTableAsSelect(tableName, sql) {
|
|
5672
|
+
return `
|
|
5673
|
+
CREATE TABLE IF NOT EXISTS \`${tableName}\`
|
|
5674
|
+
OPTIONS (
|
|
5675
|
+
expiration_timestamp=TIMESTAMP_ADD(current_timestamp(), INTERVAL 1 hour)
|
|
5676
|
+
)
|
|
5677
|
+
AS (
|
|
5678
|
+
${(0, utils_1.indent)(sql)}
|
|
5679
|
+
);
|
|
5680
|
+
`;
|
|
5681
|
+
}
|
|
5682
|
+
sqlCreateFunctionCombineLastStage(lastStageName) {
|
|
5683
|
+
return `SELECT ARRAY((SELECT AS STRUCT * FROM ${lastStageName}))
|
|
5684
|
+
`;
|
|
5685
|
+
}
|
|
5686
|
+
sqlSelectAliasAsStruct(alias) {
|
|
5687
|
+
return `(SELECT AS STRUCT ${alias}.*)`;
|
|
5688
|
+
}
|
|
5689
|
+
sqlMaybeQuoteIdentifier(identifier) {
|
|
5690
|
+
return identifier;
|
|
5691
|
+
}
|
|
5692
|
+
sqlNow() {
|
|
5693
|
+
return (0, malloy_types_1.mkExpr)`CURRENT_TIMESTAMP()`;
|
|
5694
|
+
}
|
|
5695
|
+
sqlTrunc(qi, sqlTime, units) {
|
|
5696
|
+
const tz = qtz(qi);
|
|
5697
|
+
const tzAdd = tz ? `, "${tz}"` : "";
|
|
5698
|
+
if (sqlTime.valueType === "date") {
|
|
5699
|
+
if (dateMeasureable(units)) {
|
|
5700
|
+
return (0, malloy_types_1.mkExpr)`DATE_TRUNC(${sqlTime.value},${units})`;
|
|
5701
|
+
}
|
|
5702
|
+
return (0, malloy_types_1.mkExpr)`TIMESTAMP(${sqlTime.value}${tzAdd})`;
|
|
5703
|
+
}
|
|
5704
|
+
return (0, malloy_types_1.mkExpr)`TIMESTAMP_TRUNC(${sqlTime.value},${units}${tzAdd})`;
|
|
5705
|
+
}
|
|
5706
|
+
sqlExtract(qi, expr2, units) {
|
|
5707
|
+
const extractTo = extractMap[units] || units;
|
|
5708
|
+
const tz = expr2.valueType === "timestamp" && qtz(qi);
|
|
5709
|
+
const tzAdd = tz ? ` AT TIME ZONE '${tz}'` : "";
|
|
5710
|
+
return (0, malloy_types_1.mkExpr)`EXTRACT(${extractTo} FROM ${expr2.value}${tzAdd})`;
|
|
5711
|
+
}
|
|
5712
|
+
sqlAlterTime(op, expr2, n7, timeframe) {
|
|
5713
|
+
let theTime = expr2.value;
|
|
5714
|
+
let computeType = expr2.valueType;
|
|
5715
|
+
if (timeframe !== "day" && timestampMeasureable(timeframe)) {
|
|
5716
|
+
computeType = "timestamp";
|
|
5717
|
+
if (expr2.valueType !== "timestamp") {
|
|
5718
|
+
theTime = (0, malloy_types_1.mkExpr)`TIMESTAMP(${theTime})`;
|
|
5719
|
+
}
|
|
5720
|
+
} else if (expr2.valueType === "timestamp") {
|
|
5721
|
+
theTime = (0, malloy_types_1.mkExpr)`DATETIME(${theTime})`;
|
|
5722
|
+
computeType = "datetime";
|
|
5723
|
+
}
|
|
5724
|
+
const funcName = computeType.toUpperCase() + (op === "+" ? "_ADD" : "_SUB");
|
|
5725
|
+
const newTime = (0, malloy_types_1.mkExpr)`${funcName}(${theTime}, INTERVAL ${n7} ${timeframe})`;
|
|
5726
|
+
if (computeType === expr2.valueType) {
|
|
5727
|
+
return newTime;
|
|
5728
|
+
}
|
|
5729
|
+
return (0, malloy_types_1.mkExpr)`${expr2.valueType.toUpperCase()}(${newTime})`;
|
|
5730
|
+
}
|
|
5731
|
+
ignoreInProject(fieldName) {
|
|
5732
|
+
return fieldName === "_PARTITIONTIME";
|
|
5733
|
+
}
|
|
5734
|
+
sqlCast(qi, cast) {
|
|
5735
|
+
const op = `${cast.srcType}::${cast.dstType}`;
|
|
5736
|
+
const tz = qtz(qi);
|
|
5737
|
+
if (op === "timestamp::date" && tz) {
|
|
5738
|
+
return (0, malloy_types_1.mkExpr)`DATE(${cast.expr},'${tz}')`;
|
|
5739
|
+
}
|
|
5740
|
+
if (op === "date::timestamp" && tz) {
|
|
5741
|
+
return (0, malloy_types_1.mkExpr)`TIMESTAMP(${cast.expr}, '${tz}')`;
|
|
5742
|
+
}
|
|
5743
|
+
if (cast.srcType !== cast.dstType) {
|
|
5744
|
+
const dstType = typeof cast.dstType === "string" ? this.malloyTypeToSQLType({ type: cast.dstType }) : cast.dstType.raw;
|
|
5745
|
+
const castFunc = cast.safe ? "SAFE_CAST" : "CAST";
|
|
5746
|
+
return (0, malloy_types_1.mkExpr)`${castFunc}(${cast.expr} AS ${dstType})`;
|
|
5747
|
+
}
|
|
5748
|
+
return cast.expr;
|
|
5749
|
+
}
|
|
5750
|
+
sqlRegexpMatch(expr2, regexp) {
|
|
5751
|
+
return (0, malloy_types_1.mkExpr)`REGEXP_CONTAINS(${expr2}, ${regexp})`;
|
|
5752
|
+
}
|
|
5753
|
+
sqlLiteralTime(qi, timeString, type3, timezone) {
|
|
5754
|
+
if (type3 === "date") {
|
|
5755
|
+
return `DATE('${timeString}')`;
|
|
5756
|
+
} else if (type3 === "timestamp") {
|
|
5757
|
+
let timestampArgs = `'${timeString}'`;
|
|
5758
|
+
const tz = timezone || qtz(qi);
|
|
5759
|
+
if (tz && tz !== "UTC") {
|
|
5760
|
+
timestampArgs += `,'${tz}'`;
|
|
5761
|
+
}
|
|
5762
|
+
return `TIMESTAMP(${timestampArgs})`;
|
|
5763
|
+
} else {
|
|
5764
|
+
throw new Error(`Unsupported Literal time format ${type3}`);
|
|
5765
|
+
}
|
|
5766
|
+
}
|
|
5767
|
+
sqlMeasureTime(from, to, units) {
|
|
5768
|
+
const measureMap = {
|
|
5769
|
+
"microsecond": { use: "microsecond", ratio: 1 },
|
|
5770
|
+
"millisecond": { use: "microsecond", ratio: 1e3 },
|
|
5771
|
+
"second": { use: "millisecond", ratio: 1e3 },
|
|
5772
|
+
"minute": { use: "second", ratio: 60 },
|
|
5773
|
+
"hour": { use: "minute", ratio: 60 },
|
|
5774
|
+
"day": { use: "hour", ratio: 24 },
|
|
5775
|
+
"week": { use: "day", ratio: 7 }
|
|
5776
|
+
};
|
|
5777
|
+
let lVal = from.value;
|
|
5778
|
+
let rVal = to.value;
|
|
5779
|
+
if (measureMap[units]) {
|
|
5780
|
+
const { use: measureIn, ratio } = measureMap[units];
|
|
5781
|
+
if (!timestampMeasureable(measureIn)) {
|
|
5782
|
+
throw new Error(`Measure in '${measureIn} not implemented`);
|
|
5783
|
+
}
|
|
5784
|
+
if (from.valueType !== to.valueType) {
|
|
5785
|
+
throw new Error("Can't measure difference between different types");
|
|
5786
|
+
}
|
|
5787
|
+
if (from.valueType === "date") {
|
|
5788
|
+
lVal = (0, malloy_types_1.mkExpr)`TIMESTAMP(${lVal})`;
|
|
5789
|
+
rVal = (0, malloy_types_1.mkExpr)`TIMESTAMP(${rVal})`;
|
|
5790
|
+
}
|
|
5791
|
+
let measured = (0, malloy_types_1.mkExpr)`TIMESTAMP_DIFF(${rVal},${lVal},${measureIn})`;
|
|
5792
|
+
if (ratio !== 1) {
|
|
5793
|
+
measured = (0, malloy_types_1.mkExpr)`FLOOR(${measured}/${ratio.toString()}.0)`;
|
|
5794
|
+
}
|
|
5795
|
+
return measured;
|
|
5796
|
+
}
|
|
5797
|
+
throw new Error(`Measure '${units} not implemented`);
|
|
5798
|
+
}
|
|
5799
|
+
sqlSampleTable(tableSQL, sample) {
|
|
5800
|
+
if (sample !== void 0) {
|
|
5801
|
+
if ((0, malloy_types_1.isSamplingEnable)(sample) && sample.enable) {
|
|
5802
|
+
sample = this.defaultSampling;
|
|
5803
|
+
}
|
|
5804
|
+
if ((0, malloy_types_1.isSamplingRows)(sample)) {
|
|
5805
|
+
throw new Error("StandardSQL doesn't support sampling by rows only percent");
|
|
5806
|
+
} else if ((0, malloy_types_1.isSamplingPercent)(sample)) {
|
|
5807
|
+
return `(SELECT * FROM ${tableSQL} TABLESAMPLE SYSTEM (${sample.percent} PERCENT))`;
|
|
5808
|
+
}
|
|
5809
|
+
}
|
|
5810
|
+
return tableSQL;
|
|
5811
|
+
}
|
|
5812
|
+
sqlLiteralString(literal) {
|
|
5813
|
+
const noVirgule = literal.replace(/\\/g, "\\\\");
|
|
5814
|
+
return "'" + noVirgule.replace(/'/g, "\\'") + "'";
|
|
5815
|
+
}
|
|
5816
|
+
sqlLiteralRegexp(literal) {
|
|
5817
|
+
const noVirgule = literal.replace(/\\/g, "\\\\");
|
|
5818
|
+
return "'" + noVirgule.replace(/'/g, "\\'") + "'";
|
|
5819
|
+
}
|
|
5820
|
+
getGlobalFunctionDef(name) {
|
|
5821
|
+
return functions_1.TRINO_FUNCTIONS.get(name);
|
|
5822
|
+
}
|
|
5823
|
+
malloyTypeToSQLType(malloyType) {
|
|
5824
|
+
if (malloyType.type === "number") {
|
|
5825
|
+
if (malloyType.numberType === "integer") {
|
|
5826
|
+
return "INT64";
|
|
5827
|
+
} else {
|
|
5828
|
+
return "FLOAT64";
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5831
|
+
return malloyType.type;
|
|
5832
|
+
}
|
|
5833
|
+
sqlTypeToMalloyType(_sqlType) {
|
|
5834
|
+
return void 0;
|
|
5835
|
+
}
|
|
5836
|
+
castToString(expression3) {
|
|
5837
|
+
return `CAST(${expression3} as STRING)`;
|
|
5838
|
+
}
|
|
5839
|
+
concat(...values4) {
|
|
5840
|
+
return values4.join(" || ");
|
|
5841
|
+
}
|
|
5842
|
+
validateTypeName(sqlType) {
|
|
5843
|
+
return sqlType.match(/^[A-Za-z\s(),<>0-9]*$/) !== null;
|
|
5844
|
+
}
|
|
5845
|
+
};
|
|
5846
|
+
exports.TrinoDialect = TrinoDialect;
|
|
5847
|
+
}
|
|
5848
|
+
});
|
|
5849
|
+
|
|
5850
|
+
// ../malloy/dist/dialect/trino/index.js
|
|
5851
|
+
var require_trino2 = __commonJS({
|
|
5852
|
+
"../malloy/dist/dialect/trino/index.js"(exports) {
|
|
5853
|
+
"use strict";
|
|
5854
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o5, m4, k2, k22) {
|
|
5855
|
+
if (k22 === void 0)
|
|
5856
|
+
k22 = k2;
|
|
5857
|
+
var desc = Object.getOwnPropertyDescriptor(m4, k2);
|
|
5858
|
+
if (!desc || ("get" in desc ? !m4.__esModule : desc.writable || desc.configurable)) {
|
|
5859
|
+
desc = { enumerable: true, get: function() {
|
|
5860
|
+
return m4[k2];
|
|
5861
|
+
} };
|
|
5862
|
+
}
|
|
5863
|
+
Object.defineProperty(o5, k22, desc);
|
|
5864
|
+
} : function(o5, m4, k2, k22) {
|
|
5865
|
+
if (k22 === void 0)
|
|
5866
|
+
k22 = k2;
|
|
5867
|
+
o5[k22] = m4[k2];
|
|
5868
|
+
});
|
|
5869
|
+
var __exportStar = exports && exports.__exportStar || function(m4, exports2) {
|
|
5870
|
+
for (var p3 in m4)
|
|
5871
|
+
if (p3 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p3))
|
|
5872
|
+
__createBinding(exports2, m4, p3);
|
|
5873
|
+
};
|
|
5874
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5875
|
+
__exportStar(require_trino(), exports);
|
|
5876
|
+
}
|
|
5877
|
+
});
|
|
5878
|
+
|
|
5417
5879
|
// ../malloy/dist/dialect/dialect_map.js
|
|
5418
5880
|
var require_dialect_map = __commonJS({
|
|
5419
5881
|
"../malloy/dist/dialect/dialect_map.js"(exports) {
|
|
@@ -5424,6 +5886,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
5424
5886
|
var postgres_1 = require_postgres2();
|
|
5425
5887
|
var snowflake_1 = require_snowflake2();
|
|
5426
5888
|
var standardsql_1 = require_standardsql2();
|
|
5889
|
+
var trino_1 = require_trino2();
|
|
5427
5890
|
var dialectMap = /* @__PURE__ */ new Map();
|
|
5428
5891
|
function getDialect(name) {
|
|
5429
5892
|
const d3 = dialectMap.get(name);
|
|
@@ -5441,6 +5904,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
5441
5904
|
registerDialect(new standardsql_1.StandardSQLDialect());
|
|
5442
5905
|
registerDialect(new duckdb_1.DuckDBDialect());
|
|
5443
5906
|
registerDialect(new snowflake_1.SnowflakeDialect());
|
|
5907
|
+
registerDialect(new trino_1.TrinoDialect());
|
|
5444
5908
|
function paramsEqual(a5, b4) {
|
|
5445
5909
|
return a5.params.length === b4.params.length && a5.params.every((param2, i6) => {
|
|
5446
5910
|
const otherParam = b4.params[i6];
|
|
@@ -5515,7 +5979,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
5515
5979
|
"../malloy/dist/dialect/index.js"(exports) {
|
|
5516
5980
|
"use strict";
|
|
5517
5981
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5518
|
-
exports.FUNCTIONS = exports.getDialectFunction = exports.registerDialect = exports.getDialect = exports.SnowflakeDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.params = exports.param = exports.sqlFragment = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
5982
|
+
exports.FUNCTIONS = exports.getDialectFunction = exports.registerDialect = exports.getDialect = exports.TrinoDialect = exports.SnowflakeDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.params = exports.param = exports.sqlFragment = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
5519
5983
|
var util_1 = require_util();
|
|
5520
5984
|
Object.defineProperty(exports, "arg", { enumerable: true, get: function() {
|
|
5521
5985
|
return util_1.arg;
|
|
@@ -5579,6 +6043,10 @@ ${(0, utils_1.indent)(sql)}
|
|
|
5579
6043
|
Object.defineProperty(exports, "SnowflakeDialect", { enumerable: true, get: function() {
|
|
5580
6044
|
return snowflake_1.SnowflakeDialect;
|
|
5581
6045
|
} });
|
|
6046
|
+
var trino_1 = require_trino2();
|
|
6047
|
+
Object.defineProperty(exports, "TrinoDialect", { enumerable: true, get: function() {
|
|
6048
|
+
return trino_1.TrinoDialect;
|
|
6049
|
+
} });
|
|
5582
6050
|
var dialect_map_1 = require_dialect_map();
|
|
5583
6051
|
Object.defineProperty(exports, "getDialect", { enumerable: true, get: function() {
|
|
5584
6052
|
return dialect_map_1.getDialect;
|