drizzle-cube 0.3.32 → 0.3.33
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/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/{mcp-transport-DeD7YevT.cjs → mcp-transport-CV5Mv8KV.cjs} +5 -5
- package/dist/adapters/{mcp-transport-B2rGcu1X.js → mcp-transport-n-4QT0Xg.js} +156 -149
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/server/index.cjs +12 -12
- package/dist/server/index.js +261 -254
- package/package.json +1 -1
|
@@ -418,7 +418,7 @@ function x(d, e) {
|
|
|
418
418
|
return St(e) && !st(d) && !L(d, ce) && !L(d, de) && !L(d, se) && !L(d, P) && !L(d, ot) ? new ce(d, e) : d;
|
|
419
419
|
}
|
|
420
420
|
const Q = (d, e) => o`${d} = ${x(e, d)}`, xe = (d, e) => o`${d} <> ${x(e, d)}`;
|
|
421
|
-
function
|
|
421
|
+
function _(...d) {
|
|
422
422
|
const e = d.filter(
|
|
423
423
|
(t) => t !== void 0
|
|
424
424
|
);
|
|
@@ -2534,7 +2534,7 @@ function _e(d, e) {
|
|
|
2534
2534
|
function ve(d) {
|
|
2535
2535
|
return d && typeof d == "object" ? o`${o`${d}`}` : d;
|
|
2536
2536
|
}
|
|
2537
|
-
function
|
|
2537
|
+
function v(d, e) {
|
|
2538
2538
|
const t = typeof d == "function" ? d(e) : d;
|
|
2539
2539
|
return ve(t);
|
|
2540
2540
|
}
|
|
@@ -2562,13 +2562,13 @@ function Xt(d, e) {
|
|
|
2562
2562
|
{
|
|
2563
2563
|
joinType: c,
|
|
2564
2564
|
table: t,
|
|
2565
|
-
condition:
|
|
2565
|
+
condition: _(...r)
|
|
2566
2566
|
},
|
|
2567
2567
|
{
|
|
2568
2568
|
joinType: c,
|
|
2569
2569
|
table: t,
|
|
2570
2570
|
// This will be replaced with target cube table in query planner
|
|
2571
|
-
condition:
|
|
2571
|
+
condition: _(...a)
|
|
2572
2572
|
}
|
|
2573
2573
|
],
|
|
2574
2574
|
junctionSecurityConditions: u
|
|
@@ -2774,7 +2774,7 @@ class ie {
|
|
|
2774
2774
|
* Build time dimension expression with granularity using database adapter
|
|
2775
2775
|
*/
|
|
2776
2776
|
buildTimeDimensionExpression(e, t, n) {
|
|
2777
|
-
const s =
|
|
2777
|
+
const s = v(e, n);
|
|
2778
2778
|
return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof O ? s : o`${s}`;
|
|
2779
2779
|
}
|
|
2780
2780
|
/**
|
|
@@ -2790,7 +2790,7 @@ class ie {
|
|
|
2790
2790
|
const i = typeof s == "number" ? new Date(s * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(s), r = new Date(i);
|
|
2791
2791
|
r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? s = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : s = r.toISOString();
|
|
2792
2792
|
}
|
|
2793
|
-
return
|
|
2793
|
+
return _(
|
|
2794
2794
|
Z(e, n),
|
|
2795
2795
|
ee(e, s)
|
|
2796
2796
|
);
|
|
@@ -2799,7 +2799,7 @@ class ie {
|
|
|
2799
2799
|
const n = this.parseRelativeDateRange(t);
|
|
2800
2800
|
if (n) {
|
|
2801
2801
|
let l, m;
|
|
2802
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()),
|
|
2802
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()), _(
|
|
2803
2803
|
Z(e, l),
|
|
2804
2804
|
ee(e, m)
|
|
2805
2805
|
);
|
|
@@ -2811,7 +2811,7 @@ class ie {
|
|
|
2811
2811
|
const a = new Date(i);
|
|
2812
2812
|
a.setUTCHours(23, 59, 59, 999);
|
|
2813
2813
|
let u, c;
|
|
2814
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()),
|
|
2814
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()), _(
|
|
2815
2815
|
Z(e, u),
|
|
2816
2816
|
ee(e, c)
|
|
2817
2817
|
);
|
|
@@ -2997,7 +2997,7 @@ class ge {
|
|
|
2997
2997
|
const m = typeof c == "number" ? new Date(c * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(c), p = new Date(m);
|
|
2998
2998
|
p.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? c = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(p.getTime() / 1e3) : p.getTime() : c = p.toISOString();
|
|
2999
2999
|
}
|
|
3000
|
-
return
|
|
3000
|
+
return _(
|
|
3001
3001
|
Z(e, u),
|
|
3002
3002
|
ee(e, c)
|
|
3003
3003
|
);
|
|
@@ -3013,7 +3013,7 @@ class ge {
|
|
|
3013
3013
|
return u ? $e(e, u) : null;
|
|
3014
3014
|
}
|
|
3015
3015
|
case "between":
|
|
3016
|
-
return r.length >= 2 ?
|
|
3016
|
+
return r.length >= 2 ? _(
|
|
3017
3017
|
Z(e, r[0]),
|
|
3018
3018
|
ee(e, r[1])
|
|
3019
3019
|
) : null;
|
|
@@ -3042,7 +3042,7 @@ class ge {
|
|
|
3042
3042
|
Q(e, "")
|
|
3043
3043
|
);
|
|
3044
3044
|
case "isNotEmpty":
|
|
3045
|
-
return
|
|
3045
|
+
return _(
|
|
3046
3046
|
Pe(e),
|
|
3047
3047
|
xe(e, "")
|
|
3048
3048
|
);
|
|
@@ -3065,7 +3065,7 @@ class ge {
|
|
|
3065
3065
|
buildLogicalFilter(e, t, n) {
|
|
3066
3066
|
if ("and" in e && e.and) {
|
|
3067
3067
|
const s = e.and.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
|
|
3068
|
-
return s.length > 0 ? s.length === 1 ? s[0] :
|
|
3068
|
+
return s.length > 0 ? s.length === 1 ? s[0] : _(...s) : null;
|
|
3069
3069
|
}
|
|
3070
3070
|
if ("or" in e && e.or) {
|
|
3071
3071
|
const s = e.or.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
|
|
@@ -3084,7 +3084,7 @@ class ge {
|
|
|
3084
3084
|
if (!a) return null;
|
|
3085
3085
|
const u = a.dimensions?.[r];
|
|
3086
3086
|
if (!u) return null;
|
|
3087
|
-
const c =
|
|
3087
|
+
const c = v(u.sql, n);
|
|
3088
3088
|
return this.buildFilterCondition(
|
|
3089
3089
|
c,
|
|
3090
3090
|
s.operator,
|
|
@@ -3327,7 +3327,7 @@ function on(d, e) {
|
|
|
3327
3327
|
throw new Error(
|
|
3328
3328
|
`Cannot substitute {${p}}: measure '${b}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
3329
3329
|
);
|
|
3330
|
-
const
|
|
3330
|
+
const A = $(), w = o`${A}`;
|
|
3331
3331
|
r.set(p, w);
|
|
3332
3332
|
}
|
|
3333
3333
|
const a = [], u = [];
|
|
@@ -3429,9 +3429,9 @@ class I {
|
|
|
3429
3429
|
continue;
|
|
3430
3430
|
}
|
|
3431
3431
|
X.isCalculatedMeasure(h) ? (a.push(l), Se(h.calculatedSql, m).forEach((b) => u.add(b)), c.getAllDependencies(l).forEach((b) => {
|
|
3432
|
-
const [$,
|
|
3433
|
-
if (w && w.measures[
|
|
3434
|
-
const C = w.measures[
|
|
3432
|
+
const [$, A] = b.split("."), w = t.get($);
|
|
3433
|
+
if (w && w.measures[A]) {
|
|
3434
|
+
const C = w.measures[A];
|
|
3435
3435
|
X.isCalculatedMeasure(C) && Se(C.calculatedSql, $).forEach((E) => u.add(E));
|
|
3436
3436
|
}
|
|
3437
3437
|
})) : r.push(l);
|
|
@@ -3610,14 +3610,14 @@ class I {
|
|
|
3610
3610
|
throw new Error(
|
|
3611
3611
|
`Measure '${e.name}' of type '${e.type}' is missing required 'sql' property. Only calculated measures and post-aggregation window functions can omit 'sql'.`
|
|
3612
3612
|
);
|
|
3613
|
-
let s =
|
|
3613
|
+
let s = v(e.sql, t);
|
|
3614
3614
|
if (e.filters && e.filters.length > 0) {
|
|
3615
3615
|
const i = e.filters.map((r) => {
|
|
3616
3616
|
const a = r(t);
|
|
3617
3617
|
return a ? o`(${a})` : void 0;
|
|
3618
3618
|
}).filter(Boolean);
|
|
3619
3619
|
if (i.length > 0) {
|
|
3620
|
-
const r = i.length === 1 ? i[0] :
|
|
3620
|
+
const r = i.length === 1 ? i[0] : _(...i);
|
|
3621
3621
|
s = this.databaseAdapter.buildCaseWhen([
|
|
3622
3622
|
{ when: r, then: s }
|
|
3623
3623
|
]);
|
|
@@ -3686,7 +3686,7 @@ class I {
|
|
|
3686
3686
|
if (i.partitionBy && i.partitionBy.length > 0 && n) {
|
|
3687
3687
|
const c = i.partitionBy.map((l) => {
|
|
3688
3688
|
const m = l.includes(".") ? l.split(".")[1] : l, p = n.dimensions?.[m];
|
|
3689
|
-
return p ?
|
|
3689
|
+
return p ? v(p.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${l}' not found in cube '${n.name}'`), null);
|
|
3690
3690
|
}).filter((l) => l !== null);
|
|
3691
3691
|
c.length > 0 && (r = c);
|
|
3692
3692
|
}
|
|
@@ -3696,12 +3696,12 @@ class I {
|
|
|
3696
3696
|
const m = l.field.includes(".") ? l.field.split(".")[1] : l.field, p = n.dimensions?.[m];
|
|
3697
3697
|
if (p)
|
|
3698
3698
|
return {
|
|
3699
|
-
field:
|
|
3699
|
+
field: v(p.sql, t),
|
|
3700
3700
|
direction: l.direction
|
|
3701
3701
|
};
|
|
3702
3702
|
const f = n.measures?.[m];
|
|
3703
3703
|
return f && f.sql ? {
|
|
3704
|
-
field:
|
|
3704
|
+
field: v(f.sql, t),
|
|
3705
3705
|
direction: l.direction
|
|
3706
3706
|
} : (console.warn(`[drizzle-cube] Window function order field '${l.field}' not found in cube '${n.name}'`), null);
|
|
3707
3707
|
}).filter((l) => l !== null);
|
|
@@ -3960,7 +3960,7 @@ class un {
|
|
|
3960
3960
|
i.push($);
|
|
3961
3961
|
}
|
|
3962
3962
|
} else {
|
|
3963
|
-
const y = h.dimensions[f], b =
|
|
3963
|
+
const y = h.dimensions[f], b = v(y.sql, n);
|
|
3964
3964
|
i.push(b);
|
|
3965
3965
|
}
|
|
3966
3966
|
}
|
|
@@ -4019,7 +4019,7 @@ class ln {
|
|
|
4019
4019
|
for (const r of t.dimensions) {
|
|
4020
4020
|
const [a, u] = r.split("."), c = i.get(a);
|
|
4021
4021
|
if (c && c.dimensions && c.dimensions[u]) {
|
|
4022
|
-
const l = c.dimensions[u], m =
|
|
4022
|
+
const l = c.dimensions[u], m = v(l.sql, n);
|
|
4023
4023
|
s[r] = o`${m}`.as(r);
|
|
4024
4024
|
}
|
|
4025
4025
|
}
|
|
@@ -4120,7 +4120,7 @@ class ln {
|
|
|
4120
4120
|
continue;
|
|
4121
4121
|
}
|
|
4122
4122
|
}
|
|
4123
|
-
const f = p.dimensions[m], h =
|
|
4123
|
+
const f = p.dimensions[m], h = v(f.sql, n), g = this.buildDateRangeCondition(h, c.dateRange);
|
|
4124
4124
|
g && r.push(g);
|
|
4125
4125
|
}
|
|
4126
4126
|
}
|
|
@@ -4148,7 +4148,7 @@ class ln {
|
|
|
4148
4148
|
const f = e;
|
|
4149
4149
|
if (f.and) {
|
|
4150
4150
|
const h = f.and.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
|
|
4151
|
-
return h.length > 0 ?
|
|
4151
|
+
return h.length > 0 ? _(...h) : null;
|
|
4152
4152
|
}
|
|
4153
4153
|
if (f.or) {
|
|
4154
4154
|
const h = f.or.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
|
|
@@ -4168,7 +4168,7 @@ class ln {
|
|
|
4168
4168
|
if (y)
|
|
4169
4169
|
return y;
|
|
4170
4170
|
}
|
|
4171
|
-
const h = f ? typeof l.sql == "function" ? l.sql(n) : l.sql :
|
|
4171
|
+
const h = f ? typeof l.sql == "function" ? l.sql(n) : l.sql : v(l.sql, n);
|
|
4172
4172
|
return this.buildFilterCondition(
|
|
4173
4173
|
h,
|
|
4174
4174
|
r.operator,
|
|
@@ -4452,7 +4452,7 @@ class ae {
|
|
|
4452
4452
|
const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : ve(i.source), a = n ? o`${o.identifier(n)}.${o.identifier(i.target.name)}` : ve(i.target), u = i.as || Q;
|
|
4453
4453
|
s.push(u(r, a));
|
|
4454
4454
|
}
|
|
4455
|
-
return
|
|
4455
|
+
return _(...s);
|
|
4456
4456
|
}
|
|
4457
4457
|
/**
|
|
4458
4458
|
* Get all reachable cubes from a starting cube
|
|
@@ -4651,25 +4651,25 @@ class ct {
|
|
|
4651
4651
|
if (!$)
|
|
4652
4652
|
throw new Error(`Cube '${y}' not found`);
|
|
4653
4653
|
if (b.relationship === "belongsToMany" && b.through) {
|
|
4654
|
-
const
|
|
4654
|
+
const A = Xt(b, s.securityContext);
|
|
4655
4655
|
a.push({
|
|
4656
4656
|
cube: $,
|
|
4657
4657
|
alias: `${y.toLowerCase()}_cube`,
|
|
4658
|
-
joinType:
|
|
4658
|
+
joinType: A.junctionJoins[1].joinType,
|
|
4659
4659
|
// Use the target join type
|
|
4660
|
-
joinCondition:
|
|
4660
|
+
joinCondition: A.junctionJoins[1].condition,
|
|
4661
4661
|
// Target join condition
|
|
4662
4662
|
junctionTable: {
|
|
4663
4663
|
table: b.through.table,
|
|
4664
4664
|
alias: `junction_${y.toLowerCase()}`,
|
|
4665
|
-
joinType:
|
|
4666
|
-
joinCondition:
|
|
4665
|
+
joinType: A.junctionJoins[0].joinType,
|
|
4666
|
+
joinCondition: A.junctionJoins[0].condition,
|
|
4667
4667
|
securitySql: b.through.securitySql,
|
|
4668
4668
|
sourceCubeName: g
|
|
4669
4669
|
}
|
|
4670
4670
|
});
|
|
4671
4671
|
} else {
|
|
4672
|
-
const
|
|
4672
|
+
const A = r.buildJoinCondition(
|
|
4673
4673
|
b,
|
|
4674
4674
|
null,
|
|
4675
4675
|
// No source alias needed - use the actual column
|
|
@@ -4680,7 +4680,7 @@ class ct {
|
|
|
4680
4680
|
cube: $,
|
|
4681
4681
|
alias: `${y.toLowerCase()}_cube`,
|
|
4682
4682
|
joinType: w,
|
|
4683
|
-
joinCondition:
|
|
4683
|
+
joinCondition: A
|
|
4684
4684
|
});
|
|
4685
4685
|
}
|
|
4686
4686
|
u.add(y);
|
|
@@ -4739,29 +4739,36 @@ class ct {
|
|
|
4739
4739
|
if (y.length === 0)
|
|
4740
4740
|
continue;
|
|
4741
4741
|
const b = this.analyzeJoinPathToPrimary(e, t, l.name, i);
|
|
4742
|
-
let $,
|
|
4742
|
+
let $, A;
|
|
4743
4743
|
if (b?.hasIntermediateHasMany && b.intermediateJoins.length > 0)
|
|
4744
|
-
$ = b.correctJoinKeys,
|
|
4744
|
+
$ = b.correctJoinKeys, A = b.intermediateJoins;
|
|
4745
4745
|
else {
|
|
4746
4746
|
const S = p ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, l.name);
|
|
4747
4747
|
if (!S)
|
|
4748
4748
|
continue;
|
|
4749
|
-
S.joinDef.relationship === "belongsToMany" && S.joinDef.through ? $ = S.joinDef.through.
|
|
4750
|
-
sourceColumn:
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4749
|
+
S.joinDef.relationship === "belongsToMany" && S.joinDef.through ? S.sourceCube?.name === t.name && !("reversed" in S && S.reversed) ? $ = S.joinDef.through.targetKey.map((D) => ({
|
|
4750
|
+
sourceColumn: D.source.name,
|
|
4751
|
+
// junction table column
|
|
4752
|
+
targetColumn: D.target.name,
|
|
4753
|
+
// CTE cube column
|
|
4754
|
+
sourceColumnObj: D.source,
|
|
4755
|
+
targetColumnObj: D.target
|
|
4756
|
+
})) : $ = S.joinDef.through.sourceKey.map((D) => ({
|
|
4757
|
+
sourceColumn: D.target.name,
|
|
4758
|
+
targetColumn: D.source.name,
|
|
4759
|
+
sourceColumnObj: D.target,
|
|
4760
|
+
targetColumnObj: D.source
|
|
4761
|
+
})) : $ = p || "reversed" in S && S.reversed ? S.joinDef.on.map((D) => ({
|
|
4762
|
+
sourceColumn: D.target.name,
|
|
4763
|
+
targetColumn: D.source.name,
|
|
4764
|
+
sourceColumnObj: D.target,
|
|
4765
|
+
targetColumnObj: D.source
|
|
4766
|
+
})) : S.joinDef.on.map((D) => ({
|
|
4767
|
+
sourceColumn: D.source.name,
|
|
4768
|
+
targetColumn: D.target.name,
|
|
4769
|
+
sourceColumnObj: D.source,
|
|
4770
|
+
targetColumnObj: D.target
|
|
4771
|
+
})), A = void 0;
|
|
4765
4772
|
}
|
|
4766
4773
|
const w = this.findPropagatingFilters(s, l, e), C = /* @__PURE__ */ new Map([[l.name, l]]), { aggregateMeasures: T, requiredBaseMeasures: E } = I.categorizeForPostAggregation(
|
|
4767
4774
|
y,
|
|
@@ -4774,7 +4781,7 @@ class ct {
|
|
|
4774
4781
|
const S = this.expandCalculatedMeasureDependencies(
|
|
4775
4782
|
l,
|
|
4776
4783
|
N
|
|
4777
|
-
),
|
|
4784
|
+
), R = this.findDownstreamJoinKeys(
|
|
4778
4785
|
l,
|
|
4779
4786
|
s,
|
|
4780
4787
|
e
|
|
@@ -4786,8 +4793,8 @@ class ct {
|
|
|
4786
4793
|
joinKeys: $,
|
|
4787
4794
|
measures: S,
|
|
4788
4795
|
propagatingFilters: w.length > 0 ? w : void 0,
|
|
4789
|
-
downstreamJoinKeys:
|
|
4790
|
-
intermediateJoins:
|
|
4796
|
+
downstreamJoinKeys: R.length > 0 ? R : void 0,
|
|
4797
|
+
intermediateJoins: A && A.length > 0 ? A : void 0,
|
|
4791
4798
|
cteType: "aggregate",
|
|
4792
4799
|
cteReason: f
|
|
4793
4800
|
});
|
|
@@ -4843,13 +4850,13 @@ class ct {
|
|
|
4843
4850
|
for (let f = 0; f < a.length - 1; f++) {
|
|
4844
4851
|
const h = a[f], g = a[f + 1], y = e.get(h.toCube);
|
|
4845
4852
|
if (!y) continue;
|
|
4846
|
-
const $ = y.sql(s).where,
|
|
4853
|
+
const $ = y.sql(s).where, A = g.joinDef.on[0]?.source, w = h.joinDef.on[0]?.target;
|
|
4847
4854
|
l.push({
|
|
4848
4855
|
cube: y,
|
|
4849
4856
|
joinDef: g.joinDef,
|
|
4850
4857
|
securityFilter: $,
|
|
4851
4858
|
primaryJoinColumn: w,
|
|
4852
|
-
cteJoinColumn:
|
|
4859
|
+
cteJoinColumn: A
|
|
4853
4860
|
});
|
|
4854
4861
|
}
|
|
4855
4862
|
const p = a[0].joinDef.on.map((f) => ({
|
|
@@ -5508,7 +5515,7 @@ class cn {
|
|
|
5508
5515
|
const T = C.cube.sql(n), N = [Q(C.cteJoinColumn, C.joinDef.on[0]?.target)];
|
|
5509
5516
|
C.securityFilter && N.push(C.securityFilter), f = f.leftJoin(
|
|
5510
5517
|
T.from,
|
|
5511
|
-
|
|
5518
|
+
_(...N)
|
|
5512
5519
|
);
|
|
5513
5520
|
}
|
|
5514
5521
|
const h = s ? {
|
|
@@ -5519,8 +5526,8 @@ class cn {
|
|
|
5519
5526
|
for (const C of t.timeDimensions) {
|
|
5520
5527
|
const [T, E] = C.dimension.split(".");
|
|
5521
5528
|
if (T === l && r.dimensions && r.dimensions[E] && C.dateRange) {
|
|
5522
|
-
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n),
|
|
5523
|
-
|
|
5529
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n), R = this.queryBuilder.buildDateRangeCondition(S, C.dateRange);
|
|
5530
|
+
R && y.push(R);
|
|
5524
5531
|
}
|
|
5525
5532
|
}
|
|
5526
5533
|
if (t.filters) {
|
|
@@ -5530,8 +5537,8 @@ class cn {
|
|
|
5530
5537
|
if (E === l && r.dimensions && r.dimensions[N]) {
|
|
5531
5538
|
const S = r.dimensions[N];
|
|
5532
5539
|
if (T.operator === "inDateRange") {
|
|
5533
|
-
const
|
|
5534
|
-
|
|
5540
|
+
const R = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), D = this.queryBuilder.buildDateRangeCondition(R, T.values);
|
|
5541
|
+
D && y.push(D);
|
|
5535
5542
|
}
|
|
5536
5543
|
}
|
|
5537
5544
|
}
|
|
@@ -5546,12 +5553,12 @@ class cn {
|
|
|
5546
5553
|
}
|
|
5547
5554
|
const b = [];
|
|
5548
5555
|
if (a.where && b.push(a.where), b.push(...g, ...y), b.length > 0) {
|
|
5549
|
-
const C = b.length === 1 ? b[0] :
|
|
5556
|
+
const C = b.length === 1 ? b[0] : _(...b);
|
|
5550
5557
|
f = f.where(C);
|
|
5551
5558
|
}
|
|
5552
|
-
const $ = [],
|
|
5559
|
+
const $ = [], A = /* @__PURE__ */ new Set(), w = (C) => {
|
|
5553
5560
|
const T = C?.name || (typeof C == "string" ? C : null);
|
|
5554
|
-
T && !
|
|
5561
|
+
T && !A.has(T) ? (A.add(T), $.push(C)) : T || $.push(C);
|
|
5555
5562
|
};
|
|
5556
5563
|
if (u && e.intermediateJoins) {
|
|
5557
5564
|
const C = e.intermediateJoins[0];
|
|
@@ -5567,7 +5574,7 @@ class cn {
|
|
|
5567
5574
|
for (const C of t.dimensions) {
|
|
5568
5575
|
const [T, E] = C.split(".");
|
|
5569
5576
|
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5570
|
-
const N = r.dimensions[E], S =
|
|
5577
|
+
const N = r.dimensions[E], S = v(N.sql, n);
|
|
5571
5578
|
$.push(S);
|
|
5572
5579
|
}
|
|
5573
5580
|
}
|
|
@@ -5605,7 +5612,7 @@ class cn {
|
|
|
5605
5612
|
const a = r.sourceColumnObj || o.identifier(r.sourceColumn), u = o`${o.identifier(t)}.${o.identifier(r.targetColumn)}`;
|
|
5606
5613
|
i.push(Q(a, u));
|
|
5607
5614
|
}
|
|
5608
|
-
return i.length === 1 ? i[0] :
|
|
5615
|
+
return i.length === 1 ? i[0] : _(...i);
|
|
5609
5616
|
}
|
|
5610
5617
|
/**
|
|
5611
5618
|
* Build a subquery filter for propagating filters from related cubes.
|
|
@@ -5634,12 +5641,12 @@ class cn {
|
|
|
5634
5641
|
}
|
|
5635
5642
|
if (i.length === 0)
|
|
5636
5643
|
return null;
|
|
5637
|
-
const r = i.length === 1 ? i[0] :
|
|
5644
|
+
const r = i.length === 1 ? i[0] : _(...i), a = e.joinConditions;
|
|
5638
5645
|
if (a.length === 1) {
|
|
5639
5646
|
const { source: u, target: c } = a[0], l = t.db.select({ pk: u }).from(s.from).where(r);
|
|
5640
5647
|
return o`${c} IN ${l}`;
|
|
5641
5648
|
} else {
|
|
5642
|
-
const u = a.map((m) => Q(m.source, m.target)), c =
|
|
5649
|
+
const u = a.map((m) => Q(m.source, m.target)), c = _(
|
|
5643
5650
|
...u,
|
|
5644
5651
|
r
|
|
5645
5652
|
), l = t.db.select({ one: o`1` }).from(s.from).where(c);
|
|
@@ -6173,7 +6180,7 @@ class yn {
|
|
|
6173
6180
|
const [, a] = e.bindingKey.split("."), u = t.dimensions?.[a];
|
|
6174
6181
|
if (!u)
|
|
6175
6182
|
throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
|
|
6176
|
-
return
|
|
6183
|
+
return v(u.sql, n);
|
|
6177
6184
|
}
|
|
6178
6185
|
const s = e.bindingKey.find((a) => a.cube === t.name);
|
|
6179
6186
|
if (!s)
|
|
@@ -6181,7 +6188,7 @@ class yn {
|
|
|
6181
6188
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6182
6189
|
if (!r)
|
|
6183
6190
|
throw new Error(`Binding key dimension not found: ${s.dimension}`);
|
|
6184
|
-
return
|
|
6191
|
+
return v(r.sql, n);
|
|
6185
6192
|
}
|
|
6186
6193
|
/**
|
|
6187
6194
|
* Resolve time dimension expression for a cube
|
|
@@ -6191,7 +6198,7 @@ class yn {
|
|
|
6191
6198
|
const [, a] = e.timeDimension.split("."), u = t.dimensions?.[a];
|
|
6192
6199
|
if (!u)
|
|
6193
6200
|
throw new Error(`Time dimension not found: ${e.timeDimension}`);
|
|
6194
|
-
return
|
|
6201
|
+
return v(u.sql, n);
|
|
6195
6202
|
}
|
|
6196
6203
|
const s = e.timeDimension.find((a) => a.cube === t.name);
|
|
6197
6204
|
if (!s)
|
|
@@ -6199,7 +6206,7 @@ class yn {
|
|
|
6199
6206
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6200
6207
|
if (!r)
|
|
6201
6208
|
throw new Error(`Time dimension not found: ${s.dimension}`);
|
|
6202
|
-
return
|
|
6209
|
+
return v(r.sql, n);
|
|
6203
6210
|
}
|
|
6204
6211
|
/**
|
|
6205
6212
|
* Build filter conditions for a step
|
|
@@ -6234,19 +6241,19 @@ class yn {
|
|
|
6234
6241
|
const b = e;
|
|
6235
6242
|
y = b.type === "and";
|
|
6236
6243
|
for (const $ of b.filters || []) {
|
|
6237
|
-
const
|
|
6238
|
-
|
|
6244
|
+
const A = this.buildFilterCondition($, t, n, s);
|
|
6245
|
+
A && g.push(A);
|
|
6239
6246
|
}
|
|
6240
6247
|
} else {
|
|
6241
6248
|
const b = e;
|
|
6242
6249
|
y = "and" in b && !!b.and;
|
|
6243
6250
|
const $ = b.and || b.or || [];
|
|
6244
|
-
for (const
|
|
6245
|
-
const w = this.buildFilterCondition(
|
|
6251
|
+
for (const A of $) {
|
|
6252
|
+
const w = this.buildFilterCondition(A, t, n, s);
|
|
6246
6253
|
w && g.push(w);
|
|
6247
6254
|
}
|
|
6248
6255
|
}
|
|
6249
|
-
return g.length === 0 ? null : g.length === 1 ? g[0] : y ?
|
|
6256
|
+
return g.length === 0 ? null : g.length === 1 ? g[0] : y ? _(...g) : o`(${o.join(g, o` OR `)})`;
|
|
6250
6257
|
}
|
|
6251
6258
|
const a = e, [u, c] = a.member.split("."), l = a.dateRange !== void 0;
|
|
6252
6259
|
if (a.operator !== "set" && a.operator !== "notSet" && !l && (!a.values || a.values.length === 0 || a.values[0] === void 0 || a.values[0] === ""))
|
|
@@ -6263,7 +6270,7 @@ class yn {
|
|
|
6263
6270
|
}
|
|
6264
6271
|
const f = p.dimensions?.[c];
|
|
6265
6272
|
if (!f) return null;
|
|
6266
|
-
const h =
|
|
6273
|
+
const h = v(f.sql, s);
|
|
6267
6274
|
return this.filterBuilder.buildFilterCondition(
|
|
6268
6275
|
h,
|
|
6269
6276
|
a.operator,
|
|
@@ -6302,7 +6309,7 @@ class yn {
|
|
|
6302
6309
|
step_time: o`MIN(${e.timeExpr})`.as("step_time")
|
|
6303
6310
|
}).from(s.from);
|
|
6304
6311
|
if (r = this.addCrossJoinsToQuery(r, e, t, i), i.length > 0) {
|
|
6305
|
-
const a = i.length === 1 ? i[0] :
|
|
6312
|
+
const a = i.length === 1 ? i[0] : _(...i);
|
|
6306
6313
|
r = r.where(a);
|
|
6307
6314
|
}
|
|
6308
6315
|
return r = r.groupBy(e.bindingKeyExpr), t.db.$with(n).as(r);
|
|
@@ -6335,7 +6342,7 @@ class yn {
|
|
|
6335
6342
|
o`${e.bindingKeyExpr} = ${o.identifier(i)}.binding_key`
|
|
6336
6343
|
);
|
|
6337
6344
|
if (l = this.addCrossJoinsToQuery(l, e, t, a), a.length > 0) {
|
|
6338
|
-
const m = a.length === 1 ? a[0] :
|
|
6345
|
+
const m = a.length === 1 ? a[0] : _(...a);
|
|
6339
6346
|
l = l.where(m);
|
|
6340
6347
|
}
|
|
6341
6348
|
return l = l.groupBy(e.bindingKeyExpr), t.db.$with(s).as(l);
|
|
@@ -6352,7 +6359,7 @@ class yn {
|
|
|
6352
6359
|
const a = r.joinDef, u = [];
|
|
6353
6360
|
for (const p of a.on)
|
|
6354
6361
|
p.as ? u.push(p.as(p.source, p.target)) : u.push(Q(p.source, p.target));
|
|
6355
|
-
const c = u.length === 1 ? u[0] :
|
|
6362
|
+
const c = u.length === 1 ? u[0] : _(...u), m = i.cube.sql(n);
|
|
6356
6363
|
e = e.leftJoin(m.from, c), m.where && s.push(m.where);
|
|
6357
6364
|
}
|
|
6358
6365
|
return e;
|
|
@@ -6601,7 +6608,7 @@ class Cn {
|
|
|
6601
6608
|
const [, a] = e.bindingKey.split("."), u = t.dimensions?.[a];
|
|
6602
6609
|
if (!u)
|
|
6603
6610
|
throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
|
|
6604
|
-
return
|
|
6611
|
+
return v(u.sql, n);
|
|
6605
6612
|
}
|
|
6606
6613
|
const s = e.bindingKey.find((a) => a.cube === t.name);
|
|
6607
6614
|
if (!s)
|
|
@@ -6609,7 +6616,7 @@ class Cn {
|
|
|
6609
6616
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6610
6617
|
if (!r)
|
|
6611
6618
|
throw new Error(`Binding key dimension not found: ${s.dimension}`);
|
|
6612
|
-
return
|
|
6619
|
+
return v(r.sql, n);
|
|
6613
6620
|
}
|
|
6614
6621
|
/**
|
|
6615
6622
|
* Resolve time dimension expression
|
|
@@ -6619,7 +6626,7 @@ class Cn {
|
|
|
6619
6626
|
const [, a] = e.timeDimension.split("."), u = t.dimensions?.[a];
|
|
6620
6627
|
if (!u)
|
|
6621
6628
|
throw new Error(`Time dimension not found: ${e.timeDimension}`);
|
|
6622
|
-
return
|
|
6629
|
+
return v(u.sql, n);
|
|
6623
6630
|
}
|
|
6624
6631
|
const s = e.timeDimension.find((a) => a.cube === t.name);
|
|
6625
6632
|
if (!s)
|
|
@@ -6627,7 +6634,7 @@ class Cn {
|
|
|
6627
6634
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6628
6635
|
if (!r)
|
|
6629
6636
|
throw new Error(`Time dimension not found: ${s.dimension}`);
|
|
6630
|
-
return
|
|
6637
|
+
return v(r.sql, n);
|
|
6631
6638
|
}
|
|
6632
6639
|
/**
|
|
6633
6640
|
* Resolve event dimension expression
|
|
@@ -6636,7 +6643,7 @@ class Cn {
|
|
|
6636
6643
|
const [, s] = e.eventDimension.split("."), i = t.dimensions?.[s];
|
|
6637
6644
|
if (!i)
|
|
6638
6645
|
throw new Error(`Event dimension not found: ${e.eventDimension}`);
|
|
6639
|
-
return
|
|
6646
|
+
return v(i.sql, n);
|
|
6640
6647
|
}
|
|
6641
6648
|
/**
|
|
6642
6649
|
* Build filter conditions for the starting step
|
|
@@ -6661,7 +6668,7 @@ class Cn {
|
|
|
6661
6668
|
const p = this.buildFilterCondition(m, t, n);
|
|
6662
6669
|
p && c.push(p);
|
|
6663
6670
|
}
|
|
6664
|
-
return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ?
|
|
6671
|
+
return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ? _(...c) : o`(${o.join(c, o` OR `)})`;
|
|
6665
6672
|
}
|
|
6666
6673
|
if ("type" in e && "filters" in e) {
|
|
6667
6674
|
const u = e, c = [];
|
|
@@ -6669,11 +6676,11 @@ class Cn {
|
|
|
6669
6676
|
const m = this.buildFilterCondition(l, t, n);
|
|
6670
6677
|
m && c.push(m);
|
|
6671
6678
|
}
|
|
6672
|
-
return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ?
|
|
6679
|
+
return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ? _(...c) : o`(${o.join(c, o` OR `)})`;
|
|
6673
6680
|
}
|
|
6674
6681
|
const s = e, [, i] = s.member.split("."), r = t.dimensions?.[i];
|
|
6675
6682
|
if (!r) return null;
|
|
6676
|
-
const a =
|
|
6683
|
+
const a = v(r.sql, n);
|
|
6677
6684
|
return this.filterBuilder.buildFilterCondition(
|
|
6678
6685
|
a,
|
|
6679
6686
|
s.operator,
|
|
@@ -6701,7 +6708,7 @@ class Cn {
|
|
|
6701
6708
|
event_path: o`${a}`.as("event_path")
|
|
6702
6709
|
}).from(s.from);
|
|
6703
6710
|
if (c.length > 0) {
|
|
6704
|
-
const m = c.length === 1 ? c[0] :
|
|
6711
|
+
const m = c.length === 1 ? c[0] : _(...c);
|
|
6705
6712
|
l = l.where(m);
|
|
6706
6713
|
}
|
|
6707
6714
|
return l = l.groupBy(i, a), e.entityLimit && (l = l.limit(e.entityLimit)), n.db.$with("starting_entities").as(l);
|
|
@@ -6718,7 +6725,7 @@ class Cn {
|
|
|
6718
6725
|
o`${i} = ${o.identifier(m)}.binding_key`,
|
|
6719
6726
|
o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
|
|
6720
6727
|
);
|
|
6721
|
-
const g = h.length === 1 ? h[0] :
|
|
6728
|
+
const g = h.length === 1 ? h[0] : _(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
|
|
6722
6729
|
binding_key: o`${i}`.as("binding_key"),
|
|
6723
6730
|
step_time: o`${r}`.as("step_time"),
|
|
6724
6731
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -6747,7 +6754,7 @@ class Cn {
|
|
|
6747
6754
|
o`${i} = ${o.identifier(m)}.binding_key`,
|
|
6748
6755
|
o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
|
|
6749
6756
|
);
|
|
6750
|
-
const g = h.length === 1 ? h[0] :
|
|
6757
|
+
const g = h.length === 1 ? h[0] : _(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
|
|
6751
6758
|
binding_key: o`${i}`.as("binding_key"),
|
|
6752
6759
|
step_time: o`${r}`.as("step_time"),
|
|
6753
6760
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -6778,7 +6785,7 @@ class Cn {
|
|
|
6778
6785
|
s.where && h.push(s.where), h.push(
|
|
6779
6786
|
o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
|
|
6780
6787
|
);
|
|
6781
|
-
const g = h.length === 1 ? h[0] :
|
|
6788
|
+
const g = h.length === 1 ? h[0] : _(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
|
|
6782
6789
|
binding_key: o`${i}`.as("binding_key"),
|
|
6783
6790
|
step_time: o`${r}`.as("step_time"),
|
|
6784
6791
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -6811,7 +6818,7 @@ class Cn {
|
|
|
6811
6818
|
s.where && h.push(s.where), h.push(
|
|
6812
6819
|
o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
|
|
6813
6820
|
);
|
|
6814
|
-
const g = h.length === 1 ? h[0] :
|
|
6821
|
+
const g = h.length === 1 ? h[0] : _(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
|
|
6815
6822
|
binding_key: o`${i}`.as("binding_key"),
|
|
6816
6823
|
step_time: o`${r}`.as("step_time"),
|
|
6817
6824
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -7190,12 +7197,12 @@ class wn {
|
|
|
7190
7197
|
const a = r.dimensions?.[i];
|
|
7191
7198
|
if (!a)
|
|
7192
7199
|
throw new Error(`Time dimension not found: ${i}`);
|
|
7193
|
-
const u =
|
|
7200
|
+
const u = v(a.sql, n), c = this.resolveBindingKey(e.bindingKey, r, t, n), l = this.buildFilterConditions(e.cohortFilters, r, t, n), m = this.buildFilterConditions(e.activityFilters, r, t, n), p = [];
|
|
7194
7201
|
if (e.breakdownDimensions && e.breakdownDimensions.length > 0)
|
|
7195
7202
|
for (const f of e.breakdownDimensions) {
|
|
7196
7203
|
const [h, g] = f.split("."), y = t.get(h);
|
|
7197
7204
|
if (y && y.dimensions?.[g]) {
|
|
7198
|
-
const b =
|
|
7205
|
+
const b = v(y.dimensions[g].sql, n);
|
|
7199
7206
|
p.push({ dimension: f, expr: b });
|
|
7200
7207
|
}
|
|
7201
7208
|
}
|
|
@@ -7215,7 +7222,7 @@ class wn {
|
|
|
7215
7222
|
const p = m.dimensions?.[l];
|
|
7216
7223
|
if (!p)
|
|
7217
7224
|
throw new Error(`Binding key dimension not found: ${c.dimension}`);
|
|
7218
|
-
return
|
|
7225
|
+
return v(p.sql, s);
|
|
7219
7226
|
}
|
|
7220
7227
|
const [i, r] = e.split("."), a = n.get(i);
|
|
7221
7228
|
if (!a)
|
|
@@ -7223,7 +7230,7 @@ class wn {
|
|
|
7223
7230
|
const u = a.dimensions?.[r];
|
|
7224
7231
|
if (!u)
|
|
7225
7232
|
throw new Error(`Binding key dimension not found: ${e}`);
|
|
7226
|
-
return
|
|
7233
|
+
return v(u.sql, s);
|
|
7227
7234
|
}
|
|
7228
7235
|
/**
|
|
7229
7236
|
* Build filter conditions from config filters
|
|
@@ -7247,13 +7254,13 @@ class wn {
|
|
|
7247
7254
|
const y = this.buildSingleFilterCondition(g, t, n, s);
|
|
7248
7255
|
y && p.push(y);
|
|
7249
7256
|
}
|
|
7250
|
-
return p.length === 0 ? null : p.length === 1 ? p[0] : f ?
|
|
7257
|
+
return p.length === 0 ? null : p.length === 1 ? p[0] : f ? _(...p) : o`(${o.join(p, o` OR `)})`;
|
|
7251
7258
|
}
|
|
7252
7259
|
const i = e, [r, a] = i.member.split("."), u = n.get(r);
|
|
7253
7260
|
if (!u) return null;
|
|
7254
7261
|
const c = u.dimensions?.[a];
|
|
7255
7262
|
if (!c) return null;
|
|
7256
|
-
const l =
|
|
7263
|
+
const l = v(c.sql, s);
|
|
7257
7264
|
return this.filterBuilder.buildFilterCondition(
|
|
7258
7265
|
l,
|
|
7259
7266
|
i.operator,
|
|
@@ -7289,7 +7296,7 @@ class wn {
|
|
|
7289
7296
|
}
|
|
7290
7297
|
let u = n.db.select(a).from(s.from);
|
|
7291
7298
|
if (i.length > 0) {
|
|
7292
|
-
const l = i.length === 1 ? i[0] :
|
|
7299
|
+
const l = i.length === 1 ? i[0] : _(...i);
|
|
7293
7300
|
u = u.where(l);
|
|
7294
7301
|
}
|
|
7295
7302
|
const c = [t.bindingKeyExpr];
|
|
@@ -7344,7 +7351,7 @@ class wn {
|
|
|
7344
7351
|
o`${t.bindingKeyExpr} = cohort_base.binding_key`
|
|
7345
7352
|
);
|
|
7346
7353
|
if (i.length > 0) {
|
|
7347
|
-
const m = i.length === 1 ? i[0] :
|
|
7354
|
+
const m = i.length === 1 ? i[0] : _(...i);
|
|
7348
7355
|
c = c.where(m);
|
|
7349
7356
|
}
|
|
7350
7357
|
const l = [
|
|
@@ -7533,14 +7540,14 @@ class Y {
|
|
|
7533
7540
|
const c = this.buildUnifiedQuery(u, t, a), l = this.queryBuilder.collectNumericFields(e, t), m = await this.dbExecutor.execute(c, l), p = Array.isArray(m) ? m.map((b) => {
|
|
7534
7541
|
const $ = { ...b };
|
|
7535
7542
|
if (t.timeDimensions) {
|
|
7536
|
-
for (const
|
|
7537
|
-
if (
|
|
7538
|
-
let w = $[
|
|
7543
|
+
for (const A of t.timeDimensions)
|
|
7544
|
+
if (A.dimension in $) {
|
|
7545
|
+
let w = $[A.dimension];
|
|
7539
7546
|
if (typeof w == "string" && w.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
7540
7547
|
const C = w.replace(" ", "T"), T = !C.endsWith("Z") && !C.includes("+") ? C + "Z" : C;
|
|
7541
7548
|
w = new Date(T);
|
|
7542
7549
|
}
|
|
7543
|
-
w = this.databaseAdapter.convertTimeDimensionResult(w), $[
|
|
7550
|
+
w = this.databaseAdapter.convertTimeDimensionResult(w), $[A.dimension] = w;
|
|
7544
7551
|
}
|
|
7545
7552
|
}
|
|
7546
7553
|
return $;
|
|
@@ -7822,8 +7829,8 @@ class Y {
|
|
|
7822
7829
|
if (y.dimension in g) {
|
|
7823
7830
|
let b = g[y.dimension];
|
|
7824
7831
|
if (typeof b == "string" && b.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
7825
|
-
const $ = b.replace(" ", "T"),
|
|
7826
|
-
b = new Date(
|
|
7832
|
+
const $ = b.replace(" ", "T"), A = !$.endsWith("Z") && !$.includes("+") ? $ + "Z" : $;
|
|
7833
|
+
b = new Date(A);
|
|
7827
7834
|
}
|
|
7828
7835
|
b = this.databaseAdapter.convertTimeDimensionResult(b), g[y.dimension] = b;
|
|
7829
7836
|
}
|
|
@@ -7877,15 +7884,15 @@ class Y {
|
|
|
7877
7884
|
if (!s.has(T)) {
|
|
7878
7885
|
const N = {
|
|
7879
7886
|
filters: C.filters
|
|
7880
|
-
}, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]),
|
|
7887
|
+
}, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]), R = this.queryBuilder.buildWhereConditions(
|
|
7881
7888
|
S,
|
|
7882
7889
|
N,
|
|
7883
7890
|
n
|
|
7884
7891
|
);
|
|
7885
|
-
s.set(T,
|
|
7892
|
+
s.set(T, R);
|
|
7886
7893
|
}
|
|
7887
7894
|
const E = s.get(T);
|
|
7888
|
-
E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] :
|
|
7895
|
+
E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] : _(...E));
|
|
7889
7896
|
}
|
|
7890
7897
|
}
|
|
7891
7898
|
const i = [], r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
@@ -7912,10 +7919,10 @@ class Y {
|
|
|
7912
7919
|
if (m[T]) {
|
|
7913
7920
|
const [, E] = T.split("."), N = c.get(C);
|
|
7914
7921
|
if (N && N.measures && N.measures[E]) {
|
|
7915
|
-
const S = N.measures[E],
|
|
7916
|
-
let
|
|
7922
|
+
const S = N.measures[E], R = o`${o.identifier(w.cteAlias)}.${o.identifier(E)}`;
|
|
7923
|
+
let D;
|
|
7917
7924
|
if (S.type === "calculated" && S.calculatedSql)
|
|
7918
|
-
|
|
7925
|
+
D = this.queryBuilder.buildCTECalculatedMeasure(
|
|
7919
7926
|
S,
|
|
7920
7927
|
N,
|
|
7921
7928
|
w,
|
|
@@ -7932,38 +7939,38 @@ class Y {
|
|
|
7932
7939
|
case "count":
|
|
7933
7940
|
case "countDistinct":
|
|
7934
7941
|
case "sum":
|
|
7935
|
-
|
|
7942
|
+
D = j ? G(R) : z(R);
|
|
7936
7943
|
break;
|
|
7937
7944
|
case "avg":
|
|
7938
|
-
|
|
7945
|
+
D = j ? G(R) : this.databaseAdapter.buildAvg(R);
|
|
7939
7946
|
break;
|
|
7940
7947
|
case "min":
|
|
7941
|
-
|
|
7948
|
+
D = oe(R);
|
|
7942
7949
|
break;
|
|
7943
7950
|
case "max":
|
|
7944
|
-
|
|
7951
|
+
D = G(R);
|
|
7945
7952
|
break;
|
|
7946
7953
|
case "number":
|
|
7947
|
-
|
|
7954
|
+
D = j ? G(R) : z(R);
|
|
7948
7955
|
break;
|
|
7949
7956
|
default:
|
|
7950
|
-
|
|
7957
|
+
D = j ? G(R) : z(R);
|
|
7951
7958
|
}
|
|
7952
7959
|
}
|
|
7953
|
-
m[T] = o`${
|
|
7960
|
+
m[T] = o`${D}`.as(T);
|
|
7954
7961
|
}
|
|
7955
7962
|
}
|
|
7956
7963
|
for (const T in m) {
|
|
7957
7964
|
const [E, N] = T.split(".");
|
|
7958
7965
|
if (E === C) {
|
|
7959
|
-
const S = c.get(C),
|
|
7960
|
-
if (
|
|
7966
|
+
const S = c.get(C), R = S && S.dimensions?.[N], D = T.startsWith(C + ".");
|
|
7967
|
+
if (R || D) {
|
|
7961
7968
|
let F = w.joinKeys.find((U) => U.targetColumn === N);
|
|
7962
7969
|
if (!F && S?.dimensions?.[N]) {
|
|
7963
7970
|
const U = S.dimensions[N].sql;
|
|
7964
7971
|
F = w.joinKeys.find((j) => j.targetColumnObj === U);
|
|
7965
7972
|
}
|
|
7966
|
-
F ? m[T] = o`${o.identifier(w.cteAlias)}.${o.identifier(N)}`.as(T) :
|
|
7973
|
+
F ? m[T] = o`${o.identifier(w.cteAlias)}.${o.identifier(N)}`.as(T) : D && S?.dimensions?.[N] && (m[T] = o`${o.identifier(w.cteAlias)}.${o.identifier(N)}`.as(T));
|
|
7967
7974
|
}
|
|
7968
7975
|
}
|
|
7969
7976
|
}
|
|
@@ -7976,14 +7983,14 @@ class Y {
|
|
|
7976
7983
|
if (I.isPostAggregationWindow(N)) {
|
|
7977
7984
|
const S = I.getWindowBaseMeasure(N, C);
|
|
7978
7985
|
if (S) {
|
|
7979
|
-
const [
|
|
7980
|
-
if (F?.measures?.[
|
|
7981
|
-
const U = F.measures[
|
|
7982
|
-
(q) => q.cube?.name ===
|
|
7986
|
+
const [R, D] = S.split("."), F = c.get(R);
|
|
7987
|
+
if (F?.measures?.[D]) {
|
|
7988
|
+
const U = F.measures[D], j = e.preAggregationCTEs?.find(
|
|
7989
|
+
(q) => q.cube?.name === R && q.measures?.includes(S)
|
|
7983
7990
|
);
|
|
7984
7991
|
let B;
|
|
7985
7992
|
if (j) {
|
|
7986
|
-
const q = o`${o.identifier(j.cteAlias)}.${o.identifier(
|
|
7993
|
+
const q = o`${o.identifier(j.cteAlias)}.${o.identifier(D)}`;
|
|
7987
7994
|
B = o`sum(${q})`;
|
|
7988
7995
|
} else
|
|
7989
7996
|
B = this.queryBuilder.buildMeasureExpression(U, n, F);
|
|
@@ -8049,7 +8056,7 @@ class Y {
|
|
|
8049
8056
|
const yt = o`${o.identifier(j)}.${o.identifier(Oe.sourceColumn)}`, Ie = Oe.targetColumnObj;
|
|
8050
8057
|
Ie && H.push(Q(Ie, yt));
|
|
8051
8058
|
}
|
|
8052
|
-
H.length > 0 && (U =
|
|
8059
|
+
H.length > 0 && (U = _(...H));
|
|
8053
8060
|
}
|
|
8054
8061
|
}
|
|
8055
8062
|
const B = [];
|
|
@@ -8087,24 +8094,24 @@ class Y {
|
|
|
8087
8094
|
const V = o`${o.identifier(F.cteAlias)}.${o.identifier(B.sourceColumn)}`, q = B.targetColumnObj || o.identifier(B.targetColumn);
|
|
8088
8095
|
j.push(Q(V, q));
|
|
8089
8096
|
}
|
|
8090
|
-
N = j.length === 1 ? j[0] :
|
|
8097
|
+
N = j.length === 1 ? j[0] : _(...j);
|
|
8091
8098
|
} else
|
|
8092
8099
|
N = w.joinCondition;
|
|
8093
8100
|
}
|
|
8094
|
-
const
|
|
8101
|
+
const R = w.joinType || "left", D = R !== "inner" && S ? _(N, S) : N;
|
|
8095
8102
|
try {
|
|
8096
|
-
switch (
|
|
8103
|
+
switch (R) {
|
|
8097
8104
|
case "left":
|
|
8098
|
-
f = f.leftJoin(E,
|
|
8105
|
+
f = f.leftJoin(E, D), S && h.add(w.cube.name);
|
|
8099
8106
|
break;
|
|
8100
8107
|
case "inner":
|
|
8101
8108
|
f = f.innerJoin(E, N);
|
|
8102
8109
|
break;
|
|
8103
8110
|
case "right":
|
|
8104
|
-
f = f.rightJoin(E,
|
|
8111
|
+
f = f.rightJoin(E, D), S && h.add(w.cube.name);
|
|
8105
8112
|
break;
|
|
8106
8113
|
case "full":
|
|
8107
|
-
f = f.fullJoin(E,
|
|
8114
|
+
f = f.fullJoin(E, D), S && h.add(w.cube.name);
|
|
8108
8115
|
break;
|
|
8109
8116
|
}
|
|
8110
8117
|
} catch {
|
|
@@ -8129,7 +8136,7 @@ class Y {
|
|
|
8129
8136
|
// Reuse pre-built filters for parameter deduplication
|
|
8130
8137
|
);
|
|
8131
8138
|
if (y.length > 0 && p.push(...y), p.length > 0) {
|
|
8132
|
-
const w = p.length === 1 ? p[0] :
|
|
8139
|
+
const w = p.length === 1 ? p[0] : _(...p);
|
|
8133
8140
|
f = f.where(w);
|
|
8134
8141
|
}
|
|
8135
8142
|
const b = this.queryBuilder.buildGroupByFields(
|
|
@@ -8150,11 +8157,11 @@ class Y {
|
|
|
8150
8157
|
// Pass the queryPlan to handle CTE scenarios
|
|
8151
8158
|
);
|
|
8152
8159
|
if ($.length > 0) {
|
|
8153
|
-
const w = $.length === 1 ? $[0] :
|
|
8160
|
+
const w = $.length === 1 ? $[0] : _(...$);
|
|
8154
8161
|
f = f.having(w);
|
|
8155
8162
|
}
|
|
8156
|
-
const
|
|
8157
|
-
return
|
|
8163
|
+
const A = this.queryBuilder.buildOrderBy(t);
|
|
8164
|
+
return A.length > 0 && (f = f.orderBy(...A)), f = this.queryBuilder.applyLimitAndOffset(f, t), f;
|
|
8158
8165
|
}
|
|
8159
8166
|
/**
|
|
8160
8167
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -8361,7 +8368,7 @@ class Y {
|
|
|
8361
8368
|
const m = l.dimensions?.[c];
|
|
8362
8369
|
if (!m || ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator))
|
|
8363
8370
|
continue;
|
|
8364
|
-
const f =
|
|
8371
|
+
const f = v(m.sql, s), h = this.queryBuilder.buildFilterConditionPublic(
|
|
8365
8372
|
f,
|
|
8366
8373
|
r.operator,
|
|
8367
8374
|
r.values,
|
|
@@ -8380,7 +8387,7 @@ class Y {
|
|
|
8380
8387
|
if (!c) continue;
|
|
8381
8388
|
const l = c.dimensions?.[u];
|
|
8382
8389
|
if (!l) continue;
|
|
8383
|
-
const m =
|
|
8390
|
+
const m = v(l.sql, s), p = this.queryBuilder.buildDateRangeCondition(m, i.dateRange);
|
|
8384
8391
|
p && t.set(r, p);
|
|
8385
8392
|
}
|
|
8386
8393
|
}
|
|
@@ -8412,15 +8419,15 @@ class Y {
|
|
|
8412
8419
|
const h = f.field.includes(".") ? f.field.split(".")[1] : f.field;
|
|
8413
8420
|
if (n.timeDimensions)
|
|
8414
8421
|
for (const b of n.timeDimensions) {
|
|
8415
|
-
const [$,
|
|
8416
|
-
if (
|
|
8422
|
+
const [$, A] = b.dimension.split(".");
|
|
8423
|
+
if (A === h) {
|
|
8417
8424
|
const w = u($, h);
|
|
8418
8425
|
if (w)
|
|
8419
8426
|
return {
|
|
8420
8427
|
field: w,
|
|
8421
8428
|
direction: f.direction
|
|
8422
8429
|
};
|
|
8423
|
-
const C = i.dimensions?.[
|
|
8430
|
+
const C = i.dimensions?.[A];
|
|
8424
8431
|
if (C)
|
|
8425
8432
|
return {
|
|
8426
8433
|
field: this.queryBuilder.buildTimeDimensionExpression(
|
|
@@ -8435,7 +8442,7 @@ class Y {
|
|
|
8435
8442
|
const g = i.dimensions?.[h];
|
|
8436
8443
|
if (g)
|
|
8437
8444
|
return {
|
|
8438
|
-
field:
|
|
8445
|
+
field: v(g.sql, s),
|
|
8439
8446
|
direction: f.direction
|
|
8440
8447
|
};
|
|
8441
8448
|
const y = a.measure?.includes(".") ? a.measure.split(".")[1] : a.measure;
|
|
@@ -8469,7 +8476,7 @@ class Y {
|
|
|
8469
8476
|
let l;
|
|
8470
8477
|
a.partitionBy && a.partitionBy.length > 0 && (l = a.partitionBy.map((f) => {
|
|
8471
8478
|
const h = f.includes(".") ? f.split(".")[1] : f, g = i.dimensions?.[h];
|
|
8472
|
-
return g ?
|
|
8479
|
+
return g ? v(g.sql, s) : null;
|
|
8473
8480
|
}).filter((f) => f !== null));
|
|
8474
8481
|
const m = this.databaseAdapter.buildWindowFunction(
|
|
8475
8482
|
e.type,
|