drizzle-cube 0.3.27 → 0.3.28
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/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.js +5 -5
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{DashboardEditModal-CVMSvpJ-.js → DashboardEditModal-t5XeTZom.js} +45 -45
- package/dist/client/chunks/DashboardEditModal-t5XeTZom.js.map +1 -0
- package/dist/client/chunks/{RetentionCombinedChart-BVKWmxc-.js → RetentionCombinedChart-SsBGHJWi.js} +9 -9
- package/dist/client/chunks/RetentionCombinedChart-SsBGHJWi.js.map +1 -0
- package/dist/client/chunks/{RetentionHeatmap-BiqfhGYk.js → RetentionHeatmap-BHYU8MXY.js} +8 -8
- package/dist/client/chunks/RetentionHeatmap-BHYU8MXY.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-CuTR61Ct.js → analysis-builder-CKVYG9jJ.js} +67 -67
- package/dist/client/chunks/analysis-builder-CKVYG9jJ.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-shared-D7iqklYk.js → analysis-builder-shared-CF8Vx1oD.js} +8 -8
- package/dist/client/chunks/analysis-builder-shared-CF8Vx1oD.js.map +1 -0
- package/dist/client/chunks/{chart-activity-grid-BcMRkaq4.js → chart-activity-grid-Bpu_-8uT.js} +5 -5
- package/dist/client/chunks/{chart-activity-grid-BcMRkaq4.js.map → chart-activity-grid-Bpu_-8uT.js.map} +1 -1
- package/dist/client/chunks/{chart-area-KlBSb_ur.js → chart-area-DcvLkvGb.js} +8 -8
- package/dist/client/chunks/chart-area-DcvLkvGb.js.map +1 -0
- package/dist/client/chunks/{chart-bar-D1i2jmIg.js → chart-bar-CNfm5iMY.js} +7 -7
- package/dist/client/chunks/chart-bar-CNfm5iMY.js.map +1 -0
- package/dist/client/chunks/{chart-bubble-BFjnOwNZ.js → chart-bubble-KA-RYWR8.js} +4 -4
- package/dist/client/chunks/{chart-bubble-BFjnOwNZ.js.map → chart-bubble-KA-RYWR8.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-CYMMAHau.js → chart-data-table-Cq14arji.js} +9 -9
- package/dist/client/chunks/chart-data-table-Cq14arji.js.map +1 -0
- package/dist/client/chunks/{chart-funnel-BH7r4HWZ.js → chart-funnel-DFKWS49U.js} +7 -7
- package/dist/client/chunks/chart-funnel-DFKWS49U.js.map +1 -0
- package/dist/client/chunks/{chart-heat-map-DyGtODLE.js → chart-heat-map-D2g0dbKz.js} +5 -5
- package/dist/client/chunks/chart-heat-map-D2g0dbKz.js.map +1 -0
- package/dist/client/chunks/{chart-kpi-delta-Bk396suk.js → chart-kpi-delta-Cc-jiBd0.js} +30 -30
- package/dist/client/chunks/chart-kpi-delta-Cc-jiBd0.js.map +1 -0
- package/dist/client/chunks/{chart-kpi-number-CIGqZ5Dw.js → chart-kpi-number-BXolYaZA.js} +8 -8
- package/dist/client/chunks/chart-kpi-number-BXolYaZA.js.map +1 -0
- package/dist/client/chunks/{chart-kpi-text-iwlaSQCi.js → chart-kpi-text-PA8oyypA.js} +7 -7
- package/dist/client/chunks/chart-kpi-text-PA8oyypA.js.map +1 -0
- package/dist/client/chunks/{chart-line-BKqhoW9A.js → chart-line-BOrtUdOD.js} +8 -8
- package/dist/client/chunks/chart-line-BOrtUdOD.js.map +1 -0
- package/dist/client/chunks/{chart-markdown-CiPhRY9s.js → chart-markdown-Cget3iEq.js} +6 -6
- package/dist/client/chunks/chart-markdown-Cget3iEq.js.map +1 -0
- package/dist/client/chunks/{chart-pie-BNr-GgTh.js → chart-pie-B-Sbsvd2.js} +7 -7
- package/dist/client/chunks/chart-pie-B-Sbsvd2.js.map +1 -0
- package/dist/client/chunks/{chart-radar-CYrGVYEQ.js → chart-radar-CezgvXhm.js} +6 -6
- package/dist/client/chunks/chart-radar-CezgvXhm.js.map +1 -0
- package/dist/client/chunks/{chart-radial-bar-2PR3ucIR.js → chart-radial-bar-COBPiBxm.js} +6 -6
- package/dist/client/chunks/chart-radial-bar-COBPiBxm.js.map +1 -0
- package/dist/client/chunks/{chart-sankey-C7w7h2ZV.js → chart-sankey-O4WQBRDk.js} +27 -27
- package/dist/client/chunks/{chart-sankey-C7w7h2ZV.js.map → chart-sankey-O4WQBRDk.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-D3Z9bl8H.js → chart-scatter-BVF0n9DR.js} +22 -22
- package/dist/client/chunks/chart-scatter-BVF0n9DR.js.map +1 -0
- package/dist/client/chunks/{chart-sunburst-C4ydFeaK.js → chart-sunburst-DZzVj_6S.js} +4 -4
- package/dist/client/chunks/{chart-sunburst-C4ydFeaK.js.map → chart-sunburst-DZzVj_6S.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-DCCmMyz1.js → chart-tree-map-CeEtNuo6.js} +6 -6
- package/dist/client/chunks/chart-tree-map-CeEtNuo6.js.map +1 -0
- package/dist/client/chunks/{charts-core-DIW3Dd7n.js → charts-core-DF99lItO.js} +4 -4
- package/dist/client/chunks/charts-core-DF99lItO.js.map +1 -0
- package/dist/client/chunks/{charts-loader-BCBnMYjH.js → charts-loader-AkRviD9H.js} +22 -22
- package/dist/client/chunks/{charts-loader-BCBnMYjH.js.map → charts-loader-AkRviD9H.js.map} +1 -1
- package/dist/client/chunks/{core-BITzuqYm.js → core-Bso4ultM.js} +2 -2
- package/dist/client/chunks/{core-BITzuqYm.js.map → core-Bso4ultM.js.map} +1 -1
- package/dist/client/chunks/{hooks-Dd_nnv0J.js → hooks-B69r8rwU.js} +4 -4
- package/dist/client/chunks/{hooks-Dd_nnv0J.js.map → hooks-B69r8rwU.js.map} +1 -1
- package/dist/client/chunks/{providers-BjxD1ZmC.js → providers-CxlSRYvE.js} +2 -2
- package/dist/client/chunks/{providers-BjxD1ZmC.js.map → providers-CxlSRYvE.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-Cmqp7_Mx.js → syntaxHighlighting-yTdSle2t.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-Cmqp7_Mx.js.map → syntaxHighlighting-yTdSle2t.js.map} +1 -1
- package/dist/client/chunks/{useDirtyStateTracking-B5g-bw7a.js → useDirtyStateTracking-GZtwGRu7.js} +3 -3
- package/dist/client/chunks/{useDirtyStateTracking-B5g-bw7a.js.map → useDirtyStateTracking-GZtwGRu7.js.map} +1 -1
- package/dist/client/chunks/{vendor-CJRtj0__.js → vendor-B_H-VRhj.js} +97 -99
- package/dist/client/chunks/vendor-B_H-VRhj.js.map +1 -0
- package/dist/client/components.js +4 -4
- package/dist/client/components.js.map +1 -1
- package/dist/client/hooks.js +3 -3
- package/dist/client/index.js +10 -10
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.js +6 -6
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +482 -482
- package/package.json +1 -1
- package/dist/client/chunks/DashboardEditModal-CVMSvpJ-.js.map +0 -1
- package/dist/client/chunks/RetentionCombinedChart-BVKWmxc-.js.map +0 -1
- package/dist/client/chunks/RetentionHeatmap-BiqfhGYk.js.map +0 -1
- package/dist/client/chunks/analysis-builder-CuTR61Ct.js.map +0 -1
- package/dist/client/chunks/analysis-builder-shared-D7iqklYk.js.map +0 -1
- package/dist/client/chunks/chart-area-KlBSb_ur.js.map +0 -1
- package/dist/client/chunks/chart-bar-D1i2jmIg.js.map +0 -1
- package/dist/client/chunks/chart-data-table-CYMMAHau.js.map +0 -1
- package/dist/client/chunks/chart-funnel-BH7r4HWZ.js.map +0 -1
- package/dist/client/chunks/chart-heat-map-DyGtODLE.js.map +0 -1
- package/dist/client/chunks/chart-kpi-delta-Bk396suk.js.map +0 -1
- package/dist/client/chunks/chart-kpi-number-CIGqZ5Dw.js.map +0 -1
- package/dist/client/chunks/chart-kpi-text-iwlaSQCi.js.map +0 -1
- package/dist/client/chunks/chart-line-BKqhoW9A.js.map +0 -1
- package/dist/client/chunks/chart-markdown-CiPhRY9s.js.map +0 -1
- package/dist/client/chunks/chart-pie-BNr-GgTh.js.map +0 -1
- package/dist/client/chunks/chart-radar-CYrGVYEQ.js.map +0 -1
- package/dist/client/chunks/chart-radial-bar-2PR3ucIR.js.map +0 -1
- package/dist/client/chunks/chart-scatter-D3Z9bl8H.js.map +0 -1
- package/dist/client/chunks/chart-tree-map-DCCmMyz1.js.map +0 -1
- package/dist/client/chunks/charts-core-DIW3Dd7n.js.map +0 -1
- package/dist/client/chunks/vendor-CJRtj0__.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -282,11 +282,11 @@ class $E extends Ue {
|
|
|
282
282
|
*/
|
|
283
283
|
buildWindowFunction(e, t, E, s, i) {
|
|
284
284
|
const r = E && E.length > 0 ? o`PARTITION BY ${o.join(E, o`, `)}` : o``, T = s && s.length > 0 ? o`ORDER BY ${o.join(s.map(
|
|
285
|
-
(
|
|
285
|
+
(I) => I.direction === "desc" ? o`${I.field} DESC` : o`${I.field} ASC`
|
|
286
286
|
), o`, `)}` : o``;
|
|
287
287
|
let A = o``;
|
|
288
288
|
if (i?.frame) {
|
|
289
|
-
const { type:
|
|
289
|
+
const { type: I, start: N, end: O } = i.frame, C = I.toUpperCase(), u = N === "unbounded" ? "UNBOUNDED PRECEDING" : typeof N == "number" ? `${N} PRECEDING` : "CURRENT ROW", l = O === "unbounded" ? "UNBOUNDED FOLLOWING" : O === "current" ? "CURRENT ROW" : typeof O == "number" ? `${O} FOLLOWING` : "CURRENT ROW";
|
|
290
290
|
A = o`${o.raw(C)} BETWEEN ${o.raw(u)} AND ${o.raw(l)}`;
|
|
291
291
|
}
|
|
292
292
|
const a = [];
|
|
@@ -318,7 +318,7 @@ class $E extends Ue {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
class
|
|
321
|
+
class IE extends Ue {
|
|
322
322
|
getEngineType() {
|
|
323
323
|
return "mysql";
|
|
324
324
|
}
|
|
@@ -560,11 +560,11 @@ class NE extends Ue {
|
|
|
560
560
|
*/
|
|
561
561
|
buildWindowFunction(e, t, E, s, i) {
|
|
562
562
|
const r = E && E.length > 0 ? o`PARTITION BY ${o.join(E, o`, `)}` : o``, T = s && s.length > 0 ? o`ORDER BY ${o.join(s.map(
|
|
563
|
-
(
|
|
563
|
+
(I) => I.direction === "desc" ? o`${I.field} DESC` : o`${I.field} ASC`
|
|
564
564
|
), o`, `)}` : o``;
|
|
565
565
|
let A = o``;
|
|
566
566
|
if (i?.frame) {
|
|
567
|
-
const { type:
|
|
567
|
+
const { type: I, start: N, end: O } = i.frame, C = I.toUpperCase(), u = N === "unbounded" ? "UNBOUNDED PRECEDING" : typeof N == "number" ? `${N} PRECEDING` : "CURRENT ROW", l = O === "unbounded" ? "UNBOUNDED FOLLOWING" : O === "current" ? "CURRENT ROW" : typeof O == "number" ? `${O} FOLLOWING` : "CURRENT ROW";
|
|
568
568
|
A = o`${o.raw(C)} BETWEEN ${o.raw(u)} AND ${o.raw(l)}`;
|
|
569
569
|
}
|
|
570
570
|
const a = [];
|
|
@@ -877,11 +877,11 @@ class wE extends Ue {
|
|
|
877
877
|
*/
|
|
878
878
|
buildWindowFunction(e, t, E, s, i) {
|
|
879
879
|
const r = E && E.length > 0 ? o`PARTITION BY ${o.join(E, o`, `)}` : o``, T = s && s.length > 0 ? o`ORDER BY ${o.join(s.map(
|
|
880
|
-
(
|
|
880
|
+
(I) => I.direction === "desc" ? o`${I.field} DESC` : o`${I.field} ASC`
|
|
881
881
|
), o`, `)}` : o``;
|
|
882
882
|
let A = o``;
|
|
883
883
|
if (i?.frame) {
|
|
884
|
-
const { type:
|
|
884
|
+
const { type: I, start: N, end: O } = i.frame, C = I.toUpperCase(), u = N === "unbounded" ? "UNBOUNDED PRECEDING" : typeof N == "number" ? `${N} PRECEDING` : "CURRENT ROW", l = O === "unbounded" ? "UNBOUNDED FOLLOWING" : O === "current" ? "CURRENT ROW" : typeof O == "number" ? `${O} FOLLOWING` : "CURRENT ROW";
|
|
885
885
|
A = o`${o.raw(C)} BETWEEN ${o.raw(u)} AND ${o.raw(l)}`;
|
|
886
886
|
}
|
|
887
887
|
const a = [];
|
|
@@ -913,7 +913,7 @@ class wE extends Ue {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
-
class WE extends
|
|
916
|
+
class WE extends IE {
|
|
917
917
|
getEngineType() {
|
|
918
918
|
return "singlestore";
|
|
919
919
|
}
|
|
@@ -1155,11 +1155,11 @@ class vE extends Ue {
|
|
|
1155
1155
|
*/
|
|
1156
1156
|
buildWindowFunction(e, t, E, s, i) {
|
|
1157
1157
|
const r = E && E.length > 0 ? o`PARTITION BY ${o.join(E, o`, `)}` : o``, T = s && s.length > 0 ? o`ORDER BY ${o.join(s.map(
|
|
1158
|
-
(
|
|
1158
|
+
(I) => I.direction === "desc" ? o`${I.field} DESC` : o`${I.field} ASC`
|
|
1159
1159
|
), o`, `)}` : o``;
|
|
1160
1160
|
let A = o``;
|
|
1161
1161
|
if (i?.frame) {
|
|
1162
|
-
const { type:
|
|
1162
|
+
const { type: I, start: N, end: O } = i.frame, C = I.toUpperCase(), u = N === "unbounded" ? "UNBOUNDED PRECEDING" : typeof N == "number" ? `${N} PRECEDING` : "CURRENT ROW", l = O === "unbounded" ? "UNBOUNDED FOLLOWING" : O === "current" ? "CURRENT ROW" : typeof O == "number" ? `${O} FOLLOWING` : "CURRENT ROW";
|
|
1163
1163
|
A = o`${o.raw(C)} BETWEEN ${o.raw(u)} AND ${o.raw(l)}`;
|
|
1164
1164
|
}
|
|
1165
1165
|
const a = [];
|
|
@@ -1196,7 +1196,7 @@ function XE(n) {
|
|
|
1196
1196
|
case "postgres":
|
|
1197
1197
|
return new $E();
|
|
1198
1198
|
case "mysql":
|
|
1199
|
-
return new
|
|
1199
|
+
return new IE();
|
|
1200
1200
|
case "sqlite":
|
|
1201
1201
|
return new wE();
|
|
1202
1202
|
case "singlestore":
|
|
@@ -1225,24 +1225,24 @@ function KE(n, e) {
|
|
|
1225
1225
|
i = parseFloat(S[1]);
|
|
1226
1226
|
continue;
|
|
1227
1227
|
}
|
|
1228
|
-
const
|
|
1229
|
-
if (
|
|
1230
|
-
r = parseFloat(
|
|
1228
|
+
const I = R.match(/Execution Time:\s*([\d.]+)\s*ms/i);
|
|
1229
|
+
if (I) {
|
|
1230
|
+
r = parseFloat(I[1]);
|
|
1231
1231
|
continue;
|
|
1232
1232
|
}
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1233
|
+
const N = xE(R);
|
|
1234
|
+
if (N) {
|
|
1235
|
+
N.type.includes("Seq Scan") && (s = !0), N.index && E.push(N.index), t.length === 0 && N.estimatedCost !== void 0 && (T = N.estimatedCost);
|
|
1236
1236
|
const O = R.search(/\S/);
|
|
1237
1237
|
for (; A.length > 0 && A[A.length - 1].indent >= O; )
|
|
1238
1238
|
A.pop();
|
|
1239
1239
|
if (A.length === 0)
|
|
1240
|
-
t.push(
|
|
1240
|
+
t.push(N);
|
|
1241
1241
|
else {
|
|
1242
1242
|
const C = A[A.length - 1].op;
|
|
1243
|
-
C.children || (C.children = []), C.children.push(
|
|
1243
|
+
C.children || (C.children = []), C.children.push(N);
|
|
1244
1244
|
}
|
|
1245
|
-
A.push({ indent: O, op:
|
|
1245
|
+
A.push({ indent: O, op: N });
|
|
1246
1246
|
}
|
|
1247
1247
|
}
|
|
1248
1248
|
const a = {
|
|
@@ -1461,7 +1461,7 @@ function kE(n, e) {
|
|
|
1461
1461
|
sql: e
|
|
1462
1462
|
};
|
|
1463
1463
|
}
|
|
1464
|
-
class
|
|
1464
|
+
class NE extends fe {
|
|
1465
1465
|
async execute(e, t) {
|
|
1466
1466
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1467
1467
|
const s = await e.execute();
|
|
@@ -1566,7 +1566,7 @@ class IE extends fe {
|
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
function qE(n, e) {
|
|
1569
|
-
return new
|
|
1569
|
+
return new NE(n, e, "mysql");
|
|
1570
1570
|
}
|
|
1571
1571
|
function jE(n) {
|
|
1572
1572
|
const e = n.toLowerCase(), t = n.match(/^SCAN\s+(\S+)/i);
|
|
@@ -1736,8 +1736,8 @@ class zE extends fe {
|
|
|
1736
1736
|
), R = [];
|
|
1737
1737
|
if (Array.isArray(a))
|
|
1738
1738
|
for (const S of a) {
|
|
1739
|
-
const
|
|
1740
|
-
typeof
|
|
1739
|
+
const I = S.name;
|
|
1740
|
+
typeof I == "string" && R.push(I);
|
|
1741
1741
|
}
|
|
1742
1742
|
t.push({
|
|
1743
1743
|
table_name: E.toLowerCase(),
|
|
@@ -1757,7 +1757,7 @@ class zE extends fe {
|
|
|
1757
1757
|
function dt(n, e) {
|
|
1758
1758
|
return new zE(n, e, "sqlite");
|
|
1759
1759
|
}
|
|
1760
|
-
class es extends
|
|
1760
|
+
class es extends NE {
|
|
1761
1761
|
getEngineType() {
|
|
1762
1762
|
return "singlestore";
|
|
1763
1763
|
}
|
|
@@ -2175,7 +2175,7 @@ function os(n) {
|
|
|
2175
2175
|
measures: n.measures ? [...n.measures].sort() : void 0,
|
|
2176
2176
|
dimensions: n.dimensions ? [...n.dimensions].sort() : void 0,
|
|
2177
2177
|
filters: n.filters ? K(n.filters) : void 0,
|
|
2178
|
-
timeDimensions: n.timeDimensions ?
|
|
2178
|
+
timeDimensions: n.timeDimensions ? Is(n.timeDimensions) : void 0,
|
|
2179
2179
|
limit: n.limit,
|
|
2180
2180
|
offset: n.offset,
|
|
2181
2181
|
order: n.order ? me(n.order) : void 0,
|
|
@@ -2254,7 +2254,7 @@ function K(n) {
|
|
|
2254
2254
|
};
|
|
2255
2255
|
}).sort((e, t) => JSON.stringify(e).localeCompare(JSON.stringify(t)));
|
|
2256
2256
|
}
|
|
2257
|
-
function
|
|
2257
|
+
function Is(n) {
|
|
2258
2258
|
return [...n].map((e) => ({
|
|
2259
2259
|
dimension: e.dimension,
|
|
2260
2260
|
granularity: e.granularity,
|
|
@@ -2280,7 +2280,7 @@ function Pt(n) {
|
|
|
2280
2280
|
function Qa(n, e) {
|
|
2281
2281
|
return `${e ?? "drizzle-cube:"}*${n}*`;
|
|
2282
2282
|
}
|
|
2283
|
-
class
|
|
2283
|
+
class Ne {
|
|
2284
2284
|
constructor(e) {
|
|
2285
2285
|
this.databaseAdapter = e;
|
|
2286
2286
|
}
|
|
@@ -2339,80 +2339,80 @@ class Ie {
|
|
|
2339
2339
|
parseRelativeDateRange(e) {
|
|
2340
2340
|
const t = /* @__PURE__ */ new Date(), E = e.toLowerCase().trim(), s = t.getUTCFullYear(), i = t.getUTCMonth(), r = t.getUTCDate(), T = t.getUTCDay();
|
|
2341
2341
|
if (E === "today") {
|
|
2342
|
-
const N = new Date(t);
|
|
2343
|
-
N.setUTCHours(0, 0, 0, 0);
|
|
2344
2342
|
const I = new Date(t);
|
|
2345
|
-
|
|
2343
|
+
I.setUTCHours(0, 0, 0, 0);
|
|
2344
|
+
const N = new Date(t);
|
|
2345
|
+
return N.setUTCHours(23, 59, 59, 999), { start: I, end: N };
|
|
2346
2346
|
}
|
|
2347
2347
|
if (E === "yesterday") {
|
|
2348
|
-
const N = new Date(t);
|
|
2349
|
-
N.setUTCDate(r - 1), N.setUTCHours(0, 0, 0, 0);
|
|
2350
2348
|
const I = new Date(t);
|
|
2351
|
-
|
|
2349
|
+
I.setUTCDate(r - 1), I.setUTCHours(0, 0, 0, 0);
|
|
2350
|
+
const N = new Date(t);
|
|
2351
|
+
return N.setUTCDate(r - 1), N.setUTCHours(23, 59, 59, 999), { start: I, end: N };
|
|
2352
2352
|
}
|
|
2353
2353
|
if (E === "this week") {
|
|
2354
|
-
const
|
|
2355
|
-
|
|
2356
|
-
const O = new Date(
|
|
2357
|
-
return O.setUTCDate(
|
|
2354
|
+
const I = T === 0 ? -6 : 1 - T, N = new Date(t);
|
|
2355
|
+
N.setUTCDate(r + I), N.setUTCHours(0, 0, 0, 0);
|
|
2356
|
+
const O = new Date(N);
|
|
2357
|
+
return O.setUTCDate(N.getUTCDate() + 6), O.setUTCHours(23, 59, 59, 999), { start: N, end: O };
|
|
2358
2358
|
}
|
|
2359
2359
|
if (E === "this month") {
|
|
2360
|
-
const
|
|
2361
|
-
return { start:
|
|
2360
|
+
const I = new Date(Date.UTC(s, i, 1, 0, 0, 0, 0)), N = new Date(Date.UTC(s, i + 1, 0, 23, 59, 59, 999));
|
|
2361
|
+
return { start: I, end: N };
|
|
2362
2362
|
}
|
|
2363
2363
|
if (E === "this quarter") {
|
|
2364
|
-
const
|
|
2365
|
-
return { start:
|
|
2364
|
+
const I = Math.floor(i / 3), N = new Date(Date.UTC(s, I * 3, 1, 0, 0, 0, 0)), O = new Date(Date.UTC(s, I * 3 + 3, 0, 23, 59, 59, 999));
|
|
2365
|
+
return { start: N, end: O };
|
|
2366
2366
|
}
|
|
2367
2367
|
if (E === "this year") {
|
|
2368
|
-
const
|
|
2369
|
-
return { start:
|
|
2368
|
+
const I = new Date(Date.UTC(s, 0, 1, 0, 0, 0, 0)), N = new Date(Date.UTC(s, 11, 31, 23, 59, 59, 999));
|
|
2369
|
+
return { start: I, end: N };
|
|
2370
2370
|
}
|
|
2371
2371
|
const A = E.match(/^last\s+(\d+)\s+days?$/);
|
|
2372
2372
|
if (A) {
|
|
2373
|
-
const
|
|
2374
|
-
|
|
2373
|
+
const I = parseInt(A[1], 10), N = new Date(t);
|
|
2374
|
+
N.setUTCDate(r - I + 1), N.setUTCHours(0, 0, 0, 0);
|
|
2375
2375
|
const O = new Date(t);
|
|
2376
|
-
return O.setUTCHours(23, 59, 59, 999), { start:
|
|
2376
|
+
return O.setUTCHours(23, 59, 59, 999), { start: N, end: O };
|
|
2377
2377
|
}
|
|
2378
2378
|
const a = E.match(/^last\s+(\d+)\s+weeks?$/);
|
|
2379
2379
|
if (a) {
|
|
2380
|
-
const
|
|
2381
|
-
O.setUTCDate(r -
|
|
2380
|
+
const N = parseInt(a[1], 10) * 7, O = new Date(t);
|
|
2381
|
+
O.setUTCDate(r - N + 1), O.setUTCHours(0, 0, 0, 0);
|
|
2382
2382
|
const C = new Date(t);
|
|
2383
2383
|
return C.setUTCHours(23, 59, 59, 999), { start: O, end: C };
|
|
2384
2384
|
}
|
|
2385
2385
|
if (E === "last week") {
|
|
2386
|
-
const
|
|
2387
|
-
|
|
2388
|
-
const O = new Date(
|
|
2389
|
-
return O.setUTCDate(
|
|
2386
|
+
const I = T === 0 ? -13 : -6 - T, N = new Date(t);
|
|
2387
|
+
N.setUTCDate(r + I), N.setUTCHours(0, 0, 0, 0);
|
|
2388
|
+
const O = new Date(N);
|
|
2389
|
+
return O.setUTCDate(N.getUTCDate() + 6), O.setUTCHours(23, 59, 59, 999), { start: N, end: O };
|
|
2390
2390
|
}
|
|
2391
2391
|
if (E === "last month") {
|
|
2392
|
-
const
|
|
2393
|
-
return { start:
|
|
2392
|
+
const I = new Date(Date.UTC(s, i - 1, 1, 0, 0, 0, 0)), N = new Date(Date.UTC(s, i, 0, 23, 59, 59, 999));
|
|
2393
|
+
return { start: I, end: N };
|
|
2394
2394
|
}
|
|
2395
2395
|
if (E === "last quarter") {
|
|
2396
|
-
const
|
|
2396
|
+
const I = Math.floor(i / 3), N = I === 0 ? 3 : I - 1, O = I === 0 ? s - 1 : s, C = new Date(Date.UTC(O, N * 3, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(O, N * 3 + 3, 0, 23, 59, 59, 999));
|
|
2397
2397
|
return { start: C, end: u };
|
|
2398
2398
|
}
|
|
2399
2399
|
if (E === "last year") {
|
|
2400
|
-
const
|
|
2401
|
-
return { start:
|
|
2400
|
+
const I = new Date(Date.UTC(s - 1, 0, 1, 0, 0, 0, 0)), N = new Date(Date.UTC(s - 1, 11, 31, 23, 59, 59, 999));
|
|
2401
|
+
return { start: I, end: N };
|
|
2402
2402
|
}
|
|
2403
2403
|
if (E === "last 12 months") {
|
|
2404
|
-
const
|
|
2405
|
-
return
|
|
2404
|
+
const I = new Date(Date.UTC(s, i - 11, 1, 0, 0, 0, 0)), N = new Date(t);
|
|
2405
|
+
return N.setUTCHours(23, 59, 59, 999), { start: I, end: N };
|
|
2406
2406
|
}
|
|
2407
2407
|
const R = E.match(/^last\s+(\d+)\s+months?$/);
|
|
2408
2408
|
if (R) {
|
|
2409
|
-
const
|
|
2410
|
-
return O.setUTCHours(23, 59, 59, 999), { start:
|
|
2409
|
+
const I = parseInt(R[1], 10), N = new Date(Date.UTC(s, i - I + 1, 1, 0, 0, 0, 0)), O = new Date(t);
|
|
2410
|
+
return O.setUTCHours(23, 59, 59, 999), { start: N, end: O };
|
|
2411
2411
|
}
|
|
2412
2412
|
const S = E.match(/^last\s+(\d+)\s+years?$/);
|
|
2413
2413
|
if (S) {
|
|
2414
|
-
const
|
|
2415
|
-
return O.setUTCHours(23, 59, 59, 999), { start:
|
|
2414
|
+
const I = parseInt(S[1], 10), N = new Date(Date.UTC(s - I, 0, 1, 0, 0, 0, 0)), O = new Date(t);
|
|
2415
|
+
return O.setUTCHours(23, 59, 59, 999), { start: N, end: O };
|
|
2416
2416
|
}
|
|
2417
2417
|
return null;
|
|
2418
2418
|
}
|
|
@@ -2508,8 +2508,8 @@ class he {
|
|
|
2508
2508
|
if (A && a) {
|
|
2509
2509
|
const R = E[1];
|
|
2510
2510
|
if (typeof R == "string" && /^\d{4}-\d{2}-\d{2}$/.test(R.trim())) {
|
|
2511
|
-
const S = typeof a == "number" ? new Date(a * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(a),
|
|
2512
|
-
|
|
2511
|
+
const S = typeof a == "number" ? new Date(a * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(a), I = new Date(S);
|
|
2512
|
+
I.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? a = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(I.getTime() / 1e3) : I.getTime() : a = I.toISOString();
|
|
2513
2513
|
}
|
|
2514
2514
|
return y(
|
|
2515
2515
|
ae(e, A),
|
|
@@ -2828,30 +2828,30 @@ class se {
|
|
|
2828
2828
|
return e.type === "calculated" && !!e.calculatedSql;
|
|
2829
2829
|
}
|
|
2830
2830
|
}
|
|
2831
|
-
function
|
|
2831
|
+
function Ns(n, e) {
|
|
2832
2832
|
const { cube: t, allCubes: E, resolvedMeasures: s } = e, i = St(n), r = /* @__PURE__ */ new Map();
|
|
2833
2833
|
for (const S of i) {
|
|
2834
|
-
const { originalRef:
|
|
2834
|
+
const { originalRef: I, cubeName: N, fieldName: O } = S, C = N || t.name;
|
|
2835
2835
|
if (!E.get(C))
|
|
2836
2836
|
throw new Error(
|
|
2837
|
-
`Cannot substitute {${
|
|
2837
|
+
`Cannot substitute {${I}}: cube '${C}' not found`
|
|
2838
2838
|
);
|
|
2839
2839
|
const l = `${C}.${O}`, _ = s.get(l);
|
|
2840
2840
|
if (!_)
|
|
2841
2841
|
throw new Error(
|
|
2842
|
-
`Cannot substitute {${
|
|
2842
|
+
`Cannot substitute {${I}}: measure '${l}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
2843
2843
|
);
|
|
2844
2844
|
const U = _(), D = o`${U}`;
|
|
2845
|
-
r.set(
|
|
2845
|
+
r.set(I, D);
|
|
2846
2846
|
}
|
|
2847
2847
|
const T = [], A = [];
|
|
2848
2848
|
let a = 0;
|
|
2849
2849
|
for (const S of i) {
|
|
2850
|
-
const
|
|
2851
|
-
if (
|
|
2852
|
-
T.push(n.substring(a,
|
|
2850
|
+
const I = `{${S.originalRef}}`, N = n.indexOf(I, a);
|
|
2851
|
+
if (N >= 0) {
|
|
2852
|
+
T.push(n.substring(a, N));
|
|
2853
2853
|
const O = r.get(S.originalRef);
|
|
2854
|
-
O && A.push(O), a =
|
|
2854
|
+
O && A.push(O), a = N + I.length;
|
|
2855
2855
|
}
|
|
2856
2856
|
}
|
|
2857
2857
|
if (T.push(n.substring(a)), A.length === 0)
|
|
@@ -2934,9 +2934,9 @@ class H {
|
|
|
2934
2934
|
for (const R of t.values())
|
|
2935
2935
|
a.buildGraph(R);
|
|
2936
2936
|
for (const R of e) {
|
|
2937
|
-
const [S,
|
|
2938
|
-
if (
|
|
2939
|
-
const O =
|
|
2937
|
+
const [S, I] = R.split("."), N = t.get(S);
|
|
2938
|
+
if (N && N.measures && N.measures[I]) {
|
|
2939
|
+
const O = N.measures[I];
|
|
2940
2940
|
if (H.isPostAggregationWindow(O)) {
|
|
2941
2941
|
const C = H.getWindowBaseMeasure(O, S);
|
|
2942
2942
|
C && A.add(C);
|
|
@@ -2952,26 +2952,26 @@ class H {
|
|
|
2952
2952
|
}
|
|
2953
2953
|
}
|
|
2954
2954
|
for (const R of A) {
|
|
2955
|
-
const [S,
|
|
2956
|
-
if (
|
|
2957
|
-
const O =
|
|
2955
|
+
const [S, I] = R.split("."), N = t.get(S);
|
|
2956
|
+
if (N && N.measures && N.measures[I]) {
|
|
2957
|
+
const O = N.measures[I];
|
|
2958
2958
|
if (H.isPostAggregationWindow(O))
|
|
2959
2959
|
continue;
|
|
2960
2960
|
se.isCalculatedMeasure(O) ? T.includes(R) || T.push(R) : r.includes(R) || r.push(R);
|
|
2961
2961
|
}
|
|
2962
2962
|
}
|
|
2963
2963
|
for (const R of r) {
|
|
2964
|
-
const [S,
|
|
2964
|
+
const [S, I] = R.split("."), N = t.get(S), O = N.measures[I];
|
|
2965
2965
|
if (s) {
|
|
2966
|
-
const C = s(R, O,
|
|
2966
|
+
const C = s(R, O, N);
|
|
2967
2967
|
i.set(R, () => C);
|
|
2968
2968
|
} else
|
|
2969
|
-
i.set(R, () => this.buildMeasureExpression(O, E,
|
|
2969
|
+
i.set(R, () => this.buildMeasureExpression(O, E, N));
|
|
2970
2970
|
}
|
|
2971
2971
|
if (T.length > 0) {
|
|
2972
2972
|
const R = a.topologicalSort(T);
|
|
2973
2973
|
for (const S of R) {
|
|
2974
|
-
const [
|
|
2974
|
+
const [I, N] = S.split("."), O = t.get(I), C = O.measures[N];
|
|
2975
2975
|
i.set(S, () => this.buildCalculatedMeasure(
|
|
2976
2976
|
C,
|
|
2977
2977
|
O,
|
|
@@ -2993,7 +2993,7 @@ class H {
|
|
|
2993
2993
|
`Calculated measure '${t.name}.${e.name}' missing calculatedSql property`
|
|
2994
2994
|
);
|
|
2995
2995
|
const r = this.databaseAdapter.preprocessCalculatedTemplate(e.calculatedSql);
|
|
2996
|
-
return
|
|
2996
|
+
return Ns(r, {
|
|
2997
2997
|
cube: t,
|
|
2998
2998
|
allCubes: E,
|
|
2999
2999
|
resolvedMeasures: s
|
|
@@ -3022,30 +3022,30 @@ class H {
|
|
|
3022
3022
|
for (const A of T) {
|
|
3023
3023
|
const [a, R] = A.split("."), S = s.get(a);
|
|
3024
3024
|
if (S && S.measures[R]) {
|
|
3025
|
-
const
|
|
3025
|
+
const I = S.measures[R];
|
|
3026
3026
|
if (E.measures.includes(A)) {
|
|
3027
|
-
const
|
|
3027
|
+
const N = o`${o.identifier(E.cteAlias)}.${o.identifier(R)}`;
|
|
3028
3028
|
let O;
|
|
3029
|
-
switch (
|
|
3029
|
+
switch (I.type) {
|
|
3030
3030
|
case "count":
|
|
3031
3031
|
case "countDistinct":
|
|
3032
3032
|
case "sum":
|
|
3033
|
-
O = J(
|
|
3033
|
+
O = J(N);
|
|
3034
3034
|
break;
|
|
3035
3035
|
case "avg":
|
|
3036
|
-
O = this.databaseAdapter.buildAvg(
|
|
3036
|
+
O = this.databaseAdapter.buildAvg(N);
|
|
3037
3037
|
break;
|
|
3038
3038
|
case "min":
|
|
3039
|
-
O = le(
|
|
3039
|
+
O = le(N);
|
|
3040
3040
|
break;
|
|
3041
3041
|
case "max":
|
|
3042
|
-
O = Z(
|
|
3042
|
+
O = Z(N);
|
|
3043
3043
|
break;
|
|
3044
3044
|
case "number":
|
|
3045
|
-
O = J(
|
|
3045
|
+
O = J(N);
|
|
3046
3046
|
break;
|
|
3047
3047
|
default:
|
|
3048
|
-
O = J(
|
|
3048
|
+
O = J(N);
|
|
3049
3049
|
}
|
|
3050
3050
|
r.set(A, () => O);
|
|
3051
3051
|
}
|
|
@@ -3199,23 +3199,23 @@ class H {
|
|
|
3199
3199
|
let r;
|
|
3200
3200
|
if (i.partitionBy && i.partitionBy.length > 0 && E) {
|
|
3201
3201
|
const a = i.partitionBy.map((R) => {
|
|
3202
|
-
const S = R.includes(".") ? R.split(".")[1] : R,
|
|
3203
|
-
return
|
|
3202
|
+
const S = R.includes(".") ? R.split(".")[1] : R, I = E.dimensions?.[S];
|
|
3203
|
+
return I ? b(I.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${R}' not found in cube '${E.name}'`), null);
|
|
3204
3204
|
}).filter((R) => R !== null);
|
|
3205
3205
|
a.length > 0 && (r = a);
|
|
3206
3206
|
}
|
|
3207
3207
|
let T;
|
|
3208
3208
|
if (i.orderBy && i.orderBy.length > 0 && E) {
|
|
3209
3209
|
const a = i.orderBy.map((R) => {
|
|
3210
|
-
const S = R.field.includes(".") ? R.field.split(".")[1] : R.field,
|
|
3211
|
-
if (
|
|
3210
|
+
const S = R.field.includes(".") ? R.field.split(".")[1] : R.field, I = E.dimensions?.[S];
|
|
3211
|
+
if (I)
|
|
3212
3212
|
return {
|
|
3213
|
-
field: b(
|
|
3213
|
+
field: b(I.sql, t),
|
|
3214
3214
|
direction: R.direction
|
|
3215
3215
|
};
|
|
3216
|
-
const
|
|
3217
|
-
return
|
|
3218
|
-
field: b(
|
|
3216
|
+
const N = E.measures?.[S];
|
|
3217
|
+
return N && N.sql ? {
|
|
3218
|
+
field: b(N.sql, t),
|
|
3219
3219
|
direction: R.direction
|
|
3220
3220
|
} : (console.warn(`[drizzle-cube] Window function order field '${R.field}' not found in cube '${E.name}'`), null);
|
|
3221
3221
|
}).filter((R) => R !== null);
|
|
@@ -3440,15 +3440,15 @@ class Cs {
|
|
|
3440
3440
|
const i = [], r = e instanceof Map ? e : /* @__PURE__ */ new Map([[e.name, e]]), T = t.dimensions && t.dimensions.length > 0 || t.timeDimensions && t.timeDimensions.length > 0, A = t.measures && t.measures.length > 0, a = T && !A;
|
|
3441
3441
|
let R = !1;
|
|
3442
3442
|
for (const S of t.measures || []) {
|
|
3443
|
-
const [
|
|
3444
|
-
if (O && O.measures && O.measures[
|
|
3445
|
-
const C = O.measures[
|
|
3443
|
+
const [I, N] = S.split("."), O = r.get(I);
|
|
3444
|
+
if (O && O.measures && O.measures[N]) {
|
|
3445
|
+
const C = O.measures[N];
|
|
3446
3446
|
if (this.isAggregateFunctionType(C.type) || C.type === "calculated") {
|
|
3447
3447
|
R = !0;
|
|
3448
3448
|
break;
|
|
3449
3449
|
}
|
|
3450
3450
|
if (H.isPostAggregationWindow(C)) {
|
|
3451
|
-
const u = H.getWindowBaseMeasure(C,
|
|
3451
|
+
const u = H.getWindowBaseMeasure(C, I);
|
|
3452
3452
|
if (u) {
|
|
3453
3453
|
const [l, _] = u.split("."), D = r.get(l)?.measures?.[_];
|
|
3454
3454
|
if (D && this.isAggregateFunctionType(D.type)) {
|
|
@@ -3463,27 +3463,27 @@ class Cs {
|
|
|
3463
3463
|
return [];
|
|
3464
3464
|
if (t.dimensions)
|
|
3465
3465
|
for (const S of t.dimensions) {
|
|
3466
|
-
const [
|
|
3467
|
-
if (O && O.dimensions && O.dimensions[
|
|
3468
|
-
if (s?.preAggregationCTEs?.some((u) => u.cube.name ===
|
|
3469
|
-
const u = s.preAggregationCTEs.find((_) => _.cube.name ===
|
|
3466
|
+
const [I, N] = S.split("."), O = r.get(I);
|
|
3467
|
+
if (O && O.dimensions && O.dimensions[N])
|
|
3468
|
+
if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
|
|
3469
|
+
const u = s.preAggregationCTEs.find((_) => _.cube.name === I), l = u.joinKeys.find((_) => _.targetColumn === N);
|
|
3470
3470
|
if (l && l.sourceColumnObj)
|
|
3471
3471
|
i.push(l.sourceColumnObj);
|
|
3472
3472
|
else {
|
|
3473
|
-
const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(
|
|
3473
|
+
const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
|
|
3474
3474
|
i.push(_);
|
|
3475
3475
|
}
|
|
3476
3476
|
} else {
|
|
3477
|
-
const u = O.dimensions[
|
|
3477
|
+
const u = O.dimensions[N], l = b(u.sql, E);
|
|
3478
3478
|
i.push(l);
|
|
3479
3479
|
}
|
|
3480
3480
|
}
|
|
3481
3481
|
if (t.timeDimensions)
|
|
3482
3482
|
for (const S of t.timeDimensions) {
|
|
3483
|
-
const [
|
|
3484
|
-
if (O && O.dimensions && O.dimensions[
|
|
3485
|
-
if (s?.preAggregationCTEs?.some((u) => u.cube.name ===
|
|
3486
|
-
const u = s.preAggregationCTEs.find((_) => _.cube.name ===
|
|
3483
|
+
const [I, N] = S.dimension.split("."), O = r.get(I);
|
|
3484
|
+
if (O && O.dimensions && O.dimensions[N])
|
|
3485
|
+
if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
|
|
3486
|
+
const u = s.preAggregationCTEs.find((_) => _.cube.name === I), l = u.joinKeys.find((_) => _.targetColumn === N);
|
|
3487
3487
|
if (l && l.sourceColumnObj) {
|
|
3488
3488
|
const _ = this.dateTimeBuilder.buildTimeDimensionExpression(
|
|
3489
3489
|
l.sourceColumnObj,
|
|
@@ -3492,11 +3492,11 @@ class Cs {
|
|
|
3492
3492
|
);
|
|
3493
3493
|
i.push(_);
|
|
3494
3494
|
} else {
|
|
3495
|
-
const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(
|
|
3495
|
+
const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
|
|
3496
3496
|
i.push(_);
|
|
3497
3497
|
}
|
|
3498
3498
|
} else {
|
|
3499
|
-
const u = O.dimensions[
|
|
3499
|
+
const u = O.dimensions[N], l = this.dateTimeBuilder.buildTimeDimensionExpression(
|
|
3500
3500
|
u.sql,
|
|
3501
3501
|
S.granularity,
|
|
3502
3502
|
E
|
|
@@ -3513,7 +3513,7 @@ class ls {
|
|
|
3513
3513
|
groupByBuilder;
|
|
3514
3514
|
measureBuilder;
|
|
3515
3515
|
constructor(e) {
|
|
3516
|
-
this.dateTimeBuilder = new
|
|
3516
|
+
this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder), this.groupByBuilder = new Cs(this.dateTimeBuilder), this.measureBuilder = new H(e);
|
|
3517
3517
|
}
|
|
3518
3518
|
/**
|
|
3519
3519
|
* Build resolvedMeasures map for a set of measures
|
|
@@ -3612,8 +3612,8 @@ class ls {
|
|
|
3612
3612
|
if (i && "member" in a) {
|
|
3613
3613
|
const [S] = a.member.split(".");
|
|
3614
3614
|
if (T.has(S) && i.has(S) && !A.has(S)) {
|
|
3615
|
-
const
|
|
3616
|
-
r.push(...
|
|
3615
|
+
const N = i.get(S);
|
|
3616
|
+
r.push(...N), A.add(S);
|
|
3617
3617
|
continue;
|
|
3618
3618
|
} else if (A.has(S))
|
|
3619
3619
|
continue;
|
|
@@ -3623,8 +3623,8 @@ class ls {
|
|
|
3623
3623
|
}
|
|
3624
3624
|
if (t.timeDimensions)
|
|
3625
3625
|
for (const a of t.timeDimensions) {
|
|
3626
|
-
const [R, S] = a.dimension.split("."),
|
|
3627
|
-
if (
|
|
3626
|
+
const [R, S] = a.dimension.split("."), I = T.get(R);
|
|
3627
|
+
if (I && I.dimensions[S] && a.dateRange) {
|
|
3628
3628
|
if (s?.preAggregationCTEs && s.preAggregationCTEs.some((l) => l.cube.name === R))
|
|
3629
3629
|
continue;
|
|
3630
3630
|
if (E.filterCache) {
|
|
@@ -3634,7 +3634,7 @@ class ls {
|
|
|
3634
3634
|
continue;
|
|
3635
3635
|
}
|
|
3636
3636
|
}
|
|
3637
|
-
const
|
|
3637
|
+
const N = I.dimensions[S], O = b(N.sql, E), C = this.buildDateRangeCondition(O, a.dateRange);
|
|
3638
3638
|
C && r.push(C);
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
@@ -3659,47 +3659,47 @@ class ls {
|
|
|
3659
3659
|
*/
|
|
3660
3660
|
processFilter(e, t, E, s, i) {
|
|
3661
3661
|
if ("and" in e || "or" in e) {
|
|
3662
|
-
const
|
|
3663
|
-
if (
|
|
3664
|
-
const O =
|
|
3662
|
+
const N = e;
|
|
3663
|
+
if (N.and) {
|
|
3664
|
+
const O = N.and.map((C) => this.processFilter(C, t, E, s, i)).filter((C) => C !== null);
|
|
3665
3665
|
return O.length > 0 ? y(...O) : null;
|
|
3666
3666
|
}
|
|
3667
|
-
if (
|
|
3668
|
-
const O =
|
|
3667
|
+
if (N.or) {
|
|
3668
|
+
const O = N.or.map((C) => this.processFilter(C, t, E, s, i)).filter((C) => C !== null);
|
|
3669
3669
|
return O.length > 0 ? Ce(...O) : null;
|
|
3670
3670
|
}
|
|
3671
3671
|
}
|
|
3672
3672
|
const r = e, [T, A] = r.member.split("."), a = t.get(T);
|
|
3673
3673
|
if (!a) return null;
|
|
3674
|
-
const R = a.dimensions[A], S = a.measures[A],
|
|
3675
|
-
if (!
|
|
3674
|
+
const R = a.dimensions[A], S = a.measures[A], I = R || S;
|
|
3675
|
+
if (!I) return null;
|
|
3676
3676
|
if (s === "where" && R) {
|
|
3677
3677
|
if (i?.preAggregationCTEs && i.preAggregationCTEs.some((u) => u.cube.name === T))
|
|
3678
3678
|
return null;
|
|
3679
|
-
const
|
|
3680
|
-
if (!
|
|
3679
|
+
const N = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator);
|
|
3680
|
+
if (!N && E.filterCache) {
|
|
3681
3681
|
const C = De(e), u = E.filterCache.get(C);
|
|
3682
3682
|
if (u)
|
|
3683
3683
|
return u;
|
|
3684
3684
|
}
|
|
3685
|
-
const O =
|
|
3685
|
+
const O = N ? typeof R.sql == "function" ? R.sql(E) : R.sql : b(R.sql, E);
|
|
3686
3686
|
return this.buildFilterCondition(
|
|
3687
3687
|
O,
|
|
3688
3688
|
r.operator,
|
|
3689
3689
|
r.values,
|
|
3690
|
-
|
|
3690
|
+
I,
|
|
3691
3691
|
r.dateRange
|
|
3692
3692
|
);
|
|
3693
3693
|
} else {
|
|
3694
3694
|
if (s === "where" && S)
|
|
3695
3695
|
return null;
|
|
3696
3696
|
if (s === "having" && S) {
|
|
3697
|
-
const
|
|
3697
|
+
const N = this.buildHavingMeasureExpression(T, A, S, E, i);
|
|
3698
3698
|
return this.buildFilterCondition(
|
|
3699
|
-
|
|
3699
|
+
N,
|
|
3700
3700
|
r.operator,
|
|
3701
3701
|
r.values,
|
|
3702
|
-
|
|
3702
|
+
I,
|
|
3703
3703
|
r.dateRange
|
|
3704
3704
|
);
|
|
3705
3705
|
}
|
|
@@ -3835,20 +3835,20 @@ class ue {
|
|
|
3835
3835
|
const { cube: A, path: a } = r.shift(), R = this.cubes.get(A);
|
|
3836
3836
|
if (R?.joins)
|
|
3837
3837
|
for (const [, S] of Object.entries(R.joins)) {
|
|
3838
|
-
const
|
|
3839
|
-
if (T.has(
|
|
3838
|
+
const N = Q(S.targetCube).name;
|
|
3839
|
+
if (T.has(N))
|
|
3840
3840
|
continue;
|
|
3841
3841
|
const O = [
|
|
3842
3842
|
...a,
|
|
3843
3843
|
{
|
|
3844
3844
|
fromCube: A,
|
|
3845
|
-
toCube:
|
|
3845
|
+
toCube: N,
|
|
3846
3846
|
joinDef: S
|
|
3847
3847
|
}
|
|
3848
3848
|
];
|
|
3849
|
-
if (
|
|
3849
|
+
if (N === t)
|
|
3850
3850
|
return this.setInCache(s, O), O;
|
|
3851
|
-
T.add(
|
|
3851
|
+
T.add(N), r.push({ cube: N, path: O });
|
|
3852
3852
|
}
|
|
3853
3853
|
}
|
|
3854
3854
|
return this.setInCache(s, null), null;
|
|
@@ -3881,7 +3881,7 @@ class ue {
|
|
|
3881
3881
|
const r = i.map((T) => {
|
|
3882
3882
|
let A = 0;
|
|
3883
3883
|
T.some(
|
|
3884
|
-
(S,
|
|
3884
|
+
(S, I) => S.joinDef.preferredFor?.includes(t) && I === 0
|
|
3885
3885
|
) && (A += 10);
|
|
3886
3886
|
const R = T.filter((S) => E.has(S.toCube)).length;
|
|
3887
3887
|
return A += R, A -= T.length - 1, {
|
|
@@ -3915,22 +3915,22 @@ class ue {
|
|
|
3915
3915
|
const R = this.cubes.get(T);
|
|
3916
3916
|
if (R?.joins)
|
|
3917
3917
|
for (const [, S] of Object.entries(R.joins)) {
|
|
3918
|
-
const
|
|
3919
|
-
if (a.has(
|
|
3918
|
+
const N = Q(S.targetCube).name;
|
|
3919
|
+
if (a.has(N))
|
|
3920
3920
|
continue;
|
|
3921
3921
|
const O = [
|
|
3922
3922
|
...A,
|
|
3923
3923
|
{
|
|
3924
3924
|
fromCube: T,
|
|
3925
|
-
toCube:
|
|
3925
|
+
toCube: N,
|
|
3926
3926
|
joinDef: S
|
|
3927
3927
|
}
|
|
3928
3928
|
];
|
|
3929
|
-
if (
|
|
3929
|
+
if (N === t)
|
|
3930
3930
|
i.push(O);
|
|
3931
3931
|
else {
|
|
3932
3932
|
const C = new Set(a);
|
|
3933
|
-
C.add(
|
|
3933
|
+
C.add(N), r.push({ cube: N, path: O, visited: C });
|
|
3934
3934
|
}
|
|
3935
3935
|
}
|
|
3936
3936
|
}
|
|
@@ -4135,29 +4135,29 @@ class CE {
|
|
|
4135
4135
|
buildJoinPlan(e, t, E, s, i) {
|
|
4136
4136
|
const r = this.getResolver(e), T = [], A = /* @__PURE__ */ new Set([t.name]), a = /* @__PURE__ */ new Set();
|
|
4137
4137
|
if (i.measures)
|
|
4138
|
-
for (const
|
|
4139
|
-
const [
|
|
4140
|
-
a.add(
|
|
4138
|
+
for (const I of i.measures) {
|
|
4139
|
+
const [N] = I.split(".");
|
|
4140
|
+
a.add(N);
|
|
4141
4141
|
}
|
|
4142
4142
|
const R = /* @__PURE__ */ new Set();
|
|
4143
|
-
for (const
|
|
4144
|
-
if (
|
|
4145
|
-
this.findHasManyJoinDef(t,
|
|
4143
|
+
for (const I of a) {
|
|
4144
|
+
if (I === t.name) continue;
|
|
4145
|
+
this.findHasManyJoinDef(t, I) && R.add(I);
|
|
4146
4146
|
}
|
|
4147
|
-
const S = E.filter((
|
|
4148
|
-
for (const
|
|
4149
|
-
if (A.has(
|
|
4147
|
+
const S = E.filter((I) => I !== t.name);
|
|
4148
|
+
for (const I of S) {
|
|
4149
|
+
if (A.has(I))
|
|
4150
4150
|
continue;
|
|
4151
|
-
const
|
|
4151
|
+
const N = new Set(
|
|
4152
4152
|
[...A].filter((C) => !R.has(C))
|
|
4153
4153
|
), O = r.findPathPreferring(
|
|
4154
4154
|
t.name,
|
|
4155
|
-
|
|
4155
|
+
I,
|
|
4156
4156
|
a,
|
|
4157
|
-
|
|
4157
|
+
N
|
|
4158
4158
|
);
|
|
4159
4159
|
if (!O || O.length === 0)
|
|
4160
|
-
throw new Error(`No join path found from '${t.name}' to '${
|
|
4160
|
+
throw new Error(`No join path found from '${t.name}' to '${I}'`);
|
|
4161
4161
|
for (const { toCube: C, joinDef: u } of O) {
|
|
4162
4162
|
if (A.has(C))
|
|
4163
4163
|
continue;
|
|
@@ -4237,14 +4237,14 @@ class CE {
|
|
|
4237
4237
|
alias: R.alias,
|
|
4238
4238
|
isPrimary: !1
|
|
4239
4239
|
});
|
|
4240
|
-
for (const { cube: R, alias: S, isPrimary:
|
|
4241
|
-
const
|
|
4240
|
+
for (const { cube: R, alias: S, isPrimary: I } of a) {
|
|
4241
|
+
const N = this.getCTEReason(
|
|
4242
4242
|
R,
|
|
4243
4243
|
t,
|
|
4244
4244
|
T,
|
|
4245
4245
|
s
|
|
4246
4246
|
);
|
|
4247
|
-
if (!
|
|
4247
|
+
if (!N)
|
|
4248
4248
|
continue;
|
|
4249
4249
|
const O = s.measures.filter(
|
|
4250
4250
|
(h) => h.startsWith(R.name + ".")
|
|
@@ -4256,10 +4256,10 @@ class CE {
|
|
|
4256
4256
|
if (l?.hasIntermediateHasMany && l.intermediateJoins.length > 0)
|
|
4257
4257
|
_ = l.correctJoinKeys, U = l.intermediateJoins;
|
|
4258
4258
|
else {
|
|
4259
|
-
const h =
|
|
4259
|
+
const h = I ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, R.name);
|
|
4260
4260
|
if (!h)
|
|
4261
4261
|
continue;
|
|
4262
|
-
_ =
|
|
4262
|
+
_ = I ? h.joinDef.on.map((G) => ({
|
|
4263
4263
|
sourceColumn: G.target.name,
|
|
4264
4264
|
targetColumn: G.source.name,
|
|
4265
4265
|
sourceColumnObj: G.target,
|
|
@@ -4297,7 +4297,7 @@ class CE {
|
|
|
4297
4297
|
downstreamJoinKeys: G.length > 0 ? G : void 0,
|
|
4298
4298
|
intermediateJoins: U && U.length > 0 ? U : void 0,
|
|
4299
4299
|
cteType: "aggregate",
|
|
4300
|
-
cteReason:
|
|
4300
|
+
cteReason: N
|
|
4301
4301
|
});
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
@@ -4335,12 +4335,12 @@ class CE {
|
|
|
4335
4335
|
const r = this.getResolver(e).findPath(t.name, E);
|
|
4336
4336
|
if (!r || r.length === 0)
|
|
4337
4337
|
return null;
|
|
4338
|
-
const T = r.map((
|
|
4339
|
-
fromCube:
|
|
4340
|
-
toCube:
|
|
4341
|
-
joinDef:
|
|
4338
|
+
const T = r.map((N) => ({
|
|
4339
|
+
fromCube: N.fromCube,
|
|
4340
|
+
toCube: N.toCube,
|
|
4341
|
+
joinDef: N.joinDef
|
|
4342
4342
|
}));
|
|
4343
|
-
if (!T.slice(0, -1).some((
|
|
4343
|
+
if (!T.slice(0, -1).some((N) => N.joinDef.relationship === "hasMany"))
|
|
4344
4344
|
return {
|
|
4345
4345
|
path: T,
|
|
4346
4346
|
hasIntermediateHasMany: !1,
|
|
@@ -4348,8 +4348,8 @@ class CE {
|
|
|
4348
4348
|
correctJoinKeys: []
|
|
4349
4349
|
};
|
|
4350
4350
|
const R = [];
|
|
4351
|
-
for (let
|
|
4352
|
-
const O = T[
|
|
4351
|
+
for (let N = 0; N < T.length - 1; N++) {
|
|
4352
|
+
const O = T[N], C = T[N + 1], u = e.get(O.toCube);
|
|
4353
4353
|
if (!u) continue;
|
|
4354
4354
|
const _ = u.sql(s).where, U = C.joinDef.on[0]?.source, D = O.joinDef.on[0]?.target;
|
|
4355
4355
|
R.push({
|
|
@@ -4360,19 +4360,19 @@ class CE {
|
|
|
4360
4360
|
cteJoinColumn: U
|
|
4361
4361
|
});
|
|
4362
4362
|
}
|
|
4363
|
-
const
|
|
4364
|
-
sourceColumn:
|
|
4363
|
+
const I = T[0].joinDef.on.map((N) => ({
|
|
4364
|
+
sourceColumn: N.source.name,
|
|
4365
4365
|
// Column on primary cube
|
|
4366
|
-
targetColumn:
|
|
4366
|
+
targetColumn: N.target.name,
|
|
4367
4367
|
// Column on first intermediate (which CTE will include via JOIN)
|
|
4368
|
-
sourceColumnObj:
|
|
4369
|
-
targetColumnObj:
|
|
4368
|
+
sourceColumnObj: N.source,
|
|
4369
|
+
targetColumnObj: N.target
|
|
4370
4370
|
}));
|
|
4371
4371
|
return {
|
|
4372
4372
|
path: T,
|
|
4373
4373
|
hasIntermediateHasMany: !0,
|
|
4374
4374
|
intermediateJoins: R,
|
|
4375
|
-
correctJoinKeys:
|
|
4375
|
+
correctJoinKeys: I
|
|
4376
4376
|
};
|
|
4377
4377
|
}
|
|
4378
4378
|
/**
|
|
@@ -4560,16 +4560,16 @@ class CE {
|
|
|
4560
4560
|
if (T?.joins) {
|
|
4561
4561
|
for (const [, A] of Object.entries(T.joins))
|
|
4562
4562
|
if (Q(A.targetCube).name === t.name && A.relationship === "hasMany") {
|
|
4563
|
-
const R = this.extractFiltersForCube(e.filters, r), S = this.extractTimeDimensionFiltersForCube(e, r),
|
|
4564
|
-
|
|
4563
|
+
const R = this.extractFiltersForCube(e.filters, r), S = this.extractTimeDimensionFiltersForCube(e, r), I = [...R, ...S];
|
|
4564
|
+
I.length > 0 && A.on.length > 0 && s.push({
|
|
4565
4565
|
sourceCube: T,
|
|
4566
|
-
filters:
|
|
4566
|
+
filters: I,
|
|
4567
4567
|
// Map all join keys for composite key support
|
|
4568
4568
|
// source = filterCube PK (e.g., employees.id)
|
|
4569
4569
|
// target = cteCube FK (e.g., productivity.employeeId)
|
|
4570
|
-
joinConditions: A.on.map((
|
|
4571
|
-
source:
|
|
4572
|
-
target:
|
|
4570
|
+
joinConditions: A.on.map((N) => ({
|
|
4571
|
+
source: N.source,
|
|
4572
|
+
target: N.target
|
|
4573
4573
|
}))
|
|
4574
4574
|
});
|
|
4575
4575
|
}
|
|
@@ -4720,19 +4720,19 @@ class CE {
|
|
|
4720
4720
|
a,
|
|
4721
4721
|
t
|
|
4722
4722
|
));
|
|
4723
|
-
const S = A.joinPaths.filter((C) => C.pathFound),
|
|
4723
|
+
const S = A.joinPaths.filter((C) => C.pathFound), I = A.joinPaths.filter((C) => !C.pathFound);
|
|
4724
4724
|
A.querySummary.joinCount = S.length, A.querySummary.cteCount = A.preAggregations.length, A.querySummary.hasPreAggregation = A.preAggregations.length > 0;
|
|
4725
|
-
const
|
|
4725
|
+
const N = /* @__PURE__ */ new Map();
|
|
4726
4726
|
for (const C of i) {
|
|
4727
4727
|
const u = e.get(C);
|
|
4728
|
-
u &&
|
|
4728
|
+
u && N.set(C, u);
|
|
4729
4729
|
}
|
|
4730
4730
|
const O = H.hasPostAggregationWindows(
|
|
4731
4731
|
t.measures || [],
|
|
4732
|
-
|
|
4732
|
+
N
|
|
4733
4733
|
);
|
|
4734
4734
|
A.querySummary.hasWindowFunctions = O, A.preAggregations.length > 0 ? A.querySummary.queryType = "multi_cube_cte" : A.querySummary.queryType = "multi_cube_join";
|
|
4735
|
-
for (const C of
|
|
4735
|
+
for (const C of I)
|
|
4736
4736
|
A.warnings.push(
|
|
4737
4737
|
`No join path found to cube '${C.targetCube}'. Check that joins are defined correctly.`
|
|
4738
4738
|
);
|
|
@@ -4757,31 +4757,31 @@ class CE {
|
|
|
4757
4757
|
r.set(R, (r.get(R) || 0) + 1);
|
|
4758
4758
|
const T = this.getResolver(E);
|
|
4759
4759
|
for (const R of e) {
|
|
4760
|
-
const S = E.get(R),
|
|
4760
|
+
const S = E.get(R), I = r.get(R) || 0, N = S?.joins ? Object.keys(S.joins).length : 0, O = T.canReachAll(R, e);
|
|
4761
4761
|
s.push({
|
|
4762
4762
|
cubeName: R,
|
|
4763
|
-
dimensionCount:
|
|
4764
|
-
joinCount:
|
|
4763
|
+
dimensionCount: I,
|
|
4764
|
+
joinCount: N,
|
|
4765
4765
|
canReachAll: O
|
|
4766
4766
|
});
|
|
4767
4767
|
}
|
|
4768
4768
|
if (t.dimensions && t.dimensions.length > 0) {
|
|
4769
4769
|
const R = Math.max(...s.map((S) => S.dimensionCount));
|
|
4770
4770
|
if (R > 0) {
|
|
4771
|
-
const S = s.filter((
|
|
4772
|
-
for (const
|
|
4773
|
-
if (
|
|
4771
|
+
const S = s.filter((I) => I.dimensionCount === R).sort((I, N) => I.cubeName.localeCompare(N.cubeName));
|
|
4772
|
+
for (const I of S)
|
|
4773
|
+
if (I.canReachAll)
|
|
4774
4774
|
return {
|
|
4775
|
-
selectedCube:
|
|
4775
|
+
selectedCube: I.cubeName,
|
|
4776
4776
|
reason: "most_dimensions",
|
|
4777
|
-
explanation: `Selected because it has ${
|
|
4777
|
+
explanation: `Selected because it has ${I.dimensionCount} dimension${I.dimensionCount !== 1 ? "s" : ""} in the query (defines the analytical grain)`,
|
|
4778
4778
|
candidates: s
|
|
4779
4779
|
};
|
|
4780
4780
|
}
|
|
4781
4781
|
}
|
|
4782
4782
|
const A = s.filter((R) => R.canReachAll);
|
|
4783
4783
|
if (A.length > 0) {
|
|
4784
|
-
const R = Math.max(...A.map((
|
|
4784
|
+
const R = Math.max(...A.map((I) => I.joinCount)), S = A.filter((I) => I.joinCount === R).sort((I, N) => I.cubeName.localeCompare(N.cubeName))[0];
|
|
4785
4785
|
return {
|
|
4786
4786
|
selectedCube: S.cubeName,
|
|
4787
4787
|
reason: "most_connected",
|
|
@@ -4815,9 +4815,9 @@ class CE {
|
|
|
4815
4815
|
visitedCubes: r
|
|
4816
4816
|
};
|
|
4817
4817
|
const T = i.map((A) => {
|
|
4818
|
-
const a = Tt(A.joinDef.relationship, A.joinDef.sqlJoinType), R = A.joinDef.on.map((
|
|
4819
|
-
sourceColumn:
|
|
4820
|
-
targetColumn:
|
|
4818
|
+
const a = Tt(A.joinDef.relationship, A.joinDef.sqlJoinType), R = A.joinDef.on.map((I) => ({
|
|
4819
|
+
sourceColumn: I.source.name,
|
|
4820
|
+
targetColumn: I.target.name
|
|
4821
4821
|
})), S = {
|
|
4822
4822
|
fromCube: A.fromCube,
|
|
4823
4823
|
toCube: A.toCube,
|
|
@@ -4826,11 +4826,11 @@ class CE {
|
|
|
4826
4826
|
joinColumns: R
|
|
4827
4827
|
};
|
|
4828
4828
|
if (A.joinDef.relationship === "belongsToMany" && A.joinDef.through) {
|
|
4829
|
-
const
|
|
4829
|
+
const I = A.joinDef.through;
|
|
4830
4830
|
S.junctionTable = {
|
|
4831
|
-
tableName:
|
|
4832
|
-
sourceColumns:
|
|
4833
|
-
targetColumns:
|
|
4831
|
+
tableName: I.table[/* @__PURE__ */ Symbol.for("drizzle:Name")] || "junction_table",
|
|
4832
|
+
sourceColumns: I.sourceKey.map((N) => N.target.name),
|
|
4833
|
+
targetColumns: I.targetKey.map((N) => N.source.name)
|
|
4834
4834
|
};
|
|
4835
4835
|
}
|
|
4836
4836
|
return S;
|
|
@@ -4863,12 +4863,12 @@ class CE {
|
|
|
4863
4863
|
), R = this.extractMeasuresFromFilters(s, A), S = [.../* @__PURE__ */ new Set([...a, ...R])];
|
|
4864
4864
|
if (S.length === 0)
|
|
4865
4865
|
continue;
|
|
4866
|
-
const
|
|
4866
|
+
const I = T.on.map((_) => ({
|
|
4867
4867
|
sourceColumn: _.source.name,
|
|
4868
4868
|
targetColumn: _.target.name
|
|
4869
|
-
})),
|
|
4869
|
+
})), N = /* @__PURE__ */ new Map([[r, A]]), { aggregateMeasures: O, postAggWindowMeasures: C, requiredBaseMeasures: u } = H.categorizeForPostAggregation(
|
|
4870
4870
|
S,
|
|
4871
|
-
|
|
4871
|
+
N
|
|
4872
4872
|
), l = [.../* @__PURE__ */ new Set([
|
|
4873
4873
|
...O,
|
|
4874
4874
|
...Array.from(u).filter((_) => _.startsWith(r + "."))
|
|
@@ -4881,7 +4881,7 @@ class CE {
|
|
|
4881
4881
|
reason: _ ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
|
|
4882
4882
|
reasonType: "hasMany",
|
|
4883
4883
|
measures: l,
|
|
4884
|
-
joinKeys:
|
|
4884
|
+
joinKeys: I,
|
|
4885
4885
|
cteType: "aggregate"
|
|
4886
4886
|
});
|
|
4887
4887
|
}
|
|
@@ -4969,13 +4969,13 @@ class us {
|
|
|
4969
4969
|
for (const m of e.downstreamJoinKeys)
|
|
4970
4970
|
for (const P of m.joinKeys)
|
|
4971
4971
|
P.sourceColumnObj && (a[P.sourceColumn] = P.sourceColumnObj);
|
|
4972
|
-
const R = r.name, S = /* @__PURE__ */ new Map([[R, r]]),
|
|
4972
|
+
const R = r.name, S = /* @__PURE__ */ new Map([[R, r]]), I = this.queryBuilder.buildResolvedMeasures(
|
|
4973
4973
|
e.measures,
|
|
4974
4974
|
S,
|
|
4975
4975
|
E
|
|
4976
4976
|
);
|
|
4977
4977
|
for (const m of e.measures) {
|
|
4978
|
-
const [, P] = m.split("."), M =
|
|
4978
|
+
const [, P] = m.split("."), M = I.get(m);
|
|
4979
4979
|
if (M) {
|
|
4980
4980
|
const g = M();
|
|
4981
4981
|
a[P] = o`${g}`.as(P);
|
|
@@ -4999,11 +4999,11 @@ class us {
|
|
|
4999
4999
|
}
|
|
5000
5000
|
if (Object.keys(a).length === 0)
|
|
5001
5001
|
return null;
|
|
5002
|
-
let
|
|
5002
|
+
let N = E.db.select(a).from(T.from);
|
|
5003
5003
|
if (A && e.intermediateJoins)
|
|
5004
5004
|
for (const m of e.intermediateJoins) {
|
|
5005
5005
|
const P = m.cube.sql(E), g = [X(m.cteJoinColumn, m.joinDef.on[0]?.target)];
|
|
5006
|
-
m.securityFilter && g.push(m.securityFilter),
|
|
5006
|
+
m.securityFilter && g.push(m.securityFilter), N = N.leftJoin(
|
|
5007
5007
|
P.from,
|
|
5008
5008
|
y(...g)
|
|
5009
5009
|
);
|
|
@@ -5044,7 +5044,7 @@ class us {
|
|
|
5044
5044
|
const l = [];
|
|
5045
5045
|
if (T.where && l.push(T.where), l.push(...C, ...u), l.length > 0) {
|
|
5046
5046
|
const m = l.length === 1 ? l[0] : y(...l);
|
|
5047
|
-
|
|
5047
|
+
N = N.where(m);
|
|
5048
5048
|
}
|
|
5049
5049
|
const _ = [], U = /* @__PURE__ */ new Set(), D = (m) => {
|
|
5050
5050
|
const P = m?.name || (typeof m == "string" ? m : null);
|
|
@@ -5076,7 +5076,7 @@ class us {
|
|
|
5076
5076
|
_.push(h);
|
|
5077
5077
|
}
|
|
5078
5078
|
}
|
|
5079
|
-
return _.length > 0 && (
|
|
5079
|
+
return _.length > 0 && (N = N.groupBy(..._)), E.db.$with(e.cteAlias).as(N);
|
|
5080
5080
|
}
|
|
5081
5081
|
/**
|
|
5082
5082
|
* Build join condition for CTE
|
|
@@ -5235,24 +5235,24 @@ function Ds(n, e) {
|
|
|
5235
5235
|
return n;
|
|
5236
5236
|
const a = /* @__PURE__ */ new Map();
|
|
5237
5237
|
for (const S of n) {
|
|
5238
|
-
const
|
|
5239
|
-
a.has(
|
|
5238
|
+
const I = ds(S, T), N = cs(S[t]);
|
|
5239
|
+
a.has(I) || a.set(I, /* @__PURE__ */ new Map()), a.get(I).set(N, S);
|
|
5240
5240
|
}
|
|
5241
5241
|
a.size === 0 && T.length === 0 && a.set("__all__", /* @__PURE__ */ new Map());
|
|
5242
5242
|
const R = [];
|
|
5243
|
-
for (const [S,
|
|
5244
|
-
const
|
|
5243
|
+
for (const [S, I] of a) {
|
|
5244
|
+
const N = I.size > 0 ? I.values().next().value : null;
|
|
5245
5245
|
for (const O of A) {
|
|
5246
|
-
const C = O.toISOString(), u =
|
|
5246
|
+
const C = O.toISOString(), u = I.get(C);
|
|
5247
5247
|
if (u)
|
|
5248
5248
|
R.push(u);
|
|
5249
5249
|
else {
|
|
5250
5250
|
const l = {
|
|
5251
5251
|
[t]: C
|
|
5252
5252
|
};
|
|
5253
|
-
if (
|
|
5253
|
+
if (N)
|
|
5254
5254
|
for (const _ of T)
|
|
5255
|
-
l[_] =
|
|
5255
|
+
l[_] = N[_];
|
|
5256
5256
|
for (const _ of r)
|
|
5257
5257
|
l[_] = i;
|
|
5258
5258
|
R.push(l);
|
|
@@ -5303,7 +5303,7 @@ function Mt(n, e, t) {
|
|
|
5303
5303
|
class Ps {
|
|
5304
5304
|
dateTimeBuilder;
|
|
5305
5305
|
constructor(e) {
|
|
5306
|
-
this.dateTimeBuilder = new
|
|
5306
|
+
this.dateTimeBuilder = new Ne(e);
|
|
5307
5307
|
}
|
|
5308
5308
|
/**
|
|
5309
5309
|
* Check if a query contains compareDateRange
|
|
@@ -5486,7 +5486,7 @@ class Ps {
|
|
|
5486
5486
|
}
|
|
5487
5487
|
class ps {
|
|
5488
5488
|
constructor(e) {
|
|
5489
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5489
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
|
|
5490
5490
|
}
|
|
5491
5491
|
filterBuilder;
|
|
5492
5492
|
dateTimeBuilder;
|
|
@@ -5536,14 +5536,14 @@ class ps {
|
|
|
5536
5536
|
const T = r ? new ue(t) : null, A = Array.isArray(i.filter) ? i.filter : [i.filter];
|
|
5537
5537
|
for (const a of A)
|
|
5538
5538
|
if ("member" in a) {
|
|
5539
|
-
const [R, S] = a.member.split("."),
|
|
5540
|
-
if (!
|
|
5539
|
+
const [R, S] = a.member.split("."), I = t.get(R);
|
|
5540
|
+
if (!I)
|
|
5541
5541
|
E.push(`Step ${s} filter cube not found: ${R}`);
|
|
5542
|
-
else if (
|
|
5542
|
+
else if (I.dimensions?.[S] || (I.measures?.[S] ? E.push(
|
|
5543
5543
|
`Step ${s} filter '${R}.${S}' is a measure. Funnel step filters only support dimensions, not measures.`
|
|
5544
5544
|
) : E.push(`Step ${s} filter member not found: ${S} in cube ${R}`)), r && R !== r && T) {
|
|
5545
|
-
const
|
|
5546
|
-
(!
|
|
5545
|
+
const N = T.findPath(r, R);
|
|
5546
|
+
(!N || N.length === 0) && E.push(
|
|
5547
5547
|
`Step ${s} filter '${R}.${S}' requires a join from '${r}' but no join path was found. Define a join relationship between these cubes.`
|
|
5548
5548
|
);
|
|
5549
5549
|
}
|
|
@@ -5623,13 +5623,13 @@ class ps {
|
|
|
5623
5623
|
resolveSteps(e, t, E) {
|
|
5624
5624
|
const s = new ue(t);
|
|
5625
5625
|
return e.steps.map((i, r) => {
|
|
5626
|
-
const T = this.resolveCubeForStep(i, e, t), A = this.resolveBindingKey(e, T, E), a = this.resolveTimeDimension(e, T, E), R = this.buildStepFilters(i, T, t, E), S = this.extractFilterCubeNames(i),
|
|
5627
|
-
for (const
|
|
5628
|
-
if (
|
|
5629
|
-
const O = t.get(
|
|
5626
|
+
const T = this.resolveCubeForStep(i, e, t), A = this.resolveBindingKey(e, T, E), a = this.resolveTimeDimension(e, T, E), R = this.buildStepFilters(i, T, t, E), S = this.extractFilterCubeNames(i), I = [];
|
|
5627
|
+
for (const N of S)
|
|
5628
|
+
if (N !== T.name) {
|
|
5629
|
+
const O = t.get(N);
|
|
5630
5630
|
if (O) {
|
|
5631
|
-
const C = s.findPath(T.name,
|
|
5632
|
-
C && C.length > 0 &&
|
|
5631
|
+
const C = s.findPath(T.name, N);
|
|
5632
|
+
C && C.length > 0 && I.push({ cube: O, joinPath: C });
|
|
5633
5633
|
}
|
|
5634
5634
|
}
|
|
5635
5635
|
return {
|
|
@@ -5640,7 +5640,7 @@ class ps {
|
|
|
5640
5640
|
timeExpr: a,
|
|
5641
5641
|
filterConditions: R,
|
|
5642
5642
|
timeToConvert: i.timeToConvert,
|
|
5643
|
-
joinedCubes:
|
|
5643
|
+
joinedCubes: I
|
|
5644
5644
|
};
|
|
5645
5645
|
});
|
|
5646
5646
|
}
|
|
@@ -5748,8 +5748,8 @@ class ps {
|
|
|
5748
5748
|
const T = e, [A, a] = T.member.split("."), R = T.dateRange !== void 0;
|
|
5749
5749
|
if (T.operator !== "set" && T.operator !== "notSet" && !R && (!T.values || T.values.length === 0 || T.values[0] === void 0 || T.values[0] === ""))
|
|
5750
5750
|
return null;
|
|
5751
|
-
const
|
|
5752
|
-
if (!
|
|
5751
|
+
const I = E.get(A);
|
|
5752
|
+
if (!I)
|
|
5753
5753
|
return null;
|
|
5754
5754
|
if (A !== t.name) {
|
|
5755
5755
|
const u = new ue(E).findPath(t.name, A);
|
|
@@ -5758,14 +5758,14 @@ class ps {
|
|
|
5758
5758
|
`Funnel filter: Cannot filter by '${A}.${a}' in step using '${t.name}'. No join path found. Filter will be skipped.`
|
|
5759
5759
|
), null;
|
|
5760
5760
|
}
|
|
5761
|
-
const
|
|
5762
|
-
if (!
|
|
5763
|
-
const O = b(
|
|
5761
|
+
const N = I.dimensions?.[a];
|
|
5762
|
+
if (!N) return null;
|
|
5763
|
+
const O = b(N.sql, s);
|
|
5764
5764
|
return this.filterBuilder.buildFilterCondition(
|
|
5765
5765
|
O,
|
|
5766
5766
|
T.operator,
|
|
5767
5767
|
T.values || [],
|
|
5768
|
-
|
|
5768
|
+
N,
|
|
5769
5769
|
T.dateRange
|
|
5770
5770
|
);
|
|
5771
5771
|
}
|
|
@@ -5847,8 +5847,8 @@ class ps {
|
|
|
5847
5847
|
for (const i of t.joinedCubes)
|
|
5848
5848
|
for (const r of i.joinPath) {
|
|
5849
5849
|
const T = r.joinDef, A = [];
|
|
5850
|
-
for (const
|
|
5851
|
-
|
|
5850
|
+
for (const I of T.on)
|
|
5851
|
+
I.as ? A.push(I.as(I.source, I.target)) : A.push(X(I.source, I.target));
|
|
5852
5852
|
const a = A.length === 1 ? A[0] : y(...A), S = i.cube.sql(E);
|
|
5853
5853
|
e = e.leftJoin(S.from, a), S.where && s.push(S.where);
|
|
5854
5854
|
}
|
|
@@ -5911,12 +5911,12 @@ class ps {
|
|
|
5911
5911
|
const a = o.identifier(`step_${A}_time`), R = o.identifier(`step_${A - 1}_time`), S = this.databaseAdapter.buildTimeDifferenceSeconds(
|
|
5912
5912
|
o`${a}`,
|
|
5913
5913
|
o`${R}`
|
|
5914
|
-
),
|
|
5915
|
-
r[`step_${A}_avg_seconds`] = this.databaseAdapter.buildConditionalAggregation("avg", S,
|
|
5916
|
-
const
|
|
5917
|
-
O &&
|
|
5914
|
+
), I = o`${a} IS NOT NULL`;
|
|
5915
|
+
r[`step_${A}_avg_seconds`] = this.databaseAdapter.buildConditionalAggregation("avg", S, I).as(`step_${A}_avg_seconds`), r[`step_${A}_min_seconds`] = this.databaseAdapter.buildConditionalAggregation("min", S, I).as(`step_${A}_min_seconds`), r[`step_${A}_max_seconds`] = this.databaseAdapter.buildConditionalAggregation("max", S, I).as(`step_${A}_max_seconds`);
|
|
5916
|
+
const N = this.databaseAdapter.getCapabilities(), O = this.databaseAdapter.buildPercentile(S, 50);
|
|
5917
|
+
O && N.supportsPercentileSubqueries && (r[`step_${A}_median_seconds`] = o`(SELECT ${O} FROM ${o.identifier("funnel_joined")} WHERE ${a} IS NOT NULL)`.as(`step_${A}_median_seconds`));
|
|
5918
5918
|
const C = this.databaseAdapter.buildPercentile(S, 90);
|
|
5919
|
-
C &&
|
|
5919
|
+
C && N.supportsPercentileSubqueries && (r[`step_${A}_p90_seconds`] = o`(SELECT ${C} FROM ${o.identifier("funnel_joined")} WHERE ${a} IS NOT NULL)`.as(`step_${A}_p90_seconds`));
|
|
5920
5920
|
}
|
|
5921
5921
|
const T = i.db.select(r).from(e);
|
|
5922
5922
|
return i.db.$with("funnel_metrics").as(T);
|
|
@@ -5927,7 +5927,7 @@ class Ms {
|
|
|
5927
5927
|
dateTimeBuilder;
|
|
5928
5928
|
databaseAdapter;
|
|
5929
5929
|
constructor(e) {
|
|
5930
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5930
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
|
|
5931
5931
|
}
|
|
5932
5932
|
/**
|
|
5933
5933
|
* Check if query contains flow configuration
|
|
@@ -6023,10 +6023,10 @@ class Ms {
|
|
|
6023
6023
|
stepsBefore: e.outputMode === "sunburst" ? 0 : e.stepsBefore
|
|
6024
6024
|
}, a = this.resolveFlowConfig(A, t, E), R = [], S = this.buildStartingEntitiesCTE(A, a, E);
|
|
6025
6025
|
R.push(S);
|
|
6026
|
-
const
|
|
6027
|
-
R.push(...N);
|
|
6028
|
-
const I = T ? this.buildAfterCTEsLateral(A, a, E) : this.buildAfterCTEsWindow(A, a, E);
|
|
6026
|
+
const I = T ? this.buildBeforeCTEsLateral(A, a, E) : this.buildBeforeCTEsWindow(A, a, E);
|
|
6029
6027
|
R.push(...I);
|
|
6028
|
+
const N = T ? this.buildAfterCTEsLateral(A, a, E) : this.buildAfterCTEsWindow(A, a, E);
|
|
6029
|
+
R.push(...N);
|
|
6030
6030
|
const O = this.buildNodesAggregationCTE(A, E);
|
|
6031
6031
|
R.push(O);
|
|
6032
6032
|
const C = this.buildLinksAggregationCTE(A, E);
|
|
@@ -6155,8 +6155,8 @@ class Ms {
|
|
|
6155
6155
|
if ("and" in e || "or" in e) {
|
|
6156
6156
|
const A = e, a = [], R = A.and || A.or || [];
|
|
6157
6157
|
for (const S of R) {
|
|
6158
|
-
const
|
|
6159
|
-
|
|
6158
|
+
const I = this.buildFilterCondition(S, t, E);
|
|
6159
|
+
I && a.push(I);
|
|
6160
6160
|
}
|
|
6161
6161
|
return a.length === 0 ? null : a.length === 1 ? a[0] : "and" in e ? y(...a) : o`(${o.join(a, o` OR `)})`;
|
|
6162
6162
|
}
|
|
@@ -6210,17 +6210,17 @@ class Ms {
|
|
|
6210
6210
|
buildBeforeCTEsLateral(e, t, E) {
|
|
6211
6211
|
const { cubeBase: s, bindingKeyExpr: i, timeExpr: r, eventExpr: T } = t, A = [], a = e.outputMode === "sunburst";
|
|
6212
6212
|
for (let R = 1; R <= e.stepsBefore; R++) {
|
|
6213
|
-
const S = R === 1 ? "starting_entities" : `before_step_${R - 1}`,
|
|
6213
|
+
const S = R === 1 ? "starting_entities" : `before_step_${R - 1}`, I = R === 1 ? "start_time" : "step_time", N = `before_step_${R}`, O = [];
|
|
6214
6214
|
s.where && O.push(s.where), O.push(
|
|
6215
6215
|
o`${i} = ${o.identifier(S)}.binding_key`,
|
|
6216
|
-
o`${r} < ${o.identifier(S)}.${o.identifier(
|
|
6216
|
+
o`${r} < ${o.identifier(S)}.${o.identifier(I)}`
|
|
6217
6217
|
);
|
|
6218
6218
|
const C = O.length === 1 ? O[0] : y(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, l = E.db.select({
|
|
6219
6219
|
binding_key: o`${i}`.as("binding_key"),
|
|
6220
6220
|
step_time: o`${r}`.as("step_time"),
|
|
6221
6221
|
event_type: o`${T}`.as("event_type"),
|
|
6222
6222
|
event_path: u.as("event_path")
|
|
6223
|
-
}).from(s.from).where(C).orderBy(o`${r} DESC`).limit(1), _ = E.db.$with(
|
|
6223
|
+
}).from(s.from).where(C).orderBy(o`${r} DESC`).limit(1), _ = E.db.$with(N).as(
|
|
6224
6224
|
E.db.select({
|
|
6225
6225
|
binding_key: o`e.binding_key`.as("binding_key"),
|
|
6226
6226
|
step_time: o`e.step_time`.as("step_time"),
|
|
@@ -6239,17 +6239,17 @@ class Ms {
|
|
|
6239
6239
|
buildAfterCTEsLateral(e, t, E) {
|
|
6240
6240
|
const { cubeBase: s, bindingKeyExpr: i, timeExpr: r, eventExpr: T } = t, A = [], a = e.outputMode === "sunburst";
|
|
6241
6241
|
for (let R = 1; R <= e.stepsAfter; R++) {
|
|
6242
|
-
const S = R === 1 ? "starting_entities" : `after_step_${R - 1}`,
|
|
6242
|
+
const S = R === 1 ? "starting_entities" : `after_step_${R - 1}`, I = R === 1 ? "start_time" : "step_time", N = `after_step_${R}`, O = [];
|
|
6243
6243
|
s.where && O.push(s.where), O.push(
|
|
6244
6244
|
o`${i} = ${o.identifier(S)}.binding_key`,
|
|
6245
|
-
o`${r} > ${o.identifier(S)}.${o.identifier(
|
|
6245
|
+
o`${r} > ${o.identifier(S)}.${o.identifier(I)}`
|
|
6246
6246
|
);
|
|
6247
6247
|
const C = O.length === 1 ? O[0] : y(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, l = E.db.select({
|
|
6248
6248
|
binding_key: o`${i}`.as("binding_key"),
|
|
6249
6249
|
step_time: o`${r}`.as("step_time"),
|
|
6250
6250
|
event_type: o`${T}`.as("event_type"),
|
|
6251
6251
|
event_path: u.as("event_path")
|
|
6252
|
-
}).from(s.from).where(C).orderBy(o`${r} ASC`).limit(1), _ = E.db.$with(
|
|
6252
|
+
}).from(s.from).where(C).orderBy(o`${r} ASC`).limit(1), _ = E.db.$with(N).as(
|
|
6253
6253
|
E.db.select({
|
|
6254
6254
|
binding_key: o`e.binding_key`.as("binding_key"),
|
|
6255
6255
|
step_time: o`e.step_time`.as("step_time"),
|
|
@@ -6271,9 +6271,9 @@ class Ms {
|
|
|
6271
6271
|
buildBeforeCTEsWindow(e, t, E) {
|
|
6272
6272
|
const { cubeBase: s, bindingKeyExpr: i, timeExpr: r, eventExpr: T } = t, A = [], a = e.outputMode === "sunburst";
|
|
6273
6273
|
for (let R = 1; R <= e.stepsBefore; R++) {
|
|
6274
|
-
const S = R === 1 ? "starting_entities" : `before_step_${R - 1}`,
|
|
6274
|
+
const S = R === 1 ? "starting_entities" : `before_step_${R - 1}`, I = R === 1 ? "start_time" : "step_time", N = `before_step_${R}`, O = [];
|
|
6275
6275
|
s.where && O.push(s.where), O.push(
|
|
6276
|
-
o`${r} < ${o.identifier(S)}.${o.identifier(
|
|
6276
|
+
o`${r} < ${o.identifier(S)}.${o.identifier(I)}`
|
|
6277
6277
|
);
|
|
6278
6278
|
const C = O.length === 1 ? O[0] : y(...O), u = a ? o`${T} || ${"→"} || ${o.identifier(S)}.event_path` : o`${T}`, l = E.db.select({
|
|
6279
6279
|
binding_key: o`${i}`.as("binding_key"),
|
|
@@ -6290,7 +6290,7 @@ class Ms {
|
|
|
6290
6290
|
event_type: o`event_type`.as("event_type"),
|
|
6291
6291
|
event_path: o`event_path`.as("event_path")
|
|
6292
6292
|
}).from(l.as("ranked")).where(o`rn = 1`);
|
|
6293
|
-
A.push(E.db.$with(
|
|
6293
|
+
A.push(E.db.$with(N).as(_));
|
|
6294
6294
|
}
|
|
6295
6295
|
return A;
|
|
6296
6296
|
}
|
|
@@ -6304,9 +6304,9 @@ class Ms {
|
|
|
6304
6304
|
buildAfterCTEsWindow(e, t, E) {
|
|
6305
6305
|
const { cubeBase: s, bindingKeyExpr: i, timeExpr: r, eventExpr: T } = t, A = [], a = e.outputMode === "sunburst";
|
|
6306
6306
|
for (let R = 1; R <= e.stepsAfter; R++) {
|
|
6307
|
-
const S = R === 1 ? "starting_entities" : `after_step_${R - 1}`,
|
|
6307
|
+
const S = R === 1 ? "starting_entities" : `after_step_${R - 1}`, I = R === 1 ? "start_time" : "step_time", N = `after_step_${R}`, O = [];
|
|
6308
6308
|
s.where && O.push(s.where), O.push(
|
|
6309
|
-
o`${r} > ${o.identifier(S)}.${o.identifier(
|
|
6309
|
+
o`${r} > ${o.identifier(S)}.${o.identifier(I)}`
|
|
6310
6310
|
);
|
|
6311
6311
|
const C = O.length === 1 ? O[0] : y(...O), u = a ? o`${o.identifier(S)}.event_path || ${"→"} || ${T}` : o`${T}`, l = E.db.select({
|
|
6312
6312
|
binding_key: o`${i}`.as("binding_key"),
|
|
@@ -6323,7 +6323,7 @@ class Ms {
|
|
|
6323
6323
|
event_type: o`event_type`.as("event_type"),
|
|
6324
6324
|
event_path: o`event_path`.as("event_path")
|
|
6325
6325
|
}).from(l.as("ranked")).where(o`rn = 1`);
|
|
6326
|
-
A.push(E.db.$with(
|
|
6326
|
+
A.push(E.db.$with(N).as(_));
|
|
6327
6327
|
}
|
|
6328
6328
|
return A;
|
|
6329
6329
|
}
|
|
@@ -6548,7 +6548,7 @@ function ht(n) {
|
|
|
6548
6548
|
}
|
|
6549
6549
|
class Us {
|
|
6550
6550
|
constructor(e) {
|
|
6551
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
6551
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
|
|
6552
6552
|
}
|
|
6553
6553
|
filterBuilder;
|
|
6554
6554
|
dateTimeBuilder;
|
|
@@ -6640,18 +6640,18 @@ class Us {
|
|
|
6640
6640
|
};
|
|
6641
6641
|
for (let O = 0; O < s.breakdowns.length; O++)
|
|
6642
6642
|
S[`breakdown_${O}`] = o.raw(`rc.breakdown_${O}`).as(`breakdown_${O}`);
|
|
6643
|
-
let
|
|
6643
|
+
let I = E.db.with(r, T, A, a).select(S).from(o`retention_counts rc`);
|
|
6644
6644
|
if (R) {
|
|
6645
6645
|
const O = s.breakdowns.map(
|
|
6646
6646
|
(u, l) => o`COALESCE(CAST(rc.breakdown_${o.raw(String(l))} AS TEXT), '') = COALESCE(CAST(cs.breakdown_${o.raw(String(l))} AS TEXT), '')`
|
|
6647
6647
|
), C = O.length === 1 ? O[0] : o.join(O, o` AND `);
|
|
6648
|
-
|
|
6648
|
+
I = I.innerJoin(o`cohort_sizes cs`, C);
|
|
6649
6649
|
} else
|
|
6650
|
-
|
|
6651
|
-
const
|
|
6650
|
+
I = I.innerJoin(o`cohort_sizes cs`, o`1 = 1`);
|
|
6651
|
+
const N = [];
|
|
6652
6652
|
for (let O = 0; O < s.breakdowns.length; O++)
|
|
6653
|
-
|
|
6654
|
-
return
|
|
6653
|
+
N.push(o.raw(`rc.breakdown_${O}`));
|
|
6654
|
+
return N.push(o`rc.period_number`), I = I.orderBy(...N), I;
|
|
6655
6655
|
}
|
|
6656
6656
|
/**
|
|
6657
6657
|
* Transform raw SQL results to RetentionResultRow[]
|
|
@@ -6687,32 +6687,32 @@ class Us {
|
|
|
6687
6687
|
const T = r.dimensions?.[i];
|
|
6688
6688
|
if (!T)
|
|
6689
6689
|
throw new Error(`Time dimension not found: ${i}`);
|
|
6690
|
-
const A = b(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E),
|
|
6690
|
+
const A = b(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E), I = [];
|
|
6691
6691
|
if (e.breakdownDimensions && e.breakdownDimensions.length > 0)
|
|
6692
|
-
for (const
|
|
6693
|
-
const [O, C] =
|
|
6692
|
+
for (const N of e.breakdownDimensions) {
|
|
6693
|
+
const [O, C] = N.split("."), u = t.get(O);
|
|
6694
6694
|
if (u && u.dimensions?.[C]) {
|
|
6695
6695
|
const l = b(u.dimensions[C].sql, E);
|
|
6696
|
-
|
|
6696
|
+
I.push({ dimension: N, expr: l });
|
|
6697
6697
|
}
|
|
6698
6698
|
}
|
|
6699
|
-
return { cube: r, bindingKeyExpr: a, timeExpr: A, cohortFilterConditions: R, activityFilterConditions: S, breakdowns:
|
|
6699
|
+
return { cube: r, bindingKeyExpr: a, timeExpr: A, cohortFilterConditions: R, activityFilterConditions: S, breakdowns: I };
|
|
6700
6700
|
}
|
|
6701
6701
|
/**
|
|
6702
6702
|
* Resolve binding key expression for a cube
|
|
6703
6703
|
*/
|
|
6704
6704
|
resolveBindingKey(e, t, E, s) {
|
|
6705
6705
|
if (Ut(e)) {
|
|
6706
|
-
const a = e.find((
|
|
6706
|
+
const a = e.find((N) => N.cube === t.name);
|
|
6707
6707
|
if (!a)
|
|
6708
6708
|
throw new Error(`No binding key mapping found for cube: ${t.name}`);
|
|
6709
6709
|
const R = this.extractDimensionName(a.dimension), S = E.get(a.cube);
|
|
6710
6710
|
if (!S)
|
|
6711
6711
|
throw new Error(`Binding key cube not found: ${a.cube}`);
|
|
6712
|
-
const
|
|
6713
|
-
if (!
|
|
6712
|
+
const I = S.dimensions?.[R];
|
|
6713
|
+
if (!I)
|
|
6714
6714
|
throw new Error(`Binding key dimension not found: ${a.dimension}`);
|
|
6715
|
-
return b(
|
|
6715
|
+
return b(I.sql, s);
|
|
6716
6716
|
}
|
|
6717
6717
|
const [i, r] = e.split("."), T = E.get(i);
|
|
6718
6718
|
if (!T)
|
|
@@ -6739,12 +6739,12 @@ class Us {
|
|
|
6739
6739
|
*/
|
|
6740
6740
|
buildSingleFilterCondition(e, t, E, s) {
|
|
6741
6741
|
if ("and" in e || "or" in e) {
|
|
6742
|
-
const S = e,
|
|
6742
|
+
const S = e, I = [], N = "and" in S && !!S.and, O = S.and || S.or || [];
|
|
6743
6743
|
for (const C of O) {
|
|
6744
6744
|
const u = this.buildSingleFilterCondition(C, t, E, s);
|
|
6745
|
-
u &&
|
|
6745
|
+
u && I.push(u);
|
|
6746
6746
|
}
|
|
6747
|
-
return
|
|
6747
|
+
return I.length === 0 ? null : I.length === 1 ? I[0] : N ? y(...I) : o`(${o.join(I, o` OR `)})`;
|
|
6748
6748
|
}
|
|
6749
6749
|
const i = e, [r, T] = i.member.split("."), A = E.get(r);
|
|
6750
6750
|
if (!A) return null;
|
|
@@ -7027,7 +7027,7 @@ class te {
|
|
|
7027
7027
|
this.preloadFilterCache(t, r, e, T);
|
|
7028
7028
|
const A = this.queryPlanner.createQueryPlan(e, t, T);
|
|
7029
7029
|
this.validateSecurityContext(A, T);
|
|
7030
|
-
const a = this.buildUnifiedQuery(A, t, T), R = this.queryBuilder.collectNumericFields(e, t), S = await this.dbExecutor.execute(a, R),
|
|
7030
|
+
const a = this.buildUnifiedQuery(A, t, T), R = this.queryBuilder.collectNumericFields(e, t), S = await this.dbExecutor.execute(a, R), I = Array.isArray(S) ? S.map((l) => {
|
|
7031
7031
|
const _ = { ...l };
|
|
7032
7032
|
if (t.timeDimensions) {
|
|
7033
7033
|
for (const U of t.timeDimensions)
|
|
@@ -7041,7 +7041,7 @@ class te {
|
|
|
7041
7041
|
}
|
|
7042
7042
|
}
|
|
7043
7043
|
return _;
|
|
7044
|
-
}) : [S],
|
|
7044
|
+
}) : [S], N = t.measures || [], O = Mt(I, t, N), C = this.generateAnnotations(A, t), u = {
|
|
7045
7045
|
data: O,
|
|
7046
7046
|
annotation: C,
|
|
7047
7047
|
// Include warnings from query planning (e.g., fan-out without dimensions)
|
|
@@ -7177,9 +7177,9 @@ class te {
|
|
|
7177
7177
|
};
|
|
7178
7178
|
return R.funnel = {
|
|
7179
7179
|
config: s,
|
|
7180
|
-
steps: s.steps.map((S,
|
|
7180
|
+
steps: s.steps.map((S, I) => ({
|
|
7181
7181
|
name: S.name,
|
|
7182
|
-
index:
|
|
7182
|
+
index: I,
|
|
7183
7183
|
timeToConvert: S.timeToConvert
|
|
7184
7184
|
}))
|
|
7185
7185
|
}, {
|
|
@@ -7326,10 +7326,10 @@ class te {
|
|
|
7326
7326
|
}
|
|
7327
7327
|
}
|
|
7328
7328
|
return C;
|
|
7329
|
-
}) : [a], S = t.measures || [],
|
|
7329
|
+
}) : [a], S = t.measures || [], I = Mt(R, t, S), N = this.generateAnnotations(r, t);
|
|
7330
7330
|
return {
|
|
7331
|
-
data:
|
|
7332
|
-
annotation:
|
|
7331
|
+
data: I,
|
|
7332
|
+
annotation: N
|
|
7333
7333
|
};
|
|
7334
7334
|
}
|
|
7335
7335
|
/**
|
|
@@ -7499,22 +7499,22 @@ class te {
|
|
|
7499
7499
|
}
|
|
7500
7500
|
}
|
|
7501
7501
|
}
|
|
7502
|
-
const
|
|
7503
|
-
let
|
|
7504
|
-
if (i.length > 0 && (
|
|
7502
|
+
const I = [];
|
|
7503
|
+
let N = E.db.select(S).from(A.from);
|
|
7504
|
+
if (i.length > 0 && (N = E.db.with(...i).select(S).from(A.from)), A.joins)
|
|
7505
7505
|
for (const D of A.joins)
|
|
7506
7506
|
switch (D.type || "left") {
|
|
7507
7507
|
case "left":
|
|
7508
|
-
|
|
7508
|
+
N = N.leftJoin(D.table, D.on);
|
|
7509
7509
|
break;
|
|
7510
7510
|
case "inner":
|
|
7511
|
-
|
|
7511
|
+
N = N.innerJoin(D.table, D.on);
|
|
7512
7512
|
break;
|
|
7513
7513
|
case "right":
|
|
7514
|
-
|
|
7514
|
+
N = N.rightJoin(D.table, D.on);
|
|
7515
7515
|
break;
|
|
7516
7516
|
case "full":
|
|
7517
|
-
|
|
7517
|
+
N = N.fullJoin(D.table, D.on);
|
|
7518
7518
|
break;
|
|
7519
7519
|
}
|
|
7520
7520
|
const O = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set();
|
|
@@ -7539,19 +7539,19 @@ class te {
|
|
|
7539
7539
|
try {
|
|
7540
7540
|
switch (F.joinType || "left") {
|
|
7541
7541
|
case "left":
|
|
7542
|
-
|
|
7542
|
+
N = N.leftJoin(F.table, F.joinCondition);
|
|
7543
7543
|
break;
|
|
7544
7544
|
case "inner":
|
|
7545
|
-
|
|
7545
|
+
N = N.innerJoin(F.table, F.joinCondition);
|
|
7546
7546
|
break;
|
|
7547
7547
|
case "right":
|
|
7548
|
-
|
|
7548
|
+
N = N.rightJoin(F.table, F.joinCondition);
|
|
7549
7549
|
break;
|
|
7550
7550
|
case "full":
|
|
7551
|
-
|
|
7551
|
+
N = N.fullJoin(F.table, F.joinCondition);
|
|
7552
7552
|
break;
|
|
7553
7553
|
}
|
|
7554
|
-
W.length > 0 &&
|
|
7554
|
+
W.length > 0 && I.push(...W);
|
|
7555
7555
|
} catch {
|
|
7556
7556
|
}
|
|
7557
7557
|
}
|
|
@@ -7574,28 +7574,28 @@ class te {
|
|
|
7574
7574
|
try {
|
|
7575
7575
|
switch (G) {
|
|
7576
7576
|
case "left":
|
|
7577
|
-
|
|
7577
|
+
N = N.leftJoin(M, B), h && O.add(D.cube.name);
|
|
7578
7578
|
break;
|
|
7579
7579
|
case "inner":
|
|
7580
|
-
|
|
7580
|
+
N = N.innerJoin(M, g);
|
|
7581
7581
|
break;
|
|
7582
7582
|
case "right":
|
|
7583
|
-
|
|
7583
|
+
N = N.rightJoin(M, B), h && O.add(D.cube.name);
|
|
7584
7584
|
break;
|
|
7585
7585
|
case "full":
|
|
7586
|
-
|
|
7586
|
+
N = N.fullJoin(M, B), h && O.add(D.cube.name);
|
|
7587
7587
|
break;
|
|
7588
7588
|
}
|
|
7589
7589
|
} catch {
|
|
7590
7590
|
}
|
|
7591
7591
|
}
|
|
7592
|
-
if (A.where &&
|
|
7592
|
+
if (A.where && I.push(A.where), e.joinCubes && e.joinCubes.length > 0)
|
|
7593
7593
|
for (const D of e.joinCubes) {
|
|
7594
7594
|
const m = D.cube.name;
|
|
7595
7595
|
if (r.get(m) || C.has(m) || O.has(m))
|
|
7596
7596
|
continue;
|
|
7597
7597
|
const M = D.cube.sql(E);
|
|
7598
|
-
M.where &&
|
|
7598
|
+
M.where && I.push(M.where);
|
|
7599
7599
|
}
|
|
7600
7600
|
const u = this.queryBuilder.buildWhereConditions(
|
|
7601
7601
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
@@ -7607,9 +7607,9 @@ class te {
|
|
|
7607
7607
|
s
|
|
7608
7608
|
// Reuse pre-built filters for parameter deduplication
|
|
7609
7609
|
);
|
|
7610
|
-
if (u.length > 0 &&
|
|
7611
|
-
const D =
|
|
7612
|
-
|
|
7610
|
+
if (u.length > 0 && I.push(...u), I.length > 0) {
|
|
7611
|
+
const D = I.length === 1 ? I[0] : y(...I);
|
|
7612
|
+
N = N.where(D);
|
|
7613
7613
|
}
|
|
7614
7614
|
const l = this.queryBuilder.buildGroupByFields(
|
|
7615
7615
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
@@ -7619,7 +7619,7 @@ class te {
|
|
|
7619
7619
|
e
|
|
7620
7620
|
// Pass the queryPlan to handle CTE scenarios
|
|
7621
7621
|
);
|
|
7622
|
-
l.length > 0 && (
|
|
7622
|
+
l.length > 0 && (N = N.groupBy(...l));
|
|
7623
7623
|
const _ = this.queryBuilder.buildHavingConditions(
|
|
7624
7624
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
7625
7625
|
// Single cube
|
|
@@ -7630,10 +7630,10 @@ class te {
|
|
|
7630
7630
|
);
|
|
7631
7631
|
if (_.length > 0) {
|
|
7632
7632
|
const D = _.length === 1 ? _[0] : y(..._);
|
|
7633
|
-
|
|
7633
|
+
N = N.having(D);
|
|
7634
7634
|
}
|
|
7635
7635
|
const U = this.queryBuilder.buildOrderBy(t);
|
|
7636
|
-
return U.length > 0 && (
|
|
7636
|
+
return U.length > 0 && (N = N.orderBy(...U)), N = this.queryBuilder.applyLimitAndOffset(N, t), N;
|
|
7637
7637
|
}
|
|
7638
7638
|
/**
|
|
7639
7639
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -7840,8 +7840,8 @@ class te {
|
|
|
7840
7840
|
const S = R.dimensions?.[a];
|
|
7841
7841
|
if (!S || ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator))
|
|
7842
7842
|
continue;
|
|
7843
|
-
const
|
|
7844
|
-
|
|
7843
|
+
const N = b(S.sql, s), O = this.queryBuilder.buildFilterConditionPublic(
|
|
7844
|
+
N,
|
|
7845
7845
|
r.operator,
|
|
7846
7846
|
r.values,
|
|
7847
7847
|
S,
|
|
@@ -7859,8 +7859,8 @@ class te {
|
|
|
7859
7859
|
if (!a) continue;
|
|
7860
7860
|
const R = a.dimensions?.[A];
|
|
7861
7861
|
if (!R) continue;
|
|
7862
|
-
const S = b(R.sql, s),
|
|
7863
|
-
|
|
7862
|
+
const S = b(R.sql, s), I = this.queryBuilder.buildDateRangeCondition(S, i.dateRange);
|
|
7863
|
+
I && t.set(r, I);
|
|
7864
7864
|
}
|
|
7865
7865
|
}
|
|
7866
7866
|
}
|
|
@@ -7880,15 +7880,15 @@ class te {
|
|
|
7880
7880
|
* @returns SQL expression for the window function
|
|
7881
7881
|
*/
|
|
7882
7882
|
buildPostAggregationWindowExpression(e, t, E, s, i, r) {
|
|
7883
|
-
const T = e.windowConfig || {}, A = (
|
|
7883
|
+
const T = e.windowConfig || {}, A = (N, O) => {
|
|
7884
7884
|
if (!r?.preAggregationCTEs) return null;
|
|
7885
|
-
const C = r.preAggregationCTEs.find((u) => u.cube?.name ===
|
|
7885
|
+
const C = r.preAggregationCTEs.find((u) => u.cube?.name === N);
|
|
7886
7886
|
return C && C.cteAlias ? o`${o.identifier(C.cteAlias)}.${o.identifier(O)}` : null;
|
|
7887
7887
|
};
|
|
7888
7888
|
let a;
|
|
7889
7889
|
if (T.orderBy && T.orderBy.length > 0)
|
|
7890
|
-
a = T.orderBy.map((
|
|
7891
|
-
const O =
|
|
7890
|
+
a = T.orderBy.map((N) => {
|
|
7891
|
+
const O = N.field.includes(".") ? N.field.split(".")[1] : N.field;
|
|
7892
7892
|
if (E.timeDimensions)
|
|
7893
7893
|
for (const l of E.timeDimensions) {
|
|
7894
7894
|
const [_, U] = l.dimension.split(".");
|
|
@@ -7897,7 +7897,7 @@ class te {
|
|
|
7897
7897
|
if (D)
|
|
7898
7898
|
return {
|
|
7899
7899
|
field: D,
|
|
7900
|
-
direction:
|
|
7900
|
+
direction: N.direction
|
|
7901
7901
|
};
|
|
7902
7902
|
const m = i.dimensions?.[U];
|
|
7903
7903
|
if (m)
|
|
@@ -7907,7 +7907,7 @@ class te {
|
|
|
7907
7907
|
l.granularity,
|
|
7908
7908
|
s
|
|
7909
7909
|
),
|
|
7910
|
-
direction:
|
|
7910
|
+
direction: N.direction
|
|
7911
7911
|
};
|
|
7912
7912
|
}
|
|
7913
7913
|
}
|
|
@@ -7915,16 +7915,16 @@ class te {
|
|
|
7915
7915
|
if (C)
|
|
7916
7916
|
return {
|
|
7917
7917
|
field: b(C.sql, s),
|
|
7918
|
-
direction:
|
|
7918
|
+
direction: N.direction
|
|
7919
7919
|
};
|
|
7920
7920
|
const u = T.measure?.includes(".") ? T.measure.split(".")[1] : T.measure;
|
|
7921
|
-
return O === u ||
|
|
7921
|
+
return O === u || N.field === T.measure ? {
|
|
7922
7922
|
field: t,
|
|
7923
|
-
direction:
|
|
7923
|
+
direction: N.direction
|
|
7924
7924
|
} : null;
|
|
7925
|
-
}).filter((
|
|
7925
|
+
}).filter((N) => N !== null);
|
|
7926
7926
|
else if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
7927
|
-
const
|
|
7927
|
+
const N = E.timeDimensions[0], [O, C] = N.dimension.split("."), u = A(O, C);
|
|
7928
7928
|
if (u)
|
|
7929
7929
|
a = [{
|
|
7930
7930
|
field: u,
|
|
@@ -7937,7 +7937,7 @@ class te {
|
|
|
7937
7937
|
a = [{
|
|
7938
7938
|
field: this.queryBuilder.buildTimeDimensionExpression(
|
|
7939
7939
|
_.sql,
|
|
7940
|
-
|
|
7940
|
+
N.granularity,
|
|
7941
7941
|
s
|
|
7942
7942
|
),
|
|
7943
7943
|
direction: "asc"
|
|
@@ -7946,10 +7946,10 @@ class te {
|
|
|
7946
7946
|
}
|
|
7947
7947
|
}
|
|
7948
7948
|
let R;
|
|
7949
|
-
T.partitionBy && T.partitionBy.length > 0 && (R = T.partitionBy.map((
|
|
7950
|
-
const O =
|
|
7949
|
+
T.partitionBy && T.partitionBy.length > 0 && (R = T.partitionBy.map((N) => {
|
|
7950
|
+
const O = N.includes(".") ? N.split(".")[1] : N, C = i.dimensions?.[O];
|
|
7951
7951
|
return C ? b(C.sql, s) : null;
|
|
7952
|
-
}).filter((
|
|
7952
|
+
}).filter((N) => N !== null));
|
|
7953
7953
|
const S = this.databaseAdapter.buildWindowFunction(
|
|
7954
7954
|
e.type,
|
|
7955
7955
|
t,
|
|
@@ -7978,8 +7978,8 @@ class te {
|
|
|
7978
7978
|
}
|
|
7979
7979
|
const L = (n) => n.flatMap(fs), fs = (n) => Le(gs(n)).map(hs), hs = (n) => n.replace(/ +/g, " ").trim(), gs = (n) => ({
|
|
7980
7980
|
type: "mandatory_block",
|
|
7981
|
-
items:
|
|
7982
|
-
}),
|
|
7981
|
+
items: It(n, 0)[0]
|
|
7982
|
+
}), It = (n, e, t) => {
|
|
7983
7983
|
const E = [];
|
|
7984
7984
|
for (; n[e]; ) {
|
|
7985
7985
|
const [s, i] = Gs(n, e);
|
|
@@ -8019,10 +8019,10 @@ const L = (n) => n.flatMap(fs), fs = (n) => Le(gs(n)).map(hs), hs = (n) => n.rep
|
|
|
8019
8019
|
return [t, e];
|
|
8020
8020
|
}
|
|
8021
8021
|
}, bs = (n, e) => {
|
|
8022
|
-
const [t, E] =
|
|
8022
|
+
const [t, E] = It(n, e, "}");
|
|
8023
8023
|
return [{ type: "mandatory_block", items: t }, E];
|
|
8024
8024
|
}, Fs = (n, e) => {
|
|
8025
|
-
const [t, E] =
|
|
8025
|
+
const [t, E] = It(n, e, "]");
|
|
8026
8026
|
return [{ type: "optional_block", items: t }, E];
|
|
8027
8027
|
}, Le = (n) => {
|
|
8028
8028
|
if (typeof n == "string")
|
|
@@ -12278,7 +12278,7 @@ const on = [
|
|
|
12278
12278
|
"VARBINARY",
|
|
12279
12279
|
"VARCHAR",
|
|
12280
12280
|
"VARGRAPHIC"
|
|
12281
|
-
], Sn = L(["SELECT [ALL | DISTINCT]"]),
|
|
12281
|
+
], Sn = L(["SELECT [ALL | DISTINCT]"]), In = L([
|
|
12282
12282
|
// queries
|
|
12283
12283
|
"WITH",
|
|
12284
12284
|
"FROM",
|
|
@@ -12512,7 +12512,7 @@ const on = [
|
|
|
12512
12512
|
"TRANSFER OWNERSHIP OF",
|
|
12513
12513
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
12514
12514
|
"WHILE"
|
|
12515
|
-
]),
|
|
12515
|
+
]), Nn = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), On = L([
|
|
12516
12516
|
"JOIN",
|
|
12517
12517
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12518
12518
|
"{INNER | CROSS} JOIN"
|
|
@@ -12525,8 +12525,8 @@ const on = [
|
|
|
12525
12525
|
name: "db2",
|
|
12526
12526
|
tokenizerOptions: {
|
|
12527
12527
|
reservedSelect: Sn,
|
|
12528
|
-
reservedClauses: [...
|
|
12529
|
-
reservedSetOperations:
|
|
12528
|
+
reservedClauses: [...In, ...bt, ...Ye],
|
|
12529
|
+
reservedSetOperations: Nn,
|
|
12530
12530
|
reservedJoins: On,
|
|
12531
12531
|
reservedKeywordPhrases: Cn,
|
|
12532
12532
|
reservedDataTypePhrases: ln,
|
|
@@ -16566,7 +16566,7 @@ const kn = [
|
|
|
16566
16566
|
"MBRTOUCHES",
|
|
16567
16567
|
"MBRWITHIN",
|
|
16568
16568
|
"MD5",
|
|
16569
|
-
|
|
16569
|
+
// 'MEMBER OF',
|
|
16570
16570
|
"MICROSECOND",
|
|
16571
16571
|
"MID",
|
|
16572
16572
|
"MIN",
|
|
@@ -16578,10 +16578,10 @@ const kn = [
|
|
|
16578
16578
|
"MULTIPOINT",
|
|
16579
16579
|
"MULTIPOLYGON",
|
|
16580
16580
|
"NAME_CONST",
|
|
16581
|
-
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
|
|
16581
|
+
// 'NOT',
|
|
16582
|
+
// 'NOT IN',
|
|
16583
|
+
// 'NOT LIKE',
|
|
16584
|
+
// 'NOT REGEXP',
|
|
16585
16585
|
"NOW",
|
|
16586
16586
|
"NTH_VALUE",
|
|
16587
16587
|
"NTILE",
|
|
@@ -16987,7 +16987,7 @@ const kn = [
|
|
|
16987
16987
|
"CHARACTER SET",
|
|
16988
16988
|
"{ROWS | RANGE} BETWEEN",
|
|
16989
16989
|
"IDENTIFIED BY"
|
|
16990
|
-
]),
|
|
16990
|
+
]), Ii = L([]), Ni = {
|
|
16991
16991
|
name: "mysql",
|
|
16992
16992
|
tokenizerOptions: {
|
|
16993
16993
|
reservedSelect: ai,
|
|
@@ -16995,7 +16995,7 @@ const kn = [
|
|
|
16995
16995
|
reservedSetOperations: Ai,
|
|
16996
16996
|
reservedJoins: Ri,
|
|
16997
16997
|
reservedKeywordPhrases: Si,
|
|
16998
|
-
reservedDataTypePhrases:
|
|
16998
|
+
reservedDataTypePhrases: Ii,
|
|
16999
16999
|
supportsXor: !0,
|
|
17000
17000
|
reservedKeywords: ii,
|
|
17001
17001
|
reservedDataTypes: ri,
|
|
@@ -21268,7 +21268,7 @@ const xi = [
|
|
|
21268
21268
|
"UNSIGNED",
|
|
21269
21269
|
"VARIABLES",
|
|
21270
21270
|
"YEAR_MONTH"
|
|
21271
|
-
],
|
|
21271
|
+
], Ir = [
|
|
21272
21272
|
// https://spark.apache.org/docs/latest/sql-ref-datatypes.html
|
|
21273
21273
|
"ARRAY",
|
|
21274
21274
|
"BIGINT",
|
|
@@ -21298,7 +21298,7 @@ const xi = [
|
|
|
21298
21298
|
"TINYINT",
|
|
21299
21299
|
"VARCHAR"
|
|
21300
21300
|
// No varchar type in Spark, only STRING. Added for the sake of tests
|
|
21301
|
-
],
|
|
21301
|
+
], Nr = [
|
|
21302
21302
|
// http://spark.apache.org/docs/latest/sql-ref-functions.html
|
|
21303
21303
|
//
|
|
21304
21304
|
// http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
|
|
@@ -21729,8 +21729,8 @@ const xi = [
|
|
|
21729
21729
|
reservedDataTypePhrases: _r,
|
|
21730
21730
|
supportsXor: !0,
|
|
21731
21731
|
reservedKeywords: Sr,
|
|
21732
|
-
reservedDataTypes:
|
|
21733
|
-
reservedFunctionNames:
|
|
21732
|
+
reservedDataTypes: Ir,
|
|
21733
|
+
reservedFunctionNames: Nr,
|
|
21734
21734
|
extraParens: ["[]"],
|
|
21735
21735
|
stringTypes: [
|
|
21736
21736
|
"''-bs",
|
|
@@ -24712,7 +24712,7 @@ const Dr = [
|
|
|
24712
24712
|
"WEEKDAY",
|
|
24713
24713
|
"WEEKOFYEAR",
|
|
24714
24714
|
"YEAR"
|
|
24715
|
-
], ST = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),
|
|
24715
|
+
], ST = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), IT = L([
|
|
24716
24716
|
// queries
|
|
24717
24717
|
"WITH",
|
|
24718
24718
|
"FROM",
|
|
@@ -24913,7 +24913,7 @@ const Dr = [
|
|
|
24913
24913
|
"REPEAT",
|
|
24914
24914
|
"RETURN",
|
|
24915
24915
|
"WHILE"
|
|
24916
|
-
]),
|
|
24916
|
+
]), NT = L([
|
|
24917
24917
|
"UNION [ALL | DISTINCT]",
|
|
24918
24918
|
"EXCEPT",
|
|
24919
24919
|
"INTERSECT",
|
|
@@ -24935,8 +24935,8 @@ const Dr = [
|
|
|
24935
24935
|
name: "singlestoredb",
|
|
24936
24936
|
tokenizerOptions: {
|
|
24937
24937
|
reservedSelect: ST,
|
|
24938
|
-
reservedClauses: [...
|
|
24939
|
-
reservedSetOperations:
|
|
24938
|
+
reservedClauses: [...IT, ...qt, ...ze],
|
|
24939
|
+
reservedSetOperations: NT,
|
|
24940
24940
|
reservedJoins: OT,
|
|
24941
24941
|
reservedKeywordPhrases: CT,
|
|
24942
24942
|
reservedDataTypePhrases: lT,
|
|
@@ -26056,7 +26056,7 @@ const Dr = [
|
|
|
26056
26056
|
duckdb: Yn,
|
|
26057
26057
|
hive: Qn,
|
|
26058
26058
|
mariadb: ni,
|
|
26059
|
-
mysql:
|
|
26059
|
+
mysql: Ni,
|
|
26060
26060
|
n1ql: bi,
|
|
26061
26061
|
plsql: Xi,
|
|
26062
26062
|
postgresql: tr,
|
|
@@ -26069,7 +26069,7 @@ const Dr = [
|
|
|
26069
26069
|
tidb: mi,
|
|
26070
26070
|
transactsql: aT,
|
|
26071
26071
|
trino: Zr
|
|
26072
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
26072
|
+
}, Symbol.toStringTag, { value: "Module" })), Ie = (n) => n[n.length - 1], _E = (n) => n.sort((e, t) => t.length - e.length || e.localeCompare(t)), _e = (n) => n.replace(/\s+/gu, " "), tt = (n) => /\n/.test(n), x = (n) => n.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), Zt = /\s+/uy, ne = (n) => new RegExp(`(?:${n})`, "uy"), hT = (n) => n.split("").map((e) => / /gu.test(e) ? "\\s+" : `[${e.toUpperCase()}${e.toLowerCase()}]`).join(""), gT = (n) => n + "(?:-" + n + ")*", GT = ({ prefixes: n, requirePrefix: e }) => `(?:${n.map(hT).join("|")}${e ? "" : "|"})`, yT = (n) => new RegExp(`(?:${n.map(x).join("|")}).*?(?=\r
|
|
26073
26073
|
|\r|
|
|
26074
26074
|
|$)`, "uy"), zt = (n, e = []) => {
|
|
26075
26075
|
const t = n === "open" ? 0 : 1, E = ["()", ...e].map((s) => s[t]);
|
|
@@ -26513,8 +26513,8 @@ function qT() {
|
|
|
26513
26513
|
var R = typeof a > "u" ? this.symbols.map(A).join(" ") : this.symbols.slice(0, a).map(A).join(" ") + " ● " + this.symbols.slice(a).map(A).join(" ");
|
|
26514
26514
|
return this.name + " → " + R;
|
|
26515
26515
|
};
|
|
26516
|
-
function t(a, R, S,
|
|
26517
|
-
this.rule = a, this.dot = R, this.reference = S, this.data = [], this.wantedBy =
|
|
26516
|
+
function t(a, R, S, I) {
|
|
26517
|
+
this.rule = a, this.dot = R, this.reference = S, this.data = [], this.wantedBy = I, this.isComplete = this.dot === a.symbols.length;
|
|
26518
26518
|
}
|
|
26519
26519
|
t.prototype.toString = function() {
|
|
26520
26520
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
@@ -26534,8 +26534,8 @@ function qT() {
|
|
|
26534
26534
|
this.grammar = a, this.index = R, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
26535
26535
|
}
|
|
26536
26536
|
E.prototype.process = function(a) {
|
|
26537
|
-
for (var R = this.states, S = this.wants,
|
|
26538
|
-
var O = R[
|
|
26537
|
+
for (var R = this.states, S = this.wants, I = this.completed, N = 0; N < R.length; N++) {
|
|
26538
|
+
var O = R[N];
|
|
26539
26539
|
if (O.isComplete) {
|
|
26540
26540
|
if (O.finish(), O.data !== r.fail) {
|
|
26541
26541
|
for (var C = O.wantedBy, u = C.length; u--; ) {
|
|
@@ -26554,8 +26554,8 @@ function qT() {
|
|
|
26554
26554
|
continue;
|
|
26555
26555
|
}
|
|
26556
26556
|
if (S[_]) {
|
|
26557
|
-
if (S[_].push(O),
|
|
26558
|
-
for (var U =
|
|
26557
|
+
if (S[_].push(O), I.hasOwnProperty(_))
|
|
26558
|
+
for (var U = I[_], u = 0; u < U.length; u++) {
|
|
26559
26559
|
var D = U[u];
|
|
26560
26560
|
this.complete(O, D);
|
|
26561
26561
|
}
|
|
@@ -26565,7 +26565,7 @@ function qT() {
|
|
|
26565
26565
|
}
|
|
26566
26566
|
}, E.prototype.predict = function(a) {
|
|
26567
26567
|
for (var R = this.grammar.byName[a] || [], S = 0; S < R.length; S++) {
|
|
26568
|
-
var
|
|
26568
|
+
var I = R[S], N = this.wants[a], O = new t(I, 0, this.index, N);
|
|
26569
26569
|
this.states.push(O);
|
|
26570
26570
|
}
|
|
26571
26571
|
}, E.prototype.complete = function(a, R) {
|
|
@@ -26575,17 +26575,17 @@ function qT() {
|
|
|
26575
26575
|
function s(a, R) {
|
|
26576
26576
|
this.rules = a, this.start = R || this.rules[0].name;
|
|
26577
26577
|
var S = this.byName = {};
|
|
26578
|
-
this.rules.forEach(function(
|
|
26579
|
-
S.hasOwnProperty(
|
|
26578
|
+
this.rules.forEach(function(I) {
|
|
26579
|
+
S.hasOwnProperty(I.name) || (S[I.name] = []), S[I.name].push(I);
|
|
26580
26580
|
});
|
|
26581
26581
|
}
|
|
26582
|
-
s.fromCompiled = function(
|
|
26583
|
-
var S =
|
|
26584
|
-
|
|
26585
|
-
var
|
|
26582
|
+
s.fromCompiled = function(I, R) {
|
|
26583
|
+
var S = I.Lexer;
|
|
26584
|
+
I.ParserStart && (R = I.ParserStart, I = I.ParserRules);
|
|
26585
|
+
var I = I.map(function(O) {
|
|
26586
26586
|
return new e(O.name, O.symbols, O.postprocess);
|
|
26587
|
-
}),
|
|
26588
|
-
return
|
|
26587
|
+
}), N = new s(I, R);
|
|
26588
|
+
return N.lexer = S, N;
|
|
26589
26589
|
};
|
|
26590
26590
|
function i() {
|
|
26591
26591
|
this.reset("");
|
|
@@ -26606,18 +26606,18 @@ function qT() {
|
|
|
26606
26606
|
}, i.prototype.formatError = function(a, R) {
|
|
26607
26607
|
var S = this.buffer;
|
|
26608
26608
|
if (typeof S == "string") {
|
|
26609
|
-
var
|
|
26609
|
+
var I = S.split(`
|
|
26610
26610
|
`).slice(
|
|
26611
26611
|
Math.max(0, this.line - 5),
|
|
26612
26612
|
this.line
|
|
26613
|
-
),
|
|
26613
|
+
), N = S.indexOf(`
|
|
26614
26614
|
`, this.index);
|
|
26615
|
-
|
|
26615
|
+
N === -1 && (N = S.length);
|
|
26616
26616
|
var O = this.index - this.lastLineBreak, C = String(this.line).length;
|
|
26617
26617
|
return R += " at line " + this.line + " col " + O + `:
|
|
26618
26618
|
|
|
26619
|
-
`, R +=
|
|
26620
|
-
return u(this.line -
|
|
26619
|
+
`, R += I.map(function(l, _) {
|
|
26620
|
+
return u(this.line - I.length + _ + 1, C) + " " + l;
|
|
26621
26621
|
}, this).join(`
|
|
26622
26622
|
`), R += `
|
|
26623
26623
|
` + u("", C + O) + `^
|
|
@@ -26631,18 +26631,18 @@ function qT() {
|
|
|
26631
26631
|
};
|
|
26632
26632
|
function r(a, R, S) {
|
|
26633
26633
|
if (a instanceof s)
|
|
26634
|
-
var
|
|
26634
|
+
var I = a, S = R;
|
|
26635
26635
|
else
|
|
26636
|
-
var
|
|
26637
|
-
this.grammar =
|
|
26636
|
+
var I = s.fromCompiled(a, R);
|
|
26637
|
+
this.grammar = I, this.options = {
|
|
26638
26638
|
keepHistory: !1,
|
|
26639
|
-
lexer:
|
|
26639
|
+
lexer: I.lexer || new i()
|
|
26640
26640
|
};
|
|
26641
|
-
for (var
|
|
26642
|
-
this.options[
|
|
26641
|
+
for (var N in S || {})
|
|
26642
|
+
this.options[N] = S[N];
|
|
26643
26643
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
26644
|
-
var O = new E(
|
|
26645
|
-
this.table = [O], O.wants[
|
|
26644
|
+
var O = new E(I, 0);
|
|
26645
|
+
this.table = [O], O.wants[I.start] = [], O.predict(I.start), O.process(), this.current = 0;
|
|
26646
26646
|
}
|
|
26647
26647
|
r.fail = {}, r.prototype.feed = function(a) {
|
|
26648
26648
|
var R = this.lexer;
|
|
@@ -26654,14 +26654,14 @@ function qT() {
|
|
|
26654
26654
|
} catch (M) {
|
|
26655
26655
|
var C = new E(this.grammar, this.current + 1);
|
|
26656
26656
|
this.table.push(C);
|
|
26657
|
-
var
|
|
26658
|
-
throw
|
|
26657
|
+
var I = new Error(this.reportLexerError(M));
|
|
26658
|
+
throw I.offset = this.current, I.token = M.token, I;
|
|
26659
26659
|
}
|
|
26660
|
-
var
|
|
26660
|
+
var N = this.table[this.current];
|
|
26661
26661
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
26662
26662
|
var O = this.current + 1, C = new E(this.grammar, O);
|
|
26663
26663
|
this.table.push(C);
|
|
26664
|
-
for (var u = S.text !== void 0 ? S.text : S.value, l = R.constructor === i ? S.value : S, _ =
|
|
26664
|
+
for (var u = S.text !== void 0 ? S.text : S.value, l = R.constructor === i ? S.value : S, _ = N.scannable, U = _.length; U--; ) {
|
|
26665
26665
|
var D = _[U], m = D.rule.symbols[D.dot];
|
|
26666
26666
|
if (m.test ? m.test(l) : m.type ? m.type === S.type : m.literal === u) {
|
|
26667
26667
|
var P = D.nextState({ data: l, token: S, isToken: !0, reference: O - 1 });
|
|
@@ -26669,28 +26669,28 @@ function qT() {
|
|
|
26669
26669
|
}
|
|
26670
26670
|
}
|
|
26671
26671
|
if (C.process(), C.states.length === 0) {
|
|
26672
|
-
var
|
|
26673
|
-
throw
|
|
26672
|
+
var I = new Error(this.reportError(S));
|
|
26673
|
+
throw I.offset = this.current, I.token = S, I;
|
|
26674
26674
|
}
|
|
26675
|
-
this.options.keepHistory && (
|
|
26675
|
+
this.options.keepHistory && (N.lexerState = R.save()), this.current++;
|
|
26676
26676
|
}
|
|
26677
|
-
return
|
|
26677
|
+
return N && (this.lexerState = R.save()), this.results = this.finish(), this;
|
|
26678
26678
|
}, r.prototype.reportLexerError = function(a) {
|
|
26679
|
-
var R, S,
|
|
26680
|
-
return
|
|
26679
|
+
var R, S, I = a.token;
|
|
26680
|
+
return I ? (R = "input " + JSON.stringify(I.text[0]) + " (lexer error)", S = this.lexer.formatError(I, "Syntax error")) : (R = "input (lexer error)", S = a.message), this.reportErrorCommon(S, R);
|
|
26681
26681
|
}, r.prototype.reportError = function(a) {
|
|
26682
26682
|
var R = (a.type ? a.type + " token: " : "") + JSON.stringify(a.value !== void 0 ? a.value : a), S = this.lexer.formatError(a, "Syntax error");
|
|
26683
26683
|
return this.reportErrorCommon(S, R);
|
|
26684
26684
|
}, r.prototype.reportErrorCommon = function(a, R) {
|
|
26685
26685
|
var S = [];
|
|
26686
26686
|
S.push(a);
|
|
26687
|
-
var
|
|
26687
|
+
var I = this.table.length - 2, N = this.table[I], O = N.states.filter(function(u) {
|
|
26688
26688
|
var l = u.rule.symbols[u.dot];
|
|
26689
26689
|
return l && typeof l != "string";
|
|
26690
26690
|
});
|
|
26691
26691
|
if (O.length === 0)
|
|
26692
26692
|
S.push("Unexpected " + R + `. I did not expect any more input. Here is the state of my parse table:
|
|
26693
|
-
`), this.displayStateStack(
|
|
26693
|
+
`), this.displayStateStack(N.states, S);
|
|
26694
26694
|
else {
|
|
26695
26695
|
S.push("Unexpected " + R + `. Instead, I was expecting to see one of the following:
|
|
26696
26696
|
`);
|
|
@@ -26705,9 +26705,9 @@ function qT() {
|
|
|
26705
26705
|
return S.push(""), S.join(`
|
|
26706
26706
|
`);
|
|
26707
26707
|
}, r.prototype.displayStateStack = function(a, R) {
|
|
26708
|
-
for (var S,
|
|
26709
|
-
var O = a[
|
|
26710
|
-
C === S ?
|
|
26708
|
+
for (var S, I = 0, N = 0; N < a.length; N++) {
|
|
26709
|
+
var O = a[N], C = O.rule.toString(O.dot);
|
|
26710
|
+
C === S ? I++ : (I > 0 && R.push(" ^ " + I + " more lines identical to this"), I = 0, R.push(" " + C)), S = C;
|
|
26711
26711
|
}
|
|
26712
26712
|
}, r.prototype.getSymbolDisplay = function(a) {
|
|
26713
26713
|
return T(a);
|
|
@@ -26716,8 +26716,8 @@ function qT() {
|
|
|
26716
26716
|
return null;
|
|
26717
26717
|
if (a.wantedBy.length === 0)
|
|
26718
26718
|
return [a];
|
|
26719
|
-
var S = a.wantedBy[0],
|
|
26720
|
-
return
|
|
26719
|
+
var S = a.wantedBy[0], I = [a].concat(R), N = this.buildFirstStateStack(S, I);
|
|
26720
|
+
return N === null ? null : [a].concat(N);
|
|
26721
26721
|
}, r.prototype.save = function() {
|
|
26722
26722
|
var a = this.table[this.current];
|
|
26723
26723
|
return a.lexerState = this.lexerState, a;
|
|
@@ -26730,10 +26730,10 @@ function qT() {
|
|
|
26730
26730
|
this.restore(this.table[a]);
|
|
26731
26731
|
}, r.prototype.finish = function() {
|
|
26732
26732
|
var a = [], R = this.grammar.start, S = this.table[this.table.length - 1];
|
|
26733
|
-
return S.states.forEach(function(
|
|
26734
|
-
|
|
26735
|
-
}), a.map(function(
|
|
26736
|
-
return
|
|
26733
|
+
return S.states.forEach(function(I) {
|
|
26734
|
+
I.rule.name === R && I.dot === I.rule.symbols.length && I.reference === 0 && I.data !== r.fail && a.push(I);
|
|
26735
|
+
}), a.map(function(I) {
|
|
26736
|
+
return I.data;
|
|
26737
26737
|
});
|
|
26738
26738
|
};
|
|
26739
26739
|
function T(a) {
|
|
@@ -27326,16 +27326,16 @@ class UE {
|
|
|
27326
27326
|
}
|
|
27327
27327
|
}
|
|
27328
27328
|
trimHorizontalWhitespace() {
|
|
27329
|
-
for (; Sa(
|
|
27329
|
+
for (; Sa(Ie(this.items)); )
|
|
27330
27330
|
this.items.pop();
|
|
27331
27331
|
}
|
|
27332
27332
|
trimWhitespace() {
|
|
27333
|
-
for (;
|
|
27333
|
+
for (; Ia(Ie(this.items)); )
|
|
27334
27334
|
this.items.pop();
|
|
27335
27335
|
}
|
|
27336
27336
|
addNewline(e) {
|
|
27337
27337
|
if (this.items.length > 0)
|
|
27338
|
-
switch (
|
|
27338
|
+
switch (Ie(this.items)) {
|
|
27339
27339
|
case c.NEWLINE:
|
|
27340
27340
|
this.items.pop(), this.items.push(e);
|
|
27341
27341
|
break;
|
|
@@ -27377,7 +27377,7 @@ class UE {
|
|
|
27377
27377
|
}
|
|
27378
27378
|
}
|
|
27379
27379
|
}
|
|
27380
|
-
const Sa = (n) => n === c.SPACE || n === c.SINGLE_INDENT,
|
|
27380
|
+
const Sa = (n) => n === c.SPACE || n === c.SINGLE_INDENT, Ia = (n) => n === c.SPACE || n === c.SINGLE_INDENT || n === c.NEWLINE;
|
|
27381
27381
|
function TE(n, e) {
|
|
27382
27382
|
if (e === "standard")
|
|
27383
27383
|
return n;
|
|
@@ -27387,7 +27387,7 @@ function TE(n, e) {
|
|
|
27387
27387
|
function aE(n) {
|
|
27388
27388
|
return Hs(n) || n === d.RESERVED_CLAUSE || n === d.RESERVED_SELECT || n === d.RESERVED_SET_OPERATION || n === d.RESERVED_JOIN || n === d.LIMIT;
|
|
27389
27389
|
}
|
|
27390
|
-
const nt = "top-level",
|
|
27390
|
+
const nt = "top-level", Na = "block-level";
|
|
27391
27391
|
class fE {
|
|
27392
27392
|
/**
|
|
27393
27393
|
* @param {string} indent A string to indent with
|
|
@@ -27417,14 +27417,14 @@ class fE {
|
|
|
27417
27417
|
* Increases indentation by one block-level indent.
|
|
27418
27418
|
*/
|
|
27419
27419
|
increaseBlockLevel() {
|
|
27420
|
-
this.indentTypes.push(
|
|
27420
|
+
this.indentTypes.push(Na);
|
|
27421
27421
|
}
|
|
27422
27422
|
/**
|
|
27423
27423
|
* Decreases indentation by one top-level indent.
|
|
27424
27424
|
* Does nothing when the previous indent is not top-level.
|
|
27425
27425
|
*/
|
|
27426
27426
|
decreaseTopLevel() {
|
|
27427
|
-
this.indentTypes.length > 0 &&
|
|
27427
|
+
this.indentTypes.length > 0 && Ie(this.indentTypes) === nt && this.indentTypes.pop();
|
|
27428
27428
|
}
|
|
27429
27429
|
/**
|
|
27430
27430
|
* Decreases indentation by one block-level indent.
|
|
@@ -27631,7 +27631,7 @@ class Pe {
|
|
|
27631
27631
|
// first line starts with /* or /**
|
|
27632
27632
|
/^\/\*\*?$/.test(t[0]) && // intermediate lines start with *
|
|
27633
27633
|
t.slice(1, t.length - 1).every((E) => /^\s*\*/.test(E)) && // last line ends with */
|
|
27634
|
-
/^\s*\*\/$/.test(
|
|
27634
|
+
/^\s*\*\/$/.test(Ie(t))
|
|
27635
27635
|
);
|
|
27636
27636
|
}
|
|
27637
27637
|
// Breaks up block comment to multiple lines.
|
|
@@ -27897,7 +27897,7 @@ function Se(n, e) {
|
|
|
27897
27897
|
return console.warn("SQL formatting failed:", t), n;
|
|
27898
27898
|
}
|
|
27899
27899
|
}
|
|
27900
|
-
class
|
|
27900
|
+
class Nt {
|
|
27901
27901
|
cubes = /* @__PURE__ */ new Map();
|
|
27902
27902
|
dbExecutor;
|
|
27903
27903
|
metadataCache;
|
|
@@ -28074,8 +28074,8 @@ ${t.join(`
|
|
|
28074
28074
|
const t = Object.keys(e.measures), E = Object.keys(e.dimensions), s = new Array(t.length), i = new Array(E.length);
|
|
28075
28075
|
for (let a = 0; a < t.length; a++) {
|
|
28076
28076
|
const R = t[a], S = e.measures[R];
|
|
28077
|
-
let
|
|
28078
|
-
S.drillMembers && S.drillMembers.length > 0 && (
|
|
28077
|
+
let I;
|
|
28078
|
+
S.drillMembers && S.drillMembers.length > 0 && (I = S.drillMembers.map((N) => N.includes(".") ? N : `${e.name}.${N}`)), s[a] = {
|
|
28079
28079
|
name: `${e.name}.${R}`,
|
|
28080
28080
|
title: S.title || R,
|
|
28081
28081
|
shortTitle: S.title || R,
|
|
@@ -28084,13 +28084,13 @@ ${t.join(`
|
|
|
28084
28084
|
// Measure doesn't have format field
|
|
28085
28085
|
description: S.description,
|
|
28086
28086
|
synonyms: S.synonyms,
|
|
28087
|
-
drillMembers:
|
|
28087
|
+
drillMembers: I
|
|
28088
28088
|
};
|
|
28089
28089
|
}
|
|
28090
28090
|
for (let a = 0; a < E.length; a++) {
|
|
28091
28091
|
const R = E[a], S = e.dimensions[R];
|
|
28092
|
-
let
|
|
28093
|
-
S.type === "time" && (
|
|
28092
|
+
let I;
|
|
28093
|
+
S.type === "time" && (I = S.granularities || Nt.DEFAULT_TIME_GRANULARITIES), i[a] = {
|
|
28094
28094
|
name: `${e.name}.${R}`,
|
|
28095
28095
|
title: S.title || R,
|
|
28096
28096
|
shortTitle: S.title || R,
|
|
@@ -28099,7 +28099,7 @@ ${t.join(`
|
|
|
28099
28099
|
// Dimension doesn't have format field
|
|
28100
28100
|
description: S.description,
|
|
28101
28101
|
synonyms: S.synonyms,
|
|
28102
|
-
granularities:
|
|
28102
|
+
granularities: I
|
|
28103
28103
|
};
|
|
28104
28104
|
}
|
|
28105
28105
|
const r = [];
|
|
@@ -29301,30 +29301,30 @@ function ya(n, e) {
|
|
|
29301
29301
|
R > 0.5 && (t += R * 2, E.includes("name") || E.push("name"));
|
|
29302
29302
|
const S = v(a, n.title);
|
|
29303
29303
|
if (S > 0.5 && (t += S * 1.5, E.includes("title") || E.push("title")), n.description) {
|
|
29304
|
-
const
|
|
29305
|
-
|
|
29304
|
+
const I = v(a, n.description);
|
|
29305
|
+
I > 0.3 && (t += I, E.includes("description") || E.push("description"));
|
|
29306
29306
|
}
|
|
29307
29307
|
if (n.exampleQuestions)
|
|
29308
|
-
for (const
|
|
29309
|
-
const
|
|
29310
|
-
|
|
29308
|
+
for (const I of n.exampleQuestions) {
|
|
29309
|
+
const N = v(a, I);
|
|
29310
|
+
N > 0.3 && (t += N * 1.5, E.includes("exampleQuestions") || E.push("exampleQuestions"));
|
|
29311
29311
|
}
|
|
29312
|
-
for (const
|
|
29313
|
-
let
|
|
29314
|
-
const O =
|
|
29315
|
-
if (
|
|
29316
|
-
t +=
|
|
29317
|
-
const C = s.get(
|
|
29318
|
-
s.set(
|
|
29312
|
+
for (const I of n.measures) {
|
|
29313
|
+
let N = 0;
|
|
29314
|
+
const O = I.name.split(".").pop() || I.name;
|
|
29315
|
+
if (N = Math.max(N, v(a, O)), N = Math.max(N, v(a, I.title)), I.description && (N = Math.max(N, v(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
|
|
29316
|
+
t += N, E.includes("measures") || E.push("measures");
|
|
29317
|
+
const C = s.get(I.name) || 0;
|
|
29318
|
+
s.set(I.name, Math.max(C, N));
|
|
29319
29319
|
}
|
|
29320
29320
|
}
|
|
29321
|
-
for (const
|
|
29322
|
-
let
|
|
29323
|
-
const O =
|
|
29324
|
-
if (
|
|
29325
|
-
t +=
|
|
29326
|
-
const C = i.get(
|
|
29327
|
-
i.set(
|
|
29321
|
+
for (const I of n.dimensions) {
|
|
29322
|
+
let N = 0;
|
|
29323
|
+
const O = I.name.split(".").pop() || I.name;
|
|
29324
|
+
if (N = Math.max(N, v(a, O)), N = Math.max(N, v(a, I.title)), I.description && (N = Math.max(N, v(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
|
|
29325
|
+
t += N, E.includes("dimensions") || E.push("dimensions");
|
|
29326
|
+
const C = i.get(I.name) || 0;
|
|
29327
|
+
i.set(I.name, Math.max(C, N));
|
|
29328
29328
|
}
|
|
29329
29329
|
}
|
|
29330
29330
|
}
|
|
@@ -29400,7 +29400,7 @@ function ba(n, e = {}) {
|
|
|
29400
29400
|
const { topic: t, intent: E, limit: s = 10, minScore: i = 0.1 } = e, r = [t, E].filter(Boolean).join(" ");
|
|
29401
29401
|
if (!r.trim())
|
|
29402
29402
|
return n.slice(0, s).map((a) => {
|
|
29403
|
-
const R = Rt(a), S = AE(a),
|
|
29403
|
+
const R = Rt(a), S = AE(a), I = RE(a, S), N = R.funnel || R.flow || R.retention;
|
|
29404
29404
|
return {
|
|
29405
29405
|
cube: a.name,
|
|
29406
29406
|
title: a.title,
|
|
@@ -29411,8 +29411,8 @@ function ba(n, e = {}) {
|
|
|
29411
29411
|
suggestedDimensions: a.dimensions.slice(0, 5).map((O) => O.name),
|
|
29412
29412
|
capabilities: R,
|
|
29413
29413
|
analysisConfig: S,
|
|
29414
|
-
hints:
|
|
29415
|
-
querySchemas:
|
|
29414
|
+
hints: I.length > 0 ? I : void 0,
|
|
29415
|
+
querySchemas: N ? oE : void 0
|
|
29416
29416
|
};
|
|
29417
29417
|
});
|
|
29418
29418
|
const T = Ga(r);
|
|
@@ -29420,7 +29420,7 @@ function ba(n, e = {}) {
|
|
|
29420
29420
|
return [];
|
|
29421
29421
|
const A = [];
|
|
29422
29422
|
for (const a of n) {
|
|
29423
|
-
const { score: R, matchedOn: S, suggestedMeasures:
|
|
29423
|
+
const { score: R, matchedOn: S, suggestedMeasures: I, suggestedDimensions: N } = ya(a, T);
|
|
29424
29424
|
if (R >= i) {
|
|
29425
29425
|
const O = Rt(a), C = AE(a), u = RE(a, C), l = O.funnel || O.flow || O.retention;
|
|
29426
29426
|
A.push({
|
|
@@ -29429,8 +29429,8 @@ function ba(n, e = {}) {
|
|
|
29429
29429
|
description: a.description,
|
|
29430
29430
|
relevanceScore: R,
|
|
29431
29431
|
matchedOn: S,
|
|
29432
|
-
suggestedMeasures:
|
|
29433
|
-
suggestedDimensions:
|
|
29432
|
+
suggestedMeasures: I,
|
|
29433
|
+
suggestedDimensions: N,
|
|
29434
29434
|
capabilities: O,
|
|
29435
29435
|
analysisConfig: C,
|
|
29436
29436
|
hints: u.length > 0 ? u : void 0,
|
|
@@ -29635,7 +29635,7 @@ function Ha(n) {
|
|
|
29635
29635
|
}
|
|
29636
29636
|
}
|
|
29637
29637
|
if (/^q[1-4]$/i.test(s[0])) {
|
|
29638
|
-
const i = parseInt(s[1], 10), T = (/* @__PURE__ */ new Date()).getFullYear(), A = (i - 1) * 3, a = new Date(T, A, 1), R = new Date(T, A + 3, 0), S = (
|
|
29638
|
+
const i = parseInt(s[1], 10), T = (/* @__PURE__ */ new Date()).getFullYear(), A = (i - 1) * 3, a = new Date(T, A, 1), R = new Date(T, A + 3, 0), S = (I) => I.toISOString().split("T")[0];
|
|
29639
29639
|
return { dateRange: [S(a), S(R)], granularity: "month" };
|
|
29640
29640
|
}
|
|
29641
29641
|
return { dateRange: E.getDateRange(), granularity: E.granularity };
|
|
@@ -29692,7 +29692,7 @@ function so(n, e, t) {
|
|
|
29692
29692
|
let a = 0.5;
|
|
29693
29693
|
const R = Ya(e);
|
|
29694
29694
|
R && (E.push(`Detected ${R.type} aggregation intent`), a += 0.1);
|
|
29695
|
-
const S = [],
|
|
29695
|
+
const S = [], I = e.toLowerCase();
|
|
29696
29696
|
for (const u of A.measures) {
|
|
29697
29697
|
const _ = [
|
|
29698
29698
|
(u.name.split(".").pop() || u.name).toLowerCase(),
|
|
@@ -29700,7 +29700,7 @@ function so(n, e, t) {
|
|
|
29700
29700
|
...(u.synonyms || []).map((U) => U.toLowerCase())
|
|
29701
29701
|
];
|
|
29702
29702
|
for (const U of _)
|
|
29703
|
-
if (
|
|
29703
|
+
if (I.includes(U)) {
|
|
29704
29704
|
S.push(u.name), E.push(`Matched measure '${u.name}' via keyword '${U}'`), a += 0.15;
|
|
29705
29705
|
break;
|
|
29706
29706
|
}
|
|
@@ -29717,8 +29717,8 @@ function so(n, e, t) {
|
|
|
29717
29717
|
}
|
|
29718
29718
|
}
|
|
29719
29719
|
S.length === 0 && A.measures.length > 0 && (S.push(A.measures[0].name), E.push(`Using default measure: ${A.measures[0].name}`), s.push("Could not determine specific measure from query, using default")), i.measures = S;
|
|
29720
|
-
const
|
|
29721
|
-
for (const u of
|
|
29720
|
+
const N = Va(e), O = [];
|
|
29721
|
+
for (const u of N) {
|
|
29722
29722
|
const l = Ot(T, u, "dimension");
|
|
29723
29723
|
l && (O.push(l.field), E.push(`Matched dimension '${l.field}' from grouping keyword '${u}'`), a += 0.1);
|
|
29724
29724
|
}
|
|
@@ -29730,7 +29730,7 @@ function so(n, e, t) {
|
|
|
29730
29730
|
...(l.synonyms || []).map((D) => D.toLowerCase())
|
|
29731
29731
|
];
|
|
29732
29732
|
for (const D of U)
|
|
29733
|
-
if (
|
|
29733
|
+
if (I.includes(D) && !O.includes(l.name) && (I.includes(`by ${D}`) || I.includes(`per ${D}`))) {
|
|
29734
29734
|
O.push(l.name), E.push(`Matched dimension '${l.name}' as grouping`), a += 0.1;
|
|
29735
29735
|
break;
|
|
29736
29736
|
}
|
|
@@ -29831,16 +29831,16 @@ function wa(n, e, t, E) {
|
|
|
29831
29831
|
correctedValue: a.field
|
|
29832
29832
|
}), E.set(n, a.field);
|
|
29833
29833
|
else {
|
|
29834
|
-
const R = T.measures.map((
|
|
29834
|
+
const R = T.measures.map((I) => I.name.split(".").pop()), S = Ae(r, R);
|
|
29835
29835
|
if (S) {
|
|
29836
|
-
const
|
|
29836
|
+
const I = `${i}.${S.field}`;
|
|
29837
29837
|
t.push({
|
|
29838
29838
|
type: "measure_not_found",
|
|
29839
29839
|
message: `Measure '${r}' not found on cube '${i}'`,
|
|
29840
29840
|
field: n,
|
|
29841
29841
|
suggestion: `Did you mean '${S.field}'?`,
|
|
29842
|
-
correctedValue:
|
|
29843
|
-
}), E.set(n,
|
|
29842
|
+
correctedValue: I
|
|
29843
|
+
}), E.set(n, I);
|
|
29844
29844
|
} else
|
|
29845
29845
|
t.push({
|
|
29846
29846
|
type: "measure_not_found",
|
|
@@ -29889,16 +29889,16 @@ function q(n, e, t, E) {
|
|
|
29889
29889
|
correctedValue: a.field
|
|
29890
29890
|
}), E.set(n, a.field);
|
|
29891
29891
|
else {
|
|
29892
|
-
const R = T.dimensions.map((
|
|
29892
|
+
const R = T.dimensions.map((I) => I.name.split(".").pop()), S = Ae(r, R);
|
|
29893
29893
|
if (S) {
|
|
29894
|
-
const
|
|
29894
|
+
const I = `${i}.${S.field}`;
|
|
29895
29895
|
t.push({
|
|
29896
29896
|
type: "dimension_not_found",
|
|
29897
29897
|
message: `Dimension '${r}' not found on cube '${i}'`,
|
|
29898
29898
|
field: n,
|
|
29899
29899
|
suggestion: `Did you mean '${S.field}'?`,
|
|
29900
|
-
correctedValue:
|
|
29901
|
-
}), E.set(n,
|
|
29900
|
+
correctedValue: I
|
|
29901
|
+
}), E.set(n, I);
|
|
29902
29902
|
} else
|
|
29903
29903
|
t.push({
|
|
29904
29904
|
type: "dimension_not_found",
|
|
@@ -29929,31 +29929,31 @@ function Me(n, e, t, E) {
|
|
|
29929
29929
|
});
|
|
29930
29930
|
continue;
|
|
29931
29931
|
}
|
|
29932
|
-
const [T, A] = r, a = e.find((
|
|
29932
|
+
const [T, A] = r, a = e.find((I) => I.name === T);
|
|
29933
29933
|
if (!a) {
|
|
29934
|
-
const
|
|
29935
|
-
|
|
29934
|
+
const I = e.map((O) => O.name), N = Ae(T, I);
|
|
29935
|
+
N && E.set(i, `${N.field}.${A}`), t.push({
|
|
29936
29936
|
type: "cube_not_found",
|
|
29937
29937
|
message: `Cube '${T}' not found in filter`,
|
|
29938
29938
|
field: i,
|
|
29939
|
-
suggestion:
|
|
29940
|
-
correctedValue:
|
|
29939
|
+
suggestion: N ? `Did you mean '${N.field}'?` : void 0,
|
|
29940
|
+
correctedValue: N ? `${N.field}.${A}` : void 0
|
|
29941
29941
|
});
|
|
29942
29942
|
continue;
|
|
29943
29943
|
}
|
|
29944
|
-
const R = a.dimensions.some((
|
|
29944
|
+
const R = a.dimensions.some((I) => I.name === i), S = a.measures.some((I) => I.name === i);
|
|
29945
29945
|
if (!R && !S) {
|
|
29946
|
-
const
|
|
29946
|
+
const I = [
|
|
29947
29947
|
...a.dimensions.map((O) => O.name.split(".").pop()),
|
|
29948
29948
|
...a.measures.map((O) => O.name.split(".").pop())
|
|
29949
|
-
],
|
|
29950
|
-
if (
|
|
29951
|
-
const O = `${T}.${
|
|
29949
|
+
], N = Ae(A, I);
|
|
29950
|
+
if (N) {
|
|
29951
|
+
const O = `${T}.${N.field}`;
|
|
29952
29952
|
E.set(i, O), t.push({
|
|
29953
29953
|
type: "invalid_filter",
|
|
29954
29954
|
message: `Filter field '${A}' not found on cube '${T}'`,
|
|
29955
29955
|
field: i,
|
|
29956
|
-
suggestion: `Did you mean '${
|
|
29956
|
+
suggestion: `Did you mean '${N.field}'?`,
|
|
29957
29957
|
correctedValue: O
|
|
29958
29958
|
});
|
|
29959
29959
|
} else
|
|
@@ -30102,7 +30102,7 @@ function no(n, e) {
|
|
|
30102
30102
|
};
|
|
30103
30103
|
}
|
|
30104
30104
|
function io(n) {
|
|
30105
|
-
return new
|
|
30105
|
+
return new Nt({
|
|
30106
30106
|
drizzle: n.drizzle,
|
|
30107
30107
|
schema: n.schema
|
|
30108
30108
|
});
|
|
@@ -30112,7 +30112,7 @@ export {
|
|
|
30112
30112
|
is as DuckDBExecutor,
|
|
30113
30113
|
ha as EXPLAIN_ANALYSIS_PROMPT,
|
|
30114
30114
|
ka as MemoryCacheProvider,
|
|
30115
|
-
|
|
30115
|
+
NE as MySQLExecutor,
|
|
30116
30116
|
JE as PostgresExecutor,
|
|
30117
30117
|
ls as QueryBuilder,
|
|
30118
30118
|
te as QueryExecutor,
|
|
@@ -30122,7 +30122,7 @@ export {
|
|
|
30122
30122
|
Ua as STEP1_SYSTEM_PROMPT,
|
|
30123
30123
|
fa as STEP2_SYSTEM_PROMPT,
|
|
30124
30124
|
Ma as SYSTEM_PROMPT_TEMPLATE,
|
|
30125
|
-
|
|
30125
|
+
Nt as SemanticLayerCompiler,
|
|
30126
30126
|
no as aiValidateQuery,
|
|
30127
30127
|
eo as buildExplainAnalysisPrompt,
|
|
30128
30128
|
qa as buildStep0Prompt,
|