drizzle-cube 0.2.13 → 0.2.15
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/compiler-A-Mz5Rzh.cjs +22 -0
- package/dist/adapters/{compiler-DrkCCzf0.js → compiler-CQq2_dSQ.js} +1677 -1540
- 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/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/client/charts.js +27 -36
- package/dist/client/charts.js.map +1 -1
- package/dist/client/chunks/charts-B8YMw1mi.js +7227 -0
- package/dist/client/chunks/charts-B8YMw1mi.js.map +1 -0
- package/dist/client/chunks/charts-amt7VOyw.js +277 -0
- package/dist/client/chunks/{charts-CHzWeaY1.js.map → charts-amt7VOyw.js.map} +1 -1
- package/dist/client/chunks/components-K3xrnHN-.js +13698 -0
- package/dist/client/chunks/components-K3xrnHN-.js.map +1 -0
- package/dist/client/chunks/core-Dkym7d1O.js +6 -0
- package/dist/client/chunks/core-Dkym7d1O.js.map +1 -0
- package/dist/client/chunks/{index-DlsvcKXf.js → index-B7NSVb33.js} +2 -2
- package/dist/client/chunks/{index-DlsvcKXf.js.map → index-B7NSVb33.js.map} +1 -1
- package/dist/client/chunks/javascript-DII1YQGr.js +659 -0
- package/dist/client/chunks/javascript-DII1YQGr.js.map +1 -0
- package/dist/client/components/AnalysisBuilder/AnalysisFilterItem.d.ts +1 -3
- package/dist/client/components/AnalysisBuilder/FilterConfigModal.d.ts +16 -0
- package/dist/client/components/AnalyticsPortlet.d.ts +2 -1
- package/dist/client/components/DashboardFilters/FilterEditModal.d.ts +1 -1
- package/dist/client/components/DashboardFilters/ReadOnlyFilterList.d.ts +1 -1
- package/dist/client/components/DashboardPortletCard.d.ts +3 -3
- package/dist/client/components/QueryBuilderShim.d.ts +3 -0
- package/dist/client/components/charts/ActivityGridChart.d.ts +3 -1
- package/dist/client/components/charts/AreaChart.d.ts +3 -1
- package/dist/client/components/charts/BarChart.d.ts +3 -1
- package/dist/client/components/charts/BubbleChart.d.ts +3 -1
- package/dist/client/components/charts/DataTable.d.ts +3 -1
- package/dist/client/components/charts/KpiDelta.d.ts +3 -1
- package/dist/client/components/charts/KpiNumber.d.ts +3 -1
- package/dist/client/components/charts/KpiText.d.ts +3 -1
- package/dist/client/components/charts/LineChart.d.ts +3 -1
- package/dist/client/components/charts/MarkdownChart.d.ts +3 -1
- package/dist/client/components/charts/PieChart.d.ts +3 -1
- package/dist/client/components/charts/RadarChart.d.ts +3 -1
- package/dist/client/components/charts/RadialBarChart.d.ts +3 -1
- package/dist/client/components/charts/ScatterChart.d.ts +3 -1
- package/dist/client/components/charts/TreeMapChart.d.ts +3 -1
- package/dist/client/components/{QueryBuilder → shared}/CubeMetaExplorer.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/DateRangeFilter.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterBuilder.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterGroup.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterItem.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/FilterValueSelector.d.ts +1 -1
- package/dist/client/components/{QueryBuilder → shared}/utils.d.ts +1 -1
- package/dist/client/components.d.ts +1 -1
- package/dist/client/components.js +2 -2
- package/dist/client/hooks/useCubeFieldLabel.d.ts +16 -0
- package/dist/client/hooks/useScrollDetection.d.ts +27 -0
- package/dist/client/hooks/useTheme.d.ts +11 -0
- package/dist/client/hooks.js +8 -8
- package/dist/client/icons.js +5 -5
- package/dist/client/index.d.ts +8 -3
- package/dist/client/index.js +50 -45
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers/CubeApiProvider.d.ts +22 -0
- package/dist/client/providers/CubeFeaturesProvider.d.ts +15 -0
- package/dist/client/providers/CubeMetaProvider.d.ts +17 -0
- package/dist/client/providers/CubeProvider.d.ts +28 -8
- package/dist/client/providers.js +3 -3
- package/dist/client/shared/components/CodeBlock.d.ts +10 -0
- package/dist/client/shared/index.d.ts +1 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/utils/chartUtils.d.ts +2 -2
- package/dist/client/utils/filterUtils.d.ts +15 -0
- package/dist/client/utils/index.d.ts +1 -0
- package/dist/client/{components/QueryBuilder → utils}/shareUtils.d.ts +1 -1
- package/dist/client/utils/syntaxHighlighting.d.ts +31 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +16 -16
- package/dist/server/index.d.ts +50 -0
- package/dist/server/index.js +857 -729
- package/package.json +5 -1
- package/dist/adapters/compiler-CMwSRhTS.cjs +0 -22
- package/dist/client/chunks/chart-activitygridchart-CUGN9Xq9.js +0 -2622
- package/dist/client/chunks/chart-activitygridchart-CUGN9Xq9.js.map +0 -1
- package/dist/client/chunks/chart-activitygridchart-config-AVBoHdRn.js +0 -244
- package/dist/client/chunks/chart-activitygridchart-config-AVBoHdRn.js.map +0 -1
- package/dist/client/chunks/chart-areachart-B4tknnsY.js +0 -239
- package/dist/client/chunks/chart-areachart-B4tknnsY.js.map +0 -1
- package/dist/client/chunks/chart-areachart-config-D9pPUKHZ.js +0 -78
- package/dist/client/chunks/chart-areachart-config-D9pPUKHZ.js.map +0 -1
- package/dist/client/chunks/chart-axisformatcontrols-Ch_IYF94.js +0 -196
- package/dist/client/chunks/chart-axisformatcontrols-Ch_IYF94.js.map +0 -1
- package/dist/client/chunks/chart-barchart-D_op06r-.js +0 -216
- package/dist/client/chunks/chart-barchart-D_op06r-.js.map +0 -1
- package/dist/client/chunks/chart-barchart-config-iniz62ni.js +0 -71
- package/dist/client/chunks/chart-barchart-config-iniz62ni.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-BsaIXUbS.js +0 -214
- package/dist/client/chunks/chart-bubblechart-BsaIXUbS.js.map +0 -1
- package/dist/client/chunks/chart-bubblechart-config-yLq2oyR3.js +0 -72
- package/dist/client/chunks/chart-bubblechart-config-yLq2oyR3.js.map +0 -1
- package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js +0 -103
- package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js.map +0 -1
- package/dist/client/chunks/chart-charttooltip-Bx3I8jQv.js +0 -26
- package/dist/client/chunks/chart-charttooltip-Bx3I8jQv.js.map +0 -1
- package/dist/client/chunks/chart-datatable-C7MS9q4Y.js +0 -283
- package/dist/client/chunks/chart-datatable-C7MS9q4Y.js.map +0 -1
- package/dist/client/chunks/chart-datatable-config-DmEA3A-7.js +0 -29
- package/dist/client/chunks/chart-datatable-config-DmEA3A-7.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-7-KOmb3w.js +0 -436
- package/dist/client/chunks/chart-kpidelta-7-KOmb3w.js.map +0 -1
- package/dist/client/chunks/chart-kpidelta-config-DtSDG4Kl.js +0 -98
- package/dist/client/chunks/chart-kpidelta-config-DtSDG4Kl.js.map +0 -1
- package/dist/client/chunks/chart-kpinumber-HOPfcK2N.js +0 -398
- package/dist/client/chunks/chart-kpinumber-HOPfcK2N.js.map +0 -1
- package/dist/client/chunks/chart-kpinumber-config-Da2LFeKM.js +0 -76
- package/dist/client/chunks/chart-kpinumber-config-Da2LFeKM.js.map +0 -1
- package/dist/client/chunks/chart-kpitext-BZkC9u3A.js +0 -165
- package/dist/client/chunks/chart-kpitext-BZkC9u3A.js.map +0 -1
- package/dist/client/chunks/chart-kpitext-config-DjvigyfE.js +0 -48
- package/dist/client/chunks/chart-kpitext-config-DjvigyfE.js.map +0 -1
- package/dist/client/chunks/chart-linechart-DqFmLbRe.js +0 -198
- package/dist/client/chunks/chart-linechart-DqFmLbRe.js.map +0 -1
- package/dist/client/chunks/chart-linechart-config-DLVS2Zxc.js +0 -66
- package/dist/client/chunks/chart-linechart-config-DLVS2Zxc.js.map +0 -1
- package/dist/client/chunks/chart-markdownchart-9n_TemoB.js +0 -256
- package/dist/client/chunks/chart-markdownchart-9n_TemoB.js.map +0 -1
- package/dist/client/chunks/chart-markdownchart-config-CgOA3YSw.js +0 -61
- package/dist/client/chunks/chart-markdownchart-config-CgOA3YSw.js.map +0 -1
- package/dist/client/chunks/chart-piechart-CrXFd9pE.js +0 -127
- package/dist/client/chunks/chart-piechart-CrXFd9pE.js.map +0 -1
- package/dist/client/chunks/chart-piechart-config-DgwOeKHr.js +0 -39
- package/dist/client/chunks/chart-piechart-config-DgwOeKHr.js.map +0 -1
- package/dist/client/chunks/chart-radarchart-config-BAV8D5PR.js +0 -45
- package/dist/client/chunks/chart-radarchart-config-BAV8D5PR.js.map +0 -1
- package/dist/client/chunks/chart-radarchart-tar2GBkO.js +0 -131
- package/dist/client/chunks/chart-radarchart-tar2GBkO.js.map +0 -1
- package/dist/client/chunks/chart-radialbarchart-ab8Swtal.js +0 -120
- package/dist/client/chunks/chart-radialbarchart-ab8Swtal.js.map +0 -1
- package/dist/client/chunks/chart-radialbarchart-config-CKozBBEC.js +0 -38
- package/dist/client/chunks/chart-radialbarchart-config-CKozBBEC.js.map +0 -1
- package/dist/client/chunks/chart-scatterchart-BP06BeU5.js +0 -203
- package/dist/client/chunks/chart-scatterchart-BP06BeU5.js.map +0 -1
- package/dist/client/chunks/chart-scatterchart-config-UdHmbZ3s.js +0 -54
- package/dist/client/chunks/chart-scatterchart-config-UdHmbZ3s.js.map +0 -1
- package/dist/client/chunks/chart-treemapchart-DAiixITm.js +0 -265
- package/dist/client/chunks/chart-treemapchart-DAiixITm.js.map +0 -1
- package/dist/client/chunks/chart-treemapchart-config-D17VOwTM.js +0 -47
- package/dist/client/chunks/chart-treemapchart-config-D17VOwTM.js.map +0 -1
- package/dist/client/chunks/charts-CHzWeaY1.js +0 -286
- package/dist/client/chunks/components-DnM9CCUS.js +0 -13931
- package/dist/client/chunks/components-DnM9CCUS.js.map +0 -1
- package/dist/client/components/QueryBuilder/QueryAnalysisPanel.d.ts +0 -7
- package/dist/client/components/QueryBuilder/QueryPanel.d.ts +0 -4
- package/dist/client/components/QueryBuilder/ResultsPanel.d.ts +0 -4
- package/dist/client/components/QueryBuilder/SetupPanel.d.ts +0 -11
- package/dist/client/components/QueryBuilder/ShareWarningModal.d.ts +0 -9
- package/dist/client/components/QueryBuilder/index.d.ts +0 -3
- /package/dist/client/components/{QueryBuilder → shared}/DateRangeSelector.d.ts +0 -0
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as _, eq as x, and as F, StringChunk as vT, count as
|
|
1
|
+
import { sql as _, eq as x, and as F, StringChunk as vT, count as IE, sum as f, max as q, min as k, countDistinct as QT, SQL as ZT, or as NE, arrayContained as jT, arrayOverlaps as qT, arrayContains as kT, isNotNull as gE, ne as KE, isNull as $E, notInArray as wE, inArray as OE, lt as tE, gt as sE, gte as K, lte as $, desc as zT, asc as JE } from "drizzle-orm";
|
|
2
2
|
class WE {
|
|
3
3
|
/**
|
|
4
4
|
* Default implementation returns template unchanged
|
|
@@ -149,7 +149,7 @@ class Ee extends WE {
|
|
|
149
149
|
return E;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
class
|
|
152
|
+
class mT extends WE {
|
|
153
153
|
getEngineType() {
|
|
154
154
|
return "mysql";
|
|
155
155
|
}
|
|
@@ -431,7 +431,7 @@ class Te extends WE {
|
|
|
431
431
|
return E;
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
|
-
class ee extends
|
|
434
|
+
class ee extends mT {
|
|
435
435
|
getEngineType() {
|
|
436
436
|
return "singlestore";
|
|
437
437
|
}
|
|
@@ -449,7 +449,7 @@ function Re(e) {
|
|
|
449
449
|
case "postgres":
|
|
450
450
|
return new Ee();
|
|
451
451
|
case "mysql":
|
|
452
|
-
return new
|
|
452
|
+
return new mT();
|
|
453
453
|
case "sqlite":
|
|
454
454
|
return new Te();
|
|
455
455
|
case "singlestore":
|
|
@@ -520,7 +520,7 @@ class Ae extends bE {
|
|
|
520
520
|
function xE(e, E) {
|
|
521
521
|
return new Ae(e, E, "postgres");
|
|
522
522
|
}
|
|
523
|
-
class
|
|
523
|
+
class BT extends bE {
|
|
524
524
|
async execute(E, T) {
|
|
525
525
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
526
526
|
const A = await E.execute();
|
|
@@ -559,7 +559,7 @@ class mT extends bE {
|
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
561
|
function Se(e, E) {
|
|
562
|
-
return new
|
|
562
|
+
return new BT(e, E, "mysql");
|
|
563
563
|
}
|
|
564
564
|
class Ie extends bE {
|
|
565
565
|
async execute(E, T) {
|
|
@@ -610,7 +610,7 @@ class Ie extends bE {
|
|
|
610
610
|
function vE(e, E) {
|
|
611
611
|
return new Ie(e, E, "sqlite");
|
|
612
612
|
}
|
|
613
|
-
class
|
|
613
|
+
class Ne extends BT {
|
|
614
614
|
getEngineType() {
|
|
615
615
|
return "singlestore";
|
|
616
616
|
}
|
|
@@ -618,8 +618,8 @@ class Oe extends mT {
|
|
|
618
618
|
// For now, we inherit all behavior from MySQLExecutor since
|
|
619
619
|
// SingleStore is largely MySQL-compatible
|
|
620
620
|
}
|
|
621
|
-
function
|
|
622
|
-
return new
|
|
621
|
+
function Oe(e, E) {
|
|
622
|
+
return new Ne(e, E);
|
|
623
623
|
}
|
|
624
624
|
function QE(e, E, T) {
|
|
625
625
|
if (T)
|
|
@@ -631,7 +631,7 @@ function QE(e, E, T) {
|
|
|
631
631
|
case "sqlite":
|
|
632
632
|
return vE(e, E);
|
|
633
633
|
case "singlestore":
|
|
634
|
-
return
|
|
634
|
+
return Oe(e, E);
|
|
635
635
|
}
|
|
636
636
|
if (e.all && e.run)
|
|
637
637
|
return vE(e, E);
|
|
@@ -639,7 +639,7 @@ function QE(e, E, T) {
|
|
|
639
639
|
return xE(e, E);
|
|
640
640
|
throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function j(e) {
|
|
643
643
|
return typeof e == "function" ? e() : e;
|
|
644
644
|
}
|
|
645
645
|
function fE(e, E) {
|
|
@@ -668,14 +668,14 @@ function b(e, E) {
|
|
|
668
668
|
const T = typeof e == "function" ? e(E) : e;
|
|
669
669
|
return te(T);
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function tN(e, E, T) {
|
|
672
672
|
return {
|
|
673
673
|
...e,
|
|
674
674
|
cubes: E,
|
|
675
675
|
currentCube: T
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function sN(e, E) {
|
|
679
679
|
return {
|
|
680
680
|
name: e,
|
|
681
681
|
...E
|
|
@@ -685,30 +685,30 @@ function se(e, E) {
|
|
|
685
685
|
if (e.relationship !== "belongsToMany" || !e.through)
|
|
686
686
|
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
687
687
|
const { table: T, sourceKey: R, targetKey: A, securitySql: S } = e.through, I = [];
|
|
688
|
-
for (const
|
|
689
|
-
const C =
|
|
690
|
-
I.push(C(
|
|
688
|
+
for (const O of R) {
|
|
689
|
+
const C = O.as || x;
|
|
690
|
+
I.push(C(O.source, O.target));
|
|
691
691
|
}
|
|
692
692
|
const t = [];
|
|
693
|
-
for (const
|
|
694
|
-
const C =
|
|
695
|
-
t.push(C(
|
|
693
|
+
for (const O of A) {
|
|
694
|
+
const C = O.as || x;
|
|
695
|
+
t.push(C(O.source, O.target));
|
|
696
696
|
}
|
|
697
697
|
let s;
|
|
698
698
|
if (S) {
|
|
699
|
-
const
|
|
700
|
-
s = Array.isArray(
|
|
699
|
+
const O = S(E);
|
|
700
|
+
s = Array.isArray(O) ? O : [O];
|
|
701
701
|
}
|
|
702
|
-
const
|
|
702
|
+
const N = fE("belongsToMany", e.sqlJoinType);
|
|
703
703
|
return {
|
|
704
704
|
junctionJoins: [
|
|
705
705
|
{
|
|
706
|
-
joinType:
|
|
706
|
+
joinType: N,
|
|
707
707
|
table: T,
|
|
708
708
|
condition: F(...I)
|
|
709
709
|
},
|
|
710
710
|
{
|
|
711
|
-
joinType:
|
|
711
|
+
joinType: N,
|
|
712
712
|
table: T,
|
|
713
713
|
// This will be replaced with target cube table in query planner
|
|
714
714
|
condition: F(...t)
|
|
@@ -760,8 +760,8 @@ class X {
|
|
|
760
760
|
if (R.type === "calculated" && R.calculatedSql) {
|
|
761
761
|
const A = `${E.name}.${T}`, S = this.extractDependencies(R.calculatedSql), I = /* @__PURE__ */ new Set();
|
|
762
762
|
for (const t of S) {
|
|
763
|
-
const
|
|
764
|
-
I.add(
|
|
763
|
+
const N = `${t.cubeName || E.name}.${t.fieldName}`;
|
|
764
|
+
I.add(N);
|
|
765
765
|
}
|
|
766
766
|
this.dependencyGraph.set(A, {
|
|
767
767
|
id: A,
|
|
@@ -940,7 +940,7 @@ class X {
|
|
|
940
940
|
function Ce(e, E) {
|
|
941
941
|
const { cube: T, allCubes: R, resolvedMeasures: A } = E, S = XE(e), I = /* @__PURE__ */ new Map();
|
|
942
942
|
for (const C of S) {
|
|
943
|
-
const { originalRef: n, cubeName:
|
|
943
|
+
const { originalRef: n, cubeName: r, fieldName: i } = C, a = r || T.name;
|
|
944
944
|
if (!R.get(a))
|
|
945
945
|
throw new Error(
|
|
946
946
|
`Cannot substitute {${n}}: cube '${a}' not found`
|
|
@@ -954,21 +954,21 @@ function Ce(e, E) {
|
|
|
954
954
|
I.set(n, G);
|
|
955
955
|
}
|
|
956
956
|
const t = [], s = [];
|
|
957
|
-
let
|
|
957
|
+
let N = 0;
|
|
958
958
|
for (const C of S) {
|
|
959
|
-
const n = `{${C.originalRef}}`,
|
|
960
|
-
if (
|
|
961
|
-
t.push(e.substring(
|
|
959
|
+
const n = `{${C.originalRef}}`, r = e.indexOf(n, N);
|
|
960
|
+
if (r >= 0) {
|
|
961
|
+
t.push(e.substring(N, r));
|
|
962
962
|
const i = I.get(C.originalRef);
|
|
963
|
-
i && s.push(i),
|
|
963
|
+
i && s.push(i), N = r + n.length;
|
|
964
964
|
}
|
|
965
965
|
}
|
|
966
|
-
if (t.push(e.substring(
|
|
966
|
+
if (t.push(e.substring(N)), s.length === 0)
|
|
967
967
|
return _.raw(e);
|
|
968
|
-
const
|
|
968
|
+
const O = [];
|
|
969
969
|
for (let C = 0; C < t.length; C++)
|
|
970
|
-
t[C] &&
|
|
971
|
-
return _.join(
|
|
970
|
+
t[C] && O.push(new vT(t[C])), C < s.length && O.push(s[C]);
|
|
971
|
+
return _.join(O, _.raw(""));
|
|
972
972
|
}
|
|
973
973
|
function XE(e) {
|
|
974
974
|
const E = /\{([^}]+)\}/g, T = e.matchAll(E), R = [];
|
|
@@ -990,7 +990,7 @@ function XE(e) {
|
|
|
990
990
|
}
|
|
991
991
|
return R;
|
|
992
992
|
}
|
|
993
|
-
function
|
|
993
|
+
function ne(e) {
|
|
994
994
|
const E = [];
|
|
995
995
|
let T = 0;
|
|
996
996
|
for (let I = 0; I < e.length; I++)
|
|
@@ -1023,7 +1023,7 @@ function CE(e, E) {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
return Array.from(R);
|
|
1025
1025
|
}
|
|
1026
|
-
class
|
|
1026
|
+
class re {
|
|
1027
1027
|
constructor(E) {
|
|
1028
1028
|
this.databaseAdapter = E;
|
|
1029
1029
|
}
|
|
@@ -1039,41 +1039,41 @@ class ne {
|
|
|
1039
1039
|
* @returns Map of measure names to SQL builder functions
|
|
1040
1040
|
*/
|
|
1041
1041
|
buildResolvedMeasures(E, T, R, A) {
|
|
1042
|
-
const S = /* @__PURE__ */ new Map(), I = [], t = [], s = new Set(E),
|
|
1043
|
-
for (const
|
|
1044
|
-
|
|
1045
|
-
for (const
|
|
1046
|
-
const [C, n] =
|
|
1047
|
-
if (
|
|
1048
|
-
const i =
|
|
1049
|
-
X.isCalculatedMeasure(i) ? (t.push(
|
|
1042
|
+
const S = /* @__PURE__ */ new Map(), I = [], t = [], s = new Set(E), N = new X(T);
|
|
1043
|
+
for (const O of T.values())
|
|
1044
|
+
N.buildGraph(O);
|
|
1045
|
+
for (const O of E) {
|
|
1046
|
+
const [C, n] = O.split("."), r = T.get(C);
|
|
1047
|
+
if (r && r.measures && r.measures[n]) {
|
|
1048
|
+
const i = r.measures[n];
|
|
1049
|
+
X.isCalculatedMeasure(i) ? (t.push(O), CE(i.calculatedSql, C).forEach((P) => s.add(P)), N.getAllDependencies(O).forEach((P) => {
|
|
1050
1050
|
const [U, M] = P.split("."), G = T.get(U);
|
|
1051
1051
|
if (G && G.measures[M]) {
|
|
1052
1052
|
const H = G.measures[M];
|
|
1053
1053
|
X.isCalculatedMeasure(H) && CE(H.calculatedSql, U).forEach((Y) => s.add(Y));
|
|
1054
1054
|
}
|
|
1055
|
-
})) : I.push(
|
|
1055
|
+
})) : I.push(O);
|
|
1056
1056
|
}
|
|
1057
1057
|
}
|
|
1058
|
-
for (const
|
|
1059
|
-
const [C, n] =
|
|
1060
|
-
if (
|
|
1061
|
-
const i =
|
|
1062
|
-
X.isCalculatedMeasure(i) ? t.includes(
|
|
1058
|
+
for (const O of s) {
|
|
1059
|
+
const [C, n] = O.split("."), r = T.get(C);
|
|
1060
|
+
if (r && r.measures && r.measures[n]) {
|
|
1061
|
+
const i = r.measures[n];
|
|
1062
|
+
X.isCalculatedMeasure(i) ? t.includes(O) || t.push(O) : I.includes(O) || I.push(O);
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
for (const
|
|
1066
|
-
const [C, n] =
|
|
1065
|
+
for (const O of I) {
|
|
1066
|
+
const [C, n] = O.split("."), r = T.get(C), i = r.measures[n];
|
|
1067
1067
|
if (A) {
|
|
1068
|
-
const a = A(
|
|
1069
|
-
S.set(
|
|
1068
|
+
const a = A(O, i, r);
|
|
1069
|
+
S.set(O, () => a);
|
|
1070
1070
|
} else
|
|
1071
|
-
S.set(
|
|
1071
|
+
S.set(O, () => this.buildMeasureExpression(i, R));
|
|
1072
1072
|
}
|
|
1073
1073
|
if (t.length > 0) {
|
|
1074
|
-
const
|
|
1075
|
-
for (const C of
|
|
1076
|
-
const [n,
|
|
1074
|
+
const O = N.topologicalSort(t);
|
|
1075
|
+
for (const C of O) {
|
|
1076
|
+
const [n, r] = C.split("."), i = T.get(n), a = i.measures[r];
|
|
1077
1077
|
S.set(C, () => this.buildCalculatedMeasure(
|
|
1078
1078
|
a,
|
|
1079
1079
|
i,
|
|
@@ -1094,9 +1094,9 @@ class ne {
|
|
|
1094
1094
|
const A = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1095
1095
|
if (T.dimensions)
|
|
1096
1096
|
for (const I of T.dimensions) {
|
|
1097
|
-
const [t, s] = I.split("."),
|
|
1098
|
-
if (
|
|
1099
|
-
const
|
|
1097
|
+
const [t, s] = I.split("."), N = S.get(t);
|
|
1098
|
+
if (N && N.dimensions && N.dimensions[s]) {
|
|
1099
|
+
const O = N.dimensions[s], C = b(O.sql, R);
|
|
1100
1100
|
A[I] = _`${C}`.as(I);
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
@@ -1109,24 +1109,24 @@ class ne {
|
|
|
1109
1109
|
for (const t of T.measures) {
|
|
1110
1110
|
const s = I.get(t);
|
|
1111
1111
|
if (s) {
|
|
1112
|
-
const
|
|
1113
|
-
A[t] = _`${
|
|
1112
|
+
const N = s();
|
|
1113
|
+
A[t] = _`${N}`.as(t);
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
if (T.timeDimensions)
|
|
1118
1118
|
for (const I of T.timeDimensions) {
|
|
1119
|
-
const [t, s] = I.dimension.split("."),
|
|
1120
|
-
if (
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1119
|
+
const [t, s] = I.dimension.split("."), N = S.get(t);
|
|
1120
|
+
if (N && N.dimensions && N.dimensions[s]) {
|
|
1121
|
+
const O = N.dimensions[s], C = this.buildTimeDimensionExpression(
|
|
1122
|
+
O.sql,
|
|
1123
1123
|
I.granularity,
|
|
1124
1124
|
R
|
|
1125
1125
|
);
|
|
1126
1126
|
A[I.dimension] = _`${C}`.as(I.dimension);
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
|
-
return Object.keys(A).length === 0 && (A.count =
|
|
1129
|
+
return Object.keys(A).length === 0 && (A.count = IE()), A;
|
|
1130
1130
|
}
|
|
1131
1131
|
/**
|
|
1132
1132
|
* Build calculated measure expression by substituting {member} references
|
|
@@ -1165,32 +1165,32 @@ class ne {
|
|
|
1165
1165
|
);
|
|
1166
1166
|
const I = /* @__PURE__ */ new Map(), t = CE(E.calculatedSql, T.name);
|
|
1167
1167
|
for (const s of t) {
|
|
1168
|
-
const [
|
|
1169
|
-
if (C && C.measures[
|
|
1170
|
-
const n = C.measures[
|
|
1168
|
+
const [N, O] = s.split("."), C = A.get(N);
|
|
1169
|
+
if (C && C.measures[O]) {
|
|
1170
|
+
const n = C.measures[O];
|
|
1171
1171
|
if (R.measures.includes(s)) {
|
|
1172
|
-
const
|
|
1172
|
+
const r = _`${_.identifier(R.cteAlias)}.${_.identifier(O)}`;
|
|
1173
1173
|
let i;
|
|
1174
1174
|
switch (n.type) {
|
|
1175
1175
|
case "count":
|
|
1176
1176
|
case "countDistinct":
|
|
1177
1177
|
case "sum":
|
|
1178
|
-
i = f(
|
|
1178
|
+
i = f(r);
|
|
1179
1179
|
break;
|
|
1180
1180
|
case "avg":
|
|
1181
|
-
i = this.databaseAdapter.buildAvg(
|
|
1181
|
+
i = this.databaseAdapter.buildAvg(r);
|
|
1182
1182
|
break;
|
|
1183
1183
|
case "min":
|
|
1184
|
-
i =
|
|
1184
|
+
i = k(r);
|
|
1185
1185
|
break;
|
|
1186
1186
|
case "max":
|
|
1187
|
-
i =
|
|
1187
|
+
i = q(r);
|
|
1188
1188
|
break;
|
|
1189
1189
|
case "number":
|
|
1190
|
-
i = f(
|
|
1190
|
+
i = f(r);
|
|
1191
1191
|
break;
|
|
1192
1192
|
default:
|
|
1193
|
-
i = f(
|
|
1193
|
+
i = f(r);
|
|
1194
1194
|
}
|
|
1195
1195
|
I.set(s, () => i);
|
|
1196
1196
|
}
|
|
@@ -1212,13 +1212,13 @@ class ne {
|
|
|
1212
1212
|
const I = S.preAggregationCTEs.find((t) => t.cube.name === E);
|
|
1213
1213
|
if (I && I.measures.includes(`${E}.${T}`))
|
|
1214
1214
|
if (R.type === "calculated" && R.calculatedSql) {
|
|
1215
|
-
const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((
|
|
1215
|
+
const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((N) => N.cube.name === E)?.cube;
|
|
1216
1216
|
if (!t)
|
|
1217
1217
|
throw new Error(`Cube ${E} not found in query plan`);
|
|
1218
1218
|
const s = /* @__PURE__ */ new Map([[S.primaryCube.name, S.primaryCube]]);
|
|
1219
1219
|
if (S.joinCubes)
|
|
1220
|
-
for (const
|
|
1221
|
-
s.set(
|
|
1220
|
+
for (const N of S.joinCubes)
|
|
1221
|
+
s.set(N.cube.name, N.cube);
|
|
1222
1222
|
return this.buildCTECalculatedMeasure(
|
|
1223
1223
|
R,
|
|
1224
1224
|
t,
|
|
@@ -1236,9 +1236,9 @@ class ne {
|
|
|
1236
1236
|
case "avg":
|
|
1237
1237
|
return this.databaseAdapter.buildAvg(t);
|
|
1238
1238
|
case "min":
|
|
1239
|
-
return
|
|
1239
|
+
return k(t);
|
|
1240
1240
|
case "max":
|
|
1241
|
-
return
|
|
1241
|
+
return q(t);
|
|
1242
1242
|
case "number":
|
|
1243
1243
|
return f(t);
|
|
1244
1244
|
default:
|
|
@@ -1276,7 +1276,7 @@ class ne {
|
|
|
1276
1276
|
}
|
|
1277
1277
|
switch (E.type) {
|
|
1278
1278
|
case "count":
|
|
1279
|
-
return
|
|
1279
|
+
return IE(R);
|
|
1280
1280
|
case "countDistinct":
|
|
1281
1281
|
return QT(R);
|
|
1282
1282
|
case "sum":
|
|
@@ -1284,13 +1284,13 @@ class ne {
|
|
|
1284
1284
|
case "avg":
|
|
1285
1285
|
return this.databaseAdapter.buildAvg(R);
|
|
1286
1286
|
case "min":
|
|
1287
|
-
return
|
|
1287
|
+
return k(R);
|
|
1288
1288
|
case "max":
|
|
1289
|
-
return
|
|
1289
|
+
return q(R);
|
|
1290
1290
|
case "number":
|
|
1291
1291
|
return R;
|
|
1292
1292
|
default:
|
|
1293
|
-
return
|
|
1293
|
+
return IE(R);
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
1296
|
/**
|
|
@@ -1313,12 +1313,12 @@ class ne {
|
|
|
1313
1313
|
}
|
|
1314
1314
|
if (T.timeDimensions)
|
|
1315
1315
|
for (const t of T.timeDimensions) {
|
|
1316
|
-
const [s,
|
|
1317
|
-
if (
|
|
1316
|
+
const [s, N] = t.dimension.split("."), O = I.get(s);
|
|
1317
|
+
if (O && O.dimensions[N] && t.dateRange) {
|
|
1318
1318
|
if (A?.preAggregationCTEs && A.preAggregationCTEs.some((a) => a.cube.name === s))
|
|
1319
1319
|
continue;
|
|
1320
|
-
const C =
|
|
1321
|
-
|
|
1320
|
+
const C = O.dimensions[N], n = b(C.sql, R), r = this.buildDateRangeCondition(n, t.dateRange);
|
|
1321
|
+
r && S.push(r);
|
|
1322
1322
|
}
|
|
1323
1323
|
}
|
|
1324
1324
|
return S;
|
|
@@ -1342,24 +1342,24 @@ class ne {
|
|
|
1342
1342
|
*/
|
|
1343
1343
|
processFilter(E, T, R, A, S) {
|
|
1344
1344
|
if ("and" in E || "or" in E) {
|
|
1345
|
-
const
|
|
1346
|
-
if (
|
|
1347
|
-
const i =
|
|
1345
|
+
const r = E;
|
|
1346
|
+
if (r.and) {
|
|
1347
|
+
const i = r.and.map((a) => this.processFilter(a, T, R, A, S)).filter((a) => a !== null);
|
|
1348
1348
|
return i.length > 0 ? F(...i) : null;
|
|
1349
1349
|
}
|
|
1350
|
-
if (
|
|
1351
|
-
const i =
|
|
1352
|
-
return i.length > 0 ?
|
|
1350
|
+
if (r.or) {
|
|
1351
|
+
const i = r.or.map((a) => this.processFilter(a, T, R, A, S)).filter((a) => a !== null);
|
|
1352
|
+
return i.length > 0 ? NE(...i) : null;
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
|
-
const I = E, [t, s] = I.member.split("."),
|
|
1356
|
-
if (!
|
|
1357
|
-
const
|
|
1355
|
+
const I = E, [t, s] = I.member.split("."), N = T.get(t);
|
|
1356
|
+
if (!N) return null;
|
|
1357
|
+
const O = N.dimensions[s], C = N.measures[s], n = O || C;
|
|
1358
1358
|
if (!n) return null;
|
|
1359
|
-
if (A === "where" &&
|
|
1359
|
+
if (A === "where" && O) {
|
|
1360
1360
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((l) => l.cube.name === t))
|
|
1361
1361
|
return null;
|
|
1362
|
-
const i = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(I.operator) ? typeof
|
|
1362
|
+
const i = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(I.operator) ? typeof O.sql == "function" ? O.sql(R) : O.sql : b(O.sql, R);
|
|
1363
1363
|
return this.buildFilterCondition(
|
|
1364
1364
|
i,
|
|
1365
1365
|
I.operator,
|
|
@@ -1371,9 +1371,9 @@ class ne {
|
|
|
1371
1371
|
if (A === "where" && C)
|
|
1372
1372
|
return null;
|
|
1373
1373
|
if (A === "having" && C) {
|
|
1374
|
-
const
|
|
1374
|
+
const r = this.buildHavingMeasureExpression(t, s, C, R, S);
|
|
1375
1375
|
return this.buildFilterCondition(
|
|
1376
|
-
|
|
1376
|
+
r,
|
|
1377
1377
|
I.operator,
|
|
1378
1378
|
I.values,
|
|
1379
1379
|
n,
|
|
@@ -1408,7 +1408,7 @@ class ne {
|
|
|
1408
1408
|
case "equals":
|
|
1409
1409
|
if (I.length > 1) {
|
|
1410
1410
|
if (A?.type === "time") {
|
|
1411
|
-
const s = I.map((
|
|
1411
|
+
const s = I.map((N) => this.normalizeDate(N) || N);
|
|
1412
1412
|
return OE(E, s);
|
|
1413
1413
|
}
|
|
1414
1414
|
return OE(E, I);
|
|
@@ -1428,11 +1428,11 @@ class ne {
|
|
|
1428
1428
|
case "endsWith":
|
|
1429
1429
|
return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
|
|
1430
1430
|
case "gt":
|
|
1431
|
-
return
|
|
1431
|
+
return sE(E, t);
|
|
1432
1432
|
case "gte":
|
|
1433
1433
|
return K(E, t);
|
|
1434
1434
|
case "lt":
|
|
1435
|
-
return
|
|
1435
|
+
return tE(E, t);
|
|
1436
1436
|
case "lte":
|
|
1437
1437
|
return $(E, t);
|
|
1438
1438
|
case "set":
|
|
@@ -1442,27 +1442,27 @@ class ne {
|
|
|
1442
1442
|
case "inDateRange":
|
|
1443
1443
|
if (I.length >= 2) {
|
|
1444
1444
|
const s = this.normalizeDate(I[0]);
|
|
1445
|
-
let
|
|
1446
|
-
if (s &&
|
|
1447
|
-
const
|
|
1448
|
-
if (typeof
|
|
1449
|
-
const C = typeof
|
|
1450
|
-
n.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ?
|
|
1445
|
+
let N = this.normalizeDate(I[1]);
|
|
1446
|
+
if (s && N) {
|
|
1447
|
+
const O = R[1];
|
|
1448
|
+
if (typeof O == "string" && /^\d{4}-\d{2}-\d{2}$/.test(O.trim())) {
|
|
1449
|
+
const C = typeof N == "number" ? new Date(N * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(N), n = new Date(C);
|
|
1450
|
+
n.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? N = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(n.getTime() / 1e3) : n.getTime() : N = n.toISOString();
|
|
1451
1451
|
}
|
|
1452
1452
|
return F(
|
|
1453
1453
|
K(E, s),
|
|
1454
|
-
$(E,
|
|
1454
|
+
$(E, N)
|
|
1455
1455
|
);
|
|
1456
1456
|
}
|
|
1457
1457
|
}
|
|
1458
1458
|
return null;
|
|
1459
1459
|
case "beforeDate": {
|
|
1460
1460
|
const s = this.normalizeDate(t);
|
|
1461
|
-
return s ?
|
|
1461
|
+
return s ? tE(E, s) : null;
|
|
1462
1462
|
}
|
|
1463
1463
|
case "afterDate": {
|
|
1464
1464
|
const s = this.normalizeDate(t);
|
|
1465
|
-
return s ?
|
|
1465
|
+
return s ? sE(E, s) : null;
|
|
1466
1466
|
}
|
|
1467
1467
|
case "between":
|
|
1468
1468
|
return I.length >= 2 ? F(
|
|
@@ -1470,9 +1470,9 @@ class ne {
|
|
|
1470
1470
|
$(E, I[1])
|
|
1471
1471
|
) : null;
|
|
1472
1472
|
case "notBetween":
|
|
1473
|
-
return I.length >= 2 ?
|
|
1474
|
-
|
|
1475
|
-
|
|
1473
|
+
return I.length >= 2 ? NE(
|
|
1474
|
+
tE(E, I[0]),
|
|
1475
|
+
sE(E, I[1])
|
|
1476
1476
|
) : null;
|
|
1477
1477
|
case "in":
|
|
1478
1478
|
return I.length > 0 ? OE(E, I) : null;
|
|
@@ -1489,7 +1489,7 @@ class ne {
|
|
|
1489
1489
|
case "notRegex":
|
|
1490
1490
|
return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
|
|
1491
1491
|
case "isEmpty":
|
|
1492
|
-
return
|
|
1492
|
+
return NE(
|
|
1493
1493
|
$E(E),
|
|
1494
1494
|
x(E, "")
|
|
1495
1495
|
);
|
|
@@ -1531,9 +1531,9 @@ class ne {
|
|
|
1531
1531
|
if (typeof T == "string") {
|
|
1532
1532
|
const R = this.parseRelativeDateRange(T);
|
|
1533
1533
|
if (R) {
|
|
1534
|
-
let
|
|
1535
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (
|
|
1536
|
-
K(E,
|
|
1534
|
+
let O, C;
|
|
1535
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (O = Math.floor(R.start.getTime() / 1e3), C = Math.floor(R.end.getTime() / 1e3)) : (O = R.start.getTime(), C = R.end.getTime()) : (O = R.start.toISOString(), C = R.end.toISOString()), F(
|
|
1536
|
+
K(E, O),
|
|
1537
1537
|
$(E, C)
|
|
1538
1538
|
);
|
|
1539
1539
|
}
|
|
@@ -1543,10 +1543,10 @@ class ne {
|
|
|
1543
1543
|
I.setUTCHours(0, 0, 0, 0);
|
|
1544
1544
|
const t = new Date(S);
|
|
1545
1545
|
t.setUTCHours(23, 59, 59, 999);
|
|
1546
|
-
let s,
|
|
1547
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(I.getTime() / 1e3),
|
|
1546
|
+
let s, N;
|
|
1547
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(I.getTime() / 1e3), N = Math.floor(t.getTime() / 1e3)) : (s = I.getTime(), N = t.getTime()) : (s = I.toISOString(), N = t.toISOString()), F(
|
|
1548
1548
|
K(E, s),
|
|
1549
|
-
$(E,
|
|
1549
|
+
$(E, N)
|
|
1550
1550
|
);
|
|
1551
1551
|
}
|
|
1552
1552
|
return null;
|
|
@@ -1560,78 +1560,78 @@ class ne {
|
|
|
1560
1560
|
if (R === "today") {
|
|
1561
1561
|
const n = new Date(T);
|
|
1562
1562
|
n.setUTCHours(0, 0, 0, 0);
|
|
1563
|
-
const
|
|
1564
|
-
return
|
|
1563
|
+
const r = new Date(T);
|
|
1564
|
+
return r.setUTCHours(23, 59, 59, 999), { start: n, end: r };
|
|
1565
1565
|
}
|
|
1566
1566
|
if (R === "yesterday") {
|
|
1567
1567
|
const n = new Date(T);
|
|
1568
1568
|
n.setUTCDate(I - 1), n.setUTCHours(0, 0, 0, 0);
|
|
1569
|
-
const
|
|
1570
|
-
return
|
|
1569
|
+
const r = new Date(T);
|
|
1570
|
+
return r.setUTCDate(I - 1), r.setUTCHours(23, 59, 59, 999), { start: n, end: r };
|
|
1571
1571
|
}
|
|
1572
1572
|
if (R === "this week") {
|
|
1573
|
-
const n = t === 0 ? -6 : 1 - t,
|
|
1574
|
-
|
|
1575
|
-
const i = new Date(
|
|
1576
|
-
return i.setUTCDate(
|
|
1573
|
+
const n = t === 0 ? -6 : 1 - t, r = new Date(T);
|
|
1574
|
+
r.setUTCDate(I + n), r.setUTCHours(0, 0, 0, 0);
|
|
1575
|
+
const i = new Date(r);
|
|
1576
|
+
return i.setUTCDate(r.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: r, end: i };
|
|
1577
1577
|
}
|
|
1578
1578
|
if (R === "this month") {
|
|
1579
|
-
const n = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)),
|
|
1580
|
-
return { start: n, end:
|
|
1579
|
+
const n = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, S + 1, 0, 23, 59, 59, 999));
|
|
1580
|
+
return { start: n, end: r };
|
|
1581
1581
|
}
|
|
1582
1582
|
if (R === "this quarter") {
|
|
1583
|
-
const n = Math.floor(S / 3),
|
|
1584
|
-
return { start:
|
|
1583
|
+
const n = Math.floor(S / 3), r = new Date(Date.UTC(A, n * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(A, n * 3 + 3, 0, 23, 59, 59, 999));
|
|
1584
|
+
return { start: r, end: i };
|
|
1585
1585
|
}
|
|
1586
1586
|
if (R === "this year") {
|
|
1587
|
-
const n = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)),
|
|
1588
|
-
return { start: n, end:
|
|
1587
|
+
const n = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, 11, 31, 23, 59, 59, 999));
|
|
1588
|
+
return { start: n, end: r };
|
|
1589
1589
|
}
|
|
1590
1590
|
const s = R.match(/^last\s+(\d+)\s+days?$/);
|
|
1591
1591
|
if (s) {
|
|
1592
|
-
const n = parseInt(s[1], 10),
|
|
1593
|
-
|
|
1592
|
+
const n = parseInt(s[1], 10), r = new Date(T);
|
|
1593
|
+
r.setUTCDate(I - n + 1), r.setUTCHours(0, 0, 0, 0);
|
|
1594
1594
|
const i = new Date(T);
|
|
1595
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1595
|
+
return i.setUTCHours(23, 59, 59, 999), { start: r, end: i };
|
|
1596
1596
|
}
|
|
1597
|
-
const
|
|
1598
|
-
if (
|
|
1599
|
-
const
|
|
1600
|
-
i.setUTCDate(I -
|
|
1597
|
+
const N = R.match(/^last\s+(\d+)\s+weeks?$/);
|
|
1598
|
+
if (N) {
|
|
1599
|
+
const r = parseInt(N[1], 10) * 7, i = new Date(T);
|
|
1600
|
+
i.setUTCDate(I - r + 1), i.setUTCHours(0, 0, 0, 0);
|
|
1601
1601
|
const a = new Date(T);
|
|
1602
1602
|
return a.setUTCHours(23, 59, 59, 999), { start: i, end: a };
|
|
1603
1603
|
}
|
|
1604
1604
|
if (R === "last week") {
|
|
1605
|
-
const n = t === 0 ? -13 : -6 - t,
|
|
1606
|
-
|
|
1607
|
-
const i = new Date(
|
|
1608
|
-
return i.setUTCDate(
|
|
1605
|
+
const n = t === 0 ? -13 : -6 - t, r = new Date(T);
|
|
1606
|
+
r.setUTCDate(I + n), r.setUTCHours(0, 0, 0, 0);
|
|
1607
|
+
const i = new Date(r);
|
|
1608
|
+
return i.setUTCDate(r.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: r, end: i };
|
|
1609
1609
|
}
|
|
1610
1610
|
if (R === "last month") {
|
|
1611
|
-
const n = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)),
|
|
1612
|
-
return { start: n, end:
|
|
1611
|
+
const n = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, S, 0, 23, 59, 59, 999));
|
|
1612
|
+
return { start: n, end: r };
|
|
1613
1613
|
}
|
|
1614
1614
|
if (R === "last quarter") {
|
|
1615
|
-
const n = Math.floor(S / 3),
|
|
1615
|
+
const n = Math.floor(S / 3), r = n === 0 ? 3 : n - 1, i = n === 0 ? A - 1 : A, a = new Date(Date.UTC(i, r * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, r * 3 + 3, 0, 23, 59, 59, 999));
|
|
1616
1616
|
return { start: a, end: l };
|
|
1617
1617
|
}
|
|
1618
1618
|
if (R === "last year") {
|
|
1619
|
-
const n = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)),
|
|
1620
|
-
return { start: n, end:
|
|
1619
|
+
const n = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A - 1, 11, 31, 23, 59, 59, 999));
|
|
1620
|
+
return { start: n, end: r };
|
|
1621
1621
|
}
|
|
1622
1622
|
if (R === "last 12 months") {
|
|
1623
|
-
const n = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)),
|
|
1624
|
-
return
|
|
1623
|
+
const n = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)), r = new Date(T);
|
|
1624
|
+
return r.setUTCHours(23, 59, 59, 999), { start: n, end: r };
|
|
1625
1625
|
}
|
|
1626
|
-
const
|
|
1627
|
-
if (
|
|
1628
|
-
const n = parseInt(
|
|
1629
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1626
|
+
const O = R.match(/^last\s+(\d+)\s+months?$/);
|
|
1627
|
+
if (O) {
|
|
1628
|
+
const n = parseInt(O[1], 10), r = new Date(Date.UTC(A, S - n + 1, 1, 0, 0, 0, 0)), i = new Date(T);
|
|
1629
|
+
return i.setUTCHours(23, 59, 59, 999), { start: r, end: i };
|
|
1630
1630
|
}
|
|
1631
1631
|
const C = R.match(/^last\s+(\d+)\s+years?$/);
|
|
1632
1632
|
if (C) {
|
|
1633
|
-
const n = parseInt(C[1], 10),
|
|
1634
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1633
|
+
const n = parseInt(C[1], 10), r = new Date(Date.UTC(A - n, 0, 1, 0, 0, 0, 0)), i = new Date(T);
|
|
1634
|
+
return i.setUTCHours(23, 59, 59, 999), { start: r, end: i };
|
|
1635
1635
|
}
|
|
1636
1636
|
return null;
|
|
1637
1637
|
}
|
|
@@ -1670,27 +1670,27 @@ class ne {
|
|
|
1670
1670
|
const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1671
1671
|
if (T.dimensions)
|
|
1672
1672
|
for (const s of T.dimensions) {
|
|
1673
|
-
const [
|
|
1674
|
-
if (C && C.dimensions && C.dimensions[
|
|
1675
|
-
if (A?.preAggregationCTEs?.some((
|
|
1676
|
-
const
|
|
1673
|
+
const [N, O] = s.split("."), C = t.get(N);
|
|
1674
|
+
if (C && C.dimensions && C.dimensions[O])
|
|
1675
|
+
if (A?.preAggregationCTEs?.some((r) => r.cube.name === N)) {
|
|
1676
|
+
const r = A.preAggregationCTEs.find((a) => a.cube.name === N), i = r.joinKeys.find((a) => a.targetColumn === O);
|
|
1677
1677
|
if (i && i.sourceColumnObj)
|
|
1678
1678
|
S.push(i.sourceColumnObj);
|
|
1679
1679
|
else {
|
|
1680
|
-
const a = _`${_.identifier(
|
|
1680
|
+
const a = _`${_.identifier(r.cteAlias)}.${_.identifier(O)}`;
|
|
1681
1681
|
S.push(a);
|
|
1682
1682
|
}
|
|
1683
1683
|
} else {
|
|
1684
|
-
const
|
|
1684
|
+
const r = C.dimensions[O], i = b(r.sql, R);
|
|
1685
1685
|
S.push(i);
|
|
1686
1686
|
}
|
|
1687
1687
|
}
|
|
1688
1688
|
if (T.timeDimensions)
|
|
1689
1689
|
for (const s of T.timeDimensions) {
|
|
1690
|
-
const [
|
|
1691
|
-
if (C && C.dimensions && C.dimensions[
|
|
1692
|
-
if (A?.preAggregationCTEs?.some((
|
|
1693
|
-
const
|
|
1690
|
+
const [N, O] = s.dimension.split("."), C = t.get(N);
|
|
1691
|
+
if (C && C.dimensions && C.dimensions[O])
|
|
1692
|
+
if (A?.preAggregationCTEs?.some((r) => r.cube.name === N)) {
|
|
1693
|
+
const r = A.preAggregationCTEs.find((a) => a.cube.name === N), i = r.joinKeys.find((a) => a.targetColumn === O);
|
|
1694
1694
|
if (i && i.sourceColumnObj) {
|
|
1695
1695
|
const a = this.buildTimeDimensionExpression(
|
|
1696
1696
|
i.sourceColumnObj,
|
|
@@ -1699,12 +1699,12 @@ class ne {
|
|
|
1699
1699
|
);
|
|
1700
1700
|
S.push(a);
|
|
1701
1701
|
} else {
|
|
1702
|
-
const a = _`${_.identifier(
|
|
1702
|
+
const a = _`${_.identifier(r.cteAlias)}.${_.identifier(O)}`;
|
|
1703
1703
|
S.push(a);
|
|
1704
1704
|
}
|
|
1705
1705
|
} else {
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1706
|
+
const r = C.dimensions[O], i = this.buildTimeDimensionExpression(
|
|
1707
|
+
r.sql,
|
|
1708
1708
|
s.granularity,
|
|
1709
1709
|
R
|
|
1710
1710
|
);
|
|
@@ -1748,8 +1748,8 @@ class ne {
|
|
|
1748
1748
|
for (const S of T.dimensions) {
|
|
1749
1749
|
const [I, t] = S.split("."), s = A.get(I);
|
|
1750
1750
|
if (s) {
|
|
1751
|
-
const
|
|
1752
|
-
|
|
1751
|
+
const N = s.dimensions[t];
|
|
1752
|
+
N && N.type === "number" && R.push(S);
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
return R;
|
|
@@ -1864,7 +1864,7 @@ class dT {
|
|
|
1864
1864
|
groupByFields: []
|
|
1865
1865
|
// Will be built by QueryBuilder
|
|
1866
1866
|
};
|
|
1867
|
-
const s = this.buildJoinPlan(E, t, S, R),
|
|
1867
|
+
const s = this.buildJoinPlan(E, t, S, R), N = this.planPreAggregationCTEs(E, t, s, T);
|
|
1868
1868
|
return {
|
|
1869
1869
|
primaryCube: t,
|
|
1870
1870
|
joinCubes: s,
|
|
@@ -1874,7 +1874,7 @@ class dT {
|
|
|
1874
1874
|
// Will be built by QueryBuilder
|
|
1875
1875
|
groupByFields: [],
|
|
1876
1876
|
// Will be built by QueryBuilder
|
|
1877
|
-
preAggregationCTEs:
|
|
1877
|
+
preAggregationCTEs: N
|
|
1878
1878
|
};
|
|
1879
1879
|
}
|
|
1880
1880
|
/**
|
|
@@ -1928,34 +1928,34 @@ class dT {
|
|
|
1928
1928
|
for (const s of t) {
|
|
1929
1929
|
if (I.has(s))
|
|
1930
1930
|
continue;
|
|
1931
|
-
const
|
|
1932
|
-
if (!
|
|
1931
|
+
const N = this.findJoinPath(E, T.name, s, I);
|
|
1932
|
+
if (!N || N.length === 0)
|
|
1933
1933
|
throw new Error(`No join path found from '${T.name}' to '${s}'`);
|
|
1934
|
-
for (const { toCube:
|
|
1935
|
-
if (I.has(
|
|
1934
|
+
for (const { toCube: O, joinDef: C } of N) {
|
|
1935
|
+
if (I.has(O))
|
|
1936
1936
|
continue;
|
|
1937
|
-
const n = E.get(
|
|
1937
|
+
const n = E.get(O);
|
|
1938
1938
|
if (!n)
|
|
1939
|
-
throw new Error(`Cube '${
|
|
1939
|
+
throw new Error(`Cube '${O}' not found`);
|
|
1940
1940
|
if (C.relationship === "belongsToMany" && C.through) {
|
|
1941
|
-
const
|
|
1941
|
+
const r = se(C, A.securityContext);
|
|
1942
1942
|
S.push({
|
|
1943
1943
|
cube: n,
|
|
1944
|
-
alias: `${
|
|
1945
|
-
joinType:
|
|
1944
|
+
alias: `${O.toLowerCase()}_cube`,
|
|
1945
|
+
joinType: r.junctionJoins[1].joinType,
|
|
1946
1946
|
// Use the target join type
|
|
1947
|
-
joinCondition:
|
|
1947
|
+
joinCondition: r.junctionJoins[1].condition,
|
|
1948
1948
|
// Target join condition
|
|
1949
1949
|
junctionTable: {
|
|
1950
1950
|
table: C.through.table,
|
|
1951
|
-
alias: `junction_${
|
|
1952
|
-
joinType:
|
|
1953
|
-
joinCondition:
|
|
1951
|
+
alias: `junction_${O.toLowerCase()}`,
|
|
1952
|
+
joinType: r.junctionJoins[0].joinType,
|
|
1953
|
+
joinCondition: r.junctionJoins[0].condition,
|
|
1954
1954
|
securitySql: C.through.securitySql
|
|
1955
1955
|
}
|
|
1956
1956
|
});
|
|
1957
1957
|
} else {
|
|
1958
|
-
const
|
|
1958
|
+
const r = this.buildJoinCondition(
|
|
1959
1959
|
C,
|
|
1960
1960
|
null,
|
|
1961
1961
|
// No source alias needed - use the actual column
|
|
@@ -1964,12 +1964,12 @@ class dT {
|
|
|
1964
1964
|
), i = fE(C.relationship, C.sqlJoinType);
|
|
1965
1965
|
S.push({
|
|
1966
1966
|
cube: n,
|
|
1967
|
-
alias: `${
|
|
1967
|
+
alias: `${O.toLowerCase()}_cube`,
|
|
1968
1968
|
joinType: i,
|
|
1969
|
-
joinCondition:
|
|
1969
|
+
joinCondition: r
|
|
1970
1970
|
});
|
|
1971
1971
|
}
|
|
1972
|
-
I.add(
|
|
1972
|
+
I.add(O);
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
1975
|
return S;
|
|
@@ -1996,20 +1996,20 @@ class dT {
|
|
|
1996
1996
|
{ cube: T, path: [] }
|
|
1997
1997
|
], I = /* @__PURE__ */ new Set([T, ...A]);
|
|
1998
1998
|
for (; S.length > 0; ) {
|
|
1999
|
-
const { cube: t, path: s } = S.shift(),
|
|
2000
|
-
if (
|
|
2001
|
-
for (const [,
|
|
2002
|
-
const n =
|
|
1999
|
+
const { cube: t, path: s } = S.shift(), N = E.get(t);
|
|
2000
|
+
if (N?.joins)
|
|
2001
|
+
for (const [, O] of Object.entries(N.joins)) {
|
|
2002
|
+
const n = j(O.targetCube).name;
|
|
2003
2003
|
if (I.has(n))
|
|
2004
2004
|
continue;
|
|
2005
|
-
const
|
|
2005
|
+
const r = [...s, {
|
|
2006
2006
|
fromCube: t,
|
|
2007
2007
|
toCube: n,
|
|
2008
|
-
joinDef:
|
|
2008
|
+
joinDef: O
|
|
2009
2009
|
}];
|
|
2010
2010
|
if (n === R)
|
|
2011
|
-
return
|
|
2012
|
-
I.add(n), S.push({ cube: n, path:
|
|
2011
|
+
return r;
|
|
2012
|
+
I.add(n), S.push({ cube: n, path: r });
|
|
2013
2013
|
}
|
|
2014
2014
|
}
|
|
2015
2015
|
return null;
|
|
@@ -2028,25 +2028,26 @@ class dT {
|
|
|
2028
2028
|
if (!t)
|
|
2029
2029
|
continue;
|
|
2030
2030
|
const s = A.measures ? A.measures.filter(
|
|
2031
|
-
(
|
|
2032
|
-
) : [],
|
|
2033
|
-
if (
|
|
2031
|
+
(i) => i.startsWith(I.cube.name + ".")
|
|
2032
|
+
) : [], N = this.extractMeasuresFromFilters(A, I.cube.name), O = [.../* @__PURE__ */ new Set([...s, ...N])];
|
|
2033
|
+
if (O.length === 0)
|
|
2034
2034
|
continue;
|
|
2035
2035
|
const C = this.expandCalculatedMeasureDependencies(
|
|
2036
2036
|
I.cube,
|
|
2037
|
-
|
|
2038
|
-
), n = t.on.map((
|
|
2039
|
-
sourceColumn:
|
|
2040
|
-
targetColumn:
|
|
2041
|
-
sourceColumnObj:
|
|
2042
|
-
targetColumnObj:
|
|
2043
|
-
}));
|
|
2037
|
+
O
|
|
2038
|
+
), n = t.on.map((i) => ({
|
|
2039
|
+
sourceColumn: i.source.name,
|
|
2040
|
+
targetColumn: i.target.name,
|
|
2041
|
+
sourceColumnObj: i.source,
|
|
2042
|
+
targetColumnObj: i.target
|
|
2043
|
+
})), r = this.findPropagatingFilters(A, I.cube, E);
|
|
2044
2044
|
S.push({
|
|
2045
2045
|
cube: I.cube,
|
|
2046
2046
|
alias: I.alias,
|
|
2047
2047
|
cteAlias: `${I.cube.name.toLowerCase()}_agg`,
|
|
2048
2048
|
joinKeys: n,
|
|
2049
|
-
measures: C
|
|
2049
|
+
measures: C,
|
|
2050
|
+
propagatingFilters: r.length > 0 ? r : void 0
|
|
2050
2051
|
});
|
|
2051
2052
|
}
|
|
2052
2053
|
return S;
|
|
@@ -2067,8 +2068,8 @@ class dT {
|
|
|
2067
2068
|
const t = E.measures[I];
|
|
2068
2069
|
if (t.type === "calculated" && t.calculatedSql) {
|
|
2069
2070
|
const s = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
|
|
2070
|
-
for (const
|
|
2071
|
-
R.has(
|
|
2071
|
+
for (const N of s)
|
|
2072
|
+
R.has(N) || A.push(N);
|
|
2072
2073
|
}
|
|
2073
2074
|
}
|
|
2074
2075
|
return Array.from(R);
|
|
@@ -2091,10 +2092,106 @@ class dT {
|
|
|
2091
2092
|
if (!E.joins)
|
|
2092
2093
|
return null;
|
|
2093
2094
|
for (const [, R] of Object.entries(E.joins))
|
|
2094
|
-
if (
|
|
2095
|
+
if (j(R.targetCube).name === T && R.relationship === "hasMany")
|
|
2095
2096
|
return R;
|
|
2096
2097
|
return null;
|
|
2097
2098
|
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Find filters that need to propagate from related cubes to a CTE cube.
|
|
2101
|
+
* When cube A has filters and a hasMany relationship to cube B (the CTE cube),
|
|
2102
|
+
* A's filters should propagate into B's CTE via a subquery.
|
|
2103
|
+
*
|
|
2104
|
+
* Example: Employees.createdAt filter should propagate to Productivity CTE
|
|
2105
|
+
* via: employee_id IN (SELECT id FROM employees WHERE created_at >= $date)
|
|
2106
|
+
*/
|
|
2107
|
+
findPropagatingFilters(E, T, R) {
|
|
2108
|
+
const A = [];
|
|
2109
|
+
if (!E.filters) return A;
|
|
2110
|
+
const S = /* @__PURE__ */ new Set();
|
|
2111
|
+
if (this.extractFilterCubeNamesToSet(E.filters, S), E.timeDimensions) {
|
|
2112
|
+
for (const I of E.timeDimensions)
|
|
2113
|
+
if (I.dateRange) {
|
|
2114
|
+
const [t] = I.dimension.split(".");
|
|
2115
|
+
t && S.add(t);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
for (const I of S) {
|
|
2119
|
+
if (I === T.name) continue;
|
|
2120
|
+
const t = R.get(I);
|
|
2121
|
+
if (t?.joins) {
|
|
2122
|
+
for (const [, s] of Object.entries(t.joins))
|
|
2123
|
+
if (j(s.targetCube).name === T.name && s.relationship === "hasMany") {
|
|
2124
|
+
const O = this.extractFiltersForCube(E.filters, I), C = this.extractTimeDimensionFiltersForCube(E, I), n = [...O, ...C];
|
|
2125
|
+
n.length > 0 && s.on.length > 0 && A.push({
|
|
2126
|
+
sourceCube: t,
|
|
2127
|
+
filters: n,
|
|
2128
|
+
// source = filterCube PK (e.g., employees.id)
|
|
2129
|
+
// target = cteCube FK (e.g., productivity.employeeId)
|
|
2130
|
+
joinCondition: {
|
|
2131
|
+
source: s.on[0].source,
|
|
2132
|
+
target: s.on[0].target
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
return A;
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Extract cube names from filters into a Set (helper for findPropagatingFilters)
|
|
2142
|
+
*/
|
|
2143
|
+
extractFilterCubeNamesToSet(E, T) {
|
|
2144
|
+
for (const R of E) {
|
|
2145
|
+
if ("and" in R || "or" in R) {
|
|
2146
|
+
const A = R.and || R.or || [];
|
|
2147
|
+
this.extractFilterCubeNamesToSet(A, T);
|
|
2148
|
+
continue;
|
|
2149
|
+
}
|
|
2150
|
+
if ("member" in R) {
|
|
2151
|
+
const [A] = R.member.split(".");
|
|
2152
|
+
A && T.add(A);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
/**
|
|
2157
|
+
* Extract filters for a specific cube from the filter array
|
|
2158
|
+
*/
|
|
2159
|
+
extractFiltersForCube(E, T) {
|
|
2160
|
+
const R = [];
|
|
2161
|
+
for (const A of E) {
|
|
2162
|
+
if ("and" in A) {
|
|
2163
|
+
const S = this.extractFiltersForCube(A.and || [], T);
|
|
2164
|
+
S.length > 0 && R.push({ and: S });
|
|
2165
|
+
continue;
|
|
2166
|
+
}
|
|
2167
|
+
if ("or" in A) {
|
|
2168
|
+
const S = this.extractFiltersForCube(A.or || [], T);
|
|
2169
|
+
S.length > 0 && R.push({ or: S });
|
|
2170
|
+
continue;
|
|
2171
|
+
}
|
|
2172
|
+
if ("member" in A) {
|
|
2173
|
+
const [S] = A.member.split(".");
|
|
2174
|
+
S === T && R.push(A);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
return R;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Extract time dimension date range filters as regular filters for a specific cube
|
|
2181
|
+
*/
|
|
2182
|
+
extractTimeDimensionFiltersForCube(E, T) {
|
|
2183
|
+
const R = [];
|
|
2184
|
+
if (!E.timeDimensions) return R;
|
|
2185
|
+
for (const A of E.timeDimensions) {
|
|
2186
|
+
const [S] = A.dimension.split(".");
|
|
2187
|
+
S === T && A.dateRange && R.push({
|
|
2188
|
+
member: A.dimension,
|
|
2189
|
+
operator: "inDateRange",
|
|
2190
|
+
values: Array.isArray(A.dateRange) ? A.dateRange : [A.dateRange]
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
return R;
|
|
2194
|
+
}
|
|
2098
2195
|
/**
|
|
2099
2196
|
* Analyze query planning decisions without building the full query
|
|
2100
2197
|
* Returns detailed metadata about how the query plan would be constructed
|
|
@@ -2138,23 +2235,23 @@ class dT {
|
|
|
2138
2235
|
warnings: []
|
|
2139
2236
|
};
|
|
2140
2237
|
if (S.length > 1) {
|
|
2141
|
-
const
|
|
2142
|
-
for (const
|
|
2238
|
+
const N = S.filter((r) => r !== t);
|
|
2239
|
+
for (const r of N)
|
|
2143
2240
|
s.joinPaths.push(
|
|
2144
|
-
this.analyzeJoinPath(E, t,
|
|
2241
|
+
this.analyzeJoinPath(E, t, r)
|
|
2145
2242
|
);
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2243
|
+
const O = E.get(t);
|
|
2244
|
+
O && (s.preAggregations = this.analyzePreAggregations(
|
|
2148
2245
|
E,
|
|
2149
|
-
N,
|
|
2150
2246
|
O,
|
|
2247
|
+
N,
|
|
2151
2248
|
T
|
|
2152
2249
|
));
|
|
2153
|
-
const C = s.joinPaths.filter((
|
|
2250
|
+
const C = s.joinPaths.filter((r) => r.pathFound), n = s.joinPaths.filter((r) => !r.pathFound);
|
|
2154
2251
|
s.querySummary.joinCount = C.length, s.querySummary.cteCount = s.preAggregations.length, s.querySummary.hasPreAggregation = s.preAggregations.length > 0, s.preAggregations.length > 0 ? s.querySummary.queryType = "multi_cube_cte" : s.querySummary.queryType = "multi_cube_join";
|
|
2155
|
-
for (const
|
|
2252
|
+
for (const r of n)
|
|
2156
2253
|
s.warnings.push(
|
|
2157
|
-
`No join path found to cube '${
|
|
2254
|
+
`No join path found to cube '${r.targetCube}'. Check that joins are defined correctly.`
|
|
2158
2255
|
);
|
|
2159
2256
|
}
|
|
2160
2257
|
return s;
|
|
@@ -2169,23 +2266,23 @@ class dT {
|
|
|
2169
2266
|
reason: "single_cube",
|
|
2170
2267
|
explanation: "Only one cube is used in this query"
|
|
2171
2268
|
};
|
|
2172
|
-
const A = [], S = (T.dimensions || []).map((
|
|
2173
|
-
for (const
|
|
2174
|
-
I.set(
|
|
2175
|
-
for (const
|
|
2176
|
-
const
|
|
2269
|
+
const A = [], S = (T.dimensions || []).map((N) => N.split(".")[0]), I = /* @__PURE__ */ new Map();
|
|
2270
|
+
for (const N of S)
|
|
2271
|
+
I.set(N, (I.get(N) || 0) + 1);
|
|
2272
|
+
for (const N of E) {
|
|
2273
|
+
const O = R.get(N), C = I.get(N) || 0, n = O?.joins ? Object.keys(O.joins).length : 0, r = this.canReachAllCubes(N, E, R);
|
|
2177
2274
|
A.push({
|
|
2178
|
-
cubeName:
|
|
2275
|
+
cubeName: N,
|
|
2179
2276
|
dimensionCount: C,
|
|
2180
2277
|
joinCount: n,
|
|
2181
|
-
canReachAll:
|
|
2278
|
+
canReachAll: r
|
|
2182
2279
|
});
|
|
2183
2280
|
}
|
|
2184
2281
|
if (T.dimensions && T.dimensions.length > 0) {
|
|
2185
|
-
const
|
|
2186
|
-
if (
|
|
2187
|
-
const
|
|
2188
|
-
for (const C of
|
|
2282
|
+
const N = Math.max(...A.map((O) => O.dimensionCount));
|
|
2283
|
+
if (N > 0) {
|
|
2284
|
+
const O = A.filter((C) => C.dimensionCount === N).sort((C, n) => C.cubeName.localeCompare(n.cubeName));
|
|
2285
|
+
for (const C of O)
|
|
2189
2286
|
if (C.canReachAll)
|
|
2190
2287
|
return {
|
|
2191
2288
|
selectedCube: C.cubeName,
|
|
@@ -2195,13 +2292,13 @@ class dT {
|
|
|
2195
2292
|
};
|
|
2196
2293
|
}
|
|
2197
2294
|
}
|
|
2198
|
-
const t = A.filter((
|
|
2295
|
+
const t = A.filter((N) => N.canReachAll);
|
|
2199
2296
|
if (t.length > 0) {
|
|
2200
|
-
const
|
|
2297
|
+
const N = Math.max(...t.map((C) => C.joinCount)), O = t.filter((C) => C.joinCount === N).sort((C, n) => C.cubeName.localeCompare(n.cubeName))[0];
|
|
2201
2298
|
return {
|
|
2202
|
-
selectedCube:
|
|
2299
|
+
selectedCube: O.cubeName,
|
|
2203
2300
|
reason: "most_connected",
|
|
2204
|
-
explanation: `Selected because it has ${
|
|
2301
|
+
explanation: `Selected because it has ${O.joinCount} join relationship${O.joinCount !== 1 ? "s" : ""} and can reach all other cubes`,
|
|
2205
2302
|
candidates: A
|
|
2206
2303
|
};
|
|
2207
2304
|
}
|
|
@@ -2218,20 +2315,20 @@ class dT {
|
|
|
2218
2315
|
analyzeJoinPath(E, T, R) {
|
|
2219
2316
|
const A = [T], S = [{ cube: T, path: [] }], I = /* @__PURE__ */ new Set([T]);
|
|
2220
2317
|
for (; S.length > 0; ) {
|
|
2221
|
-
const { cube: t, path: s } = S.shift(),
|
|
2222
|
-
if (
|
|
2223
|
-
for (const [,
|
|
2224
|
-
const n =
|
|
2318
|
+
const { cube: t, path: s } = S.shift(), N = E.get(t);
|
|
2319
|
+
if (N?.joins)
|
|
2320
|
+
for (const [, O] of Object.entries(N.joins)) {
|
|
2321
|
+
const n = j(O.targetCube).name;
|
|
2225
2322
|
if (I.has(n))
|
|
2226
2323
|
continue;
|
|
2227
2324
|
A.push(n), I.add(n);
|
|
2228
|
-
const
|
|
2325
|
+
const r = [...s, {
|
|
2229
2326
|
fromCube: t,
|
|
2230
2327
|
toCube: n,
|
|
2231
|
-
joinDef:
|
|
2328
|
+
joinDef: O
|
|
2232
2329
|
}];
|
|
2233
2330
|
if (n === R) {
|
|
2234
|
-
const i =
|
|
2331
|
+
const i = r.map((a) => {
|
|
2235
2332
|
const l = fE(a.joinDef.relationship, a.joinDef.sqlJoinType), P = a.joinDef.on.map((M) => ({
|
|
2236
2333
|
sourceColumn: M.source.name,
|
|
2237
2334
|
targetColumn: M.target.name
|
|
@@ -2260,7 +2357,7 @@ class dT {
|
|
|
2260
2357
|
visitedCubes: A
|
|
2261
2358
|
};
|
|
2262
2359
|
}
|
|
2263
|
-
S.push({ cube: n, path:
|
|
2360
|
+
S.push({ cube: n, path: r });
|
|
2264
2361
|
}
|
|
2265
2362
|
}
|
|
2266
2363
|
return {
|
|
@@ -2282,26 +2379,26 @@ class dT {
|
|
|
2282
2379
|
if (!t)
|
|
2283
2380
|
continue;
|
|
2284
2381
|
const s = A.measures.filter(
|
|
2285
|
-
(
|
|
2382
|
+
(O) => O.startsWith(I + ".")
|
|
2286
2383
|
);
|
|
2287
2384
|
if (s.length === 0)
|
|
2288
2385
|
continue;
|
|
2289
|
-
const
|
|
2290
|
-
sourceColumn:
|
|
2291
|
-
targetColumn:
|
|
2386
|
+
const N = t.on.map((O) => ({
|
|
2387
|
+
sourceColumn: O.source.name,
|
|
2388
|
+
targetColumn: O.target.name
|
|
2292
2389
|
}));
|
|
2293
2390
|
S.push({
|
|
2294
2391
|
cubeName: I,
|
|
2295
2392
|
cteAlias: `${I.toLowerCase()}_agg`,
|
|
2296
2393
|
reason: `hasMany relationship from ${T.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
|
|
2297
2394
|
measures: s,
|
|
2298
|
-
joinKeys:
|
|
2395
|
+
joinKeys: N
|
|
2299
2396
|
});
|
|
2300
2397
|
}
|
|
2301
2398
|
return S;
|
|
2302
2399
|
}
|
|
2303
2400
|
}
|
|
2304
|
-
function
|
|
2401
|
+
function Le(e, E, T) {
|
|
2305
2402
|
const R = [];
|
|
2306
2403
|
let A = ZE(new Date(e), T);
|
|
2307
2404
|
const S = ZE(new Date(E), T), I = 1e4;
|
|
@@ -2387,36 +2484,36 @@ function ae(e, E) {
|
|
|
2387
2484
|
return E.length === 0 ? "__all__" : E.map((T) => String(e[T] ?? "")).join("|||");
|
|
2388
2485
|
}
|
|
2389
2486
|
function oe(e, E) {
|
|
2390
|
-
const { timeDimensionKey: T, granularity: R, dateRange: A, fillValue: S, measures: I, dimensions: t } = E, s =
|
|
2487
|
+
const { timeDimensionKey: T, granularity: R, dateRange: A, fillValue: S, measures: I, dimensions: t } = E, s = Le(A[0], A[1], R);
|
|
2391
2488
|
if (s.length === 0)
|
|
2392
2489
|
return e;
|
|
2393
|
-
const
|
|
2490
|
+
const N = /* @__PURE__ */ new Map();
|
|
2394
2491
|
for (const C of e) {
|
|
2395
|
-
const n = ae(C, t),
|
|
2396
|
-
|
|
2492
|
+
const n = ae(C, t), r = ie(C[T]);
|
|
2493
|
+
N.has(n) || N.set(n, /* @__PURE__ */ new Map()), N.get(n).set(r, C);
|
|
2397
2494
|
}
|
|
2398
|
-
|
|
2399
|
-
const
|
|
2400
|
-
for (const [C, n] of
|
|
2401
|
-
const
|
|
2495
|
+
N.size === 0 && t.length === 0 && N.set("__all__", /* @__PURE__ */ new Map());
|
|
2496
|
+
const O = [];
|
|
2497
|
+
for (const [C, n] of N) {
|
|
2498
|
+
const r = n.size > 0 ? n.values().next().value : null;
|
|
2402
2499
|
for (const i of s) {
|
|
2403
2500
|
const a = i.toISOString(), l = n.get(a);
|
|
2404
2501
|
if (l)
|
|
2405
|
-
|
|
2502
|
+
O.push(l);
|
|
2406
2503
|
else {
|
|
2407
2504
|
const P = {
|
|
2408
2505
|
[T]: a
|
|
2409
2506
|
};
|
|
2410
|
-
if (
|
|
2507
|
+
if (r)
|
|
2411
2508
|
for (const U of t)
|
|
2412
|
-
P[U] =
|
|
2509
|
+
P[U] = r[U];
|
|
2413
2510
|
for (const U of I)
|
|
2414
2511
|
P[U] = S;
|
|
2415
|
-
|
|
2512
|
+
O.push(P);
|
|
2416
2513
|
}
|
|
2417
2514
|
}
|
|
2418
2515
|
}
|
|
2419
|
-
return
|
|
2516
|
+
return O;
|
|
2420
2517
|
}
|
|
2421
2518
|
function De(e) {
|
|
2422
2519
|
if (!e)
|
|
@@ -2434,34 +2531,34 @@ function Pe(e, E, T) {
|
|
|
2434
2531
|
if (!E.timeDimensions || E.timeDimensions.length === 0)
|
|
2435
2532
|
return e;
|
|
2436
2533
|
const R = E.timeDimensions.filter((s) => {
|
|
2437
|
-
const
|
|
2438
|
-
return
|
|
2534
|
+
const N = s.fillMissingDates !== !1, O = s.granularity && s.dateRange;
|
|
2535
|
+
return N && O;
|
|
2439
2536
|
});
|
|
2440
2537
|
if (R.length === 0)
|
|
2441
2538
|
return e;
|
|
2442
2539
|
const A = E.fillMissingDatesValue === void 0 ? 0 : E.fillMissingDatesValue, S = new Set(E.timeDimensions.map((s) => s.dimension)), I = (E.dimensions || []).filter((s) => !S.has(s));
|
|
2443
2540
|
let t = e;
|
|
2444
2541
|
for (const s of R) {
|
|
2445
|
-
const
|
|
2446
|
-
if (!
|
|
2542
|
+
const N = De(s.dateRange);
|
|
2543
|
+
if (!N)
|
|
2447
2544
|
continue;
|
|
2448
|
-
const
|
|
2545
|
+
const O = {
|
|
2449
2546
|
timeDimensionKey: s.dimension,
|
|
2450
2547
|
granularity: s.granularity,
|
|
2451
|
-
dateRange:
|
|
2548
|
+
dateRange: N,
|
|
2452
2549
|
fillValue: A,
|
|
2453
2550
|
measures: T,
|
|
2454
2551
|
dimensions: I
|
|
2455
2552
|
};
|
|
2456
|
-
t = oe(t,
|
|
2553
|
+
t = oe(t, O);
|
|
2457
2554
|
}
|
|
2458
2555
|
return t;
|
|
2459
2556
|
}
|
|
2460
|
-
class
|
|
2557
|
+
class nE {
|
|
2461
2558
|
constructor(E) {
|
|
2462
2559
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
2463
2560
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
2464
|
-
this.queryBuilder = new
|
|
2561
|
+
this.queryBuilder = new re(this.databaseAdapter), this.queryPlanner = new dT();
|
|
2465
2562
|
}
|
|
2466
2563
|
queryBuilder;
|
|
2467
2564
|
queryPlanner;
|
|
@@ -2478,7 +2575,7 @@ class LE {
|
|
|
2478
2575
|
db: this.dbExecutor.db,
|
|
2479
2576
|
schema: this.dbExecutor.schema,
|
|
2480
2577
|
securityContext: R
|
|
2481
|
-
}, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), s = this.queryBuilder.collectNumericFields(E, T),
|
|
2578
|
+
}, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), s = this.queryBuilder.collectNumericFields(E, T), N = await this.dbExecutor.execute(t, s), O = Array.isArray(N) ? N.map((i) => {
|
|
2482
2579
|
const a = { ...i };
|
|
2483
2580
|
if (T.timeDimensions) {
|
|
2484
2581
|
for (const l of T.timeDimensions)
|
|
@@ -2492,10 +2589,10 @@ class LE {
|
|
|
2492
2589
|
}
|
|
2493
2590
|
}
|
|
2494
2591
|
return a;
|
|
2495
|
-
}) : [
|
|
2592
|
+
}) : [N], C = T.measures || [], n = Pe(O, T, C), r = this.generateAnnotations(I, T);
|
|
2496
2593
|
return {
|
|
2497
2594
|
data: n,
|
|
2498
|
-
annotation:
|
|
2595
|
+
annotation: r
|
|
2499
2596
|
};
|
|
2500
2597
|
} catch (A) {
|
|
2501
2598
|
throw new Error(`Query execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
|
|
@@ -2519,13 +2616,13 @@ class LE {
|
|
|
2519
2616
|
for (const [U, M] of Object.entries(S.dimensions || {}))
|
|
2520
2617
|
M.sql === P.targetColumnObj && U !== P.targetColumn && (t[U] = _`${P.targetColumnObj}`.as(U));
|
|
2521
2618
|
}
|
|
2522
|
-
const s = S.name,
|
|
2619
|
+
const s = S.name, N = /* @__PURE__ */ new Map([[s, S]]), O = this.queryBuilder.buildResolvedMeasures(
|
|
2523
2620
|
E.measures,
|
|
2524
|
-
|
|
2621
|
+
N,
|
|
2525
2622
|
R
|
|
2526
2623
|
);
|
|
2527
2624
|
for (const P of E.measures) {
|
|
2528
|
-
const [, U] = P.split("."), M =
|
|
2625
|
+
const [, U] = P.split("."), M = O.get(P);
|
|
2529
2626
|
if (M) {
|
|
2530
2627
|
const G = M();
|
|
2531
2628
|
t[U] = _`${G}`.as(U);
|
|
@@ -2553,13 +2650,13 @@ class LE {
|
|
|
2553
2650
|
const n = A ? {
|
|
2554
2651
|
...A,
|
|
2555
2652
|
preAggregationCTEs: A.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
|
|
2556
|
-
} : void 0,
|
|
2653
|
+
} : void 0, r = this.queryBuilder.buildWhereConditions(S, T, R, n), i = [];
|
|
2557
2654
|
if (T.timeDimensions)
|
|
2558
2655
|
for (const P of T.timeDimensions) {
|
|
2559
2656
|
const [U, M] = P.dimension.split(".");
|
|
2560
2657
|
if (U === s && S.dimensions && S.dimensions[M] && P.dateRange) {
|
|
2561
|
-
const G = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R),
|
|
2562
|
-
|
|
2658
|
+
const G = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R), m = this.queryBuilder.buildDateRangeCondition(H, P.dateRange);
|
|
2659
|
+
m && i.push(m);
|
|
2563
2660
|
}
|
|
2564
2661
|
}
|
|
2565
2662
|
if (T.filters) {
|
|
@@ -2569,14 +2666,23 @@ class LE {
|
|
|
2569
2666
|
if (M === s && S.dimensions && S.dimensions[G]) {
|
|
2570
2667
|
const H = S.dimensions[G];
|
|
2571
2668
|
if (U.operator === "inDateRange") {
|
|
2572
|
-
const
|
|
2669
|
+
const m = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, R), Y = this.queryBuilder.buildDateRangeCondition(m, U.values);
|
|
2573
2670
|
Y && i.push(Y);
|
|
2574
2671
|
}
|
|
2575
2672
|
}
|
|
2576
2673
|
}
|
|
2577
2674
|
}
|
|
2675
|
+
if (E.propagatingFilters && E.propagatingFilters.length > 0)
|
|
2676
|
+
for (const P of E.propagatingFilters) {
|
|
2677
|
+
const U = this.buildPropagatingFilterSubquery(
|
|
2678
|
+
P,
|
|
2679
|
+
R,
|
|
2680
|
+
T
|
|
2681
|
+
);
|
|
2682
|
+
U && i.push(U);
|
|
2683
|
+
}
|
|
2578
2684
|
const a = [];
|
|
2579
|
-
if (I.where && a.push(I.where), a.push(...
|
|
2685
|
+
if (I.where && a.push(I.where), a.push(...r, ...i), a.length > 0) {
|
|
2580
2686
|
const P = a.length === 1 ? a[0] : F(...a);
|
|
2581
2687
|
C = C.where(P);
|
|
2582
2688
|
}
|
|
@@ -2616,6 +2722,28 @@ class LE {
|
|
|
2616
2722
|
}
|
|
2617
2723
|
return S.length === 1 ? S[0] : F(...S);
|
|
2618
2724
|
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Build a subquery filter for propagating filters from related cubes.
|
|
2727
|
+
* This generates: cteCube.FK IN (SELECT sourceCube.PK FROM sourceCube WHERE filters...)
|
|
2728
|
+
*
|
|
2729
|
+
* Example: For Productivity CTE with Employees.createdAt filter:
|
|
2730
|
+
* employee_id IN (SELECT id FROM employees WHERE organisation_id = $1 AND created_at >= $date)
|
|
2731
|
+
*/
|
|
2732
|
+
buildPropagatingFilterSubquery(E, T, R) {
|
|
2733
|
+
const A = E.sourceCube, S = A.sql(T), I = [];
|
|
2734
|
+
S.where && I.push(S.where);
|
|
2735
|
+
const t = {
|
|
2736
|
+
filters: E.filters
|
|
2737
|
+
}, s = /* @__PURE__ */ new Map([[A.name, A]]), N = this.queryBuilder.buildWhereConditions(
|
|
2738
|
+
s,
|
|
2739
|
+
t,
|
|
2740
|
+
T
|
|
2741
|
+
);
|
|
2742
|
+
if (I.push(...N), I.length === 0)
|
|
2743
|
+
return null;
|
|
2744
|
+
const { source: O, target: C } = E.joinCondition, n = I.length === 1 ? I[0] : F(...I), r = T.db.select({ pk: O }).from(S.from).where(n);
|
|
2745
|
+
return _`${C} IN ${r}`;
|
|
2746
|
+
}
|
|
2619
2747
|
/**
|
|
2620
2748
|
* Build unified query that works for both single and multi-cube queries
|
|
2621
2749
|
*/
|
|
@@ -2642,36 +2770,36 @@ class LE {
|
|
|
2642
2770
|
const G = M.measures[U];
|
|
2643
2771
|
let H;
|
|
2644
2772
|
if (G.type === "calculated" && G.calculatedSql) {
|
|
2645
|
-
const
|
|
2773
|
+
const m = this.getCubesFromPlan(E);
|
|
2646
2774
|
H = this.queryBuilder.buildCTECalculatedMeasure(
|
|
2647
2775
|
G,
|
|
2648
2776
|
M,
|
|
2649
2777
|
a,
|
|
2650
|
-
|
|
2778
|
+
m,
|
|
2651
2779
|
R
|
|
2652
2780
|
);
|
|
2653
2781
|
} else {
|
|
2654
|
-
const
|
|
2782
|
+
const m = _`${_.identifier(a.cteAlias)}.${_.identifier(U)}`;
|
|
2655
2783
|
switch (G.type) {
|
|
2656
2784
|
case "count":
|
|
2657
2785
|
case "countDistinct":
|
|
2658
2786
|
case "sum":
|
|
2659
|
-
H = f(
|
|
2787
|
+
H = f(m);
|
|
2660
2788
|
break;
|
|
2661
2789
|
case "avg":
|
|
2662
|
-
H = this.databaseAdapter.buildAvg(
|
|
2790
|
+
H = this.databaseAdapter.buildAvg(m);
|
|
2663
2791
|
break;
|
|
2664
2792
|
case "min":
|
|
2665
|
-
H =
|
|
2793
|
+
H = k(m);
|
|
2666
2794
|
break;
|
|
2667
2795
|
case "max":
|
|
2668
|
-
H =
|
|
2796
|
+
H = q(m);
|
|
2669
2797
|
break;
|
|
2670
2798
|
case "number":
|
|
2671
|
-
H = f(
|
|
2799
|
+
H = f(m);
|
|
2672
2800
|
break;
|
|
2673
2801
|
default:
|
|
2674
|
-
H = f(
|
|
2802
|
+
H = f(m);
|
|
2675
2803
|
}
|
|
2676
2804
|
}
|
|
2677
2805
|
s[P] = _`${H}`.as(P);
|
|
@@ -2680,34 +2808,34 @@ class LE {
|
|
|
2680
2808
|
for (const P in s) {
|
|
2681
2809
|
const [U, M] = P.split(".");
|
|
2682
2810
|
if (U === l) {
|
|
2683
|
-
const G = this.getCubesFromPlan(E).get(l), H = G && G.dimensions?.[M],
|
|
2684
|
-
if (H ||
|
|
2685
|
-
let Y = a.joinKeys.find((
|
|
2811
|
+
const G = this.getCubesFromPlan(E).get(l), H = G && G.dimensions?.[M], m = P.startsWith(l + ".");
|
|
2812
|
+
if (H || m) {
|
|
2813
|
+
let Y = a.joinKeys.find((SE) => SE.targetColumn === M);
|
|
2686
2814
|
if (!Y && G?.dimensions?.[M]) {
|
|
2687
|
-
const
|
|
2688
|
-
Y = a.joinKeys.find((xT) => xT.targetColumnObj ===
|
|
2815
|
+
const SE = G.dimensions[M].sql;
|
|
2816
|
+
Y = a.joinKeys.find((xT) => xT.targetColumnObj === SE);
|
|
2689
2817
|
}
|
|
2690
|
-
Y ? s[P] = _`${_.identifier(a.cteAlias)}.${_.identifier(M)}`.as(P) :
|
|
2818
|
+
Y ? s[P] = _`${_.identifier(a.cteAlias)}.${_.identifier(M)}`.as(P) : m && G?.dimensions?.[M] && (s[P] = _`${_.identifier(a.cteAlias)}.${_.identifier(M)}`.as(P));
|
|
2691
2819
|
}
|
|
2692
2820
|
}
|
|
2693
2821
|
}
|
|
2694
2822
|
}
|
|
2695
|
-
const
|
|
2696
|
-
let
|
|
2697
|
-
if (A.length > 0 && (
|
|
2823
|
+
const N = [];
|
|
2824
|
+
let O = R.db.select(s).from(I.from);
|
|
2825
|
+
if (A.length > 0 && (O = R.db.with(...A).select(s).from(I.from)), I.joins)
|
|
2698
2826
|
for (const a of I.joins)
|
|
2699
2827
|
switch (a.type || "left") {
|
|
2700
2828
|
case "left":
|
|
2701
|
-
|
|
2829
|
+
O = O.leftJoin(a.table, a.on);
|
|
2702
2830
|
break;
|
|
2703
2831
|
case "inner":
|
|
2704
|
-
|
|
2832
|
+
O = O.innerJoin(a.table, a.on);
|
|
2705
2833
|
break;
|
|
2706
2834
|
case "right":
|
|
2707
|
-
|
|
2835
|
+
O = O.rightJoin(a.table, a.on);
|
|
2708
2836
|
break;
|
|
2709
2837
|
case "full":
|
|
2710
|
-
|
|
2838
|
+
O = O.fullJoin(a.table, a.on);
|
|
2711
2839
|
break;
|
|
2712
2840
|
}
|
|
2713
2841
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
@@ -2722,19 +2850,19 @@ class LE {
|
|
|
2722
2850
|
try {
|
|
2723
2851
|
switch (M.joinType || "left") {
|
|
2724
2852
|
case "left":
|
|
2725
|
-
|
|
2853
|
+
O = O.leftJoin(M.table, M.joinCondition);
|
|
2726
2854
|
break;
|
|
2727
2855
|
case "inner":
|
|
2728
|
-
|
|
2856
|
+
O = O.innerJoin(M.table, M.joinCondition);
|
|
2729
2857
|
break;
|
|
2730
2858
|
case "right":
|
|
2731
|
-
|
|
2859
|
+
O = O.rightJoin(M.table, M.joinCondition);
|
|
2732
2860
|
break;
|
|
2733
2861
|
case "full":
|
|
2734
|
-
|
|
2862
|
+
O = O.fullJoin(M.table, M.joinCondition);
|
|
2735
2863
|
break;
|
|
2736
2864
|
}
|
|
2737
|
-
G.length > 0 &&
|
|
2865
|
+
G.length > 0 && N.push(...G);
|
|
2738
2866
|
} catch {
|
|
2739
2867
|
}
|
|
2740
2868
|
}
|
|
@@ -2743,27 +2871,27 @@ class LE {
|
|
|
2743
2871
|
try {
|
|
2744
2872
|
switch (a.joinType || "left") {
|
|
2745
2873
|
case "left":
|
|
2746
|
-
|
|
2874
|
+
O = O.leftJoin(P, U);
|
|
2747
2875
|
break;
|
|
2748
2876
|
case "inner":
|
|
2749
|
-
|
|
2877
|
+
O = O.innerJoin(P, U);
|
|
2750
2878
|
break;
|
|
2751
2879
|
case "right":
|
|
2752
|
-
|
|
2880
|
+
O = O.rightJoin(P, U);
|
|
2753
2881
|
break;
|
|
2754
2882
|
case "full":
|
|
2755
|
-
|
|
2883
|
+
O = O.fullJoin(P, U);
|
|
2756
2884
|
break;
|
|
2757
2885
|
}
|
|
2758
2886
|
} catch {
|
|
2759
2887
|
}
|
|
2760
2888
|
}
|
|
2761
|
-
if (I.where &&
|
|
2889
|
+
if (I.where && N.push(I.where), E.joinCubes && E.joinCubes.length > 0)
|
|
2762
2890
|
for (const a of E.joinCubes) {
|
|
2763
2891
|
if (S.get(a.cube.name))
|
|
2764
2892
|
continue;
|
|
2765
2893
|
const P = a.cube.sql(R);
|
|
2766
|
-
P.where &&
|
|
2894
|
+
P.where && N.push(P.where);
|
|
2767
2895
|
}
|
|
2768
2896
|
const C = this.queryBuilder.buildWhereConditions(
|
|
2769
2897
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2773,9 +2901,9 @@ class LE {
|
|
|
2773
2901
|
E
|
|
2774
2902
|
// Pass the queryPlan to handle CTE scenarios
|
|
2775
2903
|
);
|
|
2776
|
-
if (C.length > 0 &&
|
|
2777
|
-
const a =
|
|
2778
|
-
|
|
2904
|
+
if (C.length > 0 && N.push(...C), N.length > 0) {
|
|
2905
|
+
const a = N.length === 1 ? N[0] : F(...N);
|
|
2906
|
+
O = O.where(a);
|
|
2779
2907
|
}
|
|
2780
2908
|
const n = this.queryBuilder.buildGroupByFields(
|
|
2781
2909
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2785,8 +2913,8 @@ class LE {
|
|
|
2785
2913
|
E
|
|
2786
2914
|
// Pass the queryPlan to handle CTE scenarios
|
|
2787
2915
|
);
|
|
2788
|
-
n.length > 0 && (
|
|
2789
|
-
const
|
|
2916
|
+
n.length > 0 && (O = O.groupBy(...n));
|
|
2917
|
+
const r = this.queryBuilder.buildHavingConditions(
|
|
2790
2918
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
2791
2919
|
// Single cube
|
|
2792
2920
|
T,
|
|
@@ -2794,12 +2922,12 @@ class LE {
|
|
|
2794
2922
|
E
|
|
2795
2923
|
// Pass the queryPlan to handle CTE scenarios
|
|
2796
2924
|
);
|
|
2797
|
-
if (
|
|
2798
|
-
const a =
|
|
2799
|
-
|
|
2925
|
+
if (r.length > 0) {
|
|
2926
|
+
const a = r.length === 1 ? r[0] : F(...r);
|
|
2927
|
+
O = O.having(a);
|
|
2800
2928
|
}
|
|
2801
2929
|
const i = this.queryBuilder.buildOrderBy(T);
|
|
2802
|
-
return i.length > 0 && (
|
|
2930
|
+
return i.length > 0 && (O = O.orderBy(...i)), O = this.queryBuilder.applyLimitAndOffset(O, T), O;
|
|
2803
2931
|
}
|
|
2804
2932
|
/**
|
|
2805
2933
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -2845,36 +2973,36 @@ class LE {
|
|
|
2845
2973
|
const R = {}, A = {}, S = {}, I = [E.primaryCube];
|
|
2846
2974
|
if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), T.measures)
|
|
2847
2975
|
for (const t of T.measures) {
|
|
2848
|
-
const [s,
|
|
2849
|
-
if (
|
|
2850
|
-
const C =
|
|
2976
|
+
const [s, N] = t.split("."), O = I.find((C) => C.name === s);
|
|
2977
|
+
if (O && O.measures[N]) {
|
|
2978
|
+
const C = O.measures[N];
|
|
2851
2979
|
R[t] = {
|
|
2852
|
-
title: C.title ||
|
|
2853
|
-
shortTitle: C.title ||
|
|
2980
|
+
title: C.title || N,
|
|
2981
|
+
shortTitle: C.title || N,
|
|
2854
2982
|
type: C.type
|
|
2855
2983
|
};
|
|
2856
2984
|
}
|
|
2857
2985
|
}
|
|
2858
2986
|
if (T.dimensions)
|
|
2859
2987
|
for (const t of T.dimensions) {
|
|
2860
|
-
const [s,
|
|
2861
|
-
if (
|
|
2862
|
-
const C =
|
|
2988
|
+
const [s, N] = t.split("."), O = I.find((C) => C.name === s);
|
|
2989
|
+
if (O && O.dimensions[N]) {
|
|
2990
|
+
const C = O.dimensions[N];
|
|
2863
2991
|
A[t] = {
|
|
2864
|
-
title: C.title ||
|
|
2865
|
-
shortTitle: C.title ||
|
|
2992
|
+
title: C.title || N,
|
|
2993
|
+
shortTitle: C.title || N,
|
|
2866
2994
|
type: C.type
|
|
2867
2995
|
};
|
|
2868
2996
|
}
|
|
2869
2997
|
}
|
|
2870
2998
|
if (T.timeDimensions)
|
|
2871
2999
|
for (const t of T.timeDimensions) {
|
|
2872
|
-
const [s,
|
|
2873
|
-
if (
|
|
2874
|
-
const C =
|
|
3000
|
+
const [s, N] = t.dimension.split("."), O = I.find((C) => C.name === s);
|
|
3001
|
+
if (O && O.dimensions && O.dimensions[N]) {
|
|
3002
|
+
const C = O.dimensions[N];
|
|
2875
3003
|
S[t.dimension] = {
|
|
2876
|
-
title: C.title ||
|
|
2877
|
-
shortTitle: C.title ||
|
|
3004
|
+
title: C.title || N,
|
|
3005
|
+
shortTitle: C.title || N,
|
|
2878
3006
|
type: C.type,
|
|
2879
3007
|
granularity: t.granularity
|
|
2880
3008
|
};
|
|
@@ -2888,7 +3016,7 @@ class LE {
|
|
|
2888
3016
|
};
|
|
2889
3017
|
}
|
|
2890
3018
|
}
|
|
2891
|
-
const
|
|
3019
|
+
const L = (e) => e.flatMap(Me), Me = (e) => z(ce(e)).map(Ue), Ue = (e) => e.replace(/ +/g, " ").trim(), ce = (e) => ({
|
|
2892
3020
|
type: "mandatory_block",
|
|
2893
3021
|
items: yE(e, 0)[0]
|
|
2894
3022
|
}), yE = (e, E, T) => {
|
|
@@ -2936,17 +3064,17 @@ const r = (e) => e.flatMap(Me), Me = (e) => k(ce(e)).map(Ue), Ue = (e) => e.repl
|
|
|
2936
3064
|
}, He = (e, E) => {
|
|
2937
3065
|
const [T, R] = yE(e, E, "]");
|
|
2938
3066
|
return [{ type: "optional_block", items: T }, R];
|
|
2939
|
-
},
|
|
3067
|
+
}, z = (e) => {
|
|
2940
3068
|
if (typeof e == "string")
|
|
2941
3069
|
return [e];
|
|
2942
3070
|
if (e.type === "concatenation")
|
|
2943
|
-
return e.items.map(
|
|
3071
|
+
return e.items.map(z).reduce(me, [""]);
|
|
2944
3072
|
if (e.type === "mandatory_block")
|
|
2945
|
-
return e.items.flatMap(
|
|
3073
|
+
return e.items.flatMap(z);
|
|
2946
3074
|
if (e.type === "optional_block")
|
|
2947
|
-
return ["", ...e.items.flatMap(
|
|
3075
|
+
return ["", ...e.items.flatMap(z)];
|
|
2948
3076
|
throw new Error(`Unknown node type: ${e}`);
|
|
2949
|
-
},
|
|
3077
|
+
}, me = (e, E) => {
|
|
2950
3078
|
const T = [];
|
|
2951
3079
|
for (const R of e)
|
|
2952
3080
|
for (const A of E)
|
|
@@ -2969,7 +3097,7 @@ const pT = (e) => ({
|
|
|
2969
3097
|
STRUCT: w({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
|
|
2970
3098
|
WINDOW: w({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
|
|
2971
3099
|
VALUES: w({ text: "VALUES", type: D.RESERVED_CLAUSE })
|
|
2972
|
-
}, FT = (e) => e === D.RESERVED_DATA_TYPE || e === D.RESERVED_KEYWORD || e === D.RESERVED_FUNCTION_NAME || e === D.RESERVED_KEYWORD_PHRASE || e === D.RESERVED_DATA_TYPE_PHRASE || e === D.RESERVED_CLAUSE || e === D.RESERVED_SELECT || e === D.RESERVED_SET_OPERATION || e === D.RESERVED_JOIN || e === D.ARRAY_KEYWORD || e === D.CASE || e === D.END || e === D.WHEN || e === D.ELSE || e === D.THEN || e === D.LIMIT || e === D.BETWEEN || e === D.AND || e === D.OR || e === D.XOR,
|
|
3100
|
+
}, FT = (e) => e === D.RESERVED_DATA_TYPE || e === D.RESERVED_KEYWORD || e === D.RESERVED_FUNCTION_NAME || e === D.RESERVED_KEYWORD_PHRASE || e === D.RESERVED_DATA_TYPE_PHRASE || e === D.RESERVED_CLAUSE || e === D.RESERVED_SELECT || e === D.RESERVED_SET_OPERATION || e === D.RESERVED_JOIN || e === D.ARRAY_KEYWORD || e === D.CASE || e === D.END || e === D.WHEN || e === D.ELSE || e === D.THEN || e === D.LIMIT || e === D.BETWEEN || e === D.AND || e === D.OR || e === D.XOR, Be = (e) => e === D.AND || e === D.OR || e === D.XOR, de = [
|
|
2973
3101
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
2974
3102
|
"KEYS.NEW_KEYSET",
|
|
2975
3103
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -3646,7 +3774,7 @@ const pT = (e) => ({
|
|
|
3646
3774
|
"STRUCT",
|
|
3647
3775
|
"TIME",
|
|
3648
3776
|
"TIMEZONE"
|
|
3649
|
-
], Ye =
|
|
3777
|
+
], Ye = L(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), he = L([
|
|
3650
3778
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
3651
3779
|
"WITH [RECURSIVE]",
|
|
3652
3780
|
"FROM",
|
|
@@ -3675,9 +3803,9 @@ const pT = (e) => ({
|
|
|
3675
3803
|
"WITH CONNECTION",
|
|
3676
3804
|
"WITH PARTITION COLUMNS",
|
|
3677
3805
|
"REMOTE WITH CONNECTION"
|
|
3678
|
-
]), jE =
|
|
3806
|
+
]), jE = L([
|
|
3679
3807
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3680
|
-
]),
|
|
3808
|
+
]), rE = L([
|
|
3681
3809
|
// - create:
|
|
3682
3810
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
3683
3811
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -3765,15 +3893,15 @@ const pT = (e) => ({
|
|
|
3765
3893
|
"ASSERT",
|
|
3766
3894
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
3767
3895
|
"EXPORT DATA"
|
|
3768
|
-
]), fe =
|
|
3896
|
+
]), fe = L([
|
|
3769
3897
|
"UNION {ALL | DISTINCT}",
|
|
3770
3898
|
"EXCEPT DISTINCT",
|
|
3771
3899
|
"INTERSECT DISTINCT"
|
|
3772
|
-
]), Ve =
|
|
3900
|
+
]), Ve = L([
|
|
3773
3901
|
"JOIN",
|
|
3774
3902
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3775
3903
|
"{INNER | CROSS} JOIN"
|
|
3776
|
-
]), We =
|
|
3904
|
+
]), We = L([
|
|
3777
3905
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
3778
3906
|
"TABLESAMPLE SYSTEM",
|
|
3779
3907
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -3784,11 +3912,11 @@ const pT = (e) => ({
|
|
|
3784
3912
|
"{ROWS | RANGE} BETWEEN",
|
|
3785
3913
|
// comparison operator
|
|
3786
3914
|
"IS [NOT] DISTINCT FROM"
|
|
3787
|
-
]), be =
|
|
3915
|
+
]), be = L([]), Xe = {
|
|
3788
3916
|
name: "bigquery",
|
|
3789
3917
|
tokenizerOptions: {
|
|
3790
3918
|
reservedSelect: Ye,
|
|
3791
|
-
reservedClauses: [...he, ...
|
|
3919
|
+
reservedClauses: [...he, ...rE, ...jE],
|
|
3792
3920
|
reservedSetOperations: fe,
|
|
3793
3921
|
reservedJoins: Ve,
|
|
3794
3922
|
reservedKeywordPhrases: We,
|
|
@@ -3816,8 +3944,8 @@ const pT = (e) => ({
|
|
|
3816
3944
|
postProcess: ye
|
|
3817
3945
|
},
|
|
3818
3946
|
formatOptions: {
|
|
3819
|
-
onelineClauses: [...jE, ...
|
|
3820
|
-
tabularOnelineClauses:
|
|
3947
|
+
onelineClauses: [...jE, ...rE],
|
|
3948
|
+
tabularOnelineClauses: rE
|
|
3821
3949
|
}
|
|
3822
3950
|
};
|
|
3823
3951
|
function ye(e) {
|
|
@@ -4618,7 +4746,7 @@ const we = [
|
|
|
4618
4746
|
"VARBINARY",
|
|
4619
4747
|
"VARCHAR",
|
|
4620
4748
|
"VARGRAPHIC"
|
|
4621
|
-
], ve =
|
|
4749
|
+
], ve = L(["SELECT [ALL | DISTINCT]"]), Qe = L([
|
|
4622
4750
|
// queries
|
|
4623
4751
|
"WITH",
|
|
4624
4752
|
"FROM",
|
|
@@ -4647,9 +4775,9 @@ const we = [
|
|
|
4647
4775
|
"WHEN [NOT] MATCHED [THEN]",
|
|
4648
4776
|
"UPDATE SET",
|
|
4649
4777
|
"INSERT"
|
|
4650
|
-
]), kE =
|
|
4778
|
+
]), kE = L([
|
|
4651
4779
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
4652
|
-
]),
|
|
4780
|
+
]), LE = L([
|
|
4653
4781
|
// - create:
|
|
4654
4782
|
"CREATE [OR REPLACE] VIEW",
|
|
4655
4783
|
// - update:
|
|
@@ -4852,20 +4980,20 @@ const we = [
|
|
|
4852
4980
|
"TRANSFER OWNERSHIP OF",
|
|
4853
4981
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
4854
4982
|
"WHILE"
|
|
4855
|
-
]), Ze =
|
|
4983
|
+
]), Ze = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), je = L([
|
|
4856
4984
|
"JOIN",
|
|
4857
4985
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4858
4986
|
"{INNER | CROSS} JOIN"
|
|
4859
|
-
]), qe =
|
|
4987
|
+
]), qe = L([
|
|
4860
4988
|
"ON DELETE",
|
|
4861
4989
|
"ON UPDATE",
|
|
4862
4990
|
"SET NULL",
|
|
4863
4991
|
"{ROWS | RANGE} BETWEEN"
|
|
4864
|
-
]), ke =
|
|
4992
|
+
]), ke = L([]), ze = {
|
|
4865
4993
|
name: "db2",
|
|
4866
4994
|
tokenizerOptions: {
|
|
4867
4995
|
reservedSelect: ve,
|
|
4868
|
-
reservedClauses: [...Qe, ...kE, ...
|
|
4996
|
+
reservedClauses: [...Qe, ...kE, ...LE],
|
|
4869
4997
|
reservedSetOperations: Ze,
|
|
4870
4998
|
reservedJoins: je,
|
|
4871
4999
|
reservedKeywordPhrases: qe,
|
|
@@ -4903,8 +5031,8 @@ const we = [
|
|
|
4903
5031
|
]
|
|
4904
5032
|
},
|
|
4905
5033
|
formatOptions: {
|
|
4906
|
-
onelineClauses: [...kE, ...
|
|
4907
|
-
tabularOnelineClauses:
|
|
5034
|
+
onelineClauses: [...kE, ...LE],
|
|
5035
|
+
tabularOnelineClauses: LE
|
|
4908
5036
|
}
|
|
4909
5037
|
}, ER = [
|
|
4910
5038
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
@@ -5772,7 +5900,7 @@ const we = [
|
|
|
5772
5900
|
"VARCHAR",
|
|
5773
5901
|
"VARGRAPHIC",
|
|
5774
5902
|
"XML"
|
|
5775
|
-
], RR =
|
|
5903
|
+
], RR = L(["SELECT [ALL | DISTINCT]"]), AR = L([
|
|
5776
5904
|
// queries
|
|
5777
5905
|
"WITH [RECURSIVE]",
|
|
5778
5906
|
"INTO",
|
|
@@ -5802,7 +5930,7 @@ const we = [
|
|
|
5802
5930
|
"INSERT",
|
|
5803
5931
|
// Data definition - table
|
|
5804
5932
|
"FOR SYSTEM NAME"
|
|
5805
|
-
]), zE =
|
|
5933
|
+
]), zE = L(["CREATE [OR REPLACE] TABLE"]), _E = L([
|
|
5806
5934
|
// - create:
|
|
5807
5935
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
5808
5936
|
// - update:
|
|
@@ -5898,17 +6026,17 @@ const we = [
|
|
|
5898
6026
|
"TAG",
|
|
5899
6027
|
"TRANSFER OWNERSHIP OF",
|
|
5900
6028
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
5901
|
-
]), SR =
|
|
6029
|
+
]), SR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), IR = L([
|
|
5902
6030
|
"JOIN",
|
|
5903
6031
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5904
6032
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
5905
6033
|
"{INNER | CROSS} JOIN"
|
|
5906
|
-
]), NR =
|
|
6034
|
+
]), NR = L([
|
|
5907
6035
|
"ON DELETE",
|
|
5908
6036
|
"ON UPDATE",
|
|
5909
6037
|
"SET NULL",
|
|
5910
6038
|
"{ROWS | RANGE} BETWEEN"
|
|
5911
|
-
]), tR =
|
|
6039
|
+
]), tR = L([]), sR = {
|
|
5912
6040
|
name: "db2i",
|
|
5913
6041
|
tokenizerOptions: {
|
|
5914
6042
|
reservedSelect: RR,
|
|
@@ -6599,7 +6727,7 @@ const we = [
|
|
|
6599
6727
|
// 'NULL', we really prefer treating it as keyword
|
|
6600
6728
|
"RANK",
|
|
6601
6729
|
"ROW_NUMBER"
|
|
6602
|
-
],
|
|
6730
|
+
], nR = [
|
|
6603
6731
|
// Keywords from DuckDB:
|
|
6604
6732
|
// SELECT upper(keyword_name)
|
|
6605
6733
|
// FROM duckdb_keywords()
|
|
@@ -6681,7 +6809,7 @@ const we = [
|
|
|
6681
6809
|
"WHERE",
|
|
6682
6810
|
"WINDOW",
|
|
6683
6811
|
"WITH"
|
|
6684
|
-
],
|
|
6812
|
+
], rR = [
|
|
6685
6813
|
// Types from DuckDB:
|
|
6686
6814
|
// SELECT DISTINCT upper(type_name)
|
|
6687
6815
|
// FROM duckdb_types()
|
|
@@ -6761,7 +6889,7 @@ const we = [
|
|
|
6761
6889
|
"UUID",
|
|
6762
6890
|
"VARBINARY",
|
|
6763
6891
|
"VARCHAR"
|
|
6764
|
-
],
|
|
6892
|
+
], LR = L(["SELECT [ALL | DISTINCT]"]), _R = L([
|
|
6765
6893
|
// queries
|
|
6766
6894
|
"WITH [RECURSIVE]",
|
|
6767
6895
|
"FROM",
|
|
@@ -6785,9 +6913,9 @@ const we = [
|
|
|
6785
6913
|
"SET",
|
|
6786
6914
|
// other:
|
|
6787
6915
|
"RETURNING"
|
|
6788
|
-
]), ET =
|
|
6916
|
+
]), ET = L([
|
|
6789
6917
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
6790
|
-
]), iE =
|
|
6918
|
+
]), iE = L([
|
|
6791
6919
|
// TABLE
|
|
6792
6920
|
// - update:
|
|
6793
6921
|
"UPDATE",
|
|
@@ -6865,11 +6993,11 @@ const we = [
|
|
|
6865
6993
|
"PREPARE",
|
|
6866
6994
|
"EXECUTE",
|
|
6867
6995
|
"DEALLOCATE [PREPARE]"
|
|
6868
|
-
]), iR =
|
|
6996
|
+
]), iR = L([
|
|
6869
6997
|
"UNION [ALL | BY NAME]",
|
|
6870
6998
|
"EXCEPT [ALL]",
|
|
6871
6999
|
"INTERSECT [ALL]"
|
|
6872
|
-
]), aR =
|
|
7000
|
+
]), aR = L([
|
|
6873
7001
|
"JOIN",
|
|
6874
7002
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6875
7003
|
"{INNER | CROSS} JOIN",
|
|
@@ -6878,22 +7006,22 @@ const we = [
|
|
|
6878
7006
|
"POSITIONAL JOIN",
|
|
6879
7007
|
"ANTI JOIN",
|
|
6880
7008
|
"SEMI JOIN"
|
|
6881
|
-
]), oR =
|
|
7009
|
+
]), oR = L([
|
|
6882
7010
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
6883
7011
|
"SIMILAR TO",
|
|
6884
7012
|
"IS [NOT] DISTINCT FROM"
|
|
6885
|
-
]), DR =
|
|
7013
|
+
]), DR = L(["TIMESTAMP WITH TIME ZONE"]), PR = {
|
|
6886
7014
|
name: "duckdb",
|
|
6887
7015
|
tokenizerOptions: {
|
|
6888
|
-
reservedSelect:
|
|
7016
|
+
reservedSelect: LR,
|
|
6889
7017
|
reservedClauses: [..._R, ...ET, ...iE],
|
|
6890
7018
|
reservedSetOperations: iR,
|
|
6891
7019
|
reservedJoins: aR,
|
|
6892
7020
|
reservedKeywordPhrases: oR,
|
|
6893
7021
|
reservedDataTypePhrases: DR,
|
|
6894
7022
|
supportsXor: !0,
|
|
6895
|
-
reservedKeywords:
|
|
6896
|
-
reservedDataTypes:
|
|
7023
|
+
reservedKeywords: nR,
|
|
7024
|
+
reservedDataTypes: rR,
|
|
6897
7025
|
reservedFunctionNames: CR,
|
|
6898
7026
|
nestedBlockComments: !0,
|
|
6899
7027
|
extraParens: ["[]", "{}"],
|
|
@@ -7502,7 +7630,7 @@ const we = [
|
|
|
7502
7630
|
"STRUCT",
|
|
7503
7631
|
"TIMESTAMP",
|
|
7504
7632
|
"VARCHAR"
|
|
7505
|
-
], lR =
|
|
7633
|
+
], lR = L(["SELECT [ALL | DISTINCT]"]), uR = L([
|
|
7506
7634
|
// queries
|
|
7507
7635
|
"WITH",
|
|
7508
7636
|
"FROM",
|
|
@@ -7536,9 +7664,9 @@ const we = [
|
|
|
7536
7664
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
7537
7665
|
"LOAD DATA [LOCAL] INPATH",
|
|
7538
7666
|
"[OVERWRITE] INTO TABLE"
|
|
7539
|
-
]), TT =
|
|
7667
|
+
]), TT = L([
|
|
7540
7668
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
7541
|
-
]), aE =
|
|
7669
|
+
]), aE = L([
|
|
7542
7670
|
// - create:
|
|
7543
7671
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
7544
7672
|
// - update:
|
|
@@ -7563,21 +7691,21 @@ const we = [
|
|
|
7563
7691
|
"STORED AS",
|
|
7564
7692
|
"STORED BY",
|
|
7565
7693
|
"ROW FORMAT"
|
|
7566
|
-
]), GR =
|
|
7694
|
+
]), GR = L(["UNION [ALL | DISTINCT]"]), HR = L([
|
|
7567
7695
|
"JOIN",
|
|
7568
7696
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
7569
7697
|
"{INNER | CROSS} JOIN",
|
|
7570
7698
|
// non-standard joins
|
|
7571
7699
|
"LEFT SEMI JOIN"
|
|
7572
|
-
]),
|
|
7700
|
+
]), mR = L(["{ROWS | RANGE} BETWEEN"]), BR = L([]), dR = {
|
|
7573
7701
|
name: "hive",
|
|
7574
7702
|
tokenizerOptions: {
|
|
7575
7703
|
reservedSelect: lR,
|
|
7576
7704
|
reservedClauses: [...uR, ...TT, ...aE],
|
|
7577
7705
|
reservedSetOperations: GR,
|
|
7578
7706
|
reservedJoins: HR,
|
|
7579
|
-
reservedKeywordPhrases:
|
|
7580
|
-
reservedDataTypePhrases:
|
|
7707
|
+
reservedKeywordPhrases: mR,
|
|
7708
|
+
reservedDataTypePhrases: BR,
|
|
7581
7709
|
reservedKeywords: UR,
|
|
7582
7710
|
reservedDataTypes: cR,
|
|
7583
7711
|
reservedFunctionNames: MR,
|
|
@@ -7592,7 +7720,7 @@ const we = [
|
|
|
7592
7720
|
tabularOnelineClauses: aE
|
|
7593
7721
|
}
|
|
7594
7722
|
};
|
|
7595
|
-
function
|
|
7723
|
+
function AE(e) {
|
|
7596
7724
|
return e.map((E, T) => {
|
|
7597
7725
|
const R = e[T + 1] || v;
|
|
7598
7726
|
if (y.SET(E) && R.text === "(")
|
|
@@ -8107,7 +8235,7 @@ const pR = [
|
|
|
8107
8235
|
// CASE expression shorthands
|
|
8108
8236
|
"COALESCE",
|
|
8109
8237
|
"NULLIF"
|
|
8110
|
-
], hR =
|
|
8238
|
+
], hR = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fR = L([
|
|
8111
8239
|
// queries
|
|
8112
8240
|
"WITH [RECURSIVE]",
|
|
8113
8241
|
"FROM",
|
|
@@ -8129,9 +8257,9 @@ const pR = [
|
|
|
8129
8257
|
"SET",
|
|
8130
8258
|
// other
|
|
8131
8259
|
"RETURNING"
|
|
8132
|
-
]), eT =
|
|
8260
|
+
]), eT = L([
|
|
8133
8261
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
8134
|
-
]), oE =
|
|
8262
|
+
]), oE = L([
|
|
8135
8263
|
// - create:
|
|
8136
8264
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8137
8265
|
// - update:
|
|
@@ -8338,12 +8466,12 @@ const pR = [
|
|
|
8338
8466
|
"XA RECOVER",
|
|
8339
8467
|
"XA ROLLBACK",
|
|
8340
8468
|
"XA START"
|
|
8341
|
-
]), VR =
|
|
8469
|
+
]), VR = L([
|
|
8342
8470
|
"UNION [ALL | DISTINCT]",
|
|
8343
8471
|
"EXCEPT [ALL | DISTINCT]",
|
|
8344
8472
|
"INTERSECT [ALL | DISTINCT]",
|
|
8345
8473
|
"MINUS [ALL | DISTINCT]"
|
|
8346
|
-
]), WR =
|
|
8474
|
+
]), WR = L([
|
|
8347
8475
|
"JOIN",
|
|
8348
8476
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8349
8477
|
"{INNER | CROSS} JOIN",
|
|
@@ -8351,12 +8479,12 @@ const pR = [
|
|
|
8351
8479
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8352
8480
|
// non-standard joins
|
|
8353
8481
|
"STRAIGHT_JOIN"
|
|
8354
|
-
]), bR =
|
|
8482
|
+
]), bR = L([
|
|
8355
8483
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
8356
8484
|
"CHARACTER SET",
|
|
8357
8485
|
"{ROWS | RANGE} BETWEEN",
|
|
8358
8486
|
"IDENTIFIED BY"
|
|
8359
|
-
]), XR =
|
|
8487
|
+
]), XR = L([]), yR = {
|
|
8360
8488
|
name: "mariadb",
|
|
8361
8489
|
tokenizerOptions: {
|
|
8362
8490
|
reservedSelect: hR,
|
|
@@ -8401,7 +8529,7 @@ const pR = [
|
|
|
8401
8529
|
"*.*"
|
|
8402
8530
|
// Not actually an operator
|
|
8403
8531
|
],
|
|
8404
|
-
postProcess:
|
|
8532
|
+
postProcess: AE
|
|
8405
8533
|
},
|
|
8406
8534
|
formatOptions: {
|
|
8407
8535
|
onelineClauses: [...eT, ...oE],
|
|
@@ -9113,7 +9241,7 @@ const pR = [
|
|
|
9113
9241
|
// 'XOR',
|
|
9114
9242
|
"YEAR",
|
|
9115
9243
|
"YEARWEEK"
|
|
9116
|
-
], wR =
|
|
9244
|
+
], wR = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JR = L([
|
|
9117
9245
|
// queries
|
|
9118
9246
|
"WITH [RECURSIVE]",
|
|
9119
9247
|
"FROM",
|
|
@@ -9133,7 +9261,7 @@ const pR = [
|
|
|
9133
9261
|
"ON DUPLICATE KEY UPDATE",
|
|
9134
9262
|
// - update:
|
|
9135
9263
|
"SET"
|
|
9136
|
-
]), RT =
|
|
9264
|
+
]), RT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = L([
|
|
9137
9265
|
// - create:
|
|
9138
9266
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9139
9267
|
// - update:
|
|
@@ -9314,7 +9442,7 @@ const pR = [
|
|
|
9314
9442
|
"REPEAT",
|
|
9315
9443
|
"RETURN",
|
|
9316
9444
|
"WHILE"
|
|
9317
|
-
]), xR =
|
|
9445
|
+
]), xR = L(["UNION [ALL | DISTINCT]"]), vR = L([
|
|
9318
9446
|
"JOIN",
|
|
9319
9447
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9320
9448
|
"{INNER | CROSS} JOIN",
|
|
@@ -9322,12 +9450,12 @@ const pR = [
|
|
|
9322
9450
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9323
9451
|
// non-standard joins
|
|
9324
9452
|
"STRAIGHT_JOIN"
|
|
9325
|
-
]), QR =
|
|
9453
|
+
]), QR = L([
|
|
9326
9454
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9327
9455
|
"CHARACTER SET",
|
|
9328
9456
|
"{ROWS | RANGE} BETWEEN",
|
|
9329
9457
|
"IDENTIFIED BY"
|
|
9330
|
-
]), ZR =
|
|
9458
|
+
]), ZR = L([]), jR = {
|
|
9331
9459
|
name: "mysql",
|
|
9332
9460
|
tokenizerOptions: {
|
|
9333
9461
|
reservedSelect: wR,
|
|
@@ -9374,7 +9502,7 @@ const pR = [
|
|
|
9374
9502
|
"*.*"
|
|
9375
9503
|
// Not actually an operator
|
|
9376
9504
|
],
|
|
9377
|
-
postProcess:
|
|
9505
|
+
postProcess: AE
|
|
9378
9506
|
},
|
|
9379
9507
|
formatOptions: {
|
|
9380
9508
|
onelineClauses: [...RT, ...DE],
|
|
@@ -9945,7 +10073,7 @@ const pR = [
|
|
|
9945
10073
|
// 'XOR',
|
|
9946
10074
|
"YEAR",
|
|
9947
10075
|
"YEARWEEK"
|
|
9948
|
-
], EA =
|
|
10076
|
+
], EA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), TA = L([
|
|
9949
10077
|
// queries
|
|
9950
10078
|
"WITH [RECURSIVE]",
|
|
9951
10079
|
"FROM",
|
|
@@ -9965,7 +10093,7 @@ const pR = [
|
|
|
9965
10093
|
"ON DUPLICATE KEY UPDATE",
|
|
9966
10094
|
// - update:
|
|
9967
10095
|
"SET"
|
|
9968
|
-
]), AT =
|
|
10096
|
+
]), AT = L(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), PE = L([
|
|
9969
10097
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
9970
10098
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9971
10099
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -10080,7 +10208,7 @@ const pR = [
|
|
|
10080
10208
|
"UNLOCK TABLES",
|
|
10081
10209
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
10082
10210
|
"USE"
|
|
10083
|
-
]), eA =
|
|
10211
|
+
]), eA = L(["UNION [ALL | DISTINCT]"]), RA = L([
|
|
10084
10212
|
"JOIN",
|
|
10085
10213
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
10086
10214
|
"{INNER | CROSS} JOIN",
|
|
@@ -10088,12 +10216,12 @@ const pR = [
|
|
|
10088
10216
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
10089
10217
|
// non-standard joins
|
|
10090
10218
|
"STRAIGHT_JOIN"
|
|
10091
|
-
]), AA =
|
|
10219
|
+
]), AA = L([
|
|
10092
10220
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10093
10221
|
"CHARACTER SET",
|
|
10094
10222
|
"{ROWS | RANGE} BETWEEN",
|
|
10095
10223
|
"IDENTIFIED BY"
|
|
10096
|
-
]), SA =
|
|
10224
|
+
]), SA = L([]), IA = {
|
|
10097
10225
|
name: "tidb",
|
|
10098
10226
|
tokenizerOptions: {
|
|
10099
10227
|
reservedSelect: EA,
|
|
@@ -10140,13 +10268,13 @@ const pR = [
|
|
|
10140
10268
|
"*.*"
|
|
10141
10269
|
// Not actually an operator
|
|
10142
10270
|
],
|
|
10143
|
-
postProcess:
|
|
10271
|
+
postProcess: AE
|
|
10144
10272
|
},
|
|
10145
10273
|
formatOptions: {
|
|
10146
10274
|
onelineClauses: [...AT, ...PE],
|
|
10147
10275
|
tabularOnelineClauses: PE
|
|
10148
10276
|
}
|
|
10149
|
-
},
|
|
10277
|
+
}, NA = [
|
|
10150
10278
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
10151
10279
|
"ABORT",
|
|
10152
10280
|
"ABS",
|
|
@@ -10376,7 +10504,7 @@ const pR = [
|
|
|
10376
10504
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
10377
10505
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
10378
10506
|
"CAST"
|
|
10379
|
-
],
|
|
10507
|
+
], OA = [
|
|
10380
10508
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
10381
10509
|
"ADVISE",
|
|
10382
10510
|
"ALL",
|
|
@@ -10591,7 +10719,7 @@ const pR = [
|
|
|
10591
10719
|
// which it actually doesn't use.
|
|
10592
10720
|
//
|
|
10593
10721
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
10594
|
-
], sA =
|
|
10722
|
+
], sA = L(["SELECT [ALL | DISTINCT]"]), CA = L([
|
|
10595
10723
|
// queries
|
|
10596
10724
|
"WITH",
|
|
10597
10725
|
"FROM",
|
|
@@ -10618,7 +10746,7 @@ const pR = [
|
|
|
10618
10746
|
"NEST",
|
|
10619
10747
|
"UNNEST",
|
|
10620
10748
|
"RETURNING"
|
|
10621
|
-
]), ST =
|
|
10749
|
+
]), ST = L([
|
|
10622
10750
|
// - update:
|
|
10623
10751
|
"UPDATE",
|
|
10624
10752
|
// - delete:
|
|
@@ -10658,19 +10786,19 @@ const pR = [
|
|
|
10658
10786
|
"SET CURRENT SCHEMA",
|
|
10659
10787
|
"SHOW",
|
|
10660
10788
|
"USE [PRIMARY] KEYS"
|
|
10661
|
-
]),
|
|
10789
|
+
]), nA = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), rA = L(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), LA = L(["{ROWS | RANGE | GROUPS} BETWEEN"]), _A = L([]), iA = {
|
|
10662
10790
|
name: "n1ql",
|
|
10663
10791
|
tokenizerOptions: {
|
|
10664
10792
|
reservedSelect: sA,
|
|
10665
10793
|
reservedClauses: [...CA, ...ST],
|
|
10666
|
-
reservedSetOperations:
|
|
10667
|
-
reservedJoins:
|
|
10668
|
-
reservedKeywordPhrases:
|
|
10794
|
+
reservedSetOperations: nA,
|
|
10795
|
+
reservedJoins: rA,
|
|
10796
|
+
reservedKeywordPhrases: LA,
|
|
10669
10797
|
reservedDataTypePhrases: _A,
|
|
10670
10798
|
supportsXor: !0,
|
|
10671
|
-
reservedKeywords:
|
|
10799
|
+
reservedKeywords: OA,
|
|
10672
10800
|
reservedDataTypes: tA,
|
|
10673
|
-
reservedFunctionNames:
|
|
10801
|
+
reservedFunctionNames: NA,
|
|
10674
10802
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
10675
10803
|
// but we support them anyway as all other SQL dialects do,
|
|
10676
10804
|
// which simplifies writing tests that are shared between all dialects.
|
|
@@ -11292,7 +11420,7 @@ const pR = [
|
|
|
11292
11420
|
"PRESENTNNV",
|
|
11293
11421
|
"PRESENTV",
|
|
11294
11422
|
"PREVIOUS"
|
|
11295
|
-
], PA =
|
|
11423
|
+
], PA = L(["SELECT [ALL | DISTINCT | UNIQUE]"]), MA = L([
|
|
11296
11424
|
// queries
|
|
11297
11425
|
"WITH",
|
|
11298
11426
|
"FROM",
|
|
@@ -11316,9 +11444,9 @@ const pR = [
|
|
|
11316
11444
|
"UPDATE SET",
|
|
11317
11445
|
// other
|
|
11318
11446
|
"RETURNING"
|
|
11319
|
-
]), IT =
|
|
11447
|
+
]), IT = L([
|
|
11320
11448
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
11321
|
-
]), ME =
|
|
11449
|
+
]), ME = L([
|
|
11322
11450
|
// - create:
|
|
11323
11451
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
11324
11452
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -11346,7 +11474,7 @@ const pR = [
|
|
|
11346
11474
|
"EXCEPTION",
|
|
11347
11475
|
"LOOP",
|
|
11348
11476
|
"START WITH"
|
|
11349
|
-
]), UA =
|
|
11477
|
+
]), UA = L(["UNION [ALL]", "MINUS", "INTERSECT"]), cA = L([
|
|
11350
11478
|
"JOIN",
|
|
11351
11479
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11352
11480
|
"{INNER | CROSS} JOIN",
|
|
@@ -11354,11 +11482,11 @@ const pR = [
|
|
|
11354
11482
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11355
11483
|
// non-standard joins
|
|
11356
11484
|
"{CROSS | OUTER} APPLY"
|
|
11357
|
-
]), lA =
|
|
11485
|
+
]), lA = L([
|
|
11358
11486
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
11359
11487
|
"ON COMMIT",
|
|
11360
11488
|
"{ROWS | RANGE} BETWEEN"
|
|
11361
|
-
]), uA =
|
|
11489
|
+
]), uA = L([]), GA = {
|
|
11362
11490
|
name: "plsql",
|
|
11363
11491
|
tokenizerOptions: {
|
|
11364
11492
|
reservedSelect: PA,
|
|
@@ -11407,7 +11535,7 @@ function HA(e) {
|
|
|
11407
11535
|
let E = v;
|
|
11408
11536
|
return e.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: D.RESERVED_KEYWORD }) : (FT(T.type) && (E = T), T));
|
|
11409
11537
|
}
|
|
11410
|
-
const
|
|
11538
|
+
const mA = [
|
|
11411
11539
|
// https://www.postgresql.org/docs/14/functions.html
|
|
11412
11540
|
//
|
|
11413
11541
|
// https://www.postgresql.org/docs/14/functions-math.html
|
|
@@ -12095,7 +12223,7 @@ const BA = [
|
|
|
12095
12223
|
"PG_MCV_LIST_ITEMS",
|
|
12096
12224
|
// cast
|
|
12097
12225
|
"CAST"
|
|
12098
|
-
],
|
|
12226
|
+
], BA = [
|
|
12099
12227
|
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
|
|
12100
12228
|
"ALL",
|
|
12101
12229
|
"ANALYSE",
|
|
@@ -12248,7 +12376,7 @@ const BA = [
|
|
|
12248
12376
|
"VARCHAR",
|
|
12249
12377
|
"XML",
|
|
12250
12378
|
"ZONE"
|
|
12251
|
-
], pA =
|
|
12379
|
+
], pA = L(["SELECT [ALL | DISTINCT]"]), FA = L([
|
|
12252
12380
|
// queries
|
|
12253
12381
|
"WITH [RECURSIVE]",
|
|
12254
12382
|
"FROM",
|
|
@@ -12271,9 +12399,9 @@ const BA = [
|
|
|
12271
12399
|
"SET",
|
|
12272
12400
|
// other
|
|
12273
12401
|
"RETURNING"
|
|
12274
|
-
]),
|
|
12402
|
+
]), NT = L([
|
|
12275
12403
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
12276
|
-
]), UE =
|
|
12404
|
+
]), UE = L([
|
|
12277
12405
|
// - create
|
|
12278
12406
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
12279
12407
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -12472,17 +12600,17 @@ const BA = [
|
|
|
12472
12600
|
"START TRANSACTION",
|
|
12473
12601
|
"UNLISTEN",
|
|
12474
12602
|
"VACUUM"
|
|
12475
|
-
]), YA =
|
|
12603
|
+
]), YA = L([
|
|
12476
12604
|
"UNION [ALL | DISTINCT]",
|
|
12477
12605
|
"EXCEPT [ALL | DISTINCT]",
|
|
12478
12606
|
"INTERSECT [ALL | DISTINCT]"
|
|
12479
|
-
]), hA =
|
|
12607
|
+
]), hA = L([
|
|
12480
12608
|
"JOIN",
|
|
12481
12609
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12482
12610
|
"{INNER | CROSS} JOIN",
|
|
12483
12611
|
"NATURAL [INNER] JOIN",
|
|
12484
12612
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12485
|
-
]), fA =
|
|
12613
|
+
]), fA = L([
|
|
12486
12614
|
"PRIMARY KEY",
|
|
12487
12615
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
12488
12616
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -12493,21 +12621,21 @@ const BA = [
|
|
|
12493
12621
|
"IS [NOT] DISTINCT FROM",
|
|
12494
12622
|
"NULLS {FIRST | LAST}",
|
|
12495
12623
|
"WITH ORDINALITY"
|
|
12496
|
-
]), VA =
|
|
12624
|
+
]), VA = L([
|
|
12497
12625
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
12498
12626
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
12499
12627
|
]), WA = {
|
|
12500
12628
|
name: "postgresql",
|
|
12501
12629
|
tokenizerOptions: {
|
|
12502
12630
|
reservedSelect: pA,
|
|
12503
|
-
reservedClauses: [...FA, ...
|
|
12631
|
+
reservedClauses: [...FA, ...NT, ...UE],
|
|
12504
12632
|
reservedSetOperations: YA,
|
|
12505
12633
|
reservedJoins: hA,
|
|
12506
12634
|
reservedKeywordPhrases: fA,
|
|
12507
12635
|
reservedDataTypePhrases: VA,
|
|
12508
|
-
reservedKeywords:
|
|
12636
|
+
reservedKeywords: BA,
|
|
12509
12637
|
reservedDataTypes: dA,
|
|
12510
|
-
reservedFunctionNames:
|
|
12638
|
+
reservedFunctionNames: mA,
|
|
12511
12639
|
nestedBlockComments: !0,
|
|
12512
12640
|
extraParens: ["[]"],
|
|
12513
12641
|
underscoresInNumbers: !0,
|
|
@@ -12619,7 +12747,7 @@ const BA = [
|
|
|
12619
12747
|
},
|
|
12620
12748
|
formatOptions: {
|
|
12621
12749
|
alwaysDenseOperators: ["::", ":"],
|
|
12622
|
-
onelineClauses: [...
|
|
12750
|
+
onelineClauses: [...NT, ...UE],
|
|
12623
12751
|
tabularOnelineClauses: UE
|
|
12624
12752
|
}
|
|
12625
12753
|
}, bA = [
|
|
@@ -13178,7 +13306,7 @@ const BA = [
|
|
|
13178
13306
|
"TEXT",
|
|
13179
13307
|
"VARBYTE",
|
|
13180
13308
|
"VARCHAR"
|
|
13181
|
-
], gA =
|
|
13309
|
+
], gA = L(["SELECT [ALL | DISTINCT]"]), KA = L([
|
|
13182
13310
|
// queries
|
|
13183
13311
|
"WITH [RECURSIVE]",
|
|
13184
13312
|
"FROM",
|
|
@@ -13196,9 +13324,9 @@ const BA = [
|
|
|
13196
13324
|
"VALUES",
|
|
13197
13325
|
// - update:
|
|
13198
13326
|
"SET"
|
|
13199
|
-
]),
|
|
13327
|
+
]), OT = L([
|
|
13200
13328
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
13201
|
-
]), cE =
|
|
13329
|
+
]), cE = L([
|
|
13202
13330
|
// - create:
|
|
13203
13331
|
"CREATE [OR REPLACE | MATERIALIZED] VIEW",
|
|
13204
13332
|
// - update:
|
|
@@ -13289,13 +13417,13 @@ const BA = [
|
|
|
13289
13417
|
"START TRANSACTION",
|
|
13290
13418
|
"UNLOAD",
|
|
13291
13419
|
"VACUUM"
|
|
13292
|
-
]), $A =
|
|
13420
|
+
]), $A = L(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), wA = L([
|
|
13293
13421
|
"JOIN",
|
|
13294
13422
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13295
13423
|
"{INNER | CROSS} JOIN",
|
|
13296
13424
|
"NATURAL [INNER] JOIN",
|
|
13297
13425
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13298
|
-
]), JA =
|
|
13426
|
+
]), JA = L([
|
|
13299
13427
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
13300
13428
|
"NULL AS",
|
|
13301
13429
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -13303,11 +13431,11 @@ const BA = [
|
|
|
13303
13431
|
"HIVE METASTORE",
|
|
13304
13432
|
// in window specifications
|
|
13305
13433
|
"{ROWS | RANGE} BETWEEN"
|
|
13306
|
-
]), xA =
|
|
13434
|
+
]), xA = L([]), vA = {
|
|
13307
13435
|
name: "redshift",
|
|
13308
13436
|
tokenizerOptions: {
|
|
13309
13437
|
reservedSelect: gA,
|
|
13310
|
-
reservedClauses: [...KA, ...
|
|
13438
|
+
reservedClauses: [...KA, ...OT, ...cE],
|
|
13311
13439
|
reservedSetOperations: $A,
|
|
13312
13440
|
reservedJoins: wA,
|
|
13313
13441
|
reservedKeywordPhrases: JA,
|
|
@@ -13338,7 +13466,7 @@ const BA = [
|
|
|
13338
13466
|
},
|
|
13339
13467
|
formatOptions: {
|
|
13340
13468
|
alwaysDenseOperators: ["::"],
|
|
13341
|
-
onelineClauses: [...
|
|
13469
|
+
onelineClauses: [...OT, ...cE],
|
|
13342
13470
|
tabularOnelineClauses: cE
|
|
13343
13471
|
}
|
|
13344
13472
|
}, QA = [
|
|
@@ -13959,7 +14087,7 @@ const BA = [
|
|
|
13959
14087
|
// Shorthand functions to use in place of CASE expression
|
|
13960
14088
|
"COALESCE",
|
|
13961
14089
|
"NULLIF"
|
|
13962
|
-
], qA =
|
|
14090
|
+
], qA = L(["SELECT [ALL | DISTINCT]"]), kA = L([
|
|
13963
14091
|
// queries
|
|
13964
14092
|
"WITH",
|
|
13965
14093
|
"FROM",
|
|
@@ -13984,7 +14112,7 @@ const BA = [
|
|
|
13984
14112
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
13985
14113
|
"LOAD DATA [LOCAL] INPATH",
|
|
13986
14114
|
"[OVERWRITE] INTO TABLE"
|
|
13987
|
-
]), tT =
|
|
14115
|
+
]), tT = L(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), lE = L([
|
|
13988
14116
|
// - create:
|
|
13989
14117
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
13990
14118
|
// - drop table:
|
|
@@ -14040,11 +14168,11 @@ const BA = [
|
|
|
14040
14168
|
"SHOW TBLPROPERTIES",
|
|
14041
14169
|
"SHOW VIEWS",
|
|
14042
14170
|
"UNCACHE TABLE"
|
|
14043
|
-
]), zA =
|
|
14171
|
+
]), zA = L([
|
|
14044
14172
|
"UNION [ALL | DISTINCT]",
|
|
14045
14173
|
"EXCEPT [ALL | DISTINCT]",
|
|
14046
14174
|
"INTERSECT [ALL | DISTINCT]"
|
|
14047
|
-
]), ES =
|
|
14175
|
+
]), ES = L([
|
|
14048
14176
|
"JOIN",
|
|
14049
14177
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14050
14178
|
"{INNER | CROSS} JOIN",
|
|
@@ -14053,12 +14181,12 @@ const BA = [
|
|
|
14053
14181
|
// non-standard-joins
|
|
14054
14182
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
14055
14183
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
14056
|
-
]), TS =
|
|
14184
|
+
]), TS = L([
|
|
14057
14185
|
"ON DELETE",
|
|
14058
14186
|
"ON UPDATE",
|
|
14059
14187
|
"CURRENT ROW",
|
|
14060
14188
|
"{ROWS | RANGE} BETWEEN"
|
|
14061
|
-
]), eS =
|
|
14189
|
+
]), eS = L([]), RS = {
|
|
14062
14190
|
name: "spark",
|
|
14063
14191
|
tokenizerOptions: {
|
|
14064
14192
|
reservedSelect: qA,
|
|
@@ -14372,7 +14500,7 @@ const SS = [
|
|
|
14372
14500
|
"WINDOW",
|
|
14373
14501
|
"WITH",
|
|
14374
14502
|
"WITHOUT"
|
|
14375
|
-
],
|
|
14503
|
+
], NS = [
|
|
14376
14504
|
// SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
|
|
14377
14505
|
// Here we just list some common ones as SQL Formatter
|
|
14378
14506
|
// is only able to detect a predefined list of data types.
|
|
@@ -14393,7 +14521,7 @@ const SS = [
|
|
|
14393
14521
|
"TEXT",
|
|
14394
14522
|
"VARCHAR",
|
|
14395
14523
|
"VARYING CHARACTER"
|
|
14396
|
-
],
|
|
14524
|
+
], OS = L(["SELECT [ALL | DISTINCT]"]), tS = L([
|
|
14397
14525
|
// queries
|
|
14398
14526
|
"WITH [RECURSIVE]",
|
|
14399
14527
|
"FROM",
|
|
@@ -14414,7 +14542,7 @@ const SS = [
|
|
|
14414
14542
|
"SET",
|
|
14415
14543
|
// other:
|
|
14416
14544
|
"RETURNING"
|
|
14417
|
-
]), sT =
|
|
14545
|
+
]), sT = L(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), uE = L([
|
|
14418
14546
|
// - create:
|
|
14419
14547
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
14420
14548
|
// - update:
|
|
@@ -14433,27 +14561,27 @@ const SS = [
|
|
|
14433
14561
|
"RENAME TO",
|
|
14434
14562
|
// - set schema
|
|
14435
14563
|
"SET SCHEMA"
|
|
14436
|
-
]), sS =
|
|
14564
|
+
]), sS = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), CS = L([
|
|
14437
14565
|
"JOIN",
|
|
14438
14566
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14439
14567
|
"{INNER | CROSS} JOIN",
|
|
14440
14568
|
"NATURAL [INNER] JOIN",
|
|
14441
14569
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14442
|
-
]),
|
|
14570
|
+
]), nS = L([
|
|
14443
14571
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14444
14572
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14445
14573
|
"DO UPDATE"
|
|
14446
|
-
]),
|
|
14574
|
+
]), rS = L([]), LS = {
|
|
14447
14575
|
name: "sqlite",
|
|
14448
14576
|
tokenizerOptions: {
|
|
14449
|
-
reservedSelect:
|
|
14577
|
+
reservedSelect: OS,
|
|
14450
14578
|
reservedClauses: [...tS, ...sT, ...uE],
|
|
14451
14579
|
reservedSetOperations: sS,
|
|
14452
14580
|
reservedJoins: CS,
|
|
14453
|
-
reservedKeywordPhrases:
|
|
14454
|
-
reservedDataTypePhrases:
|
|
14581
|
+
reservedKeywordPhrases: nS,
|
|
14582
|
+
reservedDataTypePhrases: rS,
|
|
14455
14583
|
reservedKeywords: IS,
|
|
14456
|
-
reservedDataTypes:
|
|
14584
|
+
reservedDataTypes: NS,
|
|
14457
14585
|
reservedFunctionNames: SS,
|
|
14458
14586
|
stringTypes: [
|
|
14459
14587
|
"''-qq",
|
|
@@ -14805,7 +14933,7 @@ const SS = [
|
|
|
14805
14933
|
"TIMESTAMP",
|
|
14806
14934
|
"VARBINARY",
|
|
14807
14935
|
"VARCHAR"
|
|
14808
|
-
], oS =
|
|
14936
|
+
], oS = L(["SELECT [ALL | DISTINCT]"]), DS = L([
|
|
14809
14937
|
// queries
|
|
14810
14938
|
"WITH [RECURSIVE]",
|
|
14811
14939
|
"FROM",
|
|
@@ -14824,7 +14952,7 @@ const SS = [
|
|
|
14824
14952
|
"VALUES",
|
|
14825
14953
|
// - update:
|
|
14826
14954
|
"SET"
|
|
14827
|
-
]), CT =
|
|
14955
|
+
]), CT = L(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), GE = L([
|
|
14828
14956
|
// - create:
|
|
14829
14957
|
"CREATE [RECURSIVE] VIEW",
|
|
14830
14958
|
// - update:
|
|
@@ -14849,20 +14977,20 @@ const SS = [
|
|
|
14849
14977
|
"TRUNCATE TABLE",
|
|
14850
14978
|
// other
|
|
14851
14979
|
"SET SCHEMA"
|
|
14852
|
-
]), PS =
|
|
14980
|
+
]), PS = L([
|
|
14853
14981
|
"UNION [ALL | DISTINCT]",
|
|
14854
14982
|
"EXCEPT [ALL | DISTINCT]",
|
|
14855
14983
|
"INTERSECT [ALL | DISTINCT]"
|
|
14856
|
-
]), MS =
|
|
14984
|
+
]), MS = L([
|
|
14857
14985
|
"JOIN",
|
|
14858
14986
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14859
14987
|
"{INNER | CROSS} JOIN",
|
|
14860
14988
|
"NATURAL [INNER] JOIN",
|
|
14861
14989
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14862
|
-
]), US =
|
|
14990
|
+
]), US = L([
|
|
14863
14991
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14864
14992
|
"{ROWS | RANGE} BETWEEN"
|
|
14865
|
-
]), cS =
|
|
14993
|
+
]), cS = L([]), lS = {
|
|
14866
14994
|
name: "sql",
|
|
14867
14995
|
tokenizerOptions: {
|
|
14868
14996
|
reservedSelect: oS,
|
|
@@ -15596,7 +15724,7 @@ const SS = [
|
|
|
15596
15724
|
"CODEPOINTS",
|
|
15597
15725
|
"FUNCTION",
|
|
15598
15726
|
"JSONPATH"
|
|
15599
|
-
],
|
|
15727
|
+
], mS = L(["SELECT [ALL | DISTINCT]"]), BS = L([
|
|
15600
15728
|
// queries
|
|
15601
15729
|
"WITH [RECURSIVE]",
|
|
15602
15730
|
"FROM",
|
|
@@ -15624,7 +15752,7 @@ const SS = [
|
|
|
15624
15752
|
"PATTERN",
|
|
15625
15753
|
"SUBSET",
|
|
15626
15754
|
"DEFINE"
|
|
15627
|
-
]),
|
|
15755
|
+
]), nT = L(["CREATE TABLE [IF NOT EXISTS]"]), HE = L([
|
|
15628
15756
|
// - create:
|
|
15629
15757
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
15630
15758
|
// - update:
|
|
@@ -15682,25 +15810,25 @@ const SS = [
|
|
|
15682
15810
|
"SHOW ROLE GRANTS",
|
|
15683
15811
|
"SHOW FUNCTIONS",
|
|
15684
15812
|
"SHOW SESSION"
|
|
15685
|
-
]), dS =
|
|
15813
|
+
]), dS = L([
|
|
15686
15814
|
"UNION [ALL | DISTINCT]",
|
|
15687
15815
|
"EXCEPT [ALL | DISTINCT]",
|
|
15688
15816
|
"INTERSECT [ALL | DISTINCT]"
|
|
15689
|
-
]), pS =
|
|
15817
|
+
]), pS = L([
|
|
15690
15818
|
"JOIN",
|
|
15691
15819
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15692
15820
|
"{INNER | CROSS} JOIN",
|
|
15693
15821
|
"NATURAL [INNER] JOIN",
|
|
15694
15822
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
15695
|
-
]), FS =
|
|
15823
|
+
]), FS = L([
|
|
15696
15824
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
15697
15825
|
// comparison operator
|
|
15698
15826
|
"IS [NOT] DISTINCT FROM"
|
|
15699
|
-
]), YS =
|
|
15827
|
+
]), YS = L([]), hS = {
|
|
15700
15828
|
name: "trino",
|
|
15701
15829
|
tokenizerOptions: {
|
|
15702
|
-
reservedSelect:
|
|
15703
|
-
reservedClauses: [...
|
|
15830
|
+
reservedSelect: mS,
|
|
15831
|
+
reservedClauses: [...BS, ...nT, ...HE],
|
|
15704
15832
|
reservedSetOperations: dS,
|
|
15705
15833
|
reservedJoins: pS,
|
|
15706
15834
|
reservedKeywordPhrases: FS,
|
|
@@ -15736,7 +15864,7 @@ const SS = [
|
|
|
15736
15864
|
]
|
|
15737
15865
|
},
|
|
15738
15866
|
formatOptions: {
|
|
15739
|
-
onelineClauses: [...
|
|
15867
|
+
onelineClauses: [...nT, ...HE],
|
|
15740
15868
|
tabularOnelineClauses: HE
|
|
15741
15869
|
}
|
|
15742
15870
|
}, fS = [
|
|
@@ -16252,7 +16380,7 @@ const SS = [
|
|
|
16252
16380
|
"TIMESTAMP",
|
|
16253
16381
|
"VARBINARY",
|
|
16254
16382
|
"VARCHAR"
|
|
16255
|
-
], bS =
|
|
16383
|
+
], bS = L(["SELECT [ALL | DISTINCT]"]), XS = L([
|
|
16256
16384
|
// queries
|
|
16257
16385
|
"WITH",
|
|
16258
16386
|
"INTO",
|
|
@@ -16277,7 +16405,7 @@ const SS = [
|
|
|
16277
16405
|
"MERGE [INTO]",
|
|
16278
16406
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
16279
16407
|
"UPDATE SET"
|
|
16280
|
-
]),
|
|
16408
|
+
]), rT = L(["CREATE TABLE"]), mE = L([
|
|
16281
16409
|
// - create:
|
|
16282
16410
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
16283
16411
|
// - update:
|
|
@@ -16457,20 +16585,20 @@ const SS = [
|
|
|
16457
16585
|
"XACT_ABORT",
|
|
16458
16586
|
"XML INDEX",
|
|
16459
16587
|
"XML SCHEMA COLLECTION"
|
|
16460
|
-
]), yS =
|
|
16588
|
+
]), yS = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), gS = L([
|
|
16461
16589
|
"JOIN",
|
|
16462
16590
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16463
16591
|
"{INNER | CROSS} JOIN",
|
|
16464
16592
|
// non-standard joins
|
|
16465
16593
|
"{CROSS | OUTER} APPLY"
|
|
16466
|
-
]), KS =
|
|
16594
|
+
]), KS = L([
|
|
16467
16595
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
16468
16596
|
"{ROWS | RANGE} BETWEEN"
|
|
16469
|
-
]), $S =
|
|
16597
|
+
]), $S = L([]), wS = {
|
|
16470
16598
|
name: "transactsql",
|
|
16471
16599
|
tokenizerOptions: {
|
|
16472
16600
|
reservedSelect: bS,
|
|
16473
|
-
reservedClauses: [...XS, ...
|
|
16601
|
+
reservedClauses: [...XS, ...rT, ...mE],
|
|
16474
16602
|
reservedSetOperations: yS,
|
|
16475
16603
|
reservedJoins: gS,
|
|
16476
16604
|
reservedKeywordPhrases: KS,
|
|
@@ -16507,8 +16635,8 @@ const SS = [
|
|
|
16507
16635
|
},
|
|
16508
16636
|
formatOptions: {
|
|
16509
16637
|
alwaysDenseOperators: ["::"],
|
|
16510
|
-
onelineClauses: [...
|
|
16511
|
-
tabularOnelineClauses:
|
|
16638
|
+
onelineClauses: [...rT, ...mE],
|
|
16639
|
+
tabularOnelineClauses: mE
|
|
16512
16640
|
}
|
|
16513
16641
|
}, JS = [
|
|
16514
16642
|
// List of all keywords taken from:
|
|
@@ -17052,7 +17180,7 @@ const SS = [
|
|
|
17052
17180
|
"WEEKDAY",
|
|
17053
17181
|
"WEEKOFYEAR",
|
|
17054
17182
|
"YEAR"
|
|
17055
|
-
], QS =
|
|
17183
|
+
], QS = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), ZS = L([
|
|
17056
17184
|
// queries
|
|
17057
17185
|
"WITH",
|
|
17058
17186
|
"FROM",
|
|
@@ -17074,9 +17202,9 @@ const SS = [
|
|
|
17074
17202
|
// Data definition
|
|
17075
17203
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
17076
17204
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
17077
|
-
]),
|
|
17205
|
+
]), LT = L([
|
|
17078
17206
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
17079
|
-
]),
|
|
17207
|
+
]), BE = L([
|
|
17080
17208
|
// - create:
|
|
17081
17209
|
"CREATE VIEW",
|
|
17082
17210
|
// - update:
|
|
@@ -17253,29 +17381,29 @@ const SS = [
|
|
|
17253
17381
|
"REPEAT",
|
|
17254
17382
|
"RETURN",
|
|
17255
17383
|
"WHILE"
|
|
17256
|
-
]), jS =
|
|
17384
|
+
]), jS = L([
|
|
17257
17385
|
"UNION [ALL | DISTINCT]",
|
|
17258
17386
|
"EXCEPT",
|
|
17259
17387
|
"INTERSECT",
|
|
17260
17388
|
"MINUS"
|
|
17261
|
-
]), qS =
|
|
17389
|
+
]), qS = L([
|
|
17262
17390
|
"JOIN",
|
|
17263
17391
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17264
17392
|
"{INNER | CROSS} JOIN",
|
|
17265
17393
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
17266
17394
|
// non-standard joins
|
|
17267
17395
|
"STRAIGHT_JOIN"
|
|
17268
|
-
]), kS =
|
|
17396
|
+
]), kS = L([
|
|
17269
17397
|
"ON DELETE",
|
|
17270
17398
|
"ON UPDATE",
|
|
17271
17399
|
"CHARACTER SET",
|
|
17272
17400
|
"{ROWS | RANGE} BETWEEN",
|
|
17273
17401
|
"IDENTIFIED BY"
|
|
17274
|
-
]), zS =
|
|
17402
|
+
]), zS = L([]), EI = {
|
|
17275
17403
|
name: "singlestoredb",
|
|
17276
17404
|
tokenizerOptions: {
|
|
17277
17405
|
reservedSelect: QS,
|
|
17278
|
-
reservedClauses: [...ZS, ...
|
|
17406
|
+
reservedClauses: [...ZS, ...LT, ...BE],
|
|
17279
17407
|
reservedSetOperations: jS,
|
|
17280
17408
|
reservedJoins: qS,
|
|
17281
17409
|
reservedKeywordPhrases: kS,
|
|
@@ -17315,12 +17443,12 @@ const SS = [
|
|
|
17315
17443
|
"*.*"
|
|
17316
17444
|
// Not actually an operator
|
|
17317
17445
|
],
|
|
17318
|
-
postProcess:
|
|
17446
|
+
postProcess: AE
|
|
17319
17447
|
},
|
|
17320
17448
|
formatOptions: {
|
|
17321
17449
|
alwaysDenseOperators: ["::", "::$", "::%"],
|
|
17322
|
-
onelineClauses: [...
|
|
17323
|
-
tabularOnelineClauses:
|
|
17450
|
+
onelineClauses: [...LT, ...BE],
|
|
17451
|
+
tabularOnelineClauses: BE
|
|
17324
17452
|
}
|
|
17325
17453
|
}, TI = [
|
|
17326
17454
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
@@ -18064,7 +18192,7 @@ const SS = [
|
|
|
18064
18192
|
"ARRAY",
|
|
18065
18193
|
"GEOGRAPHY",
|
|
18066
18194
|
"GEOMETRY"
|
|
18067
|
-
], AI =
|
|
18195
|
+
], AI = L(["SELECT [ALL | DISTINCT]"]), SI = L([
|
|
18068
18196
|
// queries
|
|
18069
18197
|
"WITH [RECURSIVE]",
|
|
18070
18198
|
"FROM",
|
|
@@ -18092,10 +18220,10 @@ const SS = [
|
|
|
18092
18220
|
"WHEN MATCHED [AND]",
|
|
18093
18221
|
"THEN {UPDATE SET | DELETE}",
|
|
18094
18222
|
"WHEN NOT MATCHED THEN INSERT"
|
|
18095
|
-
]), _T =
|
|
18223
|
+
]), _T = L([
|
|
18096
18224
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
18097
18225
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
18098
|
-
]), dE =
|
|
18226
|
+
]), dE = L([
|
|
18099
18227
|
// - create:
|
|
18100
18228
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
18101
18229
|
// - update:
|
|
@@ -18336,21 +18464,21 @@ const SS = [
|
|
|
18336
18464
|
"USE SCHEMA",
|
|
18337
18465
|
"USE SECONDARY ROLES",
|
|
18338
18466
|
"USE WAREHOUSE"
|
|
18339
|
-
]), II =
|
|
18467
|
+
]), II = L(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), NI = L([
|
|
18340
18468
|
"[INNER] JOIN",
|
|
18341
18469
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
18342
18470
|
"{CROSS | NATURAL} JOIN"
|
|
18343
|
-
]),
|
|
18471
|
+
]), OI = L([
|
|
18344
18472
|
"{ROWS | RANGE} BETWEEN",
|
|
18345
18473
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
18346
|
-
]), tI =
|
|
18474
|
+
]), tI = L([]), sI = {
|
|
18347
18475
|
name: "snowflake",
|
|
18348
18476
|
tokenizerOptions: {
|
|
18349
18477
|
reservedSelect: AI,
|
|
18350
18478
|
reservedClauses: [...SI, ..._T, ...dE],
|
|
18351
18479
|
reservedSetOperations: II,
|
|
18352
|
-
reservedJoins:
|
|
18353
|
-
reservedKeywordPhrases:
|
|
18480
|
+
reservedJoins: NI,
|
|
18481
|
+
reservedKeywordPhrases: OI,
|
|
18354
18482
|
reservedDataTypePhrases: tI,
|
|
18355
18483
|
reservedKeywords: eI,
|
|
18356
18484
|
reservedDataTypes: RI,
|
|
@@ -18404,11 +18532,11 @@ const SS = [
|
|
|
18404
18532
|
snowflake: sI,
|
|
18405
18533
|
spark: RS,
|
|
18406
18534
|
sql: lS,
|
|
18407
|
-
sqlite:
|
|
18535
|
+
sqlite: LS,
|
|
18408
18536
|
tidb: IA,
|
|
18409
18537
|
transactsql: wS,
|
|
18410
18538
|
trino: hS
|
|
18411
|
-
}, Symbol.toStringTag, { value: "Module" })), Z = (e) => e[e.length - 1], YT = (e) => e.sort((E, T) => T.length - E.length || E.localeCompare(T)),
|
|
18539
|
+
}, Symbol.toStringTag, { value: "Module" })), Z = (e) => e[e.length - 1], YT = (e) => e.sort((E, T) => T.length - E.length || E.localeCompare(T)), EE = (e) => e.replace(/\s+/gu, " "), pE = (e) => /\n/.test(e), h = (e) => e.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), iT = /\s+/uy, g = (e) => new RegExp(`(?:${e})`, "uy"), nI = (e) => e.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), rI = (e) => e + "(?:-" + e + ")*", LI = ({ prefixes: e, requirePrefix: E }) => `(?:${e.map(nI).join("|")}${E ? "" : "|"})`, _I = (e) => new RegExp(`(?:${e.map(h).join("|")}).*?(?=\r
|
|
18412
18540
|
|\r|
|
|
18413
18541
|
|$)`, "uy"), aT = (e, E = []) => {
|
|
18414
18542
|
const T = e === "open" ? 0 : 1, R = ["()", ...E].map((A) => A[T]);
|
|
@@ -18456,9 +18584,9 @@ const SS = [
|
|
|
18456
18584
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
18457
18585
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
18458
18586
|
"q''": aI()
|
|
18459
|
-
}, hT = (e) => typeof e == "string" ? DT[e] : "regex" in e ? e.regex :
|
|
18587
|
+
}, hT = (e) => typeof e == "string" ? DT[e] : "regex" in e ? e.regex : LI(e) + DT[e.quote], oI = (e) => g(e.map((E) => "regex" in E ? E.regex : hT(E)).join("|")), fT = (e) => e.map(hT).join("|"), PT = (e) => g(fT(e)), DI = (e = {}) => g(VT(e)), VT = ({ first: e, rest: E, dashes: T, allowFirstCharNumber: R } = {}) => {
|
|
18460
18588
|
const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I = h(e ?? ""), t = h(E ?? ""), s = R ? `[${A}${S}${I}][${A}${S}${t}]*` : `[${A}${I}][${A}${S}${t}]*`;
|
|
18461
|
-
return T ?
|
|
18589
|
+
return T ? rI(s) : s;
|
|
18462
18590
|
};
|
|
18463
18591
|
function WT(e, E) {
|
|
18464
18592
|
const T = e.slice(0, E).split(/\n/);
|
|
@@ -18596,82 +18724,82 @@ class lI {
|
|
|
18596
18724
|
{
|
|
18597
18725
|
type: D.RESERVED_KEYWORD_PHRASE,
|
|
18598
18726
|
regex: V((R = E.reservedKeywordPhrases) !== null && R !== void 0 ? R : [], E.identChars),
|
|
18599
|
-
text:
|
|
18727
|
+
text: B
|
|
18600
18728
|
},
|
|
18601
18729
|
{
|
|
18602
18730
|
type: D.RESERVED_DATA_TYPE_PHRASE,
|
|
18603
18731
|
regex: V((A = E.reservedDataTypePhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
18604
|
-
text:
|
|
18732
|
+
text: B
|
|
18605
18733
|
},
|
|
18606
18734
|
{
|
|
18607
18735
|
type: D.CASE,
|
|
18608
18736
|
regex: /CASE\b/iuy,
|
|
18609
|
-
text:
|
|
18737
|
+
text: B
|
|
18610
18738
|
},
|
|
18611
18739
|
{
|
|
18612
18740
|
type: D.END,
|
|
18613
18741
|
regex: /END\b/iuy,
|
|
18614
|
-
text:
|
|
18742
|
+
text: B
|
|
18615
18743
|
},
|
|
18616
18744
|
{
|
|
18617
18745
|
type: D.BETWEEN,
|
|
18618
18746
|
regex: /BETWEEN\b/iuy,
|
|
18619
|
-
text:
|
|
18747
|
+
text: B
|
|
18620
18748
|
},
|
|
18621
18749
|
{
|
|
18622
18750
|
type: D.LIMIT,
|
|
18623
18751
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
18624
|
-
text:
|
|
18752
|
+
text: B
|
|
18625
18753
|
},
|
|
18626
18754
|
{
|
|
18627
18755
|
type: D.RESERVED_CLAUSE,
|
|
18628
18756
|
regex: V(E.reservedClauses, E.identChars),
|
|
18629
|
-
text:
|
|
18757
|
+
text: B
|
|
18630
18758
|
},
|
|
18631
18759
|
{
|
|
18632
18760
|
type: D.RESERVED_SELECT,
|
|
18633
18761
|
regex: V(E.reservedSelect, E.identChars),
|
|
18634
|
-
text:
|
|
18762
|
+
text: B
|
|
18635
18763
|
},
|
|
18636
18764
|
{
|
|
18637
18765
|
type: D.RESERVED_SET_OPERATION,
|
|
18638
18766
|
regex: V(E.reservedSetOperations, E.identChars),
|
|
18639
|
-
text:
|
|
18767
|
+
text: B
|
|
18640
18768
|
},
|
|
18641
18769
|
{
|
|
18642
18770
|
type: D.WHEN,
|
|
18643
18771
|
regex: /WHEN\b/iuy,
|
|
18644
|
-
text:
|
|
18772
|
+
text: B
|
|
18645
18773
|
},
|
|
18646
18774
|
{
|
|
18647
18775
|
type: D.ELSE,
|
|
18648
18776
|
regex: /ELSE\b/iuy,
|
|
18649
|
-
text:
|
|
18777
|
+
text: B
|
|
18650
18778
|
},
|
|
18651
18779
|
{
|
|
18652
18780
|
type: D.THEN,
|
|
18653
18781
|
regex: /THEN\b/iuy,
|
|
18654
|
-
text:
|
|
18782
|
+
text: B
|
|
18655
18783
|
},
|
|
18656
18784
|
{
|
|
18657
18785
|
type: D.RESERVED_JOIN,
|
|
18658
18786
|
regex: V(E.reservedJoins, E.identChars),
|
|
18659
|
-
text:
|
|
18787
|
+
text: B
|
|
18660
18788
|
},
|
|
18661
18789
|
{
|
|
18662
18790
|
type: D.AND,
|
|
18663
18791
|
regex: /AND\b/iuy,
|
|
18664
|
-
text:
|
|
18792
|
+
text: B
|
|
18665
18793
|
},
|
|
18666
18794
|
{
|
|
18667
18795
|
type: D.OR,
|
|
18668
18796
|
regex: /OR\b/iuy,
|
|
18669
|
-
text:
|
|
18797
|
+
text: B
|
|
18670
18798
|
},
|
|
18671
18799
|
{
|
|
18672
18800
|
type: D.XOR,
|
|
18673
18801
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
18674
|
-
text:
|
|
18802
|
+
text: B
|
|
18675
18803
|
},
|
|
18676
18804
|
...E.operatorKeyword ? [
|
|
18677
18805
|
{
|
|
@@ -18682,17 +18810,17 @@ class lI {
|
|
|
18682
18810
|
{
|
|
18683
18811
|
type: D.RESERVED_FUNCTION_NAME,
|
|
18684
18812
|
regex: V(E.reservedFunctionNames, E.identChars),
|
|
18685
|
-
text:
|
|
18813
|
+
text: B
|
|
18686
18814
|
},
|
|
18687
18815
|
{
|
|
18688
18816
|
type: D.RESERVED_DATA_TYPE,
|
|
18689
18817
|
regex: V(E.reservedDataTypes, E.identChars),
|
|
18690
|
-
text:
|
|
18818
|
+
text: B
|
|
18691
18819
|
},
|
|
18692
18820
|
{
|
|
18693
18821
|
type: D.RESERVED_KEYWORD,
|
|
18694
18822
|
regex: V(E.reservedKeywords, E.identChars),
|
|
18695
|
-
text:
|
|
18823
|
+
text: B
|
|
18696
18824
|
}
|
|
18697
18825
|
]);
|
|
18698
18826
|
}
|
|
@@ -18759,31 +18887,31 @@ class lI {
|
|
|
18759
18887
|
{
|
|
18760
18888
|
type: D.NAMED_PARAMETER,
|
|
18761
18889
|
regex: FE(s.named, VT(E.paramChars || E.identChars)),
|
|
18762
|
-
key: (
|
|
18890
|
+
key: (N) => N.slice(1)
|
|
18763
18891
|
},
|
|
18764
18892
|
{
|
|
18765
18893
|
type: D.QUOTED_PARAMETER,
|
|
18766
18894
|
regex: FE(s.quoted, fT(E.identTypes)),
|
|
18767
|
-
key: (
|
|
18768
|
-
tokenKey:
|
|
18769
|
-
quoteChar:
|
|
18895
|
+
key: (N) => (({ tokenKey: O, quoteChar: C }) => O.replace(new RegExp(h("\\" + C), "gu"), C))({
|
|
18896
|
+
tokenKey: N.slice(2, -1),
|
|
18897
|
+
quoteChar: N.slice(-1)
|
|
18770
18898
|
})
|
|
18771
18899
|
},
|
|
18772
18900
|
{
|
|
18773
18901
|
type: D.NUMBERED_PARAMETER,
|
|
18774
18902
|
regex: FE(s.numbered, "[0-9]+"),
|
|
18775
|
-
key: (
|
|
18903
|
+
key: (N) => N.slice(1)
|
|
18776
18904
|
},
|
|
18777
18905
|
{
|
|
18778
18906
|
type: D.POSITIONAL_PARAMETER,
|
|
18779
18907
|
regex: s.positional ? /[?]/y : void 0
|
|
18780
18908
|
},
|
|
18781
|
-
...s.custom.map((
|
|
18782
|
-
var
|
|
18909
|
+
...s.custom.map((N) => {
|
|
18910
|
+
var O;
|
|
18783
18911
|
return {
|
|
18784
18912
|
type: D.CUSTOM_PARAMETER,
|
|
18785
|
-
regex: g(
|
|
18786
|
-
key: (
|
|
18913
|
+
regex: g(N.regex),
|
|
18914
|
+
key: (O = N.key) !== null && O !== void 0 ? O : ((C) => C)
|
|
18787
18915
|
};
|
|
18788
18916
|
})
|
|
18789
18917
|
]);
|
|
@@ -18793,7 +18921,7 @@ class lI {
|
|
|
18793
18921
|
return E.filter((T) => !!T.regex);
|
|
18794
18922
|
}
|
|
18795
18923
|
}
|
|
18796
|
-
const
|
|
18924
|
+
const B = (e) => EE(e.toUpperCase()), UT = /* @__PURE__ */ new Map(), uI = (e) => {
|
|
18797
18925
|
let E = UT.get(e);
|
|
18798
18926
|
return E || (E = GI(e), UT.set(e, E)), E;
|
|
18799
18927
|
}, GI = (e) => ({
|
|
@@ -18807,13 +18935,13 @@ const m = (e) => z(e.toUpperCase()), UT = /* @__PURE__ */ new Map(), uI = (e) =>
|
|
|
18807
18935
|
tabularOnelineClauses: Object.fromEntries(((E = e.tabularOnelineClauses) !== null && E !== void 0 ? E : e.onelineClauses).map((T) => [T, !0]))
|
|
18808
18936
|
};
|
|
18809
18937
|
};
|
|
18810
|
-
function
|
|
18938
|
+
function mI(e) {
|
|
18811
18939
|
return e.indentStyle === "tabularLeft" || e.indentStyle === "tabularRight" ? " ".repeat(10) : e.useTabs ? " " : " ".repeat(e.tabWidth);
|
|
18812
18940
|
}
|
|
18813
18941
|
function J(e) {
|
|
18814
18942
|
return e.indentStyle === "tabularLeft" || e.indentStyle === "tabularRight";
|
|
18815
18943
|
}
|
|
18816
|
-
class
|
|
18944
|
+
class BI {
|
|
18817
18945
|
constructor(E) {
|
|
18818
18946
|
this.params = E, this.index = 0;
|
|
18819
18947
|
}
|
|
@@ -18839,42 +18967,42 @@ class mI {
|
|
|
18839
18967
|
function dI(e) {
|
|
18840
18968
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
18841
18969
|
}
|
|
18842
|
-
var
|
|
18970
|
+
var TE = { exports: {} }, pI = TE.exports, cT;
|
|
18843
18971
|
function FI() {
|
|
18844
18972
|
return cT || (cT = 1, (function(e) {
|
|
18845
18973
|
(function(E, T) {
|
|
18846
18974
|
e.exports ? e.exports = T() : E.nearley = T();
|
|
18847
18975
|
})(pI, function() {
|
|
18848
|
-
function E(
|
|
18849
|
-
return this.id = ++E.highestId, this.name =
|
|
18976
|
+
function E(N, O, C) {
|
|
18977
|
+
return this.id = ++E.highestId, this.name = N, this.symbols = O, this.postprocess = C, this;
|
|
18850
18978
|
}
|
|
18851
|
-
E.highestId = 0, E.prototype.toString = function(
|
|
18852
|
-
var
|
|
18853
|
-
return this.name + " → " +
|
|
18979
|
+
E.highestId = 0, E.prototype.toString = function(N) {
|
|
18980
|
+
var O = typeof N > "u" ? this.symbols.map(s).join(" ") : this.symbols.slice(0, N).map(s).join(" ") + " ● " + this.symbols.slice(N).map(s).join(" ");
|
|
18981
|
+
return this.name + " → " + O;
|
|
18854
18982
|
};
|
|
18855
|
-
function T(
|
|
18856
|
-
this.rule =
|
|
18983
|
+
function T(N, O, C, n) {
|
|
18984
|
+
this.rule = N, this.dot = O, this.reference = C, this.data = [], this.wantedBy = n, this.isComplete = this.dot === N.symbols.length;
|
|
18857
18985
|
}
|
|
18858
18986
|
T.prototype.toString = function() {
|
|
18859
18987
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
18860
|
-
}, T.prototype.nextState = function(
|
|
18861
|
-
var
|
|
18862
|
-
return
|
|
18988
|
+
}, T.prototype.nextState = function(N) {
|
|
18989
|
+
var O = new T(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
18990
|
+
return O.left = this, O.right = N, O.isComplete && (O.data = O.build(), O.right = void 0), O;
|
|
18863
18991
|
}, T.prototype.build = function() {
|
|
18864
|
-
var
|
|
18992
|
+
var N = [], O = this;
|
|
18865
18993
|
do
|
|
18866
|
-
|
|
18867
|
-
while (
|
|
18868
|
-
return
|
|
18994
|
+
N.push(O.right.data), O = O.left;
|
|
18995
|
+
while (O.left);
|
|
18996
|
+
return N.reverse(), N;
|
|
18869
18997
|
}, T.prototype.finish = function() {
|
|
18870
18998
|
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
|
|
18871
18999
|
};
|
|
18872
|
-
function R(
|
|
18873
|
-
this.grammar =
|
|
19000
|
+
function R(N, O) {
|
|
19001
|
+
this.grammar = N, this.index = O, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
18874
19002
|
}
|
|
18875
|
-
R.prototype.process = function(
|
|
18876
|
-
for (var
|
|
18877
|
-
var i =
|
|
19003
|
+
R.prototype.process = function(N) {
|
|
19004
|
+
for (var O = this.states, C = this.wants, n = this.completed, r = 0; r < O.length; r++) {
|
|
19005
|
+
var i = O[r];
|
|
18878
19006
|
if (i.isComplete) {
|
|
18879
19007
|
if (i.finish(), i.data !== I.fail) {
|
|
18880
19008
|
for (var a = i.wantedBy, l = a.length; l--; ) {
|
|
@@ -18902,93 +19030,93 @@ function FI() {
|
|
|
18902
19030
|
C[U] = [i], this.predict(U);
|
|
18903
19031
|
}
|
|
18904
19032
|
}
|
|
18905
|
-
}, R.prototype.predict = function(
|
|
18906
|
-
for (var
|
|
18907
|
-
var n =
|
|
19033
|
+
}, R.prototype.predict = function(N) {
|
|
19034
|
+
for (var O = this.grammar.byName[N] || [], C = 0; C < O.length; C++) {
|
|
19035
|
+
var n = O[C], r = this.wants[N], i = new T(n, 0, this.index, r);
|
|
18908
19036
|
this.states.push(i);
|
|
18909
19037
|
}
|
|
18910
|
-
}, R.prototype.complete = function(
|
|
18911
|
-
var C =
|
|
19038
|
+
}, R.prototype.complete = function(N, O) {
|
|
19039
|
+
var C = N.nextState(O);
|
|
18912
19040
|
this.states.push(C);
|
|
18913
19041
|
};
|
|
18914
|
-
function A(
|
|
18915
|
-
this.rules =
|
|
19042
|
+
function A(N, O) {
|
|
19043
|
+
this.rules = N, this.start = O || this.rules[0].name;
|
|
18916
19044
|
var C = this.byName = {};
|
|
18917
19045
|
this.rules.forEach(function(n) {
|
|
18918
19046
|
C.hasOwnProperty(n.name) || (C[n.name] = []), C[n.name].push(n);
|
|
18919
19047
|
});
|
|
18920
19048
|
}
|
|
18921
|
-
A.fromCompiled = function(n,
|
|
19049
|
+
A.fromCompiled = function(n, O) {
|
|
18922
19050
|
var C = n.Lexer;
|
|
18923
|
-
n.ParserStart && (
|
|
19051
|
+
n.ParserStart && (O = n.ParserStart, n = n.ParserRules);
|
|
18924
19052
|
var n = n.map(function(i) {
|
|
18925
19053
|
return new E(i.name, i.symbols, i.postprocess);
|
|
18926
|
-
}),
|
|
18927
|
-
return
|
|
19054
|
+
}), r = new A(n, O);
|
|
19055
|
+
return r.lexer = C, r;
|
|
18928
19056
|
};
|
|
18929
19057
|
function S() {
|
|
18930
19058
|
this.reset("");
|
|
18931
19059
|
}
|
|
18932
|
-
S.prototype.reset = function(
|
|
18933
|
-
this.buffer =
|
|
19060
|
+
S.prototype.reset = function(N, O) {
|
|
19061
|
+
this.buffer = N, this.index = 0, this.line = O ? O.line : 1, this.lastLineBreak = O ? -O.col : 0;
|
|
18934
19062
|
}, S.prototype.next = function() {
|
|
18935
19063
|
if (this.index < this.buffer.length) {
|
|
18936
|
-
var
|
|
18937
|
-
return
|
|
18938
|
-
` && (this.line += 1, this.lastLineBreak = this.index), { value:
|
|
19064
|
+
var N = this.buffer[this.index++];
|
|
19065
|
+
return N === `
|
|
19066
|
+
` && (this.line += 1, this.lastLineBreak = this.index), { value: N };
|
|
18939
19067
|
}
|
|
18940
19068
|
}, S.prototype.save = function() {
|
|
18941
19069
|
return {
|
|
18942
19070
|
line: this.line,
|
|
18943
19071
|
col: this.index - this.lastLineBreak
|
|
18944
19072
|
};
|
|
18945
|
-
}, S.prototype.formatError = function(
|
|
19073
|
+
}, S.prototype.formatError = function(N, O) {
|
|
18946
19074
|
var C = this.buffer;
|
|
18947
19075
|
if (typeof C == "string") {
|
|
18948
19076
|
var n = C.split(`
|
|
18949
19077
|
`).slice(
|
|
18950
19078
|
Math.max(0, this.line - 5),
|
|
18951
19079
|
this.line
|
|
18952
|
-
),
|
|
19080
|
+
), r = C.indexOf(`
|
|
18953
19081
|
`, this.index);
|
|
18954
|
-
|
|
19082
|
+
r === -1 && (r = C.length);
|
|
18955
19083
|
var i = this.index - this.lastLineBreak, a = String(this.line).length;
|
|
18956
|
-
return
|
|
19084
|
+
return O += " at line " + this.line + " col " + i + `:
|
|
18957
19085
|
|
|
18958
|
-
`,
|
|
19086
|
+
`, O += n.map(function(P, U) {
|
|
18959
19087
|
return l(this.line - n.length + U + 1, a) + " " + P;
|
|
18960
19088
|
}, this).join(`
|
|
18961
|
-
`),
|
|
19089
|
+
`), O += `
|
|
18962
19090
|
` + l("", a + i) + `^
|
|
18963
|
-
`,
|
|
19091
|
+
`, O;
|
|
18964
19092
|
} else
|
|
18965
|
-
return
|
|
19093
|
+
return O + " at index " + (this.index - 1);
|
|
18966
19094
|
function l(P, U) {
|
|
18967
19095
|
var M = String(P);
|
|
18968
19096
|
return Array(U - M.length + 1).join(" ") + M;
|
|
18969
19097
|
}
|
|
18970
19098
|
};
|
|
18971
|
-
function I(
|
|
18972
|
-
if (
|
|
18973
|
-
var n =
|
|
19099
|
+
function I(N, O, C) {
|
|
19100
|
+
if (N instanceof A)
|
|
19101
|
+
var n = N, C = O;
|
|
18974
19102
|
else
|
|
18975
|
-
var n = A.fromCompiled(
|
|
19103
|
+
var n = A.fromCompiled(N, O);
|
|
18976
19104
|
this.grammar = n, this.options = {
|
|
18977
19105
|
keepHistory: !1,
|
|
18978
19106
|
lexer: n.lexer || new S()
|
|
18979
19107
|
};
|
|
18980
|
-
for (var
|
|
18981
|
-
this.options[
|
|
19108
|
+
for (var r in C || {})
|
|
19109
|
+
this.options[r] = C[r];
|
|
18982
19110
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
18983
19111
|
var i = new R(n, 0);
|
|
18984
19112
|
this.table = [i], i.wants[n.start] = [], i.predict(n.start), i.process(), this.current = 0;
|
|
18985
19113
|
}
|
|
18986
|
-
I.fail = {}, I.prototype.feed = function(
|
|
18987
|
-
var
|
|
18988
|
-
|
|
19114
|
+
I.fail = {}, I.prototype.feed = function(N) {
|
|
19115
|
+
var O = this.lexer;
|
|
19116
|
+
O.reset(N, this.lexerState);
|
|
18989
19117
|
for (var C; ; ) {
|
|
18990
19118
|
try {
|
|
18991
|
-
if (C =
|
|
19119
|
+
if (C = O.next(), !C)
|
|
18992
19120
|
break;
|
|
18993
19121
|
} catch (Y) {
|
|
18994
19122
|
var a = new R(this.grammar, this.current + 1);
|
|
@@ -18996,42 +19124,42 @@ function FI() {
|
|
|
18996
19124
|
var n = new Error(this.reportLexerError(Y));
|
|
18997
19125
|
throw n.offset = this.current, n.token = Y.token, n;
|
|
18998
19126
|
}
|
|
18999
|
-
var
|
|
19127
|
+
var r = this.table[this.current];
|
|
19000
19128
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
19001
19129
|
var i = this.current + 1, a = new R(this.grammar, i);
|
|
19002
19130
|
this.table.push(a);
|
|
19003
|
-
for (var l = C.text !== void 0 ? C.text : C.value, P =
|
|
19131
|
+
for (var l = C.text !== void 0 ? C.text : C.value, P = O.constructor === S ? C.value : C, U = r.scannable, M = U.length; M--; ) {
|
|
19004
19132
|
var G = U[M], H = G.rule.symbols[G.dot];
|
|
19005
19133
|
if (H.test ? H.test(P) : H.type ? H.type === C.type : H.literal === l) {
|
|
19006
|
-
var
|
|
19007
|
-
a.states.push(
|
|
19134
|
+
var m = G.nextState({ data: P, token: C, isToken: !0, reference: i - 1 });
|
|
19135
|
+
a.states.push(m);
|
|
19008
19136
|
}
|
|
19009
19137
|
}
|
|
19010
19138
|
if (a.process(), a.states.length === 0) {
|
|
19011
19139
|
var n = new Error(this.reportError(C));
|
|
19012
19140
|
throw n.offset = this.current, n.token = C, n;
|
|
19013
19141
|
}
|
|
19014
|
-
this.options.keepHistory && (
|
|
19142
|
+
this.options.keepHistory && (r.lexerState = O.save()), this.current++;
|
|
19015
19143
|
}
|
|
19016
|
-
return
|
|
19017
|
-
}, I.prototype.reportLexerError = function(
|
|
19018
|
-
var
|
|
19019
|
-
return n ? (
|
|
19020
|
-
}, I.prototype.reportError = function(
|
|
19021
|
-
var
|
|
19022
|
-
return this.reportErrorCommon(C,
|
|
19023
|
-
}, I.prototype.reportErrorCommon = function(
|
|
19144
|
+
return r && (this.lexerState = O.save()), this.results = this.finish(), this;
|
|
19145
|
+
}, I.prototype.reportLexerError = function(N) {
|
|
19146
|
+
var O, C, n = N.token;
|
|
19147
|
+
return n ? (O = "input " + JSON.stringify(n.text[0]) + " (lexer error)", C = this.lexer.formatError(n, "Syntax error")) : (O = "input (lexer error)", C = N.message), this.reportErrorCommon(C, O);
|
|
19148
|
+
}, I.prototype.reportError = function(N) {
|
|
19149
|
+
var O = (N.type ? N.type + " token: " : "") + JSON.stringify(N.value !== void 0 ? N.value : N), C = this.lexer.formatError(N, "Syntax error");
|
|
19150
|
+
return this.reportErrorCommon(C, O);
|
|
19151
|
+
}, I.prototype.reportErrorCommon = function(N, O) {
|
|
19024
19152
|
var C = [];
|
|
19025
|
-
C.push(
|
|
19026
|
-
var n = this.table.length - 2,
|
|
19153
|
+
C.push(N);
|
|
19154
|
+
var n = this.table.length - 2, r = this.table[n], i = r.states.filter(function(l) {
|
|
19027
19155
|
var P = l.rule.symbols[l.dot];
|
|
19028
19156
|
return P && typeof P != "string";
|
|
19029
19157
|
});
|
|
19030
19158
|
if (i.length === 0)
|
|
19031
|
-
C.push("Unexpected " +
|
|
19032
|
-
`), this.displayStateStack(
|
|
19159
|
+
C.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
|
|
19160
|
+
`), this.displayStateStack(r.states, C);
|
|
19033
19161
|
else {
|
|
19034
|
-
C.push("Unexpected " +
|
|
19162
|
+
C.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
|
|
19035
19163
|
`);
|
|
19036
19164
|
var a = i.map(function(l) {
|
|
19037
19165
|
return this.buildFirstStateStack(l, []) || [l];
|
|
@@ -19043,68 +19171,68 @@ function FI() {
|
|
|
19043
19171
|
}
|
|
19044
19172
|
return C.push(""), C.join(`
|
|
19045
19173
|
`);
|
|
19046
|
-
}, I.prototype.displayStateStack = function(
|
|
19047
|
-
for (var C, n = 0,
|
|
19048
|
-
var i =
|
|
19049
|
-
a === C ? n++ : (n > 0 &&
|
|
19174
|
+
}, I.prototype.displayStateStack = function(N, O) {
|
|
19175
|
+
for (var C, n = 0, r = 0; r < N.length; r++) {
|
|
19176
|
+
var i = N[r], a = i.rule.toString(i.dot);
|
|
19177
|
+
a === C ? n++ : (n > 0 && O.push(" ^ " + n + " more lines identical to this"), n = 0, O.push(" " + a)), C = a;
|
|
19050
19178
|
}
|
|
19051
|
-
}, I.prototype.getSymbolDisplay = function(
|
|
19052
|
-
return t(
|
|
19053
|
-
}, I.prototype.buildFirstStateStack = function(
|
|
19054
|
-
if (
|
|
19179
|
+
}, I.prototype.getSymbolDisplay = function(N) {
|
|
19180
|
+
return t(N);
|
|
19181
|
+
}, I.prototype.buildFirstStateStack = function(N, O) {
|
|
19182
|
+
if (O.indexOf(N) !== -1)
|
|
19055
19183
|
return null;
|
|
19056
|
-
if (
|
|
19057
|
-
return [
|
|
19058
|
-
var C =
|
|
19059
|
-
return
|
|
19184
|
+
if (N.wantedBy.length === 0)
|
|
19185
|
+
return [N];
|
|
19186
|
+
var C = N.wantedBy[0], n = [N].concat(O), r = this.buildFirstStateStack(C, n);
|
|
19187
|
+
return r === null ? null : [N].concat(r);
|
|
19060
19188
|
}, I.prototype.save = function() {
|
|
19061
|
-
var
|
|
19062
|
-
return
|
|
19063
|
-
}, I.prototype.restore = function(
|
|
19064
|
-
var
|
|
19065
|
-
this.current =
|
|
19066
|
-
}, I.prototype.rewind = function(
|
|
19189
|
+
var N = this.table[this.current];
|
|
19190
|
+
return N.lexerState = this.lexerState, N;
|
|
19191
|
+
}, I.prototype.restore = function(N) {
|
|
19192
|
+
var O = N.index;
|
|
19193
|
+
this.current = O, this.table[O] = N, this.table.splice(O + 1), this.lexerState = N.lexerState, this.results = this.finish();
|
|
19194
|
+
}, I.prototype.rewind = function(N) {
|
|
19067
19195
|
if (!this.options.keepHistory)
|
|
19068
19196
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
19069
|
-
this.restore(this.table[
|
|
19197
|
+
this.restore(this.table[N]);
|
|
19070
19198
|
}, I.prototype.finish = function() {
|
|
19071
|
-
var
|
|
19199
|
+
var N = [], O = this.grammar.start, C = this.table[this.table.length - 1];
|
|
19072
19200
|
return C.states.forEach(function(n) {
|
|
19073
|
-
n.rule.name ===
|
|
19074
|
-
}),
|
|
19201
|
+
n.rule.name === O && n.dot === n.rule.symbols.length && n.reference === 0 && n.data !== I.fail && N.push(n);
|
|
19202
|
+
}), N.map(function(n) {
|
|
19075
19203
|
return n.data;
|
|
19076
19204
|
});
|
|
19077
19205
|
};
|
|
19078
|
-
function t(
|
|
19079
|
-
var
|
|
19080
|
-
if (
|
|
19081
|
-
return
|
|
19082
|
-
if (
|
|
19083
|
-
if (
|
|
19084
|
-
return JSON.stringify(
|
|
19085
|
-
if (
|
|
19086
|
-
return "character matching " +
|
|
19087
|
-
if (
|
|
19088
|
-
return
|
|
19089
|
-
if (
|
|
19090
|
-
return "token matching " + String(
|
|
19091
|
-
throw new Error("Unknown symbol type: " +
|
|
19206
|
+
function t(N) {
|
|
19207
|
+
var O = typeof N;
|
|
19208
|
+
if (O === "string")
|
|
19209
|
+
return N;
|
|
19210
|
+
if (O === "object") {
|
|
19211
|
+
if (N.literal)
|
|
19212
|
+
return JSON.stringify(N.literal);
|
|
19213
|
+
if (N instanceof RegExp)
|
|
19214
|
+
return "character matching " + N;
|
|
19215
|
+
if (N.type)
|
|
19216
|
+
return N.type + " token";
|
|
19217
|
+
if (N.test)
|
|
19218
|
+
return "token matching " + String(N.test);
|
|
19219
|
+
throw new Error("Unknown symbol type: " + N);
|
|
19092
19220
|
}
|
|
19093
19221
|
}
|
|
19094
|
-
function s(
|
|
19095
|
-
var
|
|
19096
|
-
if (
|
|
19097
|
-
return
|
|
19098
|
-
if (
|
|
19099
|
-
if (
|
|
19100
|
-
return JSON.stringify(
|
|
19101
|
-
if (
|
|
19102
|
-
return
|
|
19103
|
-
if (
|
|
19104
|
-
return "%" +
|
|
19105
|
-
if (
|
|
19106
|
-
return "<" + String(
|
|
19107
|
-
throw new Error("Unknown symbol type: " +
|
|
19222
|
+
function s(N) {
|
|
19223
|
+
var O = typeof N;
|
|
19224
|
+
if (O === "string")
|
|
19225
|
+
return N;
|
|
19226
|
+
if (O === "object") {
|
|
19227
|
+
if (N.literal)
|
|
19228
|
+
return JSON.stringify(N.literal);
|
|
19229
|
+
if (N instanceof RegExp)
|
|
19230
|
+
return N.toString();
|
|
19231
|
+
if (N.type)
|
|
19232
|
+
return "%" + N.type;
|
|
19233
|
+
if (N.test)
|
|
19234
|
+
return "<" + String(N.test) + ">";
|
|
19235
|
+
throw new Error("Unknown symbol type: " + N);
|
|
19108
19236
|
}
|
|
19109
19237
|
}
|
|
19110
19238
|
return {
|
|
@@ -19113,7 +19241,7 @@ function FI() {
|
|
|
19113
19241
|
Rule: E
|
|
19114
19242
|
};
|
|
19115
19243
|
});
|
|
19116
|
-
})(
|
|
19244
|
+
})(TE)), TE.exports;
|
|
19117
19245
|
}
|
|
19118
19246
|
var YI = FI();
|
|
19119
19247
|
const hI = /* @__PURE__ */ dI(YI);
|
|
@@ -19724,7 +19852,7 @@ function uT(e, E) {
|
|
|
19724
19852
|
return e.length >= 10 && e.includes(" ") && ([e, ...T] = e.split(" ")), E === "tabularLeft" ? e = e.padEnd(9, " ") : e = e.padStart(9, " "), e + ["", ...T].join(" ");
|
|
19725
19853
|
}
|
|
19726
19854
|
function GT(e) {
|
|
19727
|
-
return
|
|
19855
|
+
return Be(e) || e === D.RESERVED_CLAUSE || e === D.RESERVED_SELECT || e === D.RESERVED_SET_OPERATION || e === D.RESERVED_JOIN || e === D.LIMIT;
|
|
19728
19856
|
}
|
|
19729
19857
|
const hE = "top-level", jI = "block-level";
|
|
19730
19858
|
class KT {
|
|
@@ -19796,7 +19924,7 @@ class qI extends gT {
|
|
|
19796
19924
|
}
|
|
19797
19925
|
class VE extends Error {
|
|
19798
19926
|
}
|
|
19799
|
-
class
|
|
19927
|
+
class RE {
|
|
19800
19928
|
constructor({ cfg: E, dialectCfg: T, params: R, layout: A, inline: S = !1 }) {
|
|
19801
19929
|
this.inline = !1, this.nodes = [], this.index = -1, this.cfg = E, this.dialectCfg = T, this.inline = S, this.params = R, this.layout = A;
|
|
19802
19930
|
}
|
|
@@ -20004,7 +20132,7 @@ class eE {
|
|
|
20004
20132
|
return this.isDocComment(E) ? E.split(/\n/).map((T) => /^\s*\*/.test(T) ? " " + T.replace(/^\s*/, "") : T) : E.split(/\n/).map((T) => T.replace(/^\s*/, ""));
|
|
20005
20133
|
}
|
|
20006
20134
|
formatSubExpression(E) {
|
|
20007
|
-
return new
|
|
20135
|
+
return new RE({
|
|
20008
20136
|
cfg: this.cfg,
|
|
20009
20137
|
dialectCfg: this.dialectCfg,
|
|
20010
20138
|
params: this.params,
|
|
@@ -20015,7 +20143,7 @@ class eE {
|
|
|
20015
20143
|
formatInlineExpression(E) {
|
|
20016
20144
|
const T = this.params.getPositionalParameterIndex();
|
|
20017
20145
|
try {
|
|
20018
|
-
return new
|
|
20146
|
+
return new RE({
|
|
20019
20147
|
cfg: this.cfg,
|
|
20020
20148
|
dialectCfg: this.dialectCfg,
|
|
20021
20149
|
params: this.params,
|
|
@@ -20061,7 +20189,7 @@ class eE {
|
|
|
20061
20189
|
showNonTabularKw(E) {
|
|
20062
20190
|
switch (this.cfg.keywordCase) {
|
|
20063
20191
|
case "preserve":
|
|
20064
|
-
return
|
|
20192
|
+
return EE(E.raw);
|
|
20065
20193
|
case "upper":
|
|
20066
20194
|
return E.text;
|
|
20067
20195
|
case "lower":
|
|
@@ -20075,7 +20203,7 @@ class eE {
|
|
|
20075
20203
|
showNonTabularFunctionKw(E) {
|
|
20076
20204
|
switch (this.cfg.functionCase) {
|
|
20077
20205
|
case "preserve":
|
|
20078
|
-
return
|
|
20206
|
+
return EE(E.raw);
|
|
20079
20207
|
case "upper":
|
|
20080
20208
|
return E.text;
|
|
20081
20209
|
case "lower":
|
|
@@ -20097,7 +20225,7 @@ class eE {
|
|
|
20097
20225
|
showDataType(E) {
|
|
20098
20226
|
switch (this.cfg.dataTypeCase) {
|
|
20099
20227
|
case "preserve":
|
|
20100
|
-
return
|
|
20228
|
+
return EE(E.raw);
|
|
20101
20229
|
case "upper":
|
|
20102
20230
|
return E.text;
|
|
20103
20231
|
case "lower":
|
|
@@ -20107,7 +20235,7 @@ class eE {
|
|
|
20107
20235
|
}
|
|
20108
20236
|
class kI {
|
|
20109
20237
|
constructor(E, T) {
|
|
20110
|
-
this.dialect = E, this.cfg = T, this.params = new
|
|
20238
|
+
this.dialect = E, this.cfg = T, this.params = new BI(this.cfg.params);
|
|
20111
20239
|
}
|
|
20112
20240
|
/**
|
|
20113
20241
|
* Formats an SQL query.
|
|
@@ -20126,16 +20254,16 @@ class kI {
|
|
|
20126
20254
|
`.repeat(this.cfg.linesBetweenQueries + 1));
|
|
20127
20255
|
}
|
|
20128
20256
|
formatStatement(E) {
|
|
20129
|
-
const T = new
|
|
20257
|
+
const T = new RE({
|
|
20130
20258
|
cfg: this.cfg,
|
|
20131
20259
|
dialectCfg: this.dialect.formatOptions,
|
|
20132
20260
|
params: this.params,
|
|
20133
|
-
layout: new gT(new KT(
|
|
20261
|
+
layout: new gT(new KT(mI(this.cfg)))
|
|
20134
20262
|
}).format(E.children);
|
|
20135
20263
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(o.NEWLINE, ";") : T.add(o.NO_NEWLINE, ";")), T.toString();
|
|
20136
20264
|
}
|
|
20137
20265
|
}
|
|
20138
|
-
class
|
|
20266
|
+
class eE extends Error {
|
|
20139
20267
|
}
|
|
20140
20268
|
function zI(e) {
|
|
20141
20269
|
const E = [
|
|
@@ -20148,20 +20276,20 @@ function zI(e) {
|
|
|
20148
20276
|
];
|
|
20149
20277
|
for (const T of E)
|
|
20150
20278
|
if (T in e)
|
|
20151
|
-
throw new
|
|
20279
|
+
throw new eE(`${T} config is no more supported.`);
|
|
20152
20280
|
if (e.expressionWidth <= 0)
|
|
20153
|
-
throw new
|
|
20154
|
-
if (e.params && !
|
|
20155
|
-
throw new
|
|
20281
|
+
throw new eE(`expressionWidth config must be positive number. Received ${e.expressionWidth} instead.`);
|
|
20282
|
+
if (e.params && !EN(e.params) && console.warn('WARNING: All "params" option values should be strings.'), e.paramTypes && !TN(e.paramTypes))
|
|
20283
|
+
throw new eE("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
20156
20284
|
return e;
|
|
20157
20285
|
}
|
|
20158
|
-
function
|
|
20286
|
+
function EN(e) {
|
|
20159
20287
|
return (e instanceof Array ? e : Object.values(e)).every((T) => typeof T == "string");
|
|
20160
20288
|
}
|
|
20161
|
-
function
|
|
20289
|
+
function TN(e) {
|
|
20162
20290
|
return e.custom && Array.isArray(e.custom) ? e.custom.every((E) => E.regex !== "") : !0;
|
|
20163
20291
|
}
|
|
20164
|
-
var
|
|
20292
|
+
var eN = function(e, E) {
|
|
20165
20293
|
var T = {};
|
|
20166
20294
|
for (var R in e) Object.prototype.hasOwnProperty.call(e, R) && E.indexOf(R) < 0 && (T[R] = e[R]);
|
|
20167
20295
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -20190,7 +20318,7 @@ const $T = {
|
|
|
20190
20318
|
tsql: "transactsql",
|
|
20191
20319
|
singlestoredb: "singlestoredb",
|
|
20192
20320
|
snowflake: "snowflake"
|
|
20193
|
-
},
|
|
20321
|
+
}, RN = Object.keys($T), AN = {
|
|
20194
20322
|
tabWidth: 2,
|
|
20195
20323
|
useTabs: !1,
|
|
20196
20324
|
keywordCase: "preserve",
|
|
@@ -20203,21 +20331,21 @@ const $T = {
|
|
|
20203
20331
|
linesBetweenQueries: 1,
|
|
20204
20332
|
denseOperators: !1,
|
|
20205
20333
|
newlineBeforeSemicolon: !1
|
|
20206
|
-
},
|
|
20207
|
-
if (typeof E.language == "string" && !
|
|
20208
|
-
throw new
|
|
20334
|
+
}, SN = (e, E = {}) => {
|
|
20335
|
+
if (typeof E.language == "string" && !RN.includes(E.language))
|
|
20336
|
+
throw new eE(`Unsupported SQL dialect: ${E.language}`);
|
|
20209
20337
|
const T = $T[E.language || "sql"];
|
|
20210
|
-
return
|
|
20211
|
-
},
|
|
20212
|
-
var { dialect: T } = E, R =
|
|
20338
|
+
return IN(e, Object.assign(Object.assign({}, E), { dialect: CI[T] }));
|
|
20339
|
+
}, IN = (e, E) => {
|
|
20340
|
+
var { dialect: T } = E, R = eN(E, ["dialect"]);
|
|
20213
20341
|
if (typeof e != "string")
|
|
20214
20342
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof e);
|
|
20215
|
-
const A = zI(Object.assign(Object.assign({},
|
|
20343
|
+
const A = zI(Object.assign(Object.assign({}, AN), R));
|
|
20216
20344
|
return new kI(uI(T), A).format(e);
|
|
20217
20345
|
};
|
|
20218
20346
|
function HT(e, E) {
|
|
20219
20347
|
try {
|
|
20220
|
-
return
|
|
20348
|
+
return SN(e, {
|
|
20221
20349
|
language: {
|
|
20222
20350
|
postgres: "postgresql",
|
|
20223
20351
|
mysql: "mysql",
|
|
@@ -20233,7 +20361,7 @@ function HT(e, E) {
|
|
|
20233
20361
|
return console.warn("SQL formatting failed:", T), e;
|
|
20234
20362
|
}
|
|
20235
20363
|
}
|
|
20236
|
-
class
|
|
20364
|
+
class NN {
|
|
20237
20365
|
cubes = /* @__PURE__ */ new Map();
|
|
20238
20366
|
dbExecutor;
|
|
20239
20367
|
metadataCache;
|
|
@@ -20292,7 +20420,7 @@ class OO {
|
|
|
20292
20420
|
);
|
|
20293
20421
|
continue;
|
|
20294
20422
|
}
|
|
20295
|
-
const S =
|
|
20423
|
+
const S = ne(A.calculatedSql);
|
|
20296
20424
|
if (!S.isValid) {
|
|
20297
20425
|
T.push(
|
|
20298
20426
|
`Invalid calculatedSql syntax in '${E.name}.${R}': ${S.errors.join(", ")}`
|
|
@@ -20349,7 +20477,7 @@ ${T.join(`
|
|
|
20349
20477
|
async execute(E, T) {
|
|
20350
20478
|
if (!this.dbExecutor)
|
|
20351
20479
|
throw new Error("Database executor not configured");
|
|
20352
|
-
return new
|
|
20480
|
+
return new nE(this.dbExecutor).execute(this.cubes, E, T);
|
|
20353
20481
|
}
|
|
20354
20482
|
/**
|
|
20355
20483
|
* Execute a multi-cube query
|
|
@@ -20399,27 +20527,27 @@ ${T.join(`
|
|
|
20399
20527
|
generateCubeMetadata(E) {
|
|
20400
20528
|
const T = Object.keys(E.measures), R = Object.keys(E.dimensions), A = new Array(T.length), S = new Array(R.length);
|
|
20401
20529
|
for (let t = 0; t < T.length; t++) {
|
|
20402
|
-
const s = T[t],
|
|
20530
|
+
const s = T[t], N = E.measures[s];
|
|
20403
20531
|
A[t] = {
|
|
20404
20532
|
name: `${E.name}.${s}`,
|
|
20405
|
-
title:
|
|
20406
|
-
shortTitle:
|
|
20407
|
-
type:
|
|
20533
|
+
title: N.title || s,
|
|
20534
|
+
shortTitle: N.title || s,
|
|
20535
|
+
type: N.type,
|
|
20408
20536
|
format: void 0,
|
|
20409
20537
|
// Measure doesn't have format field
|
|
20410
|
-
description:
|
|
20538
|
+
description: N.description
|
|
20411
20539
|
};
|
|
20412
20540
|
}
|
|
20413
20541
|
for (let t = 0; t < R.length; t++) {
|
|
20414
|
-
const s = R[t],
|
|
20542
|
+
const s = R[t], N = E.dimensions[s];
|
|
20415
20543
|
S[t] = {
|
|
20416
20544
|
name: `${E.name}.${s}`,
|
|
20417
|
-
title:
|
|
20418
|
-
shortTitle:
|
|
20419
|
-
type:
|
|
20545
|
+
title: N.title || s,
|
|
20546
|
+
shortTitle: N.title || s,
|
|
20547
|
+
type: N.type,
|
|
20420
20548
|
format: void 0,
|
|
20421
20549
|
// Dimension doesn't have format field
|
|
20422
|
-
description:
|
|
20550
|
+
description: N.description
|
|
20423
20551
|
};
|
|
20424
20552
|
}
|
|
20425
20553
|
const I = [];
|
|
@@ -20429,9 +20557,9 @@ ${T.join(`
|
|
|
20429
20557
|
I.push({
|
|
20430
20558
|
targetCube: s.name,
|
|
20431
20559
|
relationship: t.relationship,
|
|
20432
|
-
joinFields: t.on.map((
|
|
20433
|
-
sourceField: this.getColumnName(
|
|
20434
|
-
targetField: this.getColumnName(
|
|
20560
|
+
joinFields: t.on.map((N) => ({
|
|
20561
|
+
sourceField: this.getColumnName(N.source),
|
|
20562
|
+
targetField: this.getColumnName(N.target)
|
|
20435
20563
|
}))
|
|
20436
20564
|
});
|
|
20437
20565
|
}
|
|
@@ -20455,7 +20583,7 @@ ${T.join(`
|
|
|
20455
20583
|
throw new Error(`Cube '${E}' not found`);
|
|
20456
20584
|
if (!this.dbExecutor)
|
|
20457
20585
|
throw new Error("Database executor not configured");
|
|
20458
|
-
const I = await new
|
|
20586
|
+
const I = await new nE(this.dbExecutor).generateSQL(A, T, R), t = this.dbExecutor.getEngineType();
|
|
20459
20587
|
return {
|
|
20460
20588
|
sql: HT(I.sql, t),
|
|
20461
20589
|
params: I.params
|
|
@@ -20467,7 +20595,7 @@ ${T.join(`
|
|
|
20467
20595
|
async generateMultiCubeSQL(E, T) {
|
|
20468
20596
|
if (!this.dbExecutor)
|
|
20469
20597
|
throw new Error("Database executor not configured");
|
|
20470
|
-
const A = await new
|
|
20598
|
+
const A = await new nE(this.dbExecutor).generateMultiCubeSQL(this.cubes, E, T), S = this.dbExecutor.getEngineType();
|
|
20471
20599
|
return {
|
|
20472
20600
|
sql: HT(A.sql, S),
|
|
20473
20601
|
params: A.params
|
|
@@ -20607,29 +20735,29 @@ function JT(e, E, T, R) {
|
|
|
20607
20735
|
}
|
|
20608
20736
|
!I.dimensions[S] && !I.measures[S] && T.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
|
|
20609
20737
|
}
|
|
20610
|
-
function
|
|
20611
|
-
return new
|
|
20738
|
+
function CN(e) {
|
|
20739
|
+
return new NN({
|
|
20612
20740
|
drizzle: e.drizzle,
|
|
20613
20741
|
schema: e.schema
|
|
20614
20742
|
});
|
|
20615
20743
|
}
|
|
20616
20744
|
export {
|
|
20617
20745
|
bE as BaseDatabaseExecutor,
|
|
20618
|
-
|
|
20746
|
+
BT as MySQLExecutor,
|
|
20619
20747
|
Ae as PostgresExecutor,
|
|
20620
|
-
|
|
20621
|
-
|
|
20748
|
+
re as QueryBuilder,
|
|
20749
|
+
nE as QueryExecutor,
|
|
20622
20750
|
dT as QueryPlanner,
|
|
20623
20751
|
Ie as SQLiteExecutor,
|
|
20624
|
-
|
|
20752
|
+
NN as SemanticLayerCompiler,
|
|
20625
20753
|
QE as createDatabaseExecutor,
|
|
20626
|
-
|
|
20627
|
-
|
|
20754
|
+
CN as createDrizzleSemanticLayer,
|
|
20755
|
+
tN as createMultiCubeContext,
|
|
20628
20756
|
Se as createMySQLExecutor,
|
|
20629
20757
|
xE as createPostgresExecutor,
|
|
20630
20758
|
vE as createSQLiteExecutor,
|
|
20631
|
-
|
|
20759
|
+
sN as defineCube,
|
|
20632
20760
|
fE as getJoinType,
|
|
20633
|
-
|
|
20761
|
+
j as resolveCubeReference,
|
|
20634
20762
|
b as resolveSqlExpression
|
|
20635
20763
|
};
|