@malloydata/render 0.0.130-dev240311192728 → 0.0.130-dev240312011825
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.
|
@@ -4967,20 +4967,28 @@ ${hackSplitComment}
|
|
|
4967
4967
|
function fnStringAgg() {
|
|
4968
4968
|
const value3 = (0, util_1.makeParam)("value", (0, util_1.maxScalar)("string"));
|
|
4969
4969
|
const separator = (0, util_1.makeParam)("separator", (0, util_1.literal)((0, util_1.maxScalar)("string")));
|
|
4970
|
-
const orderBy = {
|
|
4970
|
+
const orderBy = {
|
|
4971
|
+
type: "aggregate_order_by",
|
|
4972
|
+
prefix: " WITHIN GROUP(",
|
|
4973
|
+
suffix: ")"
|
|
4974
|
+
};
|
|
4971
4975
|
return [
|
|
4972
|
-
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param], (0, util_1.sql)`LISTAGG(${value3.arg}, ',')
|
|
4973
|
-
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param, separator.param], (0, util_1.sql)`LISTAGG(${value3.arg}, ${separator.arg})
|
|
4976
|
+
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param], (0, util_1.sql)`LISTAGG(${value3.arg}, ',')${orderBy}`, { supportsOrderBy: true, supportsLimit: false }),
|
|
4977
|
+
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param, separator.param], (0, util_1.sql)`LISTAGG(${value3.arg}, ${separator.arg})${orderBy}`, { supportsOrderBy: true, supportsLimit: false })
|
|
4974
4978
|
];
|
|
4975
4979
|
}
|
|
4976
4980
|
exports.fnStringAgg = fnStringAgg;
|
|
4977
4981
|
function fnStringAggDistinct() {
|
|
4978
4982
|
const value3 = (0, util_1.makeParam)("value", (0, util_1.maxScalar)("string"));
|
|
4979
4983
|
const separator = (0, util_1.makeParam)("separator", (0, util_1.literal)((0, util_1.maxScalar)("string")));
|
|
4980
|
-
const orderBy = {
|
|
4984
|
+
const orderBy = {
|
|
4985
|
+
type: "aggregate_order_by",
|
|
4986
|
+
prefix: " WITHIN GROUP(",
|
|
4987
|
+
suffix: ")"
|
|
4988
|
+
};
|
|
4981
4989
|
return [
|
|
4982
|
-
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param], (0, util_1.sql)`LISTAGG(DISTINCT ${value3.arg}, ',')
|
|
4983
|
-
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param, separator.param], (0, util_1.sql)`LISTAGG(DISTINCT ${value3.arg}, ${separator.arg})
|
|
4990
|
+
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param], (0, util_1.sql)`LISTAGG(DISTINCT ${value3.arg}, ',')${orderBy}`, { supportsOrderBy: true, supportsLimit: false }),
|
|
4991
|
+
(0, util_1.overload)((0, util_1.minAggregate)("string"), [value3.param, separator.param], (0, util_1.sql)`LISTAGG(DISTINCT ${value3.arg}, ${separator.arg})${orderBy}`, { supportsOrderBy: true, supportsLimit: false })
|
|
4984
4992
|
];
|
|
4985
4993
|
}
|
|
4986
4994
|
exports.fnStringAggDistinct = fnStringAggDistinct;
|
|
@@ -5802,6 +5810,7 @@ ${(0, utils_1.indent)(sql)})
|
|
|
5802
5810
|
throw new Error(`Function is not defined for dialect ${dialect}`);
|
|
5803
5811
|
}
|
|
5804
5812
|
return (0, utils_1.exprMap)(overload.dialect[dialect].e, (fragment) => {
|
|
5813
|
+
var _a, _b;
|
|
5805
5814
|
if (typeof fragment === "string") {
|
|
5806
5815
|
return [fragment];
|
|
5807
5816
|
} else if (fragment.type === "spread") {
|
|
@@ -5826,7 +5835,7 @@ ${(0, utils_1.indent)(sql)})
|
|
|
5826
5835
|
return args[entry2.argIndexes[0]];
|
|
5827
5836
|
}
|
|
5828
5837
|
} else if (fragment.type === "aggregate_order_by") {
|
|
5829
|
-
return orderBy ? [` ${orderBy}`] : [];
|
|
5838
|
+
return orderBy ? [` ${(_a = fragment.prefix) !== null && _a !== void 0 ? _a : ""}${orderBy}${(_b = fragment.suffix) !== null && _b !== void 0 ? _b : ""}`] : [];
|
|
5830
5839
|
} else if (fragment.type === "aggregate_limit") {
|
|
5831
5840
|
return limit ? [` ${limit}`] : [];
|
|
5832
5841
|
}
|
|
@@ -5871,7 +5880,7 @@ ${(0, utils_1.indent)(sql)})
|
|
|
5871
5880
|
const isSymmetric = (_a = frag.overload.isSymmetric) !== null && _a !== void 0 ? _a : false;
|
|
5872
5881
|
const distinctKey = (0, malloy_types_1.expressionIsAggregate)(overload.returnType.expressionType) && !isSymmetric && this.generateDistinctKeyIfNecessary(resultSet, context3, frag.structPath);
|
|
5873
5882
|
const aggregateLimit = frag.limit ? `LIMIT ${frag.limit}` : void 0;
|
|
5874
|
-
if (frag.name === "string_agg" && distinctKey && !context3.dialect.supportsAggDistinct) {
|
|
5883
|
+
if (frag.name === "string_agg" && distinctKey && !context3.dialect.supportsAggDistinct && context3.dialect.name !== "snowflake") {
|
|
5875
5884
|
return this.generateAsymmetricStringAggExpression(resultSet, context3, args[0], args[1], distinctKey, frag.orderBy, context3.dialect.name, state);
|
|
5876
5885
|
}
|
|
5877
5886
|
if (distinctKey) {
|
|
@@ -6537,6 +6546,9 @@ ${(0, utils_1.indent)(sql)})
|
|
|
6537
6546
|
for (const [_name, fi] of this.allFields) {
|
|
6538
6547
|
if (fi instanceof FieldInstanceField) {
|
|
6539
6548
|
if (fi.fieldUsage.type === "result") {
|
|
6549
|
+
if (fi.f.fieldDef.type === "turtle" || fi.f.fieldDef.type === "struct" || (0, malloy_types_1.expressionIsAnalytic)(fi.f.fieldDef.expressionType)) {
|
|
6550
|
+
continue;
|
|
6551
|
+
}
|
|
6540
6552
|
firstField || (firstField = fi.fieldUsage.resultIndex);
|
|
6541
6553
|
if (["date", "timestamp"].indexOf(fi.f.fieldDef.type) > -1) {
|
|
6542
6554
|
return [{ dir: "desc", field: fi.fieldUsage.resultIndex }];
|
|
@@ -7416,7 +7428,17 @@ ${(0, utils_1.indent)(select2)}) AS ${ji.alias}
|
|
|
7416
7428
|
`);
|
|
7417
7429
|
}
|
|
7418
7430
|
generateStage0Fields(resultSet, output3, stageWriter) {
|
|
7431
|
+
const scalarFields = [];
|
|
7432
|
+
const otherFields = [];
|
|
7419
7433
|
for (const [name, fi] of resultSet.allFields) {
|
|
7434
|
+
if (fi instanceof FieldInstanceField && isScalarField(fi.f)) {
|
|
7435
|
+
scalarFields.push([name, fi]);
|
|
7436
|
+
} else {
|
|
7437
|
+
otherFields.push([name, fi]);
|
|
7438
|
+
}
|
|
7439
|
+
}
|
|
7440
|
+
const orderedFields = [...scalarFields, ...otherFields];
|
|
7441
|
+
for (const [name, fi] of orderedFields) {
|
|
7420
7442
|
const outputName = this.parent.dialect.sqlMaybeQuoteIdentifier(`${name}__${resultSet.groupSet}`);
|
|
7421
7443
|
if (fi instanceof FieldInstanceField) {
|
|
7422
7444
|
if (fi.fieldUsage.type === "result") {
|