drizzle-cube 0.1.35 → 0.1.36
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-Ce33cdy6.js → compiler-ixtRH_TD.js} +407 -379
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +35 -39
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/client/chunks/{components-D3Bl_BuN.js → components-BeCaouWH.js} +2 -38
- package/dist/client/chunks/{components-D3Bl_BuN.js.map → components-BeCaouWH.js.map} +1 -1
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.d.ts +38 -2
- package/dist/server/index.js +583 -555
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as _, count as RE, sum as
|
|
1
|
+
import { sql as _, count as RE, sum as W, max as YE, min as mE, and as m, countDistinct as $T, SQL as gT, or as AE, isNotNull as WE, ne as XE, isNull as bE, eq as j, notInArray as KE, inArray as SE, lt as eE, gt as IE, gte as y, lte as $, desc as JT, asc as yE } from "drizzle-orm";
|
|
2
2
|
class dE {
|
|
3
3
|
/**
|
|
4
4
|
* Helper method to build pattern for string matching
|
|
@@ -626,11 +626,14 @@ function ER(T, E) {
|
|
|
626
626
|
case "hasMany":
|
|
627
627
|
return "left";
|
|
628
628
|
// Parent may have no children
|
|
629
|
+
case "belongsToMany":
|
|
630
|
+
return "left";
|
|
631
|
+
// Many-to-many through junction table
|
|
629
632
|
default:
|
|
630
633
|
return "left";
|
|
631
634
|
}
|
|
632
635
|
}
|
|
633
|
-
function
|
|
636
|
+
function f(T, E) {
|
|
634
637
|
return typeof T == "function" ? T(E) : T;
|
|
635
638
|
}
|
|
636
639
|
function wI(T, E, R) {
|
|
@@ -658,30 +661,30 @@ class TR {
|
|
|
658
661
|
const S = {}, e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
659
662
|
if (R.dimensions)
|
|
660
663
|
for (const O of R.dimensions) {
|
|
661
|
-
const [
|
|
664
|
+
const [s, D] = O.split("."), I = e.get(s);
|
|
662
665
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
663
|
-
const
|
|
664
|
-
S[O] = _`${
|
|
666
|
+
const N = I.dimensions[D], t = f(N.sql, A);
|
|
667
|
+
S[O] = _`${t}`.as(O);
|
|
665
668
|
}
|
|
666
669
|
}
|
|
667
670
|
if (R.measures)
|
|
668
671
|
for (const O of R.measures) {
|
|
669
|
-
const [
|
|
672
|
+
const [s, D] = O.split("."), I = e.get(s);
|
|
670
673
|
if (I && I.measures && I.measures[D]) {
|
|
671
|
-
const
|
|
672
|
-
S[O] = _`${
|
|
674
|
+
const N = I.measures[D], t = this.buildMeasureExpression(N, A);
|
|
675
|
+
S[O] = _`${t}`.as(O);
|
|
673
676
|
}
|
|
674
677
|
}
|
|
675
678
|
if (R.timeDimensions)
|
|
676
679
|
for (const O of R.timeDimensions) {
|
|
677
|
-
const [
|
|
680
|
+
const [s, D] = O.dimension.split("."), I = e.get(s);
|
|
678
681
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
679
|
-
const
|
|
680
|
-
|
|
682
|
+
const N = I.dimensions[D], t = this.buildTimeDimensionExpression(
|
|
683
|
+
N.sql,
|
|
681
684
|
O.granularity,
|
|
682
685
|
A
|
|
683
686
|
);
|
|
684
|
-
S[O.dimension] = _`${
|
|
687
|
+
S[O.dimension] = _`${t}`.as(O.dimension);
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
690
|
return Object.keys(S).length === 0 && (S.count = RE()), S;
|
|
@@ -691,24 +694,24 @@ class TR {
|
|
|
691
694
|
*/
|
|
692
695
|
buildHavingMeasureExpression(E, R, A, S, e) {
|
|
693
696
|
if (e && e.preAggregationCTEs) {
|
|
694
|
-
const O = e.preAggregationCTEs.find((
|
|
697
|
+
const O = e.preAggregationCTEs.find((s) => s.cube.name === E);
|
|
695
698
|
if (O && O.measures.includes(`${E}.${R}`)) {
|
|
696
|
-
const
|
|
699
|
+
const s = _`${_.identifier(O.cteAlias)}.${_.identifier(R)}`;
|
|
697
700
|
switch (A.type) {
|
|
698
701
|
case "count":
|
|
699
702
|
case "countDistinct":
|
|
700
703
|
case "sum":
|
|
701
|
-
return
|
|
704
|
+
return W(s);
|
|
702
705
|
case "avg":
|
|
703
|
-
return this.databaseAdapter.buildAvg(
|
|
706
|
+
return this.databaseAdapter.buildAvg(s);
|
|
704
707
|
case "min":
|
|
705
|
-
return mE(
|
|
708
|
+
return mE(s);
|
|
706
709
|
case "max":
|
|
707
|
-
return YE(
|
|
710
|
+
return YE(s);
|
|
708
711
|
case "number":
|
|
709
|
-
return
|
|
712
|
+
return W(s);
|
|
710
713
|
default:
|
|
711
|
-
return
|
|
714
|
+
return W(s);
|
|
712
715
|
}
|
|
713
716
|
}
|
|
714
717
|
}
|
|
@@ -718,7 +721,7 @@ class TR {
|
|
|
718
721
|
* Build measure expression with aggregation and filters
|
|
719
722
|
*/
|
|
720
723
|
buildMeasureExpression(E, R) {
|
|
721
|
-
let A =
|
|
724
|
+
let A = f(E.sql, R);
|
|
722
725
|
if (E.filters && E.filters.length > 0) {
|
|
723
726
|
const S = E.filters.map((e) => e(R)).filter(Boolean);
|
|
724
727
|
if (S.length > 0) {
|
|
@@ -734,7 +737,7 @@ class TR {
|
|
|
734
737
|
case "countDistinct":
|
|
735
738
|
return $T(A);
|
|
736
739
|
case "sum":
|
|
737
|
-
return
|
|
740
|
+
return W(A);
|
|
738
741
|
case "avg":
|
|
739
742
|
return this.databaseAdapter.buildAvg(A);
|
|
740
743
|
case "min":
|
|
@@ -751,7 +754,7 @@ class TR {
|
|
|
751
754
|
* Build time dimension expression with granularity using database adapter
|
|
752
755
|
*/
|
|
753
756
|
buildTimeDimensionExpression(E, R, A) {
|
|
754
|
-
const S =
|
|
757
|
+
const S = f(E, A);
|
|
755
758
|
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof gT ? S : _`${S}`;
|
|
756
759
|
}
|
|
757
760
|
/**
|
|
@@ -761,17 +764,17 @@ class TR {
|
|
|
761
764
|
buildWhereConditions(E, R, A, S) {
|
|
762
765
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
763
766
|
if (R.filters && R.filters.length > 0)
|
|
764
|
-
for (const
|
|
765
|
-
const D = this.processFilter(
|
|
767
|
+
for (const s of R.filters) {
|
|
768
|
+
const D = this.processFilter(s, O, A, "where", S);
|
|
766
769
|
D && e.push(D);
|
|
767
770
|
}
|
|
768
771
|
if (R.timeDimensions)
|
|
769
|
-
for (const
|
|
770
|
-
const [D, I] =
|
|
771
|
-
if (
|
|
772
|
+
for (const s of R.timeDimensions) {
|
|
773
|
+
const [D, I] = s.dimension.split("."), N = O.get(D);
|
|
774
|
+
if (N && N.dimensions[I] && s.dateRange) {
|
|
772
775
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((r) => r.cube.name === D))
|
|
773
776
|
continue;
|
|
774
|
-
const
|
|
777
|
+
const t = N.dimensions[I], L = f(t.sql, A), P = this.buildDateRangeCondition(L, s.dateRange);
|
|
775
778
|
P && e.push(P);
|
|
776
779
|
}
|
|
777
780
|
}
|
|
@@ -784,8 +787,8 @@ class TR {
|
|
|
784
787
|
buildHavingConditions(E, R, A, S) {
|
|
785
788
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
786
789
|
if (R.filters && R.filters.length > 0)
|
|
787
|
-
for (const
|
|
788
|
-
const D = this.processFilter(
|
|
790
|
+
for (const s of R.filters) {
|
|
791
|
+
const D = this.processFilter(s, O, A, "having", S);
|
|
789
792
|
D && e.push(D);
|
|
790
793
|
}
|
|
791
794
|
return e;
|
|
@@ -806,20 +809,20 @@ class TR {
|
|
|
806
809
|
return a.length > 0 ? AE(...a) : null;
|
|
807
810
|
}
|
|
808
811
|
}
|
|
809
|
-
const O = E, [
|
|
812
|
+
const O = E, [s, D] = O.member.split("."), I = R.get(s);
|
|
810
813
|
if (!I) return null;
|
|
811
|
-
const
|
|
814
|
+
const N = I.dimensions[D], t = I.measures[D], L = N || t;
|
|
812
815
|
if (!L) return null;
|
|
813
|
-
if (S === "where" &&
|
|
814
|
-
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name ===
|
|
816
|
+
if (S === "where" && N) {
|
|
817
|
+
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name === s))
|
|
815
818
|
return null;
|
|
816
|
-
const P =
|
|
819
|
+
const P = f(N.sql, A);
|
|
817
820
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
818
821
|
} else {
|
|
819
|
-
if (S === "where" &&
|
|
822
|
+
if (S === "where" && t)
|
|
820
823
|
return null;
|
|
821
|
-
if (S === "having" &&
|
|
822
|
-
const P = this.buildHavingMeasureExpression(
|
|
824
|
+
if (S === "having" && t) {
|
|
825
|
+
const P = this.buildHavingMeasureExpression(s, D, t, A, e);
|
|
823
826
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
824
827
|
}
|
|
825
828
|
}
|
|
@@ -831,7 +834,7 @@ class TR {
|
|
|
831
834
|
buildFilterCondition(E, R, A, S) {
|
|
832
835
|
if (!A || A.length === 0)
|
|
833
836
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
834
|
-
const e = A.filter((
|
|
837
|
+
const e = A.filter((s) => !(s == null || s === "" || typeof s == "string" && s.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
|
|
835
838
|
if (e.length === 0 && !["set", "notSet"].includes(R))
|
|
836
839
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
837
840
|
const O = e[0];
|
|
@@ -839,13 +842,13 @@ class TR {
|
|
|
839
842
|
case "equals":
|
|
840
843
|
if (e.length > 1) {
|
|
841
844
|
if (S?.type === "time") {
|
|
842
|
-
const
|
|
843
|
-
return SE(E,
|
|
845
|
+
const s = e.map((D) => this.normalizeDate(D) || D);
|
|
846
|
+
return SE(E, s);
|
|
844
847
|
}
|
|
845
848
|
return SE(E, e);
|
|
846
849
|
} else if (e.length === 1) {
|
|
847
|
-
const
|
|
848
|
-
return j(E,
|
|
850
|
+
const s = S?.type === "time" && this.normalizeDate(O) || O;
|
|
851
|
+
return j(E, s);
|
|
849
852
|
}
|
|
850
853
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
851
854
|
case "notEquals":
|
|
@@ -867,26 +870,26 @@ class TR {
|
|
|
867
870
|
case "lte":
|
|
868
871
|
return $(E, O);
|
|
869
872
|
case "set":
|
|
870
|
-
return
|
|
873
|
+
return WE(E);
|
|
871
874
|
case "notSet":
|
|
872
875
|
return bE(E);
|
|
873
876
|
case "inDateRange":
|
|
874
877
|
if (e.length >= 2) {
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
878
|
+
const s = this.normalizeDate(e[0]), D = this.normalizeDate(e[1]);
|
|
879
|
+
if (s && D)
|
|
877
880
|
return m(
|
|
878
|
-
y(E,
|
|
881
|
+
y(E, s),
|
|
879
882
|
$(E, D)
|
|
880
883
|
);
|
|
881
884
|
}
|
|
882
885
|
return null;
|
|
883
886
|
case "beforeDate": {
|
|
884
|
-
const
|
|
885
|
-
return
|
|
887
|
+
const s = this.normalizeDate(O);
|
|
888
|
+
return s ? eE(E, s) : null;
|
|
886
889
|
}
|
|
887
890
|
case "afterDate": {
|
|
888
|
-
const
|
|
889
|
-
return
|
|
891
|
+
const s = this.normalizeDate(O);
|
|
892
|
+
return s ? IE(E, s) : null;
|
|
890
893
|
}
|
|
891
894
|
case "between":
|
|
892
895
|
return e.length >= 2 ? m(
|
|
@@ -919,7 +922,7 @@ class TR {
|
|
|
919
922
|
);
|
|
920
923
|
case "isNotEmpty":
|
|
921
924
|
return m(
|
|
922
|
-
|
|
925
|
+
WE(E),
|
|
923
926
|
XE(E, "")
|
|
924
927
|
);
|
|
925
928
|
default:
|
|
@@ -962,74 +965,74 @@ class TR {
|
|
|
962
965
|
* Handles all 14 DATE_RANGE_OPTIONS from the client
|
|
963
966
|
*/
|
|
964
967
|
parseRelativeDateRange(E) {
|
|
965
|
-
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), O = R.getUTCDate(),
|
|
968
|
+
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), O = R.getUTCDate(), s = R.getUTCDay();
|
|
966
969
|
if (A === "today") {
|
|
967
|
-
const
|
|
968
|
-
|
|
970
|
+
const t = new Date(R);
|
|
971
|
+
t.setUTCHours(0, 0, 0, 0);
|
|
969
972
|
const L = new Date(R);
|
|
970
|
-
return L.setUTCHours(23, 59, 59, 999), { start:
|
|
973
|
+
return L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
|
|
971
974
|
}
|
|
972
975
|
if (A === "yesterday") {
|
|
973
|
-
const
|
|
974
|
-
|
|
976
|
+
const t = new Date(R);
|
|
977
|
+
t.setUTCDate(O - 1), t.setUTCHours(0, 0, 0, 0);
|
|
975
978
|
const L = new Date(R);
|
|
976
|
-
return L.setUTCDate(O - 1), L.setUTCHours(23, 59, 59, 999), { start:
|
|
979
|
+
return L.setUTCDate(O - 1), L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
|
|
977
980
|
}
|
|
978
981
|
if (A === "this week") {
|
|
979
|
-
const
|
|
980
|
-
L.setUTCDate(O +
|
|
982
|
+
const t = s === 0 ? -6 : 1 - s, L = new Date(R);
|
|
983
|
+
L.setUTCDate(O + t), L.setUTCHours(0, 0, 0, 0);
|
|
981
984
|
const P = new Date(L);
|
|
982
985
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
983
986
|
}
|
|
984
987
|
if (A === "this month") {
|
|
985
|
-
const
|
|
986
|
-
return { start:
|
|
988
|
+
const t = new Date(Date.UTC(S, e, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, e + 1, 0, 23, 59, 59, 999));
|
|
989
|
+
return { start: t, end: L };
|
|
987
990
|
}
|
|
988
991
|
if (A === "this quarter") {
|
|
989
|
-
const
|
|
992
|
+
const t = Math.floor(e / 3), L = new Date(Date.UTC(S, t * 3, 1, 0, 0, 0, 0)), P = new Date(Date.UTC(S, t * 3 + 3, 0, 23, 59, 59, 999));
|
|
990
993
|
return { start: L, end: P };
|
|
991
994
|
}
|
|
992
995
|
if (A === "this year") {
|
|
993
|
-
const
|
|
994
|
-
return { start:
|
|
996
|
+
const t = new Date(Date.UTC(S, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, 11, 31, 23, 59, 59, 999));
|
|
997
|
+
return { start: t, end: L };
|
|
995
998
|
}
|
|
996
999
|
const D = A.match(/^last\s+(\d+)\s+days?$/);
|
|
997
1000
|
if (D) {
|
|
998
|
-
const
|
|
999
|
-
L.setUTCDate(O -
|
|
1001
|
+
const t = parseInt(D[1], 10), L = new Date(R);
|
|
1002
|
+
L.setUTCDate(O - t + 1), L.setUTCHours(0, 0, 0, 0);
|
|
1000
1003
|
const P = new Date(R);
|
|
1001
1004
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1002
1005
|
}
|
|
1003
1006
|
if (A === "last week") {
|
|
1004
|
-
const
|
|
1005
|
-
L.setUTCDate(O +
|
|
1007
|
+
const t = s === 0 ? -13 : -6 - s, L = new Date(R);
|
|
1008
|
+
L.setUTCDate(O + t), L.setUTCHours(0, 0, 0, 0);
|
|
1006
1009
|
const P = new Date(L);
|
|
1007
1010
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1008
1011
|
}
|
|
1009
1012
|
if (A === "last month") {
|
|
1010
|
-
const
|
|
1011
|
-
return { start:
|
|
1013
|
+
const t = new Date(Date.UTC(S, e - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, e, 0, 23, 59, 59, 999));
|
|
1014
|
+
return { start: t, end: L };
|
|
1012
1015
|
}
|
|
1013
1016
|
if (A === "last quarter") {
|
|
1014
|
-
const
|
|
1017
|
+
const t = Math.floor(e / 3), L = t === 0 ? 3 : t - 1, P = t === 0 ? S - 1 : S, a = new Date(Date.UTC(P, L * 3, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(P, L * 3 + 3, 0, 23, 59, 59, 999));
|
|
1015
1018
|
return { start: a, end: r };
|
|
1016
1019
|
}
|
|
1017
1020
|
if (A === "last year") {
|
|
1018
|
-
const
|
|
1019
|
-
return { start:
|
|
1021
|
+
const t = new Date(Date.UTC(S - 1, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S - 1, 11, 31, 23, 59, 59, 999));
|
|
1022
|
+
return { start: t, end: L };
|
|
1020
1023
|
}
|
|
1021
1024
|
if (A === "last 12 months") {
|
|
1022
|
-
const
|
|
1023
|
-
return L.setUTCHours(23, 59, 59, 999), { start:
|
|
1025
|
+
const t = new Date(Date.UTC(S, e - 11, 1, 0, 0, 0, 0)), L = new Date(R);
|
|
1026
|
+
return L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
|
|
1024
1027
|
}
|
|
1025
1028
|
const I = A.match(/^last\s+(\d+)\s+months?$/);
|
|
1026
1029
|
if (I) {
|
|
1027
|
-
const
|
|
1030
|
+
const t = parseInt(I[1], 10), L = new Date(Date.UTC(S, e - t + 1, 1, 0, 0, 0, 0)), P = new Date(R);
|
|
1028
1031
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1029
1032
|
}
|
|
1030
|
-
const
|
|
1031
|
-
if (
|
|
1032
|
-
const
|
|
1033
|
+
const N = A.match(/^last\s+(\d+)\s+years?$/);
|
|
1034
|
+
if (N) {
|
|
1035
|
+
const t = parseInt(N[1], 10), L = new Date(Date.UTC(S - t, 0, 1, 0, 0, 0, 0)), P = new Date(R);
|
|
1033
1036
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1034
1037
|
}
|
|
1035
1038
|
return null;
|
|
@@ -1062,30 +1065,30 @@ class TR {
|
|
|
1062
1065
|
const e = [];
|
|
1063
1066
|
if (!(R.measures && R.measures.length > 0))
|
|
1064
1067
|
return [];
|
|
1065
|
-
const
|
|
1068
|
+
const s = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1066
1069
|
if (R.dimensions)
|
|
1067
1070
|
for (const D of R.dimensions) {
|
|
1068
|
-
const [I,
|
|
1069
|
-
if (
|
|
1071
|
+
const [I, N] = D.split("."), t = s.get(I);
|
|
1072
|
+
if (t && t.dimensions && t.dimensions[N])
|
|
1070
1073
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1071
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), a = P.joinKeys.find((r) => r.targetColumn ===
|
|
1074
|
+
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), a = P.joinKeys.find((r) => r.targetColumn === N);
|
|
1072
1075
|
if (a && a.sourceColumnObj)
|
|
1073
1076
|
e.push(a.sourceColumnObj);
|
|
1074
1077
|
else {
|
|
1075
|
-
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(
|
|
1078
|
+
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(N)}`;
|
|
1076
1079
|
e.push(r);
|
|
1077
1080
|
}
|
|
1078
1081
|
} else {
|
|
1079
|
-
const P =
|
|
1082
|
+
const P = t.dimensions[N], a = f(P.sql, A);
|
|
1080
1083
|
e.push(a);
|
|
1081
1084
|
}
|
|
1082
1085
|
}
|
|
1083
1086
|
if (R.timeDimensions)
|
|
1084
1087
|
for (const D of R.timeDimensions) {
|
|
1085
|
-
const [I,
|
|
1086
|
-
if (
|
|
1088
|
+
const [I, N] = D.dimension.split("."), t = s.get(I);
|
|
1089
|
+
if (t && t.dimensions && t.dimensions[N])
|
|
1087
1090
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1088
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), a = P.joinKeys.find((r) => r.targetColumn ===
|
|
1091
|
+
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), a = P.joinKeys.find((r) => r.targetColumn === N);
|
|
1089
1092
|
if (a && a.sourceColumnObj) {
|
|
1090
1093
|
const r = this.buildTimeDimensionExpression(
|
|
1091
1094
|
a.sourceColumnObj,
|
|
@@ -1094,11 +1097,11 @@ class TR {
|
|
|
1094
1097
|
);
|
|
1095
1098
|
e.push(r);
|
|
1096
1099
|
} else {
|
|
1097
|
-
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(
|
|
1100
|
+
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(N)}`;
|
|
1098
1101
|
e.push(r);
|
|
1099
1102
|
}
|
|
1100
1103
|
} else {
|
|
1101
|
-
const P =
|
|
1104
|
+
const P = t.dimensions[N], a = this.buildTimeDimensionExpression(
|
|
1102
1105
|
P.sql,
|
|
1103
1106
|
D.granularity,
|
|
1104
1107
|
A
|
|
@@ -1121,15 +1124,15 @@ class TR {
|
|
|
1121
1124
|
for (const [e, O] of Object.entries(E.order)) {
|
|
1122
1125
|
if (!S.includes(e))
|
|
1123
1126
|
throw new Error(`Cannot order by '${e}': field is not selected in the query`);
|
|
1124
|
-
const
|
|
1125
|
-
A.push(
|
|
1127
|
+
const s = O === "desc" ? JT(_.identifier(e)) : yE(_.identifier(e));
|
|
1128
|
+
A.push(s);
|
|
1126
1129
|
}
|
|
1127
1130
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
1128
1131
|
const e = new Set(Object.keys(E.order || {})), O = [...E.timeDimensions].sort(
|
|
1129
|
-
(
|
|
1132
|
+
(s, D) => s.dimension.localeCompare(D.dimension)
|
|
1130
1133
|
);
|
|
1131
|
-
for (const
|
|
1132
|
-
e.has(
|
|
1134
|
+
for (const s of O)
|
|
1135
|
+
e.has(s.dimension) || A.push(yE(_.identifier(s.dimension)));
|
|
1133
1136
|
}
|
|
1134
1137
|
return A;
|
|
1135
1138
|
}
|
|
@@ -1141,9 +1144,9 @@ class TR {
|
|
|
1141
1144
|
const A = [], S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1142
1145
|
if (R.measures && A.push(...R.measures), R.dimensions)
|
|
1143
1146
|
for (const e of R.dimensions) {
|
|
1144
|
-
const [O,
|
|
1147
|
+
const [O, s] = e.split("."), D = S.get(O);
|
|
1145
1148
|
if (D) {
|
|
1146
|
-
const I = D.dimensions[
|
|
1149
|
+
const I = D.dimensions[s];
|
|
1147
1150
|
I && I.type === "number" && A.push(e);
|
|
1148
1151
|
}
|
|
1149
1152
|
}
|
|
@@ -1244,12 +1247,12 @@ class RR {
|
|
|
1244
1247
|
const S = this.analyzeCubeUsage(R), e = Array.from(S);
|
|
1245
1248
|
if (e.length === 0)
|
|
1246
1249
|
throw new Error("No cubes found in query");
|
|
1247
|
-
const O = this.choosePrimaryCube(e, R, E),
|
|
1248
|
-
if (!
|
|
1250
|
+
const O = this.choosePrimaryCube(e, R, E), s = E.get(O);
|
|
1251
|
+
if (!s)
|
|
1249
1252
|
throw new Error(`Primary cube '${O}' not found`);
|
|
1250
1253
|
if (e.length === 1)
|
|
1251
1254
|
return {
|
|
1252
|
-
primaryCube:
|
|
1255
|
+
primaryCube: s,
|
|
1253
1256
|
joinCubes: [],
|
|
1254
1257
|
// Empty for single cube
|
|
1255
1258
|
selections: {},
|
|
@@ -1259,9 +1262,9 @@ class RR {
|
|
|
1259
1262
|
groupByFields: []
|
|
1260
1263
|
// Will be built by QueryBuilder
|
|
1261
1264
|
};
|
|
1262
|
-
const D = this.buildJoinPlan(E,
|
|
1265
|
+
const D = this.buildJoinPlan(E, s, e), I = this.planPreAggregationCTEs(E, s, D, R);
|
|
1263
1266
|
return {
|
|
1264
|
-
primaryCube:
|
|
1267
|
+
primaryCube: s,
|
|
1265
1268
|
joinCubes: D,
|
|
1266
1269
|
selections: {},
|
|
1267
1270
|
// Will be built by QueryBuilder
|
|
@@ -1282,8 +1285,8 @@ class RR {
|
|
|
1282
1285
|
for (const O of S)
|
|
1283
1286
|
e.set(O, (e.get(O) || 0) + 1);
|
|
1284
1287
|
if (e.size > 0) {
|
|
1285
|
-
const O = Math.max(...e.values()),
|
|
1286
|
-
for (const D of
|
|
1288
|
+
const O = Math.max(...e.values()), s = [...e.entries()].filter(([, D]) => D === O).map(([D]) => D).sort();
|
|
1289
|
+
for (const D of s)
|
|
1287
1290
|
if (this.canReachAllCubes(D, E, A))
|
|
1288
1291
|
return D;
|
|
1289
1292
|
}
|
|
@@ -1292,12 +1295,12 @@ class RR {
|
|
|
1292
1295
|
const S = /* @__PURE__ */ new Map();
|
|
1293
1296
|
for (const e of E)
|
|
1294
1297
|
if (this.canReachAllCubes(e, E, A)) {
|
|
1295
|
-
const O = A.get(e),
|
|
1296
|
-
S.set(e,
|
|
1298
|
+
const O = A.get(e), s = O?.joins ? Object.keys(O.joins).length : 0;
|
|
1299
|
+
S.set(e, s);
|
|
1297
1300
|
}
|
|
1298
1301
|
if (S.size > 0) {
|
|
1299
1302
|
const e = Math.max(...S.values());
|
|
1300
|
-
return [...S.entries()].filter(([,
|
|
1303
|
+
return [...S.entries()].filter(([, s]) => s === e).map(([s]) => s).sort()[0];
|
|
1301
1304
|
}
|
|
1302
1305
|
}
|
|
1303
1306
|
return [...E].sort()[0];
|
|
@@ -1319,28 +1322,28 @@ class RR {
|
|
|
1319
1322
|
* Supports both direct joins and transitive joins through intermediate cubes
|
|
1320
1323
|
*/
|
|
1321
1324
|
buildJoinPlan(E, R, A) {
|
|
1322
|
-
const S = [], e = /* @__PURE__ */ new Set([R.name]), O = A.filter((
|
|
1323
|
-
for (const
|
|
1324
|
-
if (e.has(
|
|
1325
|
+
const S = [], e = /* @__PURE__ */ new Set([R.name]), O = A.filter((s) => s !== R.name);
|
|
1326
|
+
for (const s of O) {
|
|
1327
|
+
if (e.has(s))
|
|
1325
1328
|
continue;
|
|
1326
|
-
const D = this.findJoinPath(E, R.name,
|
|
1329
|
+
const D = this.findJoinPath(E, R.name, s, e);
|
|
1327
1330
|
if (!D || D.length === 0)
|
|
1328
|
-
throw new Error(`No join path found from '${R.name}' to '${
|
|
1329
|
-
for (const { toCube: I, joinDef:
|
|
1331
|
+
throw new Error(`No join path found from '${R.name}' to '${s}'`);
|
|
1332
|
+
for (const { toCube: I, joinDef: N } of D) {
|
|
1330
1333
|
if (e.has(I))
|
|
1331
1334
|
continue;
|
|
1332
|
-
const
|
|
1333
|
-
if (!
|
|
1335
|
+
const t = E.get(I);
|
|
1336
|
+
if (!t)
|
|
1334
1337
|
throw new Error(`Cube '${I}' not found`);
|
|
1335
1338
|
const L = this.buildJoinCondition(
|
|
1336
|
-
|
|
1339
|
+
N,
|
|
1337
1340
|
null,
|
|
1338
1341
|
// No source alias needed - use the actual column
|
|
1339
1342
|
null
|
|
1340
1343
|
// No target alias needed - use the actual column
|
|
1341
|
-
), P = ER(
|
|
1344
|
+
), P = ER(N.relationship, N.sqlJoinType);
|
|
1342
1345
|
S.push({
|
|
1343
|
-
cube:
|
|
1346
|
+
cube: t,
|
|
1344
1347
|
alias: `${I.toLowerCase()}_cube`,
|
|
1345
1348
|
joinType: P,
|
|
1346
1349
|
joinCondition: L
|
|
@@ -1355,8 +1358,8 @@ class RR {
|
|
|
1355
1358
|
buildJoinCondition(E, R, A) {
|
|
1356
1359
|
const S = [];
|
|
1357
1360
|
for (const e of E.on) {
|
|
1358
|
-
const O = R ? _`${_.identifier(R)}.${_.identifier(e.source.name)}` : e.source,
|
|
1359
|
-
S.push(D(O,
|
|
1361
|
+
const O = R ? _`${_.identifier(R)}.${_.identifier(e.source.name)}` : e.source, s = A ? _`${_.identifier(A)}.${_.identifier(e.target.name)}` : e.target, D = e.as || j;
|
|
1362
|
+
S.push(D(O, s));
|
|
1360
1363
|
}
|
|
1361
1364
|
return m(...S);
|
|
1362
1365
|
}
|
|
@@ -1371,16 +1374,16 @@ class RR {
|
|
|
1371
1374
|
{ cube: R, path: [] }
|
|
1372
1375
|
], O = /* @__PURE__ */ new Set([R, ...S]);
|
|
1373
1376
|
for (; e.length > 0; ) {
|
|
1374
|
-
const { cube:
|
|
1377
|
+
const { cube: s, path: D } = e.shift(), I = E.get(s);
|
|
1375
1378
|
if (I?.joins)
|
|
1376
|
-
for (const [,
|
|
1377
|
-
const L = wE(
|
|
1379
|
+
for (const [, N] of Object.entries(I.joins)) {
|
|
1380
|
+
const L = wE(N.targetCube).name;
|
|
1378
1381
|
if (O.has(L))
|
|
1379
1382
|
continue;
|
|
1380
1383
|
const P = [...D, {
|
|
1381
|
-
fromCube:
|
|
1384
|
+
fromCube: s,
|
|
1382
1385
|
toCube: L,
|
|
1383
|
-
joinDef:
|
|
1386
|
+
joinDef: N
|
|
1384
1387
|
}];
|
|
1385
1388
|
if (L === A)
|
|
1386
1389
|
return P;
|
|
@@ -1397,15 +1400,15 @@ class RR {
|
|
|
1397
1400
|
if (!S.measures || S.measures.length === 0)
|
|
1398
1401
|
return e;
|
|
1399
1402
|
for (const O of A) {
|
|
1400
|
-
const
|
|
1401
|
-
if (!
|
|
1403
|
+
const s = this.findHasManyJoinDef(R, O.cube.name);
|
|
1404
|
+
if (!s)
|
|
1402
1405
|
continue;
|
|
1403
1406
|
const D = S.measures ? S.measures.filter(
|
|
1404
1407
|
(L) => L.startsWith(O.cube.name + ".")
|
|
1405
|
-
) : [], I = this.extractMeasuresFromFilters(S, O.cube.name),
|
|
1406
|
-
if (
|
|
1408
|
+
) : [], I = this.extractMeasuresFromFilters(S, O.cube.name), N = [.../* @__PURE__ */ new Set([...D, ...I])];
|
|
1409
|
+
if (N.length === 0)
|
|
1407
1410
|
continue;
|
|
1408
|
-
const
|
|
1411
|
+
const t = s.on.map((L) => ({
|
|
1409
1412
|
sourceColumn: L.source.name,
|
|
1410
1413
|
targetColumn: L.target.name,
|
|
1411
1414
|
sourceColumnObj: L.source,
|
|
@@ -1415,8 +1418,8 @@ class RR {
|
|
|
1415
1418
|
cube: O.cube,
|
|
1416
1419
|
alias: O.alias,
|
|
1417
1420
|
cteAlias: `${O.cube.name.toLowerCase()}_agg`,
|
|
1418
|
-
joinKeys:
|
|
1419
|
-
measures:
|
|
1421
|
+
joinKeys: t,
|
|
1422
|
+
measures: N
|
|
1420
1423
|
});
|
|
1421
1424
|
}
|
|
1422
1425
|
return e;
|
|
@@ -1454,7 +1457,7 @@ class OE {
|
|
|
1454
1457
|
db: this.dbExecutor.db,
|
|
1455
1458
|
schema: this.dbExecutor.schema,
|
|
1456
1459
|
securityContext: A
|
|
1457
|
-
}, O = this.queryPlanner.createQueryPlan(E, R, e),
|
|
1460
|
+
}, O = this.queryPlanner.createQueryPlan(E, R, e), s = this.buildUnifiedQuery(O, R, e), D = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(s, D), N = Array.isArray(I) ? I.map((L) => {
|
|
1458
1461
|
const P = { ...L };
|
|
1459
1462
|
if (R.timeDimensions) {
|
|
1460
1463
|
for (const a of R.timeDimensions)
|
|
@@ -1468,10 +1471,10 @@ class OE {
|
|
|
1468
1471
|
}
|
|
1469
1472
|
}
|
|
1470
1473
|
return P;
|
|
1471
|
-
}) : [I],
|
|
1474
|
+
}) : [I], t = this.generateAnnotations(O, R);
|
|
1472
1475
|
return {
|
|
1473
|
-
data:
|
|
1474
|
-
annotation:
|
|
1476
|
+
data: N,
|
|
1477
|
+
annotation: t
|
|
1475
1478
|
};
|
|
1476
1479
|
} catch (S) {
|
|
1477
1480
|
throw new Error(`Query execution failed: ${S instanceof Error ? S.message : "Unknown error"}`);
|
|
@@ -1488,18 +1491,18 @@ class OE {
|
|
|
1488
1491
|
* Build pre-aggregation CTE for hasMany relationships
|
|
1489
1492
|
*/
|
|
1490
1493
|
buildPreAggregationCTE(E, R, A, S) {
|
|
1491
|
-
const e = E.cube, O = e.sql(A),
|
|
1494
|
+
const e = E.cube, O = e.sql(A), s = {};
|
|
1492
1495
|
for (const r of E.joinKeys)
|
|
1493
1496
|
if (r.targetColumnObj) {
|
|
1494
|
-
|
|
1497
|
+
s[r.targetColumn] = r.targetColumnObj;
|
|
1495
1498
|
for (const [U, o] of Object.entries(e.dimensions || {}))
|
|
1496
|
-
o.sql === r.targetColumnObj && U !== r.targetColumn && (
|
|
1499
|
+
o.sql === r.targetColumnObj && U !== r.targetColumn && (s[U] = _`${r.targetColumnObj}`.as(U));
|
|
1497
1500
|
}
|
|
1498
1501
|
for (const r of E.measures) {
|
|
1499
1502
|
const [, U] = r.split(".");
|
|
1500
1503
|
if (e.measures && e.measures[U]) {
|
|
1501
|
-
const o = e.measures[U],
|
|
1502
|
-
|
|
1504
|
+
const o = e.measures[U], l = this.queryBuilder.buildMeasureExpression(o, A);
|
|
1505
|
+
s[U] = _`${l}`.as(U);
|
|
1503
1506
|
}
|
|
1504
1507
|
}
|
|
1505
1508
|
const D = e.name;
|
|
@@ -1507,48 +1510,48 @@ class OE {
|
|
|
1507
1510
|
for (const r of R.dimensions) {
|
|
1508
1511
|
const [U, o] = r.split(".");
|
|
1509
1512
|
if (U === D && e.dimensions && e.dimensions[o]) {
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1513
|
+
const l = e.dimensions[o], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A);
|
|
1514
|
+
s[o] = _`${c}`.as(o);
|
|
1512
1515
|
}
|
|
1513
1516
|
}
|
|
1514
1517
|
if (R.timeDimensions)
|
|
1515
1518
|
for (const r of R.timeDimensions) {
|
|
1516
1519
|
const [U, o] = r.dimension.split(".");
|
|
1517
1520
|
if (U === D && e.dimensions && e.dimensions[o]) {
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1521
|
+
const l = e.dimensions[o], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, r.granularity, A);
|
|
1522
|
+
s[o] = _`${c}`.as(o);
|
|
1520
1523
|
}
|
|
1521
1524
|
}
|
|
1522
|
-
if (Object.keys(
|
|
1525
|
+
if (Object.keys(s).length === 0)
|
|
1523
1526
|
return null;
|
|
1524
|
-
let I = A.db.select(
|
|
1525
|
-
const
|
|
1527
|
+
let I = A.db.select(s).from(O.from);
|
|
1528
|
+
const N = S ? {
|
|
1526
1529
|
...S,
|
|
1527
1530
|
preAggregationCTEs: S.preAggregationCTEs?.filter((r) => r.cube.name !== e.name)
|
|
1528
|
-
} : void 0,
|
|
1531
|
+
} : void 0, t = this.queryBuilder.buildWhereConditions(e, R, A, N), L = [];
|
|
1529
1532
|
if (R.timeDimensions)
|
|
1530
1533
|
for (const r of R.timeDimensions) {
|
|
1531
1534
|
const [U, o] = r.dimension.split(".");
|
|
1532
1535
|
if (U === D && e.dimensions && e.dimensions[o] && r.dateRange) {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1536
|
+
const l = e.dimensions[o], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), H = this.queryBuilder.buildDateRangeCondition(c, r.dateRange);
|
|
1537
|
+
H && L.push(H);
|
|
1535
1538
|
}
|
|
1536
1539
|
}
|
|
1537
1540
|
if (R.filters) {
|
|
1538
1541
|
for (const r of R.filters)
|
|
1539
1542
|
if (!("and" in r) && !("or" in r) && "member" in r && "operator" in r) {
|
|
1540
|
-
const U = r, [o,
|
|
1541
|
-
if (o === D && e.dimensions && e.dimensions[
|
|
1542
|
-
const
|
|
1543
|
+
const U = r, [o, l] = U.member.split(".");
|
|
1544
|
+
if (o === D && e.dimensions && e.dimensions[l]) {
|
|
1545
|
+
const c = e.dimensions[l];
|
|
1543
1546
|
if (U.operator === "inDateRange") {
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1547
|
+
const H = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), u = this.queryBuilder.buildDateRangeCondition(H, U.values);
|
|
1548
|
+
u && L.push(u);
|
|
1546
1549
|
}
|
|
1547
1550
|
}
|
|
1548
1551
|
}
|
|
1549
1552
|
}
|
|
1550
1553
|
const P = [];
|
|
1551
|
-
if (O.where && P.push(O.where), P.push(...
|
|
1554
|
+
if (O.where && P.push(O.where), P.push(...t, ...L), P.length > 0) {
|
|
1552
1555
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1553
1556
|
I = I.where(r);
|
|
1554
1557
|
}
|
|
@@ -1559,16 +1562,16 @@ class OE {
|
|
|
1559
1562
|
for (const r of R.dimensions) {
|
|
1560
1563
|
const [U, o] = r.split(".");
|
|
1561
1564
|
if (U === D && e.dimensions && e.dimensions[o]) {
|
|
1562
|
-
const
|
|
1563
|
-
a.push(
|
|
1565
|
+
const l = e.dimensions[o], c = f(l.sql, A);
|
|
1566
|
+
a.push(c);
|
|
1564
1567
|
}
|
|
1565
1568
|
}
|
|
1566
1569
|
if (R.timeDimensions)
|
|
1567
1570
|
for (const r of R.timeDimensions) {
|
|
1568
1571
|
const [U, o] = r.dimension.split(".");
|
|
1569
1572
|
if (U === D && e.dimensions && e.dimensions[o]) {
|
|
1570
|
-
const
|
|
1571
|
-
a.push(
|
|
1573
|
+
const l = e.dimensions[o], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, r.granularity, A);
|
|
1574
|
+
a.push(c);
|
|
1572
1575
|
}
|
|
1573
1576
|
}
|
|
1574
1577
|
return a.length > 0 && (I = I.groupBy(...a)), A.db.$with(E.cteAlias).as(I);
|
|
@@ -1583,8 +1586,8 @@ class OE {
|
|
|
1583
1586
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
1584
1587
|
const e = [];
|
|
1585
1588
|
for (const O of S.joinKeys) {
|
|
1586
|
-
const
|
|
1587
|
-
e.push(j(
|
|
1589
|
+
const s = O.sourceColumnObj || _.identifier(O.sourceColumn), D = _`${_.identifier(R)}.${_.identifier(O.targetColumn)}`;
|
|
1590
|
+
e.push(j(s, D));
|
|
1588
1591
|
}
|
|
1589
1592
|
return e.length === 1 ? e[0] : m(...e);
|
|
1590
1593
|
}
|
|
@@ -1609,98 +1612,123 @@ class OE {
|
|
|
1609
1612
|
const U = r.cube.name;
|
|
1610
1613
|
for (const o of r.measures)
|
|
1611
1614
|
if (D[o]) {
|
|
1612
|
-
const [,
|
|
1613
|
-
if (
|
|
1614
|
-
const
|
|
1615
|
+
const [, l] = o.split("."), c = this.getCubesFromPlan(E).get(U);
|
|
1616
|
+
if (c && c.measures && c.measures[l]) {
|
|
1617
|
+
const H = c.measures[l], u = _`${_.identifier(r.cteAlias)}.${_.identifier(l)}`;
|
|
1615
1618
|
let p;
|
|
1616
|
-
switch (
|
|
1619
|
+
switch (H.type) {
|
|
1617
1620
|
case "count":
|
|
1618
1621
|
case "countDistinct":
|
|
1619
1622
|
case "sum":
|
|
1620
|
-
p =
|
|
1623
|
+
p = W(u);
|
|
1621
1624
|
break;
|
|
1622
1625
|
case "avg":
|
|
1623
|
-
p = this.databaseAdapter.buildAvg(
|
|
1626
|
+
p = this.databaseAdapter.buildAvg(u);
|
|
1624
1627
|
break;
|
|
1625
1628
|
case "min":
|
|
1626
|
-
p = mE(
|
|
1629
|
+
p = mE(u);
|
|
1627
1630
|
break;
|
|
1628
1631
|
case "max":
|
|
1629
|
-
p = YE(
|
|
1632
|
+
p = YE(u);
|
|
1630
1633
|
break;
|
|
1631
1634
|
case "number":
|
|
1632
|
-
p =
|
|
1635
|
+
p = W(u);
|
|
1633
1636
|
break;
|
|
1634
1637
|
default:
|
|
1635
|
-
p =
|
|
1638
|
+
p = W(u);
|
|
1636
1639
|
}
|
|
1637
1640
|
D[o] = _`${p}`.as(o);
|
|
1638
1641
|
}
|
|
1639
1642
|
}
|
|
1640
1643
|
for (const o in D) {
|
|
1641
|
-
const [
|
|
1642
|
-
if (
|
|
1643
|
-
const
|
|
1644
|
-
if (
|
|
1645
|
-
let K = r.joinKeys.find((TE) => TE.targetColumn ===
|
|
1646
|
-
if (!K &&
|
|
1647
|
-
const TE =
|
|
1644
|
+
const [l, c] = o.split(".");
|
|
1645
|
+
if (l === U) {
|
|
1646
|
+
const H = this.getCubesFromPlan(E).get(U), u = H && H.dimensions?.[c], p = o.startsWith(U + ".");
|
|
1647
|
+
if (u || p) {
|
|
1648
|
+
let K = r.joinKeys.find((TE) => TE.targetColumn === c);
|
|
1649
|
+
if (!K && H?.dimensions?.[c]) {
|
|
1650
|
+
const TE = H.dimensions[c].sql;
|
|
1648
1651
|
K = r.joinKeys.find((yT) => yT.targetColumnObj === TE);
|
|
1649
1652
|
}
|
|
1650
|
-
K ? D[o] = _`${_.identifier(r.cteAlias)}.${_.identifier(
|
|
1653
|
+
K ? D[o] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(o) : p && H?.dimensions?.[c] && (D[o] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(o));
|
|
1651
1654
|
}
|
|
1652
1655
|
}
|
|
1653
1656
|
}
|
|
1654
1657
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1658
|
+
const I = [];
|
|
1659
|
+
let N = A.db.select(D).from(O.from);
|
|
1660
|
+
if (S.length > 0 && (N = A.db.with(...S).select(D).from(O.from)), O.joins)
|
|
1657
1661
|
for (const r of O.joins)
|
|
1658
1662
|
switch (r.type || "left") {
|
|
1659
1663
|
case "left":
|
|
1660
|
-
|
|
1664
|
+
N = N.leftJoin(r.table, r.on);
|
|
1661
1665
|
break;
|
|
1662
1666
|
case "inner":
|
|
1663
|
-
|
|
1667
|
+
N = N.innerJoin(r.table, r.on);
|
|
1664
1668
|
break;
|
|
1665
1669
|
case "right":
|
|
1666
|
-
|
|
1670
|
+
N = N.rightJoin(r.table, r.on);
|
|
1667
1671
|
break;
|
|
1668
1672
|
case "full":
|
|
1669
|
-
|
|
1673
|
+
N = N.fullJoin(r.table, r.on);
|
|
1670
1674
|
break;
|
|
1671
1675
|
}
|
|
1672
1676
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
1673
1677
|
for (const r of E.joinCubes) {
|
|
1674
1678
|
const U = e.get(r.cube.name);
|
|
1675
|
-
|
|
1676
|
-
|
|
1679
|
+
if (r.junctionTable) {
|
|
1680
|
+
const c = r.junctionTable, H = [];
|
|
1681
|
+
if (c.securitySql) {
|
|
1682
|
+
const u = c.securitySql(A.securityContext);
|
|
1683
|
+
Array.isArray(u) ? H.push(...u) : H.push(u);
|
|
1684
|
+
}
|
|
1685
|
+
try {
|
|
1686
|
+
switch (c.joinType || "left") {
|
|
1687
|
+
case "left":
|
|
1688
|
+
N = N.leftJoin(c.table, c.joinCondition);
|
|
1689
|
+
break;
|
|
1690
|
+
case "inner":
|
|
1691
|
+
N = N.innerJoin(c.table, c.joinCondition);
|
|
1692
|
+
break;
|
|
1693
|
+
case "right":
|
|
1694
|
+
N = N.rightJoin(c.table, c.joinCondition);
|
|
1695
|
+
break;
|
|
1696
|
+
case "full":
|
|
1697
|
+
N = N.fullJoin(c.table, c.joinCondition);
|
|
1698
|
+
break;
|
|
1699
|
+
}
|
|
1700
|
+
H.length > 0 && I.push(...H);
|
|
1701
|
+
} catch {
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
let o, l;
|
|
1705
|
+
U ? (o = _`${_.identifier(U)}`, l = this.buildCTEJoinCondition(r, U, E)) : (o = r.cube.sql(A).from, l = r.joinCondition);
|
|
1677
1706
|
try {
|
|
1678
1707
|
switch (r.joinType || "left") {
|
|
1679
1708
|
case "left":
|
|
1680
|
-
|
|
1709
|
+
N = N.leftJoin(o, l);
|
|
1681
1710
|
break;
|
|
1682
1711
|
case "inner":
|
|
1683
|
-
|
|
1712
|
+
N = N.innerJoin(o, l);
|
|
1684
1713
|
break;
|
|
1685
1714
|
case "right":
|
|
1686
|
-
|
|
1715
|
+
N = N.rightJoin(o, l);
|
|
1687
1716
|
break;
|
|
1688
1717
|
case "full":
|
|
1689
|
-
|
|
1718
|
+
N = N.fullJoin(o, l);
|
|
1690
1719
|
break;
|
|
1691
1720
|
}
|
|
1692
1721
|
} catch {
|
|
1693
1722
|
}
|
|
1694
1723
|
}
|
|
1695
|
-
|
|
1696
|
-
if (O.where && C.push(O.where), E.joinCubes && E.joinCubes.length > 0)
|
|
1724
|
+
if (O.where && I.push(O.where), E.joinCubes && E.joinCubes.length > 0)
|
|
1697
1725
|
for (const r of E.joinCubes) {
|
|
1698
1726
|
if (e.get(r.cube.name))
|
|
1699
1727
|
continue;
|
|
1700
1728
|
const o = r.cube.sql(A);
|
|
1701
|
-
o.where &&
|
|
1729
|
+
o.where && I.push(o.where);
|
|
1702
1730
|
}
|
|
1703
|
-
const
|
|
1731
|
+
const t = this.queryBuilder.buildWhereConditions(
|
|
1704
1732
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1705
1733
|
// Single cube
|
|
1706
1734
|
R,
|
|
@@ -1708,9 +1736,9 @@ class OE {
|
|
|
1708
1736
|
E
|
|
1709
1737
|
// Pass the queryPlan to handle CTE scenarios
|
|
1710
1738
|
);
|
|
1711
|
-
if (
|
|
1712
|
-
const r =
|
|
1713
|
-
|
|
1739
|
+
if (t.length > 0 && I.push(...t), I.length > 0) {
|
|
1740
|
+
const r = I.length === 1 ? I[0] : m(...I);
|
|
1741
|
+
N = N.where(r);
|
|
1714
1742
|
}
|
|
1715
1743
|
const L = this.queryBuilder.buildGroupByFields(
|
|
1716
1744
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -1720,7 +1748,7 @@ class OE {
|
|
|
1720
1748
|
E
|
|
1721
1749
|
// Pass the queryPlan to handle CTE scenarios
|
|
1722
1750
|
);
|
|
1723
|
-
L.length > 0 && (
|
|
1751
|
+
L.length > 0 && (N = N.groupBy(...L));
|
|
1724
1752
|
const P = this.queryBuilder.buildHavingConditions(
|
|
1725
1753
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1726
1754
|
// Single cube
|
|
@@ -1731,10 +1759,10 @@ class OE {
|
|
|
1731
1759
|
);
|
|
1732
1760
|
if (P.length > 0) {
|
|
1733
1761
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1734
|
-
|
|
1762
|
+
N = N.having(r);
|
|
1735
1763
|
}
|
|
1736
1764
|
const a = this.queryBuilder.buildOrderBy(R);
|
|
1737
|
-
return a.length > 0 && (
|
|
1765
|
+
return a.length > 0 && (N = N.orderBy(...a)), N = this.queryBuilder.applyLimitAndOffset(N, R), N;
|
|
1738
1766
|
}
|
|
1739
1767
|
/**
|
|
1740
1768
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -1767,10 +1795,10 @@ class OE {
|
|
|
1767
1795
|
db: this.dbExecutor.db,
|
|
1768
1796
|
schema: this.dbExecutor.schema,
|
|
1769
1797
|
securityContext: A
|
|
1770
|
-
}, e = this.queryPlanner.createQueryPlan(E, R, S),
|
|
1798
|
+
}, e = this.queryPlanner.createQueryPlan(E, R, S), s = this.buildUnifiedQuery(e, R, S).toSQL();
|
|
1771
1799
|
return {
|
|
1772
|
-
sql:
|
|
1773
|
-
params:
|
|
1800
|
+
sql: s.sql,
|
|
1801
|
+
params: s.params
|
|
1774
1802
|
};
|
|
1775
1803
|
}
|
|
1776
1804
|
/**
|
|
@@ -1778,40 +1806,40 @@ class OE {
|
|
|
1778
1806
|
*/
|
|
1779
1807
|
generateAnnotations(E, R) {
|
|
1780
1808
|
const A = {}, S = {}, e = {}, O = [E.primaryCube];
|
|
1781
|
-
if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((
|
|
1782
|
-
for (const
|
|
1783
|
-
const [D, I] =
|
|
1784
|
-
if (
|
|
1785
|
-
const
|
|
1786
|
-
A[
|
|
1787
|
-
title:
|
|
1788
|
-
shortTitle:
|
|
1789
|
-
type:
|
|
1809
|
+
if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((s) => s.cube)), R.measures)
|
|
1810
|
+
for (const s of R.measures) {
|
|
1811
|
+
const [D, I] = s.split("."), N = O.find((t) => t.name === D);
|
|
1812
|
+
if (N && N.measures[I]) {
|
|
1813
|
+
const t = N.measures[I];
|
|
1814
|
+
A[s] = {
|
|
1815
|
+
title: t.title || I,
|
|
1816
|
+
shortTitle: t.title || I,
|
|
1817
|
+
type: t.type
|
|
1790
1818
|
};
|
|
1791
1819
|
}
|
|
1792
1820
|
}
|
|
1793
1821
|
if (R.dimensions)
|
|
1794
|
-
for (const
|
|
1795
|
-
const [D, I] =
|
|
1796
|
-
if (
|
|
1797
|
-
const
|
|
1798
|
-
S[
|
|
1799
|
-
title:
|
|
1800
|
-
shortTitle:
|
|
1801
|
-
type:
|
|
1822
|
+
for (const s of R.dimensions) {
|
|
1823
|
+
const [D, I] = s.split("."), N = O.find((t) => t.name === D);
|
|
1824
|
+
if (N && N.dimensions[I]) {
|
|
1825
|
+
const t = N.dimensions[I];
|
|
1826
|
+
S[s] = {
|
|
1827
|
+
title: t.title || I,
|
|
1828
|
+
shortTitle: t.title || I,
|
|
1829
|
+
type: t.type
|
|
1802
1830
|
};
|
|
1803
1831
|
}
|
|
1804
1832
|
}
|
|
1805
1833
|
if (R.timeDimensions)
|
|
1806
|
-
for (const
|
|
1807
|
-
const [D, I] =
|
|
1808
|
-
if (
|
|
1809
|
-
const
|
|
1810
|
-
e[
|
|
1811
|
-
title:
|
|
1812
|
-
shortTitle:
|
|
1813
|
-
type:
|
|
1814
|
-
granularity:
|
|
1834
|
+
for (const s of R.timeDimensions) {
|
|
1835
|
+
const [D, I] = s.dimension.split("."), N = O.find((t) => t.name === D);
|
|
1836
|
+
if (N && N.dimensions && N.dimensions[I]) {
|
|
1837
|
+
const t = N.dimensions[I];
|
|
1838
|
+
e[s.dimension] = {
|
|
1839
|
+
title: t.title || I,
|
|
1840
|
+
shortTitle: t.title || I,
|
|
1841
|
+
type: t.type,
|
|
1842
|
+
granularity: s.granularity
|
|
1815
1843
|
};
|
|
1816
1844
|
}
|
|
1817
1845
|
}
|
|
@@ -1823,7 +1851,7 @@ class OE {
|
|
|
1823
1851
|
};
|
|
1824
1852
|
}
|
|
1825
1853
|
}
|
|
1826
|
-
const
|
|
1854
|
+
const C = (T) => T.flatMap(AR), AR = (T) => Q(eR(T)).map(SR), SR = (T) => T.replace(/ +/g, " ").trim(), eR = (T) => ({
|
|
1827
1855
|
type: "mandatory_block",
|
|
1828
1856
|
items: hE(T, 0)[0]
|
|
1829
1857
|
}), hE = (T, E, R) => {
|
|
@@ -2581,7 +2609,7 @@ const HT = (T) => ({
|
|
|
2581
2609
|
"STRUCT",
|
|
2582
2610
|
"TIME",
|
|
2583
2611
|
"TIMEZONE"
|
|
2584
|
-
], DR =
|
|
2612
|
+
], DR = C(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), iR = C([
|
|
2585
2613
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
2586
2614
|
"WITH [RECURSIVE]",
|
|
2587
2615
|
"FROM",
|
|
@@ -2610,9 +2638,9 @@ const HT = (T) => ({
|
|
|
2610
2638
|
"WITH CONNECTION",
|
|
2611
2639
|
"WITH PARTITION COLUMNS",
|
|
2612
2640
|
"REMOTE WITH CONNECTION"
|
|
2613
|
-
]), xE =
|
|
2641
|
+
]), xE = C([
|
|
2614
2642
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
2615
|
-
]), NE =
|
|
2643
|
+
]), NE = C([
|
|
2616
2644
|
// - create:
|
|
2617
2645
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
2618
2646
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -2700,15 +2728,15 @@ const HT = (T) => ({
|
|
|
2700
2728
|
"ASSERT",
|
|
2701
2729
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
2702
2730
|
"EXPORT DATA"
|
|
2703
|
-
]), PR =
|
|
2731
|
+
]), PR = C([
|
|
2704
2732
|
"UNION {ALL | DISTINCT}",
|
|
2705
2733
|
"EXCEPT DISTINCT",
|
|
2706
2734
|
"INTERSECT DISTINCT"
|
|
2707
|
-
]), aR =
|
|
2735
|
+
]), aR = C([
|
|
2708
2736
|
"JOIN",
|
|
2709
2737
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
2710
2738
|
"{INNER | CROSS} JOIN"
|
|
2711
|
-
]), oR =
|
|
2739
|
+
]), oR = C([
|
|
2712
2740
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
2713
2741
|
"TABLESAMPLE SYSTEM",
|
|
2714
2742
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -2719,7 +2747,7 @@ const HT = (T) => ({
|
|
|
2719
2747
|
"{ROWS | RANGE} BETWEEN",
|
|
2720
2748
|
// comparison operator
|
|
2721
2749
|
"IS [NOT] DISTINCT FROM"
|
|
2722
|
-
]), MR =
|
|
2750
|
+
]), MR = C([]), UR = {
|
|
2723
2751
|
name: "bigquery",
|
|
2724
2752
|
tokenizerOptions: {
|
|
2725
2753
|
reservedSelect: DR,
|
|
@@ -3553,7 +3581,7 @@ const uR = [
|
|
|
3553
3581
|
"VARBINARY",
|
|
3554
3582
|
"VARCHAR",
|
|
3555
3583
|
"VARGRAPHIC"
|
|
3556
|
-
], YR =
|
|
3584
|
+
], YR = C(["SELECT [ALL | DISTINCT]"]), mR = C([
|
|
3557
3585
|
// queries
|
|
3558
3586
|
"WITH",
|
|
3559
3587
|
"FROM",
|
|
@@ -3582,9 +3610,9 @@ const uR = [
|
|
|
3582
3610
|
"WHEN [NOT] MATCHED [THEN]",
|
|
3583
3611
|
"UPDATE SET",
|
|
3584
3612
|
"INSERT"
|
|
3585
|
-
]), QE =
|
|
3613
|
+
]), QE = C([
|
|
3586
3614
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3587
|
-
]), sE =
|
|
3615
|
+
]), sE = C([
|
|
3588
3616
|
// - create:
|
|
3589
3617
|
"CREATE [OR REPLACE] VIEW",
|
|
3590
3618
|
// - update:
|
|
@@ -3787,16 +3815,16 @@ const uR = [
|
|
|
3787
3815
|
"TRANSFER OWNERSHIP OF",
|
|
3788
3816
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
3789
3817
|
"WHILE"
|
|
3790
|
-
]), pR =
|
|
3818
|
+
]), pR = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), dR = C([
|
|
3791
3819
|
"JOIN",
|
|
3792
3820
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3793
3821
|
"{INNER | CROSS} JOIN"
|
|
3794
|
-
]), VR =
|
|
3822
|
+
]), VR = C([
|
|
3795
3823
|
"ON DELETE",
|
|
3796
3824
|
"ON UPDATE",
|
|
3797
3825
|
"SET NULL",
|
|
3798
3826
|
"{ROWS | RANGE} BETWEEN"
|
|
3799
|
-
]), hR =
|
|
3827
|
+
]), hR = C([]), fR = {
|
|
3800
3828
|
name: "db2",
|
|
3801
3829
|
tokenizerOptions: {
|
|
3802
3830
|
reservedSelect: YR,
|
|
@@ -3841,7 +3869,7 @@ const uR = [
|
|
|
3841
3869
|
onelineClauses: [...QE, ...sE],
|
|
3842
3870
|
tabularOnelineClauses: sE
|
|
3843
3871
|
}
|
|
3844
|
-
},
|
|
3872
|
+
}, WR = [
|
|
3845
3873
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
3846
3874
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
3847
3875
|
"ARRAY_AGG",
|
|
@@ -4707,7 +4735,7 @@ const uR = [
|
|
|
4707
4735
|
"VARCHAR",
|
|
4708
4736
|
"VARGRAPHIC",
|
|
4709
4737
|
"XML"
|
|
4710
|
-
], KR =
|
|
4738
|
+
], KR = C(["SELECT [ALL | DISTINCT]"]), yR = C([
|
|
4711
4739
|
// queries
|
|
4712
4740
|
"WITH [RECURSIVE]",
|
|
4713
4741
|
"INTO",
|
|
@@ -4737,7 +4765,7 @@ const uR = [
|
|
|
4737
4765
|
"INSERT",
|
|
4738
4766
|
// Data definition - table
|
|
4739
4767
|
"FOR SYSTEM NAME"
|
|
4740
|
-
]), ZE =
|
|
4768
|
+
]), ZE = C(["CREATE [OR REPLACE] TABLE"]), tE = C([
|
|
4741
4769
|
// - create:
|
|
4742
4770
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
4743
4771
|
// - update:
|
|
@@ -4833,17 +4861,17 @@ const uR = [
|
|
|
4833
4861
|
"TAG",
|
|
4834
4862
|
"TRANSFER OWNERSHIP OF",
|
|
4835
4863
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
4836
|
-
]), $R =
|
|
4864
|
+
]), $R = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), gR = C([
|
|
4837
4865
|
"JOIN",
|
|
4838
4866
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4839
4867
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
4840
4868
|
"{INNER | CROSS} JOIN"
|
|
4841
|
-
]), JR =
|
|
4869
|
+
]), JR = C([
|
|
4842
4870
|
"ON DELETE",
|
|
4843
4871
|
"ON UPDATE",
|
|
4844
4872
|
"SET NULL",
|
|
4845
4873
|
"{ROWS | RANGE} BETWEEN"
|
|
4846
|
-
]), wR =
|
|
4874
|
+
]), wR = C([]), xR = {
|
|
4847
4875
|
name: "db2i",
|
|
4848
4876
|
tokenizerOptions: {
|
|
4849
4877
|
reservedSelect: KR,
|
|
@@ -4854,7 +4882,7 @@ const uR = [
|
|
|
4854
4882
|
reservedDataTypePhrases: wR,
|
|
4855
4883
|
reservedKeywords: XR,
|
|
4856
4884
|
reservedDataTypes: bR,
|
|
4857
|
-
reservedFunctionNames:
|
|
4885
|
+
reservedFunctionNames: WR,
|
|
4858
4886
|
nestedBlockComments: !0,
|
|
4859
4887
|
extraParens: ["[]"],
|
|
4860
4888
|
stringTypes: [
|
|
@@ -5696,7 +5724,7 @@ const uR = [
|
|
|
5696
5724
|
"UUID",
|
|
5697
5725
|
"VARBINARY",
|
|
5698
5726
|
"VARCHAR"
|
|
5699
|
-
], qR =
|
|
5727
|
+
], qR = C(["SELECT [ALL | DISTINCT]"]), kR = C([
|
|
5700
5728
|
// queries
|
|
5701
5729
|
"WITH [RECURSIVE]",
|
|
5702
5730
|
"FROM",
|
|
@@ -5720,9 +5748,9 @@ const uR = [
|
|
|
5720
5748
|
"SET",
|
|
5721
5749
|
// other:
|
|
5722
5750
|
"RETURNING"
|
|
5723
|
-
]), qE =
|
|
5751
|
+
]), qE = C([
|
|
5724
5752
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
5725
|
-
]), CE =
|
|
5753
|
+
]), CE = C([
|
|
5726
5754
|
// TABLE
|
|
5727
5755
|
// - update:
|
|
5728
5756
|
"UPDATE",
|
|
@@ -5800,11 +5828,11 @@ const uR = [
|
|
|
5800
5828
|
"PREPARE",
|
|
5801
5829
|
"EXECUTE",
|
|
5802
5830
|
"DEALLOCATE [PREPARE]"
|
|
5803
|
-
]), jR =
|
|
5831
|
+
]), jR = C([
|
|
5804
5832
|
"UNION [ALL | BY NAME]",
|
|
5805
5833
|
"EXCEPT [ALL]",
|
|
5806
5834
|
"INTERSECT [ALL]"
|
|
5807
|
-
]), zR =
|
|
5835
|
+
]), zR = C([
|
|
5808
5836
|
"JOIN",
|
|
5809
5837
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5810
5838
|
"{INNER | CROSS} JOIN",
|
|
@@ -5813,11 +5841,11 @@ const uR = [
|
|
|
5813
5841
|
"POSITIONAL JOIN",
|
|
5814
5842
|
"ANTI JOIN",
|
|
5815
5843
|
"SEMI JOIN"
|
|
5816
|
-
]), EA =
|
|
5844
|
+
]), EA = C([
|
|
5817
5845
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
5818
5846
|
"SIMILAR TO",
|
|
5819
5847
|
"IS [NOT] DISTINCT FROM"
|
|
5820
|
-
]), TA =
|
|
5848
|
+
]), TA = C(["TIMESTAMP WITH TIME ZONE"]), RA = {
|
|
5821
5849
|
name: "duckdb",
|
|
5822
5850
|
tokenizerOptions: {
|
|
5823
5851
|
reservedSelect: qR,
|
|
@@ -6437,7 +6465,7 @@ const uR = [
|
|
|
6437
6465
|
"STRUCT",
|
|
6438
6466
|
"TIMESTAMP",
|
|
6439
6467
|
"VARCHAR"
|
|
6440
|
-
], IA =
|
|
6468
|
+
], IA = C(["SELECT [ALL | DISTINCT]"]), OA = C([
|
|
6441
6469
|
// queries
|
|
6442
6470
|
"WITH",
|
|
6443
6471
|
"FROM",
|
|
@@ -6471,9 +6499,9 @@ const uR = [
|
|
|
6471
6499
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
6472
6500
|
"LOAD DATA [LOCAL] INPATH",
|
|
6473
6501
|
"[OVERWRITE] INTO TABLE"
|
|
6474
|
-
]), kE =
|
|
6502
|
+
]), kE = C([
|
|
6475
6503
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
6476
|
-
]), LE =
|
|
6504
|
+
]), LE = C([
|
|
6477
6505
|
// - create:
|
|
6478
6506
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
6479
6507
|
// - update:
|
|
@@ -6498,13 +6526,13 @@ const uR = [
|
|
|
6498
6526
|
"STORED AS",
|
|
6499
6527
|
"STORED BY",
|
|
6500
6528
|
"ROW FORMAT"
|
|
6501
|
-
]), NA =
|
|
6529
|
+
]), NA = C(["UNION [ALL | DISTINCT]"]), sA = C([
|
|
6502
6530
|
"JOIN",
|
|
6503
6531
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6504
6532
|
"{INNER | CROSS} JOIN",
|
|
6505
6533
|
// non-standard joins
|
|
6506
6534
|
"LEFT SEMI JOIN"
|
|
6507
|
-
]), tA =
|
|
6535
|
+
]), tA = C(["{ROWS | RANGE} BETWEEN"]), CA = C([]), LA = {
|
|
6508
6536
|
name: "hive",
|
|
6509
6537
|
tokenizerOptions: {
|
|
6510
6538
|
reservedSelect: IA,
|
|
@@ -7042,7 +7070,7 @@ const _A = [
|
|
|
7042
7070
|
// CASE expression shorthands
|
|
7043
7071
|
"COALESCE",
|
|
7044
7072
|
"NULLIF"
|
|
7045
|
-
], DA =
|
|
7073
|
+
], DA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), iA = C([
|
|
7046
7074
|
// queries
|
|
7047
7075
|
"WITH [RECURSIVE]",
|
|
7048
7076
|
"FROM",
|
|
@@ -7064,9 +7092,9 @@ const _A = [
|
|
|
7064
7092
|
"SET",
|
|
7065
7093
|
// other
|
|
7066
7094
|
"RETURNING"
|
|
7067
|
-
]), jE =
|
|
7095
|
+
]), jE = C([
|
|
7068
7096
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
7069
|
-
]), _E =
|
|
7097
|
+
]), _E = C([
|
|
7070
7098
|
// - create:
|
|
7071
7099
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
7072
7100
|
// - update:
|
|
@@ -7273,12 +7301,12 @@ const _A = [
|
|
|
7273
7301
|
"XA RECOVER",
|
|
7274
7302
|
"XA ROLLBACK",
|
|
7275
7303
|
"XA START"
|
|
7276
|
-
]), PA =
|
|
7304
|
+
]), PA = C([
|
|
7277
7305
|
"UNION [ALL | DISTINCT]",
|
|
7278
7306
|
"EXCEPT [ALL | DISTINCT]",
|
|
7279
7307
|
"INTERSECT [ALL | DISTINCT]",
|
|
7280
7308
|
"MINUS [ALL | DISTINCT]"
|
|
7281
|
-
]), aA =
|
|
7309
|
+
]), aA = C([
|
|
7282
7310
|
"JOIN",
|
|
7283
7311
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
7284
7312
|
"{INNER | CROSS} JOIN",
|
|
@@ -7286,12 +7314,12 @@ const _A = [
|
|
|
7286
7314
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7287
7315
|
// non-standard joins
|
|
7288
7316
|
"STRAIGHT_JOIN"
|
|
7289
|
-
]), oA =
|
|
7317
|
+
]), oA = C([
|
|
7290
7318
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7291
7319
|
"CHARACTER SET",
|
|
7292
7320
|
"{ROWS | RANGE} BETWEEN",
|
|
7293
7321
|
"IDENTIFIED BY"
|
|
7294
|
-
]), MA =
|
|
7322
|
+
]), MA = C([]), UA = {
|
|
7295
7323
|
name: "mariadb",
|
|
7296
7324
|
tokenizerOptions: {
|
|
7297
7325
|
reservedSelect: DA,
|
|
@@ -8048,7 +8076,7 @@ const _A = [
|
|
|
8048
8076
|
// 'XOR',
|
|
8049
8077
|
"YEAR",
|
|
8050
8078
|
"YEARWEEK"
|
|
8051
|
-
], HA =
|
|
8079
|
+
], HA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), uA = C([
|
|
8052
8080
|
// queries
|
|
8053
8081
|
"WITH [RECURSIVE]",
|
|
8054
8082
|
"FROM",
|
|
@@ -8068,7 +8096,7 @@ const _A = [
|
|
|
8068
8096
|
"ON DUPLICATE KEY UPDATE",
|
|
8069
8097
|
// - update:
|
|
8070
8098
|
"SET"
|
|
8071
|
-
]), zE =
|
|
8099
|
+
]), zE = C(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), rE = C([
|
|
8072
8100
|
// - create:
|
|
8073
8101
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8074
8102
|
// - update:
|
|
@@ -8249,7 +8277,7 @@ const _A = [
|
|
|
8249
8277
|
"REPEAT",
|
|
8250
8278
|
"RETURN",
|
|
8251
8279
|
"WHILE"
|
|
8252
|
-
]), BA =
|
|
8280
|
+
]), BA = C(["UNION [ALL | DISTINCT]"]), FA = C([
|
|
8253
8281
|
"JOIN",
|
|
8254
8282
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8255
8283
|
"{INNER | CROSS} JOIN",
|
|
@@ -8257,12 +8285,12 @@ const _A = [
|
|
|
8257
8285
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8258
8286
|
// non-standard joins
|
|
8259
8287
|
"STRAIGHT_JOIN"
|
|
8260
|
-
]), YA =
|
|
8288
|
+
]), YA = C([
|
|
8261
8289
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8262
8290
|
"CHARACTER SET",
|
|
8263
8291
|
"{ROWS | RANGE} BETWEEN",
|
|
8264
8292
|
"IDENTIFIED BY"
|
|
8265
|
-
]), mA =
|
|
8293
|
+
]), mA = C([]), pA = {
|
|
8266
8294
|
name: "mysql",
|
|
8267
8295
|
tokenizerOptions: {
|
|
8268
8296
|
reservedSelect: HA,
|
|
@@ -8880,7 +8908,7 @@ const _A = [
|
|
|
8880
8908
|
// 'XOR',
|
|
8881
8909
|
"YEAR",
|
|
8882
8910
|
"YEARWEEK"
|
|
8883
|
-
],
|
|
8911
|
+
], fA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), WA = C([
|
|
8884
8912
|
// queries
|
|
8885
8913
|
"WITH [RECURSIVE]",
|
|
8886
8914
|
"FROM",
|
|
@@ -8900,7 +8928,7 @@ const _A = [
|
|
|
8900
8928
|
"ON DUPLICATE KEY UPDATE",
|
|
8901
8929
|
// - update:
|
|
8902
8930
|
"SET"
|
|
8903
|
-
]), ET =
|
|
8931
|
+
]), ET = C(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), nE = C([
|
|
8904
8932
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
8905
8933
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8906
8934
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -9015,7 +9043,7 @@ const _A = [
|
|
|
9015
9043
|
"UNLOCK TABLES",
|
|
9016
9044
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
9017
9045
|
"USE"
|
|
9018
|
-
]), XA =
|
|
9046
|
+
]), XA = C(["UNION [ALL | DISTINCT]"]), bA = C([
|
|
9019
9047
|
"JOIN",
|
|
9020
9048
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9021
9049
|
"{INNER | CROSS} JOIN",
|
|
@@ -9023,16 +9051,16 @@ const _A = [
|
|
|
9023
9051
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9024
9052
|
// non-standard joins
|
|
9025
9053
|
"STRAIGHT_JOIN"
|
|
9026
|
-
]), KA =
|
|
9054
|
+
]), KA = C([
|
|
9027
9055
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9028
9056
|
"CHARACTER SET",
|
|
9029
9057
|
"{ROWS | RANGE} BETWEEN",
|
|
9030
9058
|
"IDENTIFIED BY"
|
|
9031
|
-
]), yA =
|
|
9059
|
+
]), yA = C([]), $A = {
|
|
9032
9060
|
name: "tidb",
|
|
9033
9061
|
tokenizerOptions: {
|
|
9034
|
-
reservedSelect:
|
|
9035
|
-
reservedClauses: [...
|
|
9062
|
+
reservedSelect: fA,
|
|
9063
|
+
reservedClauses: [...WA, ...ET, ...nE],
|
|
9036
9064
|
reservedSetOperations: XA,
|
|
9037
9065
|
reservedJoins: bA,
|
|
9038
9066
|
reservedKeywordPhrases: KA,
|
|
@@ -9526,7 +9554,7 @@ const _A = [
|
|
|
9526
9554
|
// which it actually doesn't use.
|
|
9527
9555
|
//
|
|
9528
9556
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
9529
|
-
], xA =
|
|
9557
|
+
], xA = C(["SELECT [ALL | DISTINCT]"]), vA = C([
|
|
9530
9558
|
// queries
|
|
9531
9559
|
"WITH",
|
|
9532
9560
|
"FROM",
|
|
@@ -9553,7 +9581,7 @@ const _A = [
|
|
|
9553
9581
|
"NEST",
|
|
9554
9582
|
"UNNEST",
|
|
9555
9583
|
"RETURNING"
|
|
9556
|
-
]), TT =
|
|
9584
|
+
]), TT = C([
|
|
9557
9585
|
// - update:
|
|
9558
9586
|
"UPDATE",
|
|
9559
9587
|
// - delete:
|
|
@@ -9593,7 +9621,7 @@ const _A = [
|
|
|
9593
9621
|
"SET CURRENT SCHEMA",
|
|
9594
9622
|
"SHOW",
|
|
9595
9623
|
"USE [PRIMARY] KEYS"
|
|
9596
|
-
]), QA =
|
|
9624
|
+
]), QA = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), ZA = C(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), qA = C(["{ROWS | RANGE | GROUPS} BETWEEN"]), kA = C([]), jA = {
|
|
9597
9625
|
name: "n1ql",
|
|
9598
9626
|
tokenizerOptions: {
|
|
9599
9627
|
reservedSelect: xA,
|
|
@@ -10227,7 +10255,7 @@ const _A = [
|
|
|
10227
10255
|
"PRESENTNNV",
|
|
10228
10256
|
"PRESENTV",
|
|
10229
10257
|
"PREVIOUS"
|
|
10230
|
-
], RS =
|
|
10258
|
+
], RS = C(["SELECT [ALL | DISTINCT | UNIQUE]"]), AS = C([
|
|
10231
10259
|
// queries
|
|
10232
10260
|
"WITH",
|
|
10233
10261
|
"FROM",
|
|
@@ -10251,9 +10279,9 @@ const _A = [
|
|
|
10251
10279
|
"UPDATE SET",
|
|
10252
10280
|
// other
|
|
10253
10281
|
"RETURNING"
|
|
10254
|
-
]), RT =
|
|
10282
|
+
]), RT = C([
|
|
10255
10283
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
10256
|
-
]), DE =
|
|
10284
|
+
]), DE = C([
|
|
10257
10285
|
// - create:
|
|
10258
10286
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
10259
10287
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -10281,7 +10309,7 @@ const _A = [
|
|
|
10281
10309
|
"EXCEPTION",
|
|
10282
10310
|
"LOOP",
|
|
10283
10311
|
"START WITH"
|
|
10284
|
-
]), SS =
|
|
10312
|
+
]), SS = C(["UNION [ALL]", "MINUS", "INTERSECT"]), eS = C([
|
|
10285
10313
|
"JOIN",
|
|
10286
10314
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10287
10315
|
"{INNER | CROSS} JOIN",
|
|
@@ -10289,11 +10317,11 @@ const _A = [
|
|
|
10289
10317
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10290
10318
|
// non-standard joins
|
|
10291
10319
|
"{CROSS | OUTER} APPLY"
|
|
10292
|
-
]), IS =
|
|
10320
|
+
]), IS = C([
|
|
10293
10321
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10294
10322
|
"ON COMMIT",
|
|
10295
10323
|
"{ROWS | RANGE} BETWEEN"
|
|
10296
|
-
]), OS =
|
|
10324
|
+
]), OS = C([]), NS = {
|
|
10297
10325
|
name: "plsql",
|
|
10298
10326
|
tokenizerOptions: {
|
|
10299
10327
|
reservedSelect: RS,
|
|
@@ -11179,7 +11207,7 @@ const tS = [
|
|
|
11179
11207
|
"VARCHAR",
|
|
11180
11208
|
"XML",
|
|
11181
11209
|
"ZONE"
|
|
11182
|
-
], _S =
|
|
11210
|
+
], _S = C(["SELECT [ALL | DISTINCT]"]), rS = C([
|
|
11183
11211
|
// queries
|
|
11184
11212
|
"WITH [RECURSIVE]",
|
|
11185
11213
|
"FROM",
|
|
@@ -11202,9 +11230,9 @@ const tS = [
|
|
|
11202
11230
|
"SET",
|
|
11203
11231
|
// other
|
|
11204
11232
|
"RETURNING"
|
|
11205
|
-
]), AT =
|
|
11233
|
+
]), AT = C([
|
|
11206
11234
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
11207
|
-
]), iE =
|
|
11235
|
+
]), iE = C([
|
|
11208
11236
|
// - create
|
|
11209
11237
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
11210
11238
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -11402,17 +11430,17 @@ const tS = [
|
|
|
11402
11430
|
"START TRANSACTION",
|
|
11403
11431
|
"UNLISTEN",
|
|
11404
11432
|
"VACUUM"
|
|
11405
|
-
]), nS =
|
|
11433
|
+
]), nS = C([
|
|
11406
11434
|
"UNION [ALL | DISTINCT]",
|
|
11407
11435
|
"EXCEPT [ALL | DISTINCT]",
|
|
11408
11436
|
"INTERSECT [ALL | DISTINCT]"
|
|
11409
|
-
]), DS =
|
|
11437
|
+
]), DS = C([
|
|
11410
11438
|
"JOIN",
|
|
11411
11439
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11412
11440
|
"{INNER | CROSS} JOIN",
|
|
11413
11441
|
"NATURAL [INNER] JOIN",
|
|
11414
11442
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
11415
|
-
]), iS =
|
|
11443
|
+
]), iS = C([
|
|
11416
11444
|
"PRIMARY KEY",
|
|
11417
11445
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
11418
11446
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -11423,7 +11451,7 @@ const tS = [
|
|
|
11423
11451
|
"IS [NOT] DISTINCT FROM",
|
|
11424
11452
|
"NULLS {FIRST | LAST}",
|
|
11425
11453
|
"WITH ORDINALITY"
|
|
11426
|
-
]), PS =
|
|
11454
|
+
]), PS = C([
|
|
11427
11455
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
11428
11456
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
11429
11457
|
]), aS = {
|
|
@@ -12108,7 +12136,7 @@ const tS = [
|
|
|
12108
12136
|
"TEXT",
|
|
12109
12137
|
"VARBYTE",
|
|
12110
12138
|
"VARCHAR"
|
|
12111
|
-
], GS =
|
|
12139
|
+
], GS = C(["SELECT [ALL | DISTINCT]"]), cS = C([
|
|
12112
12140
|
// queries
|
|
12113
12141
|
"WITH [RECURSIVE]",
|
|
12114
12142
|
"FROM",
|
|
@@ -12126,9 +12154,9 @@ const tS = [
|
|
|
12126
12154
|
"VALUES",
|
|
12127
12155
|
// - update:
|
|
12128
12156
|
"SET"
|
|
12129
|
-
]), ST =
|
|
12157
|
+
]), ST = C([
|
|
12130
12158
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
12131
|
-
]), PE =
|
|
12159
|
+
]), PE = C([
|
|
12132
12160
|
// - create:
|
|
12133
12161
|
"CREATE [OR REPLACE | MATERIALIZED] VIEW",
|
|
12134
12162
|
// - update:
|
|
@@ -12219,13 +12247,13 @@ const tS = [
|
|
|
12219
12247
|
"START TRANSACTION",
|
|
12220
12248
|
"UNLOAD",
|
|
12221
12249
|
"VACUUM"
|
|
12222
|
-
]), lS =
|
|
12250
|
+
]), lS = C(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), HS = C([
|
|
12223
12251
|
"JOIN",
|
|
12224
12252
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12225
12253
|
"{INNER | CROSS} JOIN",
|
|
12226
12254
|
"NATURAL [INNER] JOIN",
|
|
12227
12255
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12228
|
-
]), uS =
|
|
12256
|
+
]), uS = C([
|
|
12229
12257
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12230
12258
|
"NULL AS",
|
|
12231
12259
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12233,7 +12261,7 @@ const tS = [
|
|
|
12233
12261
|
"HIVE METASTORE",
|
|
12234
12262
|
// in window specifications
|
|
12235
12263
|
"{ROWS | RANGE} BETWEEN"
|
|
12236
|
-
]), BS =
|
|
12264
|
+
]), BS = C([]), FS = {
|
|
12237
12265
|
name: "redshift",
|
|
12238
12266
|
tokenizerOptions: {
|
|
12239
12267
|
reservedSelect: GS,
|
|
@@ -12889,7 +12917,7 @@ const tS = [
|
|
|
12889
12917
|
// Shorthand functions to use in place of CASE expression
|
|
12890
12918
|
"COALESCE",
|
|
12891
12919
|
"NULLIF"
|
|
12892
|
-
], dS =
|
|
12920
|
+
], dS = C(["SELECT [ALL | DISTINCT]"]), VS = C([
|
|
12893
12921
|
// queries
|
|
12894
12922
|
"WITH",
|
|
12895
12923
|
"FROM",
|
|
@@ -12914,7 +12942,7 @@ const tS = [
|
|
|
12914
12942
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
12915
12943
|
"LOAD DATA [LOCAL] INPATH",
|
|
12916
12944
|
"[OVERWRITE] INTO TABLE"
|
|
12917
|
-
]), eT =
|
|
12945
|
+
]), eT = C(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), aE = C([
|
|
12918
12946
|
// - create:
|
|
12919
12947
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
12920
12948
|
// - drop table:
|
|
@@ -12970,11 +12998,11 @@ const tS = [
|
|
|
12970
12998
|
"SHOW TBLPROPERTIES",
|
|
12971
12999
|
"SHOW VIEWS",
|
|
12972
13000
|
"UNCACHE TABLE"
|
|
12973
|
-
]), hS =
|
|
13001
|
+
]), hS = C([
|
|
12974
13002
|
"UNION [ALL | DISTINCT]",
|
|
12975
13003
|
"EXCEPT [ALL | DISTINCT]",
|
|
12976
13004
|
"INTERSECT [ALL | DISTINCT]"
|
|
12977
|
-
]),
|
|
13005
|
+
]), fS = C([
|
|
12978
13006
|
"JOIN",
|
|
12979
13007
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12980
13008
|
"{INNER | CROSS} JOIN",
|
|
@@ -12983,19 +13011,19 @@ const tS = [
|
|
|
12983
13011
|
// non-standard-joins
|
|
12984
13012
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
12985
13013
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
12986
|
-
]),
|
|
13014
|
+
]), WS = C([
|
|
12987
13015
|
"ON DELETE",
|
|
12988
13016
|
"ON UPDATE",
|
|
12989
13017
|
"CURRENT ROW",
|
|
12990
13018
|
"{ROWS | RANGE} BETWEEN"
|
|
12991
|
-
]), XS =
|
|
13019
|
+
]), XS = C([]), bS = {
|
|
12992
13020
|
name: "spark",
|
|
12993
13021
|
tokenizerOptions: {
|
|
12994
13022
|
reservedSelect: dS,
|
|
12995
13023
|
reservedClauses: [...VS, ...eT, ...aE],
|
|
12996
13024
|
reservedSetOperations: hS,
|
|
12997
|
-
reservedJoins:
|
|
12998
|
-
reservedKeywordPhrases:
|
|
13025
|
+
reservedJoins: fS,
|
|
13026
|
+
reservedKeywordPhrases: WS,
|
|
12999
13027
|
reservedDataTypePhrases: XS,
|
|
13000
13028
|
supportsXor: !0,
|
|
13001
13029
|
reservedKeywords: YS,
|
|
@@ -13323,7 +13351,7 @@ const yS = [
|
|
|
13323
13351
|
"TEXT",
|
|
13324
13352
|
"VARCHAR",
|
|
13325
13353
|
"VARYING CHARACTER"
|
|
13326
|
-
], JS =
|
|
13354
|
+
], JS = C(["SELECT [ALL | DISTINCT]"]), wS = C([
|
|
13327
13355
|
// queries
|
|
13328
13356
|
"WITH [RECURSIVE]",
|
|
13329
13357
|
"FROM",
|
|
@@ -13344,7 +13372,7 @@ const yS = [
|
|
|
13344
13372
|
"SET",
|
|
13345
13373
|
// other:
|
|
13346
13374
|
"RETURNING"
|
|
13347
|
-
]), IT =
|
|
13375
|
+
]), IT = C(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), oE = C([
|
|
13348
13376
|
// - create:
|
|
13349
13377
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
13350
13378
|
// - update:
|
|
@@ -13363,17 +13391,17 @@ const yS = [
|
|
|
13363
13391
|
"RENAME TO",
|
|
13364
13392
|
// - set schema
|
|
13365
13393
|
"SET SCHEMA"
|
|
13366
|
-
]), xS =
|
|
13394
|
+
]), xS = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), vS = C([
|
|
13367
13395
|
"JOIN",
|
|
13368
13396
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13369
13397
|
"{INNER | CROSS} JOIN",
|
|
13370
13398
|
"NATURAL [INNER] JOIN",
|
|
13371
13399
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13372
|
-
]), QS =
|
|
13400
|
+
]), QS = C([
|
|
13373
13401
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13374
13402
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
13375
13403
|
"DO UPDATE"
|
|
13376
|
-
]), ZS =
|
|
13404
|
+
]), ZS = C([]), qS = {
|
|
13377
13405
|
name: "sqlite",
|
|
13378
13406
|
tokenizerOptions: {
|
|
13379
13407
|
reservedSelect: JS,
|
|
@@ -13735,7 +13763,7 @@ const yS = [
|
|
|
13735
13763
|
"TIMESTAMP",
|
|
13736
13764
|
"VARBINARY",
|
|
13737
13765
|
"VARCHAR"
|
|
13738
|
-
], Ee =
|
|
13766
|
+
], Ee = C(["SELECT [ALL | DISTINCT]"]), Te = C([
|
|
13739
13767
|
// queries
|
|
13740
13768
|
"WITH [RECURSIVE]",
|
|
13741
13769
|
"FROM",
|
|
@@ -13754,7 +13782,7 @@ const yS = [
|
|
|
13754
13782
|
"VALUES",
|
|
13755
13783
|
// - update:
|
|
13756
13784
|
"SET"
|
|
13757
|
-
]), OT =
|
|
13785
|
+
]), OT = C(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), ME = C([
|
|
13758
13786
|
// - create:
|
|
13759
13787
|
"CREATE [RECURSIVE] VIEW",
|
|
13760
13788
|
// - update:
|
|
@@ -13779,20 +13807,20 @@ const yS = [
|
|
|
13779
13807
|
"TRUNCATE TABLE",
|
|
13780
13808
|
// other
|
|
13781
13809
|
"SET SCHEMA"
|
|
13782
|
-
]), Re =
|
|
13810
|
+
]), Re = C([
|
|
13783
13811
|
"UNION [ALL | DISTINCT]",
|
|
13784
13812
|
"EXCEPT [ALL | DISTINCT]",
|
|
13785
13813
|
"INTERSECT [ALL | DISTINCT]"
|
|
13786
|
-
]), Ae =
|
|
13814
|
+
]), Ae = C([
|
|
13787
13815
|
"JOIN",
|
|
13788
13816
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13789
13817
|
"{INNER | CROSS} JOIN",
|
|
13790
13818
|
"NATURAL [INNER] JOIN",
|
|
13791
13819
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13792
|
-
]), Se =
|
|
13820
|
+
]), Se = C([
|
|
13793
13821
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13794
13822
|
"{ROWS | RANGE} BETWEEN"
|
|
13795
|
-
]), ee =
|
|
13823
|
+
]), ee = C([]), Ie = {
|
|
13796
13824
|
name: "sql",
|
|
13797
13825
|
tokenizerOptions: {
|
|
13798
13826
|
reservedSelect: Ee,
|
|
@@ -14526,7 +14554,7 @@ const yS = [
|
|
|
14526
14554
|
"CODEPOINTS",
|
|
14527
14555
|
"FUNCTION",
|
|
14528
14556
|
"JSONPATH"
|
|
14529
|
-
], te =
|
|
14557
|
+
], te = C(["SELECT [ALL | DISTINCT]"]), Ce = C([
|
|
14530
14558
|
// queries
|
|
14531
14559
|
"WITH [RECURSIVE]",
|
|
14532
14560
|
"FROM",
|
|
@@ -14554,7 +14582,7 @@ const yS = [
|
|
|
14554
14582
|
"PATTERN",
|
|
14555
14583
|
"SUBSET",
|
|
14556
14584
|
"DEFINE"
|
|
14557
|
-
]), NT =
|
|
14585
|
+
]), NT = C(["CREATE TABLE [IF NOT EXISTS]"]), UE = C([
|
|
14558
14586
|
// - create:
|
|
14559
14587
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
14560
14588
|
// - update:
|
|
@@ -14612,21 +14640,21 @@ const yS = [
|
|
|
14612
14640
|
"SHOW ROLE GRANTS",
|
|
14613
14641
|
"SHOW FUNCTIONS",
|
|
14614
14642
|
"SHOW SESSION"
|
|
14615
|
-
]), Le =
|
|
14643
|
+
]), Le = C([
|
|
14616
14644
|
"UNION [ALL | DISTINCT]",
|
|
14617
14645
|
"EXCEPT [ALL | DISTINCT]",
|
|
14618
14646
|
"INTERSECT [ALL | DISTINCT]"
|
|
14619
|
-
]), _e =
|
|
14647
|
+
]), _e = C([
|
|
14620
14648
|
"JOIN",
|
|
14621
14649
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14622
14650
|
"{INNER | CROSS} JOIN",
|
|
14623
14651
|
"NATURAL [INNER] JOIN",
|
|
14624
14652
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14625
|
-
]), re =
|
|
14653
|
+
]), re = C([
|
|
14626
14654
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14627
14655
|
// comparison operator
|
|
14628
14656
|
"IS [NOT] DISTINCT FROM"
|
|
14629
|
-
]), ne =
|
|
14657
|
+
]), ne = C([]), De = {
|
|
14630
14658
|
name: "trino",
|
|
14631
14659
|
tokenizerOptions: {
|
|
14632
14660
|
reservedSelect: te,
|
|
@@ -15182,7 +15210,7 @@ const yS = [
|
|
|
15182
15210
|
"TIMESTAMP",
|
|
15183
15211
|
"VARBINARY",
|
|
15184
15212
|
"VARCHAR"
|
|
15185
|
-
], oe =
|
|
15213
|
+
], oe = C(["SELECT [ALL | DISTINCT]"]), Me = C([
|
|
15186
15214
|
// queries
|
|
15187
15215
|
"WITH",
|
|
15188
15216
|
"INTO",
|
|
@@ -15207,7 +15235,7 @@ const yS = [
|
|
|
15207
15235
|
"MERGE [INTO]",
|
|
15208
15236
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
15209
15237
|
"UPDATE SET"
|
|
15210
|
-
]), sT =
|
|
15238
|
+
]), sT = C(["CREATE TABLE"]), GE = C([
|
|
15211
15239
|
// - create:
|
|
15212
15240
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
15213
15241
|
// - update:
|
|
@@ -15387,16 +15415,16 @@ const yS = [
|
|
|
15387
15415
|
"XACT_ABORT",
|
|
15388
15416
|
"XML INDEX",
|
|
15389
15417
|
"XML SCHEMA COLLECTION"
|
|
15390
|
-
]), Ue =
|
|
15418
|
+
]), Ue = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), Ge = C([
|
|
15391
15419
|
"JOIN",
|
|
15392
15420
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15393
15421
|
"{INNER | CROSS} JOIN",
|
|
15394
15422
|
// non-standard joins
|
|
15395
15423
|
"{CROSS | OUTER} APPLY"
|
|
15396
|
-
]), ce =
|
|
15424
|
+
]), ce = C([
|
|
15397
15425
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
15398
15426
|
"{ROWS | RANGE} BETWEEN"
|
|
15399
|
-
]), le =
|
|
15427
|
+
]), le = C([]), He = {
|
|
15400
15428
|
name: "transactsql",
|
|
15401
15429
|
tokenizerOptions: {
|
|
15402
15430
|
reservedSelect: oe,
|
|
@@ -15982,7 +16010,7 @@ const yS = [
|
|
|
15982
16010
|
"WEEKDAY",
|
|
15983
16011
|
"WEEKOFYEAR",
|
|
15984
16012
|
"YEAR"
|
|
15985
|
-
], Ye =
|
|
16013
|
+
], Ye = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), me = C([
|
|
15986
16014
|
// queries
|
|
15987
16015
|
"WITH",
|
|
15988
16016
|
"FROM",
|
|
@@ -16004,9 +16032,9 @@ const yS = [
|
|
|
16004
16032
|
// Data definition
|
|
16005
16033
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
16006
16034
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
16007
|
-
]), tT =
|
|
16035
|
+
]), tT = C([
|
|
16008
16036
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
16009
|
-
]), cE =
|
|
16037
|
+
]), cE = C([
|
|
16010
16038
|
// - create:
|
|
16011
16039
|
"CREATE VIEW",
|
|
16012
16040
|
// - update:
|
|
@@ -16183,25 +16211,25 @@ const yS = [
|
|
|
16183
16211
|
"REPEAT",
|
|
16184
16212
|
"RETURN",
|
|
16185
16213
|
"WHILE"
|
|
16186
|
-
]), pe =
|
|
16214
|
+
]), pe = C([
|
|
16187
16215
|
"UNION [ALL | DISTINCT]",
|
|
16188
16216
|
"EXCEPT",
|
|
16189
16217
|
"INTERSECT",
|
|
16190
16218
|
"MINUS"
|
|
16191
|
-
]), de =
|
|
16219
|
+
]), de = C([
|
|
16192
16220
|
"JOIN",
|
|
16193
16221
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16194
16222
|
"{INNER | CROSS} JOIN",
|
|
16195
16223
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
16196
16224
|
// non-standard joins
|
|
16197
16225
|
"STRAIGHT_JOIN"
|
|
16198
|
-
]), Ve =
|
|
16226
|
+
]), Ve = C([
|
|
16199
16227
|
"ON DELETE",
|
|
16200
16228
|
"ON UPDATE",
|
|
16201
16229
|
"CHARACTER SET",
|
|
16202
16230
|
"{ROWS | RANGE} BETWEEN",
|
|
16203
16231
|
"IDENTIFIED BY"
|
|
16204
|
-
]), he =
|
|
16232
|
+
]), he = C([]), fe = {
|
|
16205
16233
|
name: "singlestoredb",
|
|
16206
16234
|
tokenizerOptions: {
|
|
16207
16235
|
reservedSelect: Ye,
|
|
@@ -16252,7 +16280,7 @@ const yS = [
|
|
|
16252
16280
|
onelineClauses: [...tT, ...cE],
|
|
16253
16281
|
tabularOnelineClauses: cE
|
|
16254
16282
|
}
|
|
16255
|
-
},
|
|
16283
|
+
}, We = [
|
|
16256
16284
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
16257
16285
|
//
|
|
16258
16286
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -16994,7 +17022,7 @@ const yS = [
|
|
|
16994
17022
|
"ARRAY",
|
|
16995
17023
|
"GEOGRAPHY",
|
|
16996
17024
|
"GEOMETRY"
|
|
16997
|
-
], Ke =
|
|
17025
|
+
], Ke = C(["SELECT [ALL | DISTINCT]"]), ye = C([
|
|
16998
17026
|
// queries
|
|
16999
17027
|
"WITH [RECURSIVE]",
|
|
17000
17028
|
"FROM",
|
|
@@ -17022,10 +17050,10 @@ const yS = [
|
|
|
17022
17050
|
"WHEN MATCHED [AND]",
|
|
17023
17051
|
"THEN {UPDATE SET | DELETE}",
|
|
17024
17052
|
"WHEN NOT MATCHED THEN INSERT"
|
|
17025
|
-
]), CT =
|
|
17053
|
+
]), CT = C([
|
|
17026
17054
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
17027
17055
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
17028
|
-
]), lE =
|
|
17056
|
+
]), lE = C([
|
|
17029
17057
|
// - create:
|
|
17030
17058
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
17031
17059
|
// - update:
|
|
@@ -17266,14 +17294,14 @@ const yS = [
|
|
|
17266
17294
|
"USE SCHEMA",
|
|
17267
17295
|
"USE SECONDARY ROLES",
|
|
17268
17296
|
"USE WAREHOUSE"
|
|
17269
|
-
]), $e =
|
|
17297
|
+
]), $e = C(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), ge = C([
|
|
17270
17298
|
"[INNER] JOIN",
|
|
17271
17299
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17272
17300
|
"{CROSS | NATURAL} JOIN"
|
|
17273
|
-
]), Je =
|
|
17301
|
+
]), Je = C([
|
|
17274
17302
|
"{ROWS | RANGE} BETWEEN",
|
|
17275
17303
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17276
|
-
]), we =
|
|
17304
|
+
]), we = C([]), xe = {
|
|
17277
17305
|
name: "snowflake",
|
|
17278
17306
|
tokenizerOptions: {
|
|
17279
17307
|
reservedSelect: Ke,
|
|
@@ -17284,7 +17312,7 @@ const yS = [
|
|
|
17284
17312
|
reservedDataTypePhrases: we,
|
|
17285
17313
|
reservedKeywords: Xe,
|
|
17286
17314
|
reservedDataTypes: be,
|
|
17287
|
-
reservedFunctionNames:
|
|
17315
|
+
reservedFunctionNames: We,
|
|
17288
17316
|
stringTypes: ["$$", "''-qq-bs"],
|
|
17289
17317
|
identTypes: ['""-qq'],
|
|
17290
17318
|
variableTypes: [
|
|
@@ -17320,7 +17348,7 @@ const yS = [
|
|
|
17320
17348
|
}, ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17321
17349
|
__proto__: null,
|
|
17322
17350
|
bigquery: UR,
|
|
17323
|
-
db2:
|
|
17351
|
+
db2: fR,
|
|
17324
17352
|
db2i: xR,
|
|
17325
17353
|
duckdb: RA,
|
|
17326
17354
|
hive: LA,
|
|
@@ -17330,7 +17358,7 @@ const yS = [
|
|
|
17330
17358
|
plsql: NS,
|
|
17331
17359
|
postgresql: aS,
|
|
17332
17360
|
redshift: FS,
|
|
17333
|
-
singlestoredb:
|
|
17361
|
+
singlestoredb: fe,
|
|
17334
17362
|
snowflake: xe,
|
|
17335
17363
|
spark: bS,
|
|
17336
17364
|
sql: Ie,
|
|
@@ -17359,7 +17387,7 @@ const yS = [
|
|
|
17359
17387
|
"[": "]",
|
|
17360
17388
|
"(": ")",
|
|
17361
17389
|
"{": "}"
|
|
17362
|
-
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([O,
|
|
17390
|
+
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([O, s]) => E.replace(/{left}/g, d(O)).replace(/{right}/g, d(s))), A = d(Object.keys(T).join(""));
|
|
17363
17391
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
|
|
17364
17392
|
}, nT = {
|
|
17365
17393
|
// - backtick quoted (using `` to escape)
|
|
@@ -17387,7 +17415,7 @@ const yS = [
|
|
|
17387
17415
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
17388
17416
|
"q''": ze()
|
|
17389
17417
|
}, FT = (T) => typeof T == "string" ? nT[T] : "regex" in T ? T.regex : qe(T) + nT[T.quote], EI = (T) => b(T.map((E) => "regex" in E ? E.regex : FT(E)).join("|")), YT = (T) => T.map(FT).join("|"), DT = (T) => b(YT(T)), TI = (T = {}) => b(mT(T)), mT = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
|
|
17390
|
-
const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = d(T ?? ""),
|
|
17418
|
+
const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = d(T ?? ""), s = d(E ?? ""), D = A ? `[${S}${e}${O}][${S}${e}${s}]*` : `[${S}${O}][${S}${e}${s}]*`;
|
|
17391
17419
|
return R ? Ze(D) : D;
|
|
17392
17420
|
};
|
|
17393
17421
|
function pT(T, E) {
|
|
@@ -17526,82 +17554,82 @@ class II {
|
|
|
17526
17554
|
{
|
|
17527
17555
|
type: i.RESERVED_KEYWORD_PHRASE,
|
|
17528
17556
|
regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
17529
|
-
text:
|
|
17557
|
+
text: B
|
|
17530
17558
|
},
|
|
17531
17559
|
{
|
|
17532
17560
|
type: i.RESERVED_DATA_TYPE_PHRASE,
|
|
17533
17561
|
regex: V((S = E.reservedDataTypePhrases) !== null && S !== void 0 ? S : [], E.identChars),
|
|
17534
|
-
text:
|
|
17562
|
+
text: B
|
|
17535
17563
|
},
|
|
17536
17564
|
{
|
|
17537
17565
|
type: i.CASE,
|
|
17538
17566
|
regex: /CASE\b/iuy,
|
|
17539
|
-
text:
|
|
17567
|
+
text: B
|
|
17540
17568
|
},
|
|
17541
17569
|
{
|
|
17542
17570
|
type: i.END,
|
|
17543
17571
|
regex: /END\b/iuy,
|
|
17544
|
-
text:
|
|
17572
|
+
text: B
|
|
17545
17573
|
},
|
|
17546
17574
|
{
|
|
17547
17575
|
type: i.BETWEEN,
|
|
17548
17576
|
regex: /BETWEEN\b/iuy,
|
|
17549
|
-
text:
|
|
17577
|
+
text: B
|
|
17550
17578
|
},
|
|
17551
17579
|
{
|
|
17552
17580
|
type: i.LIMIT,
|
|
17553
17581
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
17554
|
-
text:
|
|
17582
|
+
text: B
|
|
17555
17583
|
},
|
|
17556
17584
|
{
|
|
17557
17585
|
type: i.RESERVED_CLAUSE,
|
|
17558
17586
|
regex: V(E.reservedClauses, E.identChars),
|
|
17559
|
-
text:
|
|
17587
|
+
text: B
|
|
17560
17588
|
},
|
|
17561
17589
|
{
|
|
17562
17590
|
type: i.RESERVED_SELECT,
|
|
17563
17591
|
regex: V(E.reservedSelect, E.identChars),
|
|
17564
|
-
text:
|
|
17592
|
+
text: B
|
|
17565
17593
|
},
|
|
17566
17594
|
{
|
|
17567
17595
|
type: i.RESERVED_SET_OPERATION,
|
|
17568
17596
|
regex: V(E.reservedSetOperations, E.identChars),
|
|
17569
|
-
text:
|
|
17597
|
+
text: B
|
|
17570
17598
|
},
|
|
17571
17599
|
{
|
|
17572
17600
|
type: i.WHEN,
|
|
17573
17601
|
regex: /WHEN\b/iuy,
|
|
17574
|
-
text:
|
|
17602
|
+
text: B
|
|
17575
17603
|
},
|
|
17576
17604
|
{
|
|
17577
17605
|
type: i.ELSE,
|
|
17578
17606
|
regex: /ELSE\b/iuy,
|
|
17579
|
-
text:
|
|
17607
|
+
text: B
|
|
17580
17608
|
},
|
|
17581
17609
|
{
|
|
17582
17610
|
type: i.THEN,
|
|
17583
17611
|
regex: /THEN\b/iuy,
|
|
17584
|
-
text:
|
|
17612
|
+
text: B
|
|
17585
17613
|
},
|
|
17586
17614
|
{
|
|
17587
17615
|
type: i.RESERVED_JOIN,
|
|
17588
17616
|
regex: V(E.reservedJoins, E.identChars),
|
|
17589
|
-
text:
|
|
17617
|
+
text: B
|
|
17590
17618
|
},
|
|
17591
17619
|
{
|
|
17592
17620
|
type: i.AND,
|
|
17593
17621
|
regex: /AND\b/iuy,
|
|
17594
|
-
text:
|
|
17622
|
+
text: B
|
|
17595
17623
|
},
|
|
17596
17624
|
{
|
|
17597
17625
|
type: i.OR,
|
|
17598
17626
|
regex: /OR\b/iuy,
|
|
17599
|
-
text:
|
|
17627
|
+
text: B
|
|
17600
17628
|
},
|
|
17601
17629
|
{
|
|
17602
17630
|
type: i.XOR,
|
|
17603
17631
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
17604
|
-
text:
|
|
17632
|
+
text: B
|
|
17605
17633
|
},
|
|
17606
17634
|
...E.operatorKeyword ? [
|
|
17607
17635
|
{
|
|
@@ -17612,17 +17640,17 @@ class II {
|
|
|
17612
17640
|
{
|
|
17613
17641
|
type: i.RESERVED_FUNCTION_NAME,
|
|
17614
17642
|
regex: V(E.reservedFunctionNames, E.identChars),
|
|
17615
|
-
text:
|
|
17643
|
+
text: B
|
|
17616
17644
|
},
|
|
17617
17645
|
{
|
|
17618
17646
|
type: i.RESERVED_DATA_TYPE,
|
|
17619
17647
|
regex: V(E.reservedDataTypes, E.identChars),
|
|
17620
|
-
text:
|
|
17648
|
+
text: B
|
|
17621
17649
|
},
|
|
17622
17650
|
{
|
|
17623
17651
|
type: i.RESERVED_KEYWORD,
|
|
17624
17652
|
regex: V(E.reservedKeywords, E.identChars),
|
|
17625
|
-
text:
|
|
17653
|
+
text: B
|
|
17626
17654
|
}
|
|
17627
17655
|
]);
|
|
17628
17656
|
}
|
|
@@ -17677,13 +17705,13 @@ class II {
|
|
|
17677
17705
|
// These rules can't be blindly cached as the paramTypesOverrides object
|
|
17678
17706
|
// can differ on each invocation of the format() function.
|
|
17679
17707
|
buildParamRules(E, R) {
|
|
17680
|
-
var A, S, e, O,
|
|
17708
|
+
var A, S, e, O, s;
|
|
17681
17709
|
const D = {
|
|
17682
17710
|
named: R?.named || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
|
|
17683
17711
|
quoted: R?.quoted || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.quoted) || [],
|
|
17684
17712
|
numbered: R?.numbered || ((e = E.paramTypes) === null || e === void 0 ? void 0 : e.numbered) || [],
|
|
17685
17713
|
positional: typeof R?.positional == "boolean" ? R.positional : (O = E.paramTypes) === null || O === void 0 ? void 0 : O.positional,
|
|
17686
|
-
custom: R?.custom || ((
|
|
17714
|
+
custom: R?.custom || ((s = E.paramTypes) === null || s === void 0 ? void 0 : s.custom) || []
|
|
17687
17715
|
};
|
|
17688
17716
|
return this.validRules([
|
|
17689
17717
|
{
|
|
@@ -17694,7 +17722,7 @@ class II {
|
|
|
17694
17722
|
{
|
|
17695
17723
|
type: i.QUOTED_PARAMETER,
|
|
17696
17724
|
regex: uE(D.quoted, YT(E.identTypes)),
|
|
17697
|
-
key: (I) => (({ tokenKey:
|
|
17725
|
+
key: (I) => (({ tokenKey: N, quoteChar: t }) => N.replace(new RegExp(d("\\" + t), "gu"), t))({
|
|
17698
17726
|
tokenKey: I.slice(2, -1),
|
|
17699
17727
|
quoteChar: I.slice(-1)
|
|
17700
17728
|
})
|
|
@@ -17709,11 +17737,11 @@ class II {
|
|
|
17709
17737
|
regex: D.positional ? /[?]/y : void 0
|
|
17710
17738
|
},
|
|
17711
17739
|
...D.custom.map((I) => {
|
|
17712
|
-
var
|
|
17740
|
+
var N;
|
|
17713
17741
|
return {
|
|
17714
17742
|
type: i.CUSTOM_PARAMETER,
|
|
17715
17743
|
regex: b(I.regex),
|
|
17716
|
-
key: (
|
|
17744
|
+
key: (N = I.key) !== null && N !== void 0 ? N : ((t) => t)
|
|
17717
17745
|
};
|
|
17718
17746
|
})
|
|
17719
17747
|
]);
|
|
@@ -17723,7 +17751,7 @@ class II {
|
|
|
17723
17751
|
return E.filter((R) => !!R.regex);
|
|
17724
17752
|
}
|
|
17725
17753
|
}
|
|
17726
|
-
const
|
|
17754
|
+
const B = (T) => Z(T.toUpperCase()), PT = /* @__PURE__ */ new Map(), OI = (T) => {
|
|
17727
17755
|
let E = PT.get(T);
|
|
17728
17756
|
return E || (E = NI(T), PT.set(T, E)), E;
|
|
17729
17757
|
}, NI = (T) => ({
|
|
@@ -17775,36 +17803,36 @@ function rI() {
|
|
|
17775
17803
|
(function(E, R) {
|
|
17776
17804
|
T.exports ? T.exports = R() : E.nearley = R();
|
|
17777
17805
|
})(_I, function() {
|
|
17778
|
-
function E(I,
|
|
17779
|
-
return this.id = ++E.highestId, this.name = I, this.symbols =
|
|
17806
|
+
function E(I, N, t) {
|
|
17807
|
+
return this.id = ++E.highestId, this.name = I, this.symbols = N, this.postprocess = t, this;
|
|
17780
17808
|
}
|
|
17781
17809
|
E.highestId = 0, E.prototype.toString = function(I) {
|
|
17782
|
-
var
|
|
17783
|
-
return this.name + " → " +
|
|
17810
|
+
var N = typeof I > "u" ? this.symbols.map(D).join(" ") : this.symbols.slice(0, I).map(D).join(" ") + " ● " + this.symbols.slice(I).map(D).join(" ");
|
|
17811
|
+
return this.name + " → " + N;
|
|
17784
17812
|
};
|
|
17785
|
-
function R(I,
|
|
17786
|
-
this.rule = I, this.dot =
|
|
17813
|
+
function R(I, N, t, L) {
|
|
17814
|
+
this.rule = I, this.dot = N, this.reference = t, this.data = [], this.wantedBy = L, this.isComplete = this.dot === I.symbols.length;
|
|
17787
17815
|
}
|
|
17788
17816
|
R.prototype.toString = function() {
|
|
17789
17817
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
17790
17818
|
}, R.prototype.nextState = function(I) {
|
|
17791
|
-
var
|
|
17792
|
-
return
|
|
17819
|
+
var N = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
17820
|
+
return N.left = this, N.right = I, N.isComplete && (N.data = N.build(), N.right = void 0), N;
|
|
17793
17821
|
}, R.prototype.build = function() {
|
|
17794
|
-
var I = [],
|
|
17822
|
+
var I = [], N = this;
|
|
17795
17823
|
do
|
|
17796
|
-
I.push(
|
|
17797
|
-
while (
|
|
17824
|
+
I.push(N.right.data), N = N.left;
|
|
17825
|
+
while (N.left);
|
|
17798
17826
|
return I.reverse(), I;
|
|
17799
17827
|
}, R.prototype.finish = function() {
|
|
17800
17828
|
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, O.fail));
|
|
17801
17829
|
};
|
|
17802
|
-
function A(I,
|
|
17803
|
-
this.grammar = I, this.index =
|
|
17830
|
+
function A(I, N) {
|
|
17831
|
+
this.grammar = I, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
17804
17832
|
}
|
|
17805
17833
|
A.prototype.process = function(I) {
|
|
17806
|
-
for (var
|
|
17807
|
-
var a =
|
|
17834
|
+
for (var N = this.states, t = this.wants, L = this.completed, P = 0; P < N.length; P++) {
|
|
17835
|
+
var a = N[P];
|
|
17808
17836
|
if (a.isComplete) {
|
|
17809
17837
|
if (a.finish(), a.data !== O.fail) {
|
|
17810
17838
|
for (var r = a.wantedBy, U = r.length; U--; ) {
|
|
@@ -17812,55 +17840,55 @@ function rI() {
|
|
|
17812
17840
|
this.complete(o, a);
|
|
17813
17841
|
}
|
|
17814
17842
|
if (a.reference === this.index) {
|
|
17815
|
-
var
|
|
17816
|
-
(this.completed[
|
|
17843
|
+
var l = a.rule.name;
|
|
17844
|
+
(this.completed[l] = this.completed[l] || []).push(a);
|
|
17817
17845
|
}
|
|
17818
17846
|
}
|
|
17819
17847
|
} else {
|
|
17820
|
-
var
|
|
17821
|
-
if (typeof
|
|
17848
|
+
var l = a.rule.symbols[a.dot];
|
|
17849
|
+
if (typeof l != "string") {
|
|
17822
17850
|
this.scannable.push(a);
|
|
17823
17851
|
continue;
|
|
17824
17852
|
}
|
|
17825
|
-
if (
|
|
17826
|
-
if (
|
|
17827
|
-
for (var
|
|
17828
|
-
var
|
|
17829
|
-
this.complete(a,
|
|
17853
|
+
if (t[l]) {
|
|
17854
|
+
if (t[l].push(a), L.hasOwnProperty(l))
|
|
17855
|
+
for (var c = L[l], U = 0; U < c.length; U++) {
|
|
17856
|
+
var H = c[U];
|
|
17857
|
+
this.complete(a, H);
|
|
17830
17858
|
}
|
|
17831
17859
|
} else
|
|
17832
|
-
|
|
17860
|
+
t[l] = [a], this.predict(l);
|
|
17833
17861
|
}
|
|
17834
17862
|
}
|
|
17835
17863
|
}, A.prototype.predict = function(I) {
|
|
17836
|
-
for (var
|
|
17837
|
-
var L =
|
|
17864
|
+
for (var N = this.grammar.byName[I] || [], t = 0; t < N.length; t++) {
|
|
17865
|
+
var L = N[t], P = this.wants[I], a = new R(L, 0, this.index, P);
|
|
17838
17866
|
this.states.push(a);
|
|
17839
17867
|
}
|
|
17840
|
-
}, A.prototype.complete = function(I,
|
|
17841
|
-
var
|
|
17842
|
-
this.states.push(
|
|
17868
|
+
}, A.prototype.complete = function(I, N) {
|
|
17869
|
+
var t = I.nextState(N);
|
|
17870
|
+
this.states.push(t);
|
|
17843
17871
|
};
|
|
17844
|
-
function S(I,
|
|
17845
|
-
this.rules = I, this.start =
|
|
17846
|
-
var
|
|
17872
|
+
function S(I, N) {
|
|
17873
|
+
this.rules = I, this.start = N || this.rules[0].name;
|
|
17874
|
+
var t = this.byName = {};
|
|
17847
17875
|
this.rules.forEach(function(L) {
|
|
17848
|
-
|
|
17876
|
+
t.hasOwnProperty(L.name) || (t[L.name] = []), t[L.name].push(L);
|
|
17849
17877
|
});
|
|
17850
17878
|
}
|
|
17851
|
-
S.fromCompiled = function(L,
|
|
17852
|
-
var
|
|
17853
|
-
L.ParserStart && (
|
|
17879
|
+
S.fromCompiled = function(L, N) {
|
|
17880
|
+
var t = L.Lexer;
|
|
17881
|
+
L.ParserStart && (N = L.ParserStart, L = L.ParserRules);
|
|
17854
17882
|
var L = L.map(function(a) {
|
|
17855
17883
|
return new E(a.name, a.symbols, a.postprocess);
|
|
17856
|
-
}), P = new S(L,
|
|
17857
|
-
return P.lexer =
|
|
17884
|
+
}), P = new S(L, N);
|
|
17885
|
+
return P.lexer = t, P;
|
|
17858
17886
|
};
|
|
17859
17887
|
function e() {
|
|
17860
17888
|
this.reset("");
|
|
17861
17889
|
}
|
|
17862
|
-
e.prototype.reset = function(I,
|
|
17863
|
-
this.buffer = I, this.index = 0, this.line =
|
|
17890
|
+
e.prototype.reset = function(I, N) {
|
|
17891
|
+
this.buffer = I, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
|
|
17864
17892
|
}, e.prototype.next = function() {
|
|
17865
17893
|
if (this.index < this.buffer.length) {
|
|
17866
17894
|
var I = this.buffer[this.index++];
|
|
@@ -17872,53 +17900,53 @@ function rI() {
|
|
|
17872
17900
|
line: this.line,
|
|
17873
17901
|
col: this.index - this.lastLineBreak
|
|
17874
17902
|
};
|
|
17875
|
-
}, e.prototype.formatError = function(I,
|
|
17876
|
-
var
|
|
17877
|
-
if (typeof
|
|
17878
|
-
var L =
|
|
17903
|
+
}, e.prototype.formatError = function(I, N) {
|
|
17904
|
+
var t = this.buffer;
|
|
17905
|
+
if (typeof t == "string") {
|
|
17906
|
+
var L = t.split(`
|
|
17879
17907
|
`).slice(
|
|
17880
17908
|
Math.max(0, this.line - 5),
|
|
17881
17909
|
this.line
|
|
17882
|
-
), P =
|
|
17910
|
+
), P = t.indexOf(`
|
|
17883
17911
|
`, this.index);
|
|
17884
|
-
P === -1 && (P =
|
|
17912
|
+
P === -1 && (P = t.length);
|
|
17885
17913
|
var a = this.index - this.lastLineBreak, r = String(this.line).length;
|
|
17886
|
-
return
|
|
17914
|
+
return N += " at line " + this.line + " col " + a + `:
|
|
17887
17915
|
|
|
17888
|
-
`,
|
|
17889
|
-
return U(this.line - L.length +
|
|
17916
|
+
`, N += L.map(function(o, l) {
|
|
17917
|
+
return U(this.line - L.length + l + 1, r) + " " + o;
|
|
17890
17918
|
}, this).join(`
|
|
17891
|
-
`),
|
|
17919
|
+
`), N += `
|
|
17892
17920
|
` + U("", r + a) + `^
|
|
17893
|
-
`,
|
|
17921
|
+
`, N;
|
|
17894
17922
|
} else
|
|
17895
|
-
return
|
|
17896
|
-
function U(o,
|
|
17897
|
-
var
|
|
17898
|
-
return Array(
|
|
17923
|
+
return N + " at index " + (this.index - 1);
|
|
17924
|
+
function U(o, l) {
|
|
17925
|
+
var c = String(o);
|
|
17926
|
+
return Array(l - c.length + 1).join(" ") + c;
|
|
17899
17927
|
}
|
|
17900
17928
|
};
|
|
17901
|
-
function O(I,
|
|
17929
|
+
function O(I, N, t) {
|
|
17902
17930
|
if (I instanceof S)
|
|
17903
|
-
var L = I,
|
|
17931
|
+
var L = I, t = N;
|
|
17904
17932
|
else
|
|
17905
|
-
var L = S.fromCompiled(I,
|
|
17933
|
+
var L = S.fromCompiled(I, N);
|
|
17906
17934
|
this.grammar = L, this.options = {
|
|
17907
17935
|
keepHistory: !1,
|
|
17908
17936
|
lexer: L.lexer || new e()
|
|
17909
17937
|
};
|
|
17910
|
-
for (var P in
|
|
17911
|
-
this.options[P] =
|
|
17938
|
+
for (var P in t || {})
|
|
17939
|
+
this.options[P] = t[P];
|
|
17912
17940
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
17913
17941
|
var a = new A(L, 0);
|
|
17914
17942
|
this.table = [a], a.wants[L.start] = [], a.predict(L.start), a.process(), this.current = 0;
|
|
17915
17943
|
}
|
|
17916
17944
|
O.fail = {}, O.prototype.feed = function(I) {
|
|
17917
|
-
var
|
|
17918
|
-
|
|
17919
|
-
for (var
|
|
17945
|
+
var N = this.lexer;
|
|
17946
|
+
N.reset(I, this.lexerState);
|
|
17947
|
+
for (var t; ; ) {
|
|
17920
17948
|
try {
|
|
17921
|
-
if (
|
|
17949
|
+
if (t = N.next(), !t)
|
|
17922
17950
|
break;
|
|
17923
17951
|
} catch (K) {
|
|
17924
17952
|
var r = new A(this.grammar, this.current + 1);
|
|
@@ -17930,86 +17958,86 @@ function rI() {
|
|
|
17930
17958
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
17931
17959
|
var a = this.current + 1, r = new A(this.grammar, a);
|
|
17932
17960
|
this.table.push(r);
|
|
17933
|
-
for (var U =
|
|
17934
|
-
var
|
|
17935
|
-
if (
|
|
17936
|
-
var p =
|
|
17961
|
+
for (var U = t.text !== void 0 ? t.text : t.value, o = N.constructor === e ? t.value : t, l = P.scannable, c = l.length; c--; ) {
|
|
17962
|
+
var H = l[c], u = H.rule.symbols[H.dot];
|
|
17963
|
+
if (u.test ? u.test(o) : u.type ? u.type === t.type : u.literal === U) {
|
|
17964
|
+
var p = H.nextState({ data: o, token: t, isToken: !0, reference: a - 1 });
|
|
17937
17965
|
r.states.push(p);
|
|
17938
17966
|
}
|
|
17939
17967
|
}
|
|
17940
17968
|
if (r.process(), r.states.length === 0) {
|
|
17941
|
-
var L = new Error(this.reportError(
|
|
17942
|
-
throw L.offset = this.current, L.token =
|
|
17969
|
+
var L = new Error(this.reportError(t));
|
|
17970
|
+
throw L.offset = this.current, L.token = t, L;
|
|
17943
17971
|
}
|
|
17944
|
-
this.options.keepHistory && (P.lexerState =
|
|
17972
|
+
this.options.keepHistory && (P.lexerState = N.save()), this.current++;
|
|
17945
17973
|
}
|
|
17946
|
-
return P && (this.lexerState =
|
|
17974
|
+
return P && (this.lexerState = N.save()), this.results = this.finish(), this;
|
|
17947
17975
|
}, O.prototype.reportLexerError = function(I) {
|
|
17948
|
-
var
|
|
17949
|
-
return L ? (
|
|
17976
|
+
var N, t, L = I.token;
|
|
17977
|
+
return L ? (N = "input " + JSON.stringify(L.text[0]) + " (lexer error)", t = this.lexer.formatError(L, "Syntax error")) : (N = "input (lexer error)", t = I.message), this.reportErrorCommon(t, N);
|
|
17950
17978
|
}, O.prototype.reportError = function(I) {
|
|
17951
|
-
var
|
|
17952
|
-
return this.reportErrorCommon(
|
|
17953
|
-
}, O.prototype.reportErrorCommon = function(I,
|
|
17954
|
-
var
|
|
17955
|
-
|
|
17979
|
+
var N = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), t = this.lexer.formatError(I, "Syntax error");
|
|
17980
|
+
return this.reportErrorCommon(t, N);
|
|
17981
|
+
}, O.prototype.reportErrorCommon = function(I, N) {
|
|
17982
|
+
var t = [];
|
|
17983
|
+
t.push(I);
|
|
17956
17984
|
var L = this.table.length - 2, P = this.table[L], a = P.states.filter(function(U) {
|
|
17957
17985
|
var o = U.rule.symbols[U.dot];
|
|
17958
17986
|
return o && typeof o != "string";
|
|
17959
17987
|
});
|
|
17960
17988
|
if (a.length === 0)
|
|
17961
|
-
|
|
17962
|
-
`), this.displayStateStack(P.states,
|
|
17989
|
+
t.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
|
|
17990
|
+
`), this.displayStateStack(P.states, t);
|
|
17963
17991
|
else {
|
|
17964
|
-
|
|
17992
|
+
t.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
17965
17993
|
`);
|
|
17966
17994
|
var r = a.map(function(U) {
|
|
17967
17995
|
return this.buildFirstStateStack(U, []) || [U];
|
|
17968
17996
|
}, this);
|
|
17969
17997
|
r.forEach(function(U) {
|
|
17970
|
-
var o = U[0],
|
|
17971
|
-
|
|
17998
|
+
var o = U[0], l = o.rule.symbols[o.dot], c = this.getSymbolDisplay(l);
|
|
17999
|
+
t.push("A " + c + " based on:"), this.displayStateStack(U, t);
|
|
17972
18000
|
}, this);
|
|
17973
18001
|
}
|
|
17974
|
-
return
|
|
18002
|
+
return t.push(""), t.join(`
|
|
17975
18003
|
`);
|
|
17976
|
-
}, O.prototype.displayStateStack = function(I,
|
|
17977
|
-
for (var
|
|
18004
|
+
}, O.prototype.displayStateStack = function(I, N) {
|
|
18005
|
+
for (var t, L = 0, P = 0; P < I.length; P++) {
|
|
17978
18006
|
var a = I[P], r = a.rule.toString(a.dot);
|
|
17979
|
-
r ===
|
|
18007
|
+
r === t ? L++ : (L > 0 && N.push(" ^ " + L + " more lines identical to this"), L = 0, N.push(" " + r)), t = r;
|
|
17980
18008
|
}
|
|
17981
18009
|
}, O.prototype.getSymbolDisplay = function(I) {
|
|
17982
|
-
return
|
|
17983
|
-
}, O.prototype.buildFirstStateStack = function(I,
|
|
17984
|
-
if (
|
|
18010
|
+
return s(I);
|
|
18011
|
+
}, O.prototype.buildFirstStateStack = function(I, N) {
|
|
18012
|
+
if (N.indexOf(I) !== -1)
|
|
17985
18013
|
return null;
|
|
17986
18014
|
if (I.wantedBy.length === 0)
|
|
17987
18015
|
return [I];
|
|
17988
|
-
var
|
|
18016
|
+
var t = I.wantedBy[0], L = [I].concat(N), P = this.buildFirstStateStack(t, L);
|
|
17989
18017
|
return P === null ? null : [I].concat(P);
|
|
17990
18018
|
}, O.prototype.save = function() {
|
|
17991
18019
|
var I = this.table[this.current];
|
|
17992
18020
|
return I.lexerState = this.lexerState, I;
|
|
17993
18021
|
}, O.prototype.restore = function(I) {
|
|
17994
|
-
var
|
|
17995
|
-
this.current =
|
|
18022
|
+
var N = I.index;
|
|
18023
|
+
this.current = N, this.table[N] = I, this.table.splice(N + 1), this.lexerState = I.lexerState, this.results = this.finish();
|
|
17996
18024
|
}, O.prototype.rewind = function(I) {
|
|
17997
18025
|
if (!this.options.keepHistory)
|
|
17998
18026
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
17999
18027
|
this.restore(this.table[I]);
|
|
18000
18028
|
}, O.prototype.finish = function() {
|
|
18001
|
-
var I = [],
|
|
18002
|
-
return
|
|
18003
|
-
L.rule.name ===
|
|
18029
|
+
var I = [], N = this.grammar.start, t = this.table[this.table.length - 1];
|
|
18030
|
+
return t.states.forEach(function(L) {
|
|
18031
|
+
L.rule.name === N && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== O.fail && I.push(L);
|
|
18004
18032
|
}), I.map(function(L) {
|
|
18005
18033
|
return L.data;
|
|
18006
18034
|
});
|
|
18007
18035
|
};
|
|
18008
|
-
function
|
|
18009
|
-
var
|
|
18010
|
-
if (
|
|
18036
|
+
function s(I) {
|
|
18037
|
+
var N = typeof I;
|
|
18038
|
+
if (N === "string")
|
|
18011
18039
|
return I;
|
|
18012
|
-
if (
|
|
18040
|
+
if (N === "object") {
|
|
18013
18041
|
if (I.literal)
|
|
18014
18042
|
return JSON.stringify(I.literal);
|
|
18015
18043
|
if (I instanceof RegExp)
|
|
@@ -18022,10 +18050,10 @@ function rI() {
|
|
|
18022
18050
|
}
|
|
18023
18051
|
}
|
|
18024
18052
|
function D(I) {
|
|
18025
|
-
var
|
|
18026
|
-
if (
|
|
18053
|
+
var N = typeof I;
|
|
18054
|
+
if (N === "string")
|
|
18027
18055
|
return I;
|
|
18028
|
-
if (
|
|
18056
|
+
if (N === "object") {
|
|
18029
18057
|
if (I.literal)
|
|
18030
18058
|
return JSON.stringify(I.literal);
|
|
18031
18059
|
if (I instanceof RegExp)
|
|
@@ -18121,7 +18149,7 @@ var M;
|
|
|
18121
18149
|
function BE(T) {
|
|
18122
18150
|
return T[0];
|
|
18123
18151
|
}
|
|
18124
|
-
const G = new hT((T) => []), h = ([[T]]) => T,
|
|
18152
|
+
const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
18125
18153
|
type: M.keyword,
|
|
18126
18154
|
tokenType: T.type,
|
|
18127
18155
|
text: T.text,
|
|
@@ -18130,14 +18158,14 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18130
18158
|
type: M.data_type,
|
|
18131
18159
|
text: T.text,
|
|
18132
18160
|
raw: T.raw
|
|
18133
|
-
}),
|
|
18161
|
+
}), Y = (T, { leading: E, trailing: R }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), lI = (T, { leading: E, trailing: R }) => {
|
|
18134
18162
|
if (E?.length) {
|
|
18135
18163
|
const [A, ...S] = T;
|
|
18136
|
-
T = [
|
|
18164
|
+
T = [Y(A, { leading: E }), ...S];
|
|
18137
18165
|
}
|
|
18138
18166
|
if (R?.length) {
|
|
18139
18167
|
const A = T.slice(0, -1), S = T[T.length - 1];
|
|
18140
|
-
T = [...A,
|
|
18168
|
+
T = [...A, Y(S, { trailing: R })];
|
|
18141
18169
|
}
|
|
18142
18170
|
return T;
|
|
18143
18171
|
}, HI = {
|
|
@@ -18191,14 +18219,14 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18191
18219
|
const [S, e] = A;
|
|
18192
18220
|
return {
|
|
18193
18221
|
type: M.limit_clause,
|
|
18194
|
-
limitKw: F(
|
|
18222
|
+
limitKw: Y(F(T), { trailing: E }),
|
|
18195
18223
|
offset: R,
|
|
18196
18224
|
count: e
|
|
18197
18225
|
};
|
|
18198
18226
|
} else
|
|
18199
18227
|
return {
|
|
18200
18228
|
type: M.limit_clause,
|
|
18201
|
-
limitKw: F(
|
|
18229
|
+
limitKw: Y(F(T), { trailing: E }),
|
|
18202
18230
|
count: R
|
|
18203
18231
|
};
|
|
18204
18232
|
}
|
|
@@ -18214,7 +18242,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18214
18242
|
symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
|
|
18215
18243
|
postprocess: ([T, [E, R]]) => ({
|
|
18216
18244
|
type: M.clause,
|
|
18217
|
-
nameKw:
|
|
18245
|
+
nameKw: F(T),
|
|
18218
18246
|
children: [E, ...R]
|
|
18219
18247
|
})
|
|
18220
18248
|
},
|
|
@@ -18223,7 +18251,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18223
18251
|
symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
|
|
18224
18252
|
postprocess: ([T]) => ({
|
|
18225
18253
|
type: M.clause,
|
|
18226
|
-
nameKw:
|
|
18254
|
+
nameKw: F(T),
|
|
18227
18255
|
children: []
|
|
18228
18256
|
})
|
|
18229
18257
|
},
|
|
@@ -18239,7 +18267,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18239
18267
|
symbols: [G.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
|
|
18240
18268
|
postprocess: ([T, E]) => ({
|
|
18241
18269
|
type: M.clause,
|
|
18242
|
-
nameKw:
|
|
18270
|
+
nameKw: F(T),
|
|
18243
18271
|
children: E
|
|
18244
18272
|
})
|
|
18245
18273
|
},
|
|
@@ -18250,7 +18278,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18250
18278
|
symbols: [G.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
|
|
18251
18279
|
postprocess: ([T, E]) => ({
|
|
18252
18280
|
type: M.set_operation,
|
|
18253
|
-
nameKw:
|
|
18281
|
+
nameKw: F(T),
|
|
18254
18282
|
children: E
|
|
18255
18283
|
})
|
|
18256
18284
|
},
|
|
@@ -18274,17 +18302,17 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18274
18302
|
{
|
|
18275
18303
|
name: "expression_with_comments_",
|
|
18276
18304
|
symbols: ["expression", "_"],
|
|
18277
|
-
postprocess: ([T, E]) =>
|
|
18305
|
+
postprocess: ([T, E]) => Y(T, { trailing: E })
|
|
18278
18306
|
},
|
|
18279
18307
|
{
|
|
18280
18308
|
name: "_expression_with_comments",
|
|
18281
18309
|
symbols: ["_", "expression"],
|
|
18282
|
-
postprocess: ([T, E]) =>
|
|
18310
|
+
postprocess: ([T, E]) => Y(E, { leading: T })
|
|
18283
18311
|
},
|
|
18284
18312
|
{
|
|
18285
18313
|
name: "_andless_expression_with_comments",
|
|
18286
18314
|
symbols: ["_", "andless_expression"],
|
|
18287
|
-
postprocess: ([T, E]) =>
|
|
18315
|
+
postprocess: ([T, E]) => Y(E, { leading: T })
|
|
18288
18316
|
},
|
|
18289
18317
|
{ name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
|
|
18290
18318
|
{ name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
|
|
@@ -18323,7 +18351,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18323
18351
|
symbols: [G.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
|
|
18324
18352
|
postprocess: ([T, E, R]) => ({
|
|
18325
18353
|
type: M.array_subscript,
|
|
18326
|
-
array:
|
|
18354
|
+
array: Y({ type: M.identifier, quoted: !1, text: T.text }, { trailing: E }),
|
|
18327
18355
|
parenthesis: R
|
|
18328
18356
|
})
|
|
18329
18357
|
},
|
|
@@ -18332,7 +18360,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18332
18360
|
symbols: [G.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
|
|
18333
18361
|
postprocess: ([T, E, R]) => ({
|
|
18334
18362
|
type: M.array_subscript,
|
|
18335
|
-
array: F(
|
|
18363
|
+
array: Y(F(T), { trailing: E }),
|
|
18336
18364
|
parenthesis: R
|
|
18337
18365
|
})
|
|
18338
18366
|
},
|
|
@@ -18341,7 +18369,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18341
18369
|
symbols: [G.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
|
|
18342
18370
|
postprocess: ([T, E, R]) => ({
|
|
18343
18371
|
type: M.function_call,
|
|
18344
|
-
nameKw: F(
|
|
18372
|
+
nameKw: Y(F(T), { trailing: E }),
|
|
18345
18373
|
parenthesis: R
|
|
18346
18374
|
})
|
|
18347
18375
|
},
|
|
@@ -18393,9 +18421,9 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18393
18421
|
// %ARRAY_IDENTIFIER on the left side of <array_subscript>.
|
|
18394
18422
|
([T, E, R, A, [S]]) => ({
|
|
18395
18423
|
type: M.property_access,
|
|
18396
|
-
object:
|
|
18424
|
+
object: Y(T, { trailing: E }),
|
|
18397
18425
|
operator: R.text,
|
|
18398
|
-
property:
|
|
18426
|
+
property: Y(S, { leading: A })
|
|
18399
18427
|
})
|
|
18400
18428
|
)
|
|
18401
18429
|
},
|
|
@@ -18404,10 +18432,10 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18404
18432
|
symbols: [G.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", G.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
|
|
18405
18433
|
postprocess: ([T, E, R, A, S, e, O]) => ({
|
|
18406
18434
|
type: M.between_predicate,
|
|
18407
|
-
betweenKw:
|
|
18435
|
+
betweenKw: F(T),
|
|
18408
18436
|
expr1: lI(R, { leading: E, trailing: A }),
|
|
18409
|
-
andKw:
|
|
18410
|
-
expr2: [
|
|
18437
|
+
andKw: F(S),
|
|
18438
|
+
expr2: [Y(O, { leading: e })]
|
|
18411
18439
|
})
|
|
18412
18440
|
},
|
|
18413
18441
|
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: BE },
|
|
@@ -18419,8 +18447,8 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18419
18447
|
symbols: [G.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", G.has("END") ? { type: "END" } : END],
|
|
18420
18448
|
postprocess: ([T, E, R, A, S]) => ({
|
|
18421
18449
|
type: M.case_expression,
|
|
18422
|
-
caseKw: F(
|
|
18423
|
-
endKw:
|
|
18450
|
+
caseKw: Y(F(T), { trailing: E }),
|
|
18451
|
+
endKw: F(S),
|
|
18424
18452
|
expr: R || [],
|
|
18425
18453
|
clauses: A
|
|
18426
18454
|
})
|
|
@@ -18430,8 +18458,8 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18430
18458
|
symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", G.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
|
|
18431
18459
|
postprocess: ([T, E, R, A, S, e]) => ({
|
|
18432
18460
|
type: M.case_when,
|
|
18433
|
-
whenKw: F(
|
|
18434
|
-
thenKw: F(
|
|
18461
|
+
whenKw: Y(F(T), { trailing: E }),
|
|
18462
|
+
thenKw: Y(F(A), { trailing: S }),
|
|
18435
18463
|
condition: R,
|
|
18436
18464
|
result: e
|
|
18437
18465
|
})
|
|
@@ -18441,7 +18469,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18441
18469
|
symbols: [G.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
|
|
18442
18470
|
postprocess: ([T, E, R]) => ({
|
|
18443
18471
|
type: M.case_else,
|
|
18444
|
-
elseKw: F(
|
|
18472
|
+
elseKw: Y(F(T), { trailing: E }),
|
|
18445
18473
|
result: R
|
|
18446
18474
|
})
|
|
18447
18475
|
},
|
|
@@ -18470,7 +18498,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18470
18498
|
{
|
|
18471
18499
|
name: "keyword",
|
|
18472
18500
|
symbols: ["keyword$subexpression$1"],
|
|
18473
|
-
postprocess: ([[T]]) =>
|
|
18501
|
+
postprocess: ([[T]]) => F(T)
|
|
18474
18502
|
},
|
|
18475
18503
|
{ name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
|
|
18476
18504
|
{ name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE_PHRASE") ? { type: "RESERVED_DATA_TYPE_PHRASE" } : RESERVED_DATA_TYPE_PHRASE] },
|
|
@@ -18484,7 +18512,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18484
18512
|
symbols: [G.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
18485
18513
|
postprocess: ([T, E, R]) => ({
|
|
18486
18514
|
type: M.parameterized_data_type,
|
|
18487
|
-
dataType:
|
|
18515
|
+
dataType: Y(oT(T), { trailing: E }),
|
|
18488
18516
|
parenthesis: R
|
|
18489
18517
|
})
|
|
18490
18518
|
},
|
|
@@ -18494,7 +18522,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18494
18522
|
{
|
|
18495
18523
|
name: "logic_operator",
|
|
18496
18524
|
symbols: ["logic_operator$subexpression$1"],
|
|
18497
|
-
postprocess: ([[T]]) =>
|
|
18525
|
+
postprocess: ([[T]]) => F(T)
|
|
18498
18526
|
},
|
|
18499
18527
|
{ name: "other_keyword$subexpression$1", symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN] },
|
|
18500
18528
|
{ name: "other_keyword$subexpression$1", symbols: [G.has("THEN") ? { type: "THEN" } : THEN] },
|
|
@@ -18503,7 +18531,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18503
18531
|
{
|
|
18504
18532
|
name: "other_keyword",
|
|
18505
18533
|
symbols: ["other_keyword$subexpression$1"],
|
|
18506
|
-
postprocess: ([[T]]) =>
|
|
18534
|
+
postprocess: ([[T]]) => F(T)
|
|
18507
18535
|
},
|
|
18508
18536
|
{ name: "_$ebnf$1", symbols: [] },
|
|
18509
18537
|
{ name: "_$ebnf$1", symbols: ["_$ebnf$1", "comment"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
@@ -18559,7 +18587,7 @@ var n;
|
|
|
18559
18587
|
(function(T) {
|
|
18560
18588
|
T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
18561
18589
|
})(n = n || (n = {}));
|
|
18562
|
-
class
|
|
18590
|
+
class fT {
|
|
18563
18591
|
constructor(E) {
|
|
18564
18592
|
this.indentation = E, this.items = [];
|
|
18565
18593
|
}
|
|
@@ -18657,7 +18685,7 @@ function UT(T) {
|
|
|
18657
18685
|
return LR(T) || T === i.RESERVED_CLAUSE || T === i.RESERVED_SELECT || T === i.RESERVED_SET_OPERATION || T === i.RESERVED_JOIN || T === i.LIMIT;
|
|
18658
18686
|
}
|
|
18659
18687
|
const FE = "top-level", pI = "block-level";
|
|
18660
|
-
class
|
|
18688
|
+
class WT {
|
|
18661
18689
|
/**
|
|
18662
18690
|
* @param {string} indent A string to indent with
|
|
18663
18691
|
*/
|
|
@@ -18705,9 +18733,9 @@ class fT {
|
|
|
18705
18733
|
;
|
|
18706
18734
|
}
|
|
18707
18735
|
}
|
|
18708
|
-
class dI extends
|
|
18736
|
+
class dI extends fT {
|
|
18709
18737
|
constructor(E) {
|
|
18710
|
-
super(new
|
|
18738
|
+
super(new WT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
18711
18739
|
}
|
|
18712
18740
|
add(...E) {
|
|
18713
18741
|
if (E.forEach((R) => this.addToLength(R)), this.length > this.expressionWidth)
|
|
@@ -19060,7 +19088,7 @@ class VI {
|
|
|
19060
19088
|
cfg: this.cfg,
|
|
19061
19089
|
dialectCfg: this.dialect.formatOptions,
|
|
19062
19090
|
params: this.params,
|
|
19063
|
-
layout: new
|
|
19091
|
+
layout: new fT(new WT(tI(this.cfg)))
|
|
19064
19092
|
}).format(E.children);
|
|
19065
19093
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(n.NEWLINE, ";") : R.add(n.NO_NEWLINE, ";")), R.toString();
|
|
19066
19094
|
}
|
|
@@ -19081,14 +19109,14 @@ function hI(T) {
|
|
|
19081
19109
|
throw new k(`${R} config is no more supported.`);
|
|
19082
19110
|
if (T.expressionWidth <= 0)
|
|
19083
19111
|
throw new k(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
19084
|
-
if (T.params && !
|
|
19112
|
+
if (T.params && !fI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !WI(T.paramTypes))
|
|
19085
19113
|
throw new k("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
19086
19114
|
return T;
|
|
19087
19115
|
}
|
|
19088
|
-
function
|
|
19116
|
+
function fI(T) {
|
|
19089
19117
|
return (T instanceof Array ? T : Object.values(T)).every((R) => typeof R == "string");
|
|
19090
19118
|
}
|
|
19091
|
-
function
|
|
19119
|
+
function WI(T) {
|
|
19092
19120
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
19093
19121
|
}
|
|
19094
19122
|
var XI = function(T, E) {
|
|
@@ -19163,7 +19191,7 @@ function GT(T, E) {
|
|
|
19163
19191
|
return console.warn("SQL formatting failed:", R), T;
|
|
19164
19192
|
}
|
|
19165
19193
|
}
|
|
19166
|
-
class
|
|
19194
|
+
class fE {
|
|
19167
19195
|
cubes = /* @__PURE__ */ new Map();
|
|
19168
19196
|
dbExecutor;
|
|
19169
19197
|
metadataCache;
|
|
@@ -19280,9 +19308,9 @@ class WE {
|
|
|
19280
19308
|
*/
|
|
19281
19309
|
generateCubeMetadata(E) {
|
|
19282
19310
|
const R = Object.keys(E.measures), A = Object.keys(E.dimensions), S = new Array(R.length), e = new Array(A.length);
|
|
19283
|
-
for (let
|
|
19284
|
-
const D = R[
|
|
19285
|
-
S[
|
|
19311
|
+
for (let s = 0; s < R.length; s++) {
|
|
19312
|
+
const D = R[s], I = E.measures[D];
|
|
19313
|
+
S[s] = {
|
|
19286
19314
|
name: `${E.name}.${D}`,
|
|
19287
19315
|
title: I.title || D,
|
|
19288
19316
|
shortTitle: I.title || D,
|
|
@@ -19292,9 +19320,9 @@ class WE {
|
|
|
19292
19320
|
description: I.description
|
|
19293
19321
|
};
|
|
19294
19322
|
}
|
|
19295
|
-
for (let
|
|
19296
|
-
const D = A[
|
|
19297
|
-
e[
|
|
19323
|
+
for (let s = 0; s < A.length; s++) {
|
|
19324
|
+
const D = A[s], I = E.dimensions[D];
|
|
19325
|
+
e[s] = {
|
|
19298
19326
|
name: `${E.name}.${D}`,
|
|
19299
19327
|
title: I.title || D,
|
|
19300
19328
|
shortTitle: I.title || D,
|
|
@@ -19306,12 +19334,12 @@ class WE {
|
|
|
19306
19334
|
}
|
|
19307
19335
|
const O = [];
|
|
19308
19336
|
if (E.joins)
|
|
19309
|
-
for (const [,
|
|
19310
|
-
const D = typeof
|
|
19337
|
+
for (const [, s] of Object.entries(E.joins)) {
|
|
19338
|
+
const D = typeof s.targetCube == "function" ? s.targetCube() : s.targetCube;
|
|
19311
19339
|
O.push({
|
|
19312
19340
|
targetCube: D.name,
|
|
19313
|
-
relationship:
|
|
19314
|
-
joinFields:
|
|
19341
|
+
relationship: s.relationship,
|
|
19342
|
+
joinFields: s.on.map((I) => ({
|
|
19315
19343
|
sourceField: this.getColumnName(I.source),
|
|
19316
19344
|
targetField: this.getColumnName(I.target)
|
|
19317
19345
|
}))
|
|
@@ -19337,9 +19365,9 @@ class WE {
|
|
|
19337
19365
|
throw new Error(`Cube '${E}' not found`);
|
|
19338
19366
|
if (!this.dbExecutor)
|
|
19339
19367
|
throw new Error("Database executor not configured");
|
|
19340
|
-
const O = await new OE(this.dbExecutor).generateSQL(S, R, A),
|
|
19368
|
+
const O = await new OE(this.dbExecutor).generateSQL(S, R, A), s = this.dbExecutor.getEngineType();
|
|
19341
19369
|
return {
|
|
19342
|
-
sql: GT(O.sql,
|
|
19370
|
+
sql: GT(O.sql, s),
|
|
19343
19371
|
params: O.params
|
|
19344
19372
|
};
|
|
19345
19373
|
}
|
|
@@ -19405,12 +19433,12 @@ function bT(T, E) {
|
|
|
19405
19433
|
continue;
|
|
19406
19434
|
}
|
|
19407
19435
|
A.add(e);
|
|
19408
|
-
const
|
|
19409
|
-
if (!
|
|
19436
|
+
const s = T.get(e);
|
|
19437
|
+
if (!s) {
|
|
19410
19438
|
R.push(`Cube '${e}' not found (referenced in measure '${S}')`);
|
|
19411
19439
|
continue;
|
|
19412
19440
|
}
|
|
19413
|
-
|
|
19441
|
+
s.measures[O] || R.push(`Measure '${O}' not found on cube '${e}'`);
|
|
19414
19442
|
}
|
|
19415
19443
|
if (E.dimensions)
|
|
19416
19444
|
for (const S of E.dimensions) {
|
|
@@ -19420,12 +19448,12 @@ function bT(T, E) {
|
|
|
19420
19448
|
continue;
|
|
19421
19449
|
}
|
|
19422
19450
|
A.add(e);
|
|
19423
|
-
const
|
|
19424
|
-
if (!
|
|
19451
|
+
const s = T.get(e);
|
|
19452
|
+
if (!s) {
|
|
19425
19453
|
R.push(`Cube '${e}' not found (referenced in dimension '${S}')`);
|
|
19426
19454
|
continue;
|
|
19427
19455
|
}
|
|
19428
|
-
|
|
19456
|
+
s.dimensions[O] || R.push(`Dimension '${O}' not found on cube '${e}'`);
|
|
19429
19457
|
}
|
|
19430
19458
|
if (E.timeDimensions)
|
|
19431
19459
|
for (const S of E.timeDimensions) {
|
|
@@ -19435,12 +19463,12 @@ function bT(T, E) {
|
|
|
19435
19463
|
continue;
|
|
19436
19464
|
}
|
|
19437
19465
|
A.add(e);
|
|
19438
|
-
const
|
|
19439
|
-
if (!
|
|
19466
|
+
const s = T.get(e);
|
|
19467
|
+
if (!s) {
|
|
19440
19468
|
R.push(`Cube '${e}' not found (referenced in timeDimension '${S.dimension}')`);
|
|
19441
19469
|
continue;
|
|
19442
19470
|
}
|
|
19443
|
-
|
|
19471
|
+
s.dimensions[O] || R.push(`TimeDimension '${O}' not found on cube '${e}' (must be a dimension with time type)`);
|
|
19444
19472
|
}
|
|
19445
19473
|
if (E.filters)
|
|
19446
19474
|
for (const S of E.filters)
|
|
@@ -19452,8 +19480,8 @@ function bT(T, E) {
|
|
|
19452
19480
|
}
|
|
19453
19481
|
function KT(T, E, R, A) {
|
|
19454
19482
|
if ("and" in T || "or" in T) {
|
|
19455
|
-
const
|
|
19456
|
-
for (const D of
|
|
19483
|
+
const s = T.and || T.or || [];
|
|
19484
|
+
for (const D of s)
|
|
19457
19485
|
KT(D, E, R, A);
|
|
19458
19486
|
return;
|
|
19459
19487
|
}
|
|
@@ -19475,11 +19503,11 @@ function KT(T, E, R, A) {
|
|
|
19475
19503
|
!O.dimensions[e] && !O.measures[e] && R.push(`Filter field '${e}' not found on cube '${S}' (must be a dimension or measure)`);
|
|
19476
19504
|
}
|
|
19477
19505
|
function vI(T) {
|
|
19478
|
-
return new
|
|
19506
|
+
return new fE(T);
|
|
19479
19507
|
}
|
|
19480
|
-
const gI = new
|
|
19508
|
+
const gI = new fE(), QI = gI;
|
|
19481
19509
|
function ZI(T) {
|
|
19482
|
-
return new
|
|
19510
|
+
return new fE({
|
|
19483
19511
|
drizzle: T.drizzle,
|
|
19484
19512
|
schema: T.schema
|
|
19485
19513
|
});
|
|
@@ -19598,7 +19626,7 @@ export {
|
|
|
19598
19626
|
OE as QueryExecutor,
|
|
19599
19627
|
RR as QueryPlanner,
|
|
19600
19628
|
kT as SQLiteExecutor,
|
|
19601
|
-
|
|
19629
|
+
fE as SemanticLayerCompiler,
|
|
19602
19630
|
qI as SemanticLayerUtils,
|
|
19603
19631
|
JE as createDatabaseExecutor,
|
|
19604
19632
|
ZI as createDrizzleSemanticLayer,
|
|
@@ -19611,6 +19639,6 @@ export {
|
|
|
19611
19639
|
xI as defineCube,
|
|
19612
19640
|
ER as getJoinType,
|
|
19613
19641
|
wE as resolveCubeReference,
|
|
19614
|
-
|
|
19642
|
+
f as resolveSqlExpression,
|
|
19615
19643
|
gI as semanticLayer
|
|
19616
19644
|
};
|