drizzle-cube 0.1.36 → 0.1.37
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-ixtRH_TD.js → compiler-CiUqnN3l.js} +676 -618
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.js +938 -880
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as _, count as RE, sum as W, max as YE, min as mE,
|
|
1
|
+
import { sql as _, eq as w, and as m, count as RE, sum as W, max as YE, min as mE, countDistinct as gT, SQL as JT, or as AE, isNotNull as WE, ne as XE, isNull as bE, notInArray as yE, inArray as SE, lt as eE, gt as IE, gte as K, lte as $, desc as wT, asc as KE } from "drizzle-orm";
|
|
2
2
|
class dE {
|
|
3
3
|
/**
|
|
4
4
|
* Helper method to build pattern for string matching
|
|
@@ -18,7 +18,7 @@ class dE {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class xT extends dE {
|
|
22
22
|
getEngineType() {
|
|
23
23
|
return "postgres";
|
|
24
24
|
}
|
|
@@ -267,7 +267,7 @@ class cT extends dE {
|
|
|
267
267
|
return E;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
class
|
|
270
|
+
class vT extends dE {
|
|
271
271
|
getEngineType() {
|
|
272
272
|
return "sqlite";
|
|
273
273
|
}
|
|
@@ -403,7 +403,7 @@ class xT extends dE {
|
|
|
403
403
|
return E;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
class
|
|
406
|
+
class QT extends cT {
|
|
407
407
|
getEngineType() {
|
|
408
408
|
return "singlestore";
|
|
409
409
|
}
|
|
@@ -416,29 +416,29 @@ class vT extends cT {
|
|
|
416
416
|
// These limitations are typically handled at the query building level
|
|
417
417
|
// rather than in the adapter, but can be addressed here if needed
|
|
418
418
|
}
|
|
419
|
-
function
|
|
419
|
+
function ZT(T) {
|
|
420
420
|
switch (T) {
|
|
421
421
|
case "postgres":
|
|
422
|
-
return new
|
|
422
|
+
return new xT();
|
|
423
423
|
case "mysql":
|
|
424
424
|
return new cT();
|
|
425
425
|
case "sqlite":
|
|
426
|
-
return new xT();
|
|
427
|
-
case "singlestore":
|
|
428
426
|
return new vT();
|
|
427
|
+
case "singlestore":
|
|
428
|
+
return new QT();
|
|
429
429
|
default:
|
|
430
430
|
throw new Error(`Unsupported database engine: ${T}`);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
class
|
|
433
|
+
class hE {
|
|
434
434
|
constructor(E, R, A) {
|
|
435
435
|
this.db = E, this.schema = R;
|
|
436
436
|
const S = A || this.getEngineType();
|
|
437
|
-
this.databaseAdapter =
|
|
437
|
+
this.databaseAdapter = ZT(S);
|
|
438
438
|
}
|
|
439
439
|
databaseAdapter;
|
|
440
440
|
}
|
|
441
|
-
class
|
|
441
|
+
class qT extends hE {
|
|
442
442
|
async execute(E, R) {
|
|
443
443
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
444
444
|
const S = await E.execute();
|
|
@@ -490,9 +490,9 @@ class ZT extends VE {
|
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
function $E(T, E) {
|
|
493
|
-
return new
|
|
493
|
+
return new qT(T, E, "postgres");
|
|
494
494
|
}
|
|
495
|
-
class lT extends
|
|
495
|
+
class lT extends hE {
|
|
496
496
|
async execute(E, R) {
|
|
497
497
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
498
498
|
const S = await E.execute();
|
|
@@ -530,10 +530,10 @@ class lT extends VE {
|
|
|
530
530
|
return "mysql";
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function jT(T, E) {
|
|
534
534
|
return new lT(T, E, "mysql");
|
|
535
535
|
}
|
|
536
|
-
class kT extends
|
|
536
|
+
class kT extends hE {
|
|
537
537
|
async execute(E, R) {
|
|
538
538
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
539
539
|
const A = await E.execute();
|
|
@@ -582,7 +582,7 @@ class kT extends VE {
|
|
|
582
582
|
function gE(T, E) {
|
|
583
583
|
return new kT(T, E, "sqlite");
|
|
584
584
|
}
|
|
585
|
-
class
|
|
585
|
+
class zT extends lT {
|
|
586
586
|
getEngineType() {
|
|
587
587
|
return "singlestore";
|
|
588
588
|
}
|
|
@@ -590,8 +590,8 @@ class jT extends lT {
|
|
|
590
590
|
// For now, we inherit all behavior from MySQLExecutor since
|
|
591
591
|
// SingleStore is largely MySQL-compatible
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
return new
|
|
593
|
+
function ER(T, E) {
|
|
594
|
+
return new zT(T, E);
|
|
595
595
|
}
|
|
596
596
|
function JE(T, E, R) {
|
|
597
597
|
if (R)
|
|
@@ -599,11 +599,11 @@ function JE(T, E, R) {
|
|
|
599
599
|
case "postgres":
|
|
600
600
|
return $E(T, E);
|
|
601
601
|
case "mysql":
|
|
602
|
-
return
|
|
602
|
+
return jT(T, E);
|
|
603
603
|
case "sqlite":
|
|
604
604
|
return gE(T, E);
|
|
605
605
|
case "singlestore":
|
|
606
|
-
return
|
|
606
|
+
return ER(T, E);
|
|
607
607
|
}
|
|
608
608
|
if (T.all && T.run)
|
|
609
609
|
return gE(T, E);
|
|
@@ -614,7 +614,7 @@ function JE(T, E, R) {
|
|
|
614
614
|
function wE(T) {
|
|
615
615
|
return typeof T == "function" ? T() : T;
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function HT(T, E) {
|
|
618
618
|
if (E) return E;
|
|
619
619
|
switch (T) {
|
|
620
620
|
case "belongsTo":
|
|
@@ -636,20 +636,56 @@ function ER(T, E) {
|
|
|
636
636
|
function f(T, E) {
|
|
637
637
|
return typeof T == "function" ? T(E) : T;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function xI(T, E, R) {
|
|
640
640
|
return {
|
|
641
641
|
...T,
|
|
642
642
|
cubes: E,
|
|
643
643
|
currentCube: R
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function vI(T, E) {
|
|
647
647
|
return {
|
|
648
648
|
name: T,
|
|
649
649
|
...E
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
|
-
|
|
652
|
+
function TR(T, E) {
|
|
653
|
+
if (T.relationship !== "belongsToMany" || !T.through)
|
|
654
|
+
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
655
|
+
const { table: R, sourceKey: A, targetKey: S, securitySql: e } = T.through, O = [];
|
|
656
|
+
for (const N of A) {
|
|
657
|
+
const s = N.as || w;
|
|
658
|
+
O.push(s(N.source, N.target));
|
|
659
|
+
}
|
|
660
|
+
const t = [];
|
|
661
|
+
for (const N of S) {
|
|
662
|
+
const s = N.as || w;
|
|
663
|
+
t.push(s(N.source, N.target));
|
|
664
|
+
}
|
|
665
|
+
let D;
|
|
666
|
+
if (e) {
|
|
667
|
+
const N = e(E);
|
|
668
|
+
D = Array.isArray(N) ? N : [N];
|
|
669
|
+
}
|
|
670
|
+
const I = HT("belongsToMany", T.sqlJoinType);
|
|
671
|
+
return {
|
|
672
|
+
junctionJoins: [
|
|
673
|
+
{
|
|
674
|
+
joinType: I,
|
|
675
|
+
table: R,
|
|
676
|
+
condition: m(...O)
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
joinType: I,
|
|
680
|
+
table: R,
|
|
681
|
+
// This will be replaced with target cube table in query planner
|
|
682
|
+
condition: m(...t)
|
|
683
|
+
}
|
|
684
|
+
],
|
|
685
|
+
junctionSecurityConditions: D
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
class RR {
|
|
653
689
|
constructor(E) {
|
|
654
690
|
this.databaseAdapter = E;
|
|
655
691
|
}
|
|
@@ -661,30 +697,30 @@ class TR {
|
|
|
661
697
|
const S = {}, e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
662
698
|
if (R.dimensions)
|
|
663
699
|
for (const O of R.dimensions) {
|
|
664
|
-
const [
|
|
700
|
+
const [t, D] = O.split("."), I = e.get(t);
|
|
665
701
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
666
|
-
const N = I.dimensions[D],
|
|
667
|
-
S[O] = _`${
|
|
702
|
+
const N = I.dimensions[D], s = f(N.sql, A);
|
|
703
|
+
S[O] = _`${s}`.as(O);
|
|
668
704
|
}
|
|
669
705
|
}
|
|
670
706
|
if (R.measures)
|
|
671
707
|
for (const O of R.measures) {
|
|
672
|
-
const [
|
|
708
|
+
const [t, D] = O.split("."), I = e.get(t);
|
|
673
709
|
if (I && I.measures && I.measures[D]) {
|
|
674
|
-
const N = I.measures[D],
|
|
675
|
-
S[O] = _`${
|
|
710
|
+
const N = I.measures[D], s = this.buildMeasureExpression(N, A);
|
|
711
|
+
S[O] = _`${s}`.as(O);
|
|
676
712
|
}
|
|
677
713
|
}
|
|
678
714
|
if (R.timeDimensions)
|
|
679
715
|
for (const O of R.timeDimensions) {
|
|
680
|
-
const [
|
|
716
|
+
const [t, D] = O.dimension.split("."), I = e.get(t);
|
|
681
717
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
682
|
-
const N = I.dimensions[D],
|
|
718
|
+
const N = I.dimensions[D], s = this.buildTimeDimensionExpression(
|
|
683
719
|
N.sql,
|
|
684
720
|
O.granularity,
|
|
685
721
|
A
|
|
686
722
|
);
|
|
687
|
-
S[O.dimension] = _`${
|
|
723
|
+
S[O.dimension] = _`${s}`.as(O.dimension);
|
|
688
724
|
}
|
|
689
725
|
}
|
|
690
726
|
return Object.keys(S).length === 0 && (S.count = RE()), S;
|
|
@@ -694,24 +730,24 @@ class TR {
|
|
|
694
730
|
*/
|
|
695
731
|
buildHavingMeasureExpression(E, R, A, S, e) {
|
|
696
732
|
if (e && e.preAggregationCTEs) {
|
|
697
|
-
const O = e.preAggregationCTEs.find((
|
|
733
|
+
const O = e.preAggregationCTEs.find((t) => t.cube.name === E);
|
|
698
734
|
if (O && O.measures.includes(`${E}.${R}`)) {
|
|
699
|
-
const
|
|
735
|
+
const t = _`${_.identifier(O.cteAlias)}.${_.identifier(R)}`;
|
|
700
736
|
switch (A.type) {
|
|
701
737
|
case "count":
|
|
702
738
|
case "countDistinct":
|
|
703
739
|
case "sum":
|
|
704
|
-
return W(
|
|
740
|
+
return W(t);
|
|
705
741
|
case "avg":
|
|
706
|
-
return this.databaseAdapter.buildAvg(
|
|
742
|
+
return this.databaseAdapter.buildAvg(t);
|
|
707
743
|
case "min":
|
|
708
|
-
return mE(
|
|
744
|
+
return mE(t);
|
|
709
745
|
case "max":
|
|
710
|
-
return YE(
|
|
746
|
+
return YE(t);
|
|
711
747
|
case "number":
|
|
712
|
-
return W(
|
|
748
|
+
return W(t);
|
|
713
749
|
default:
|
|
714
|
-
return W(
|
|
750
|
+
return W(t);
|
|
715
751
|
}
|
|
716
752
|
}
|
|
717
753
|
}
|
|
@@ -735,7 +771,7 @@ class TR {
|
|
|
735
771
|
case "count":
|
|
736
772
|
return RE(A);
|
|
737
773
|
case "countDistinct":
|
|
738
|
-
return
|
|
774
|
+
return gT(A);
|
|
739
775
|
case "sum":
|
|
740
776
|
return W(A);
|
|
741
777
|
case "avg":
|
|
@@ -755,7 +791,7 @@ class TR {
|
|
|
755
791
|
*/
|
|
756
792
|
buildTimeDimensionExpression(E, R, A) {
|
|
757
793
|
const S = f(E, A);
|
|
758
|
-
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof
|
|
794
|
+
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof JT ? S : _`${S}`;
|
|
759
795
|
}
|
|
760
796
|
/**
|
|
761
797
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -764,17 +800,17 @@ class TR {
|
|
|
764
800
|
buildWhereConditions(E, R, A, S) {
|
|
765
801
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
766
802
|
if (R.filters && R.filters.length > 0)
|
|
767
|
-
for (const
|
|
768
|
-
const D = this.processFilter(
|
|
803
|
+
for (const t of R.filters) {
|
|
804
|
+
const D = this.processFilter(t, O, A, "where", S);
|
|
769
805
|
D && e.push(D);
|
|
770
806
|
}
|
|
771
807
|
if (R.timeDimensions)
|
|
772
|
-
for (const
|
|
773
|
-
const [D, I] =
|
|
774
|
-
if (N && N.dimensions[I] &&
|
|
808
|
+
for (const t of R.timeDimensions) {
|
|
809
|
+
const [D, I] = t.dimension.split("."), N = O.get(D);
|
|
810
|
+
if (N && N.dimensions[I] && t.dateRange) {
|
|
775
811
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((r) => r.cube.name === D))
|
|
776
812
|
continue;
|
|
777
|
-
const
|
|
813
|
+
const s = N.dimensions[I], L = f(s.sql, A), P = this.buildDateRangeCondition(L, t.dateRange);
|
|
778
814
|
P && e.push(P);
|
|
779
815
|
}
|
|
780
816
|
}
|
|
@@ -787,8 +823,8 @@ class TR {
|
|
|
787
823
|
buildHavingConditions(E, R, A, S) {
|
|
788
824
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
789
825
|
if (R.filters && R.filters.length > 0)
|
|
790
|
-
for (const
|
|
791
|
-
const D = this.processFilter(
|
|
826
|
+
for (const t of R.filters) {
|
|
827
|
+
const D = this.processFilter(t, O, A, "having", S);
|
|
792
828
|
D && e.push(D);
|
|
793
829
|
}
|
|
794
830
|
return e;
|
|
@@ -801,28 +837,28 @@ class TR {
|
|
|
801
837
|
if ("and" in E || "or" in E) {
|
|
802
838
|
const P = E;
|
|
803
839
|
if (P.and) {
|
|
804
|
-
const
|
|
805
|
-
return
|
|
840
|
+
const o = P.and.map((r) => this.processFilter(r, R, A, S, e)).filter((r) => r !== null);
|
|
841
|
+
return o.length > 0 ? m(...o) : null;
|
|
806
842
|
}
|
|
807
843
|
if (P.or) {
|
|
808
|
-
const
|
|
809
|
-
return
|
|
844
|
+
const o = P.or.map((r) => this.processFilter(r, R, A, S, e)).filter((r) => r !== null);
|
|
845
|
+
return o.length > 0 ? AE(...o) : null;
|
|
810
846
|
}
|
|
811
847
|
}
|
|
812
|
-
const O = E, [
|
|
848
|
+
const O = E, [t, D] = O.member.split("."), I = R.get(t);
|
|
813
849
|
if (!I) return null;
|
|
814
|
-
const N = I.dimensions[D],
|
|
850
|
+
const N = I.dimensions[D], s = I.measures[D], L = N || s;
|
|
815
851
|
if (!L) return null;
|
|
816
852
|
if (S === "where" && N) {
|
|
817
|
-
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name ===
|
|
853
|
+
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name === t))
|
|
818
854
|
return null;
|
|
819
855
|
const P = f(N.sql, A);
|
|
820
856
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
821
857
|
} else {
|
|
822
|
-
if (S === "where" &&
|
|
858
|
+
if (S === "where" && s)
|
|
823
859
|
return null;
|
|
824
|
-
if (S === "having" &&
|
|
825
|
-
const P = this.buildHavingMeasureExpression(
|
|
860
|
+
if (S === "having" && s) {
|
|
861
|
+
const P = this.buildHavingMeasureExpression(t, D, s, A, e);
|
|
826
862
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
827
863
|
}
|
|
828
864
|
}
|
|
@@ -834,7 +870,7 @@ class TR {
|
|
|
834
870
|
buildFilterCondition(E, R, A, S) {
|
|
835
871
|
if (!A || A.length === 0)
|
|
836
872
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
837
|
-
const e = A.filter((
|
|
873
|
+
const e = A.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
|
|
838
874
|
if (e.length === 0 && !["set", "notSet"].includes(R))
|
|
839
875
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
840
876
|
const O = e[0];
|
|
@@ -842,17 +878,17 @@ class TR {
|
|
|
842
878
|
case "equals":
|
|
843
879
|
if (e.length > 1) {
|
|
844
880
|
if (S?.type === "time") {
|
|
845
|
-
const
|
|
846
|
-
return SE(E,
|
|
881
|
+
const t = e.map((D) => this.normalizeDate(D) || D);
|
|
882
|
+
return SE(E, t);
|
|
847
883
|
}
|
|
848
884
|
return SE(E, e);
|
|
849
885
|
} else if (e.length === 1) {
|
|
850
|
-
const
|
|
851
|
-
return
|
|
886
|
+
const t = S?.type === "time" && this.normalizeDate(O) || O;
|
|
887
|
+
return w(E, t);
|
|
852
888
|
}
|
|
853
889
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
854
890
|
case "notEquals":
|
|
855
|
-
return e.length > 1 ?
|
|
891
|
+
return e.length > 1 ? yE(E, e) : e.length === 1 ? XE(E, O) : null;
|
|
856
892
|
case "contains":
|
|
857
893
|
return this.databaseAdapter.buildStringCondition(E, "contains", O);
|
|
858
894
|
case "notContains":
|
|
@@ -864,7 +900,7 @@ class TR {
|
|
|
864
900
|
case "gt":
|
|
865
901
|
return IE(E, O);
|
|
866
902
|
case "gte":
|
|
867
|
-
return
|
|
903
|
+
return K(E, O);
|
|
868
904
|
case "lt":
|
|
869
905
|
return eE(E, O);
|
|
870
906
|
case "lte":
|
|
@@ -875,25 +911,25 @@ class TR {
|
|
|
875
911
|
return bE(E);
|
|
876
912
|
case "inDateRange":
|
|
877
913
|
if (e.length >= 2) {
|
|
878
|
-
const
|
|
879
|
-
if (
|
|
914
|
+
const t = this.normalizeDate(e[0]), D = this.normalizeDate(e[1]);
|
|
915
|
+
if (t && D)
|
|
880
916
|
return m(
|
|
881
|
-
|
|
917
|
+
K(E, t),
|
|
882
918
|
$(E, D)
|
|
883
919
|
);
|
|
884
920
|
}
|
|
885
921
|
return null;
|
|
886
922
|
case "beforeDate": {
|
|
887
|
-
const
|
|
888
|
-
return
|
|
923
|
+
const t = this.normalizeDate(O);
|
|
924
|
+
return t ? eE(E, t) : null;
|
|
889
925
|
}
|
|
890
926
|
case "afterDate": {
|
|
891
|
-
const
|
|
892
|
-
return
|
|
927
|
+
const t = this.normalizeDate(O);
|
|
928
|
+
return t ? IE(E, t) : null;
|
|
893
929
|
}
|
|
894
930
|
case "between":
|
|
895
931
|
return e.length >= 2 ? m(
|
|
896
|
-
|
|
932
|
+
K(E, e[0]),
|
|
897
933
|
$(E, e[1])
|
|
898
934
|
) : null;
|
|
899
935
|
case "notBetween":
|
|
@@ -904,7 +940,7 @@ class TR {
|
|
|
904
940
|
case "in":
|
|
905
941
|
return e.length > 0 ? SE(E, e) : null;
|
|
906
942
|
case "notIn":
|
|
907
|
-
return e.length > 0 ?
|
|
943
|
+
return e.length > 0 ? yE(E, e) : null;
|
|
908
944
|
case "like":
|
|
909
945
|
return this.databaseAdapter.buildStringCondition(E, "like", O);
|
|
910
946
|
case "notLike":
|
|
@@ -918,7 +954,7 @@ class TR {
|
|
|
918
954
|
case "isEmpty":
|
|
919
955
|
return AE(
|
|
920
956
|
bE(E),
|
|
921
|
-
|
|
957
|
+
w(E, "")
|
|
922
958
|
);
|
|
923
959
|
case "isNotEmpty":
|
|
924
960
|
return m(
|
|
@@ -937,7 +973,7 @@ class TR {
|
|
|
937
973
|
if (Array.isArray(R) && R.length >= 2) {
|
|
938
974
|
const A = this.normalizeDate(R[0]), S = this.normalizeDate(R[1]);
|
|
939
975
|
return !A || !S ? null : m(
|
|
940
|
-
|
|
976
|
+
K(E, A),
|
|
941
977
|
$(E, S)
|
|
942
978
|
);
|
|
943
979
|
}
|
|
@@ -945,7 +981,7 @@ class TR {
|
|
|
945
981
|
const A = this.parseRelativeDateRange(R);
|
|
946
982
|
if (A)
|
|
947
983
|
return m(
|
|
948
|
-
|
|
984
|
+
K(E, A.start),
|
|
949
985
|
$(E, A.end)
|
|
950
986
|
);
|
|
951
987
|
const S = this.normalizeDate(R);
|
|
@@ -954,7 +990,7 @@ class TR {
|
|
|
954
990
|
e.setUTCHours(0, 0, 0, 0);
|
|
955
991
|
const O = new Date(S);
|
|
956
992
|
return O.setUTCHours(23, 59, 59, 999), m(
|
|
957
|
-
|
|
993
|
+
K(E, e),
|
|
958
994
|
$(E, O)
|
|
959
995
|
);
|
|
960
996
|
}
|
|
@@ -965,74 +1001,74 @@ class TR {
|
|
|
965
1001
|
* Handles all 14 DATE_RANGE_OPTIONS from the client
|
|
966
1002
|
*/
|
|
967
1003
|
parseRelativeDateRange(E) {
|
|
968
|
-
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), O = R.getUTCDate(),
|
|
1004
|
+
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), e = R.getUTCMonth(), O = R.getUTCDate(), t = R.getUTCDay();
|
|
969
1005
|
if (A === "today") {
|
|
970
|
-
const
|
|
971
|
-
|
|
1006
|
+
const s = new Date(R);
|
|
1007
|
+
s.setUTCHours(0, 0, 0, 0);
|
|
972
1008
|
const L = new Date(R);
|
|
973
|
-
return L.setUTCHours(23, 59, 59, 999), { start:
|
|
1009
|
+
return L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
|
|
974
1010
|
}
|
|
975
1011
|
if (A === "yesterday") {
|
|
976
|
-
const
|
|
977
|
-
|
|
1012
|
+
const s = new Date(R);
|
|
1013
|
+
s.setUTCDate(O - 1), s.setUTCHours(0, 0, 0, 0);
|
|
978
1014
|
const L = new Date(R);
|
|
979
|
-
return L.setUTCDate(O - 1), L.setUTCHours(23, 59, 59, 999), { start:
|
|
1015
|
+
return L.setUTCDate(O - 1), L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
|
|
980
1016
|
}
|
|
981
1017
|
if (A === "this week") {
|
|
982
|
-
const
|
|
983
|
-
L.setUTCDate(O +
|
|
1018
|
+
const s = t === 0 ? -6 : 1 - t, L = new Date(R);
|
|
1019
|
+
L.setUTCDate(O + s), L.setUTCHours(0, 0, 0, 0);
|
|
984
1020
|
const P = new Date(L);
|
|
985
1021
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
986
1022
|
}
|
|
987
1023
|
if (A === "this month") {
|
|
988
|
-
const
|
|
989
|
-
return { start:
|
|
1024
|
+
const s = new Date(Date.UTC(S, e, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, e + 1, 0, 23, 59, 59, 999));
|
|
1025
|
+
return { start: s, end: L };
|
|
990
1026
|
}
|
|
991
1027
|
if (A === "this quarter") {
|
|
992
|
-
const
|
|
1028
|
+
const s = Math.floor(e / 3), L = new Date(Date.UTC(S, s * 3, 1, 0, 0, 0, 0)), P = new Date(Date.UTC(S, s * 3 + 3, 0, 23, 59, 59, 999));
|
|
993
1029
|
return { start: L, end: P };
|
|
994
1030
|
}
|
|
995
1031
|
if (A === "this year") {
|
|
996
|
-
const
|
|
997
|
-
return { start:
|
|
1032
|
+
const s = new Date(Date.UTC(S, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, 11, 31, 23, 59, 59, 999));
|
|
1033
|
+
return { start: s, end: L };
|
|
998
1034
|
}
|
|
999
1035
|
const D = A.match(/^last\s+(\d+)\s+days?$/);
|
|
1000
1036
|
if (D) {
|
|
1001
|
-
const
|
|
1002
|
-
L.setUTCDate(O -
|
|
1037
|
+
const s = parseInt(D[1], 10), L = new Date(R);
|
|
1038
|
+
L.setUTCDate(O - s + 1), L.setUTCHours(0, 0, 0, 0);
|
|
1003
1039
|
const P = new Date(R);
|
|
1004
1040
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1005
1041
|
}
|
|
1006
1042
|
if (A === "last week") {
|
|
1007
|
-
const
|
|
1008
|
-
L.setUTCDate(O +
|
|
1043
|
+
const s = t === 0 ? -13 : -6 - t, L = new Date(R);
|
|
1044
|
+
L.setUTCDate(O + s), L.setUTCHours(0, 0, 0, 0);
|
|
1009
1045
|
const P = new Date(L);
|
|
1010
1046
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1011
1047
|
}
|
|
1012
1048
|
if (A === "last month") {
|
|
1013
|
-
const
|
|
1014
|
-
return { start:
|
|
1049
|
+
const s = new Date(Date.UTC(S, e - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(S, e, 0, 23, 59, 59, 999));
|
|
1050
|
+
return { start: s, end: L };
|
|
1015
1051
|
}
|
|
1016
1052
|
if (A === "last quarter") {
|
|
1017
|
-
const
|
|
1018
|
-
return { start:
|
|
1053
|
+
const s = Math.floor(e / 3), L = s === 0 ? 3 : s - 1, P = s === 0 ? S - 1 : S, o = 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));
|
|
1054
|
+
return { start: o, end: r };
|
|
1019
1055
|
}
|
|
1020
1056
|
if (A === "last year") {
|
|
1021
|
-
const
|
|
1022
|
-
return { start:
|
|
1057
|
+
const s = 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));
|
|
1058
|
+
return { start: s, end: L };
|
|
1023
1059
|
}
|
|
1024
1060
|
if (A === "last 12 months") {
|
|
1025
|
-
const
|
|
1026
|
-
return L.setUTCHours(23, 59, 59, 999), { start:
|
|
1061
|
+
const s = new Date(Date.UTC(S, e - 11, 1, 0, 0, 0, 0)), L = new Date(R);
|
|
1062
|
+
return L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
|
|
1027
1063
|
}
|
|
1028
1064
|
const I = A.match(/^last\s+(\d+)\s+months?$/);
|
|
1029
1065
|
if (I) {
|
|
1030
|
-
const
|
|
1066
|
+
const s = parseInt(I[1], 10), L = new Date(Date.UTC(S, e - s + 1, 1, 0, 0, 0, 0)), P = new Date(R);
|
|
1031
1067
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1032
1068
|
}
|
|
1033
1069
|
const N = A.match(/^last\s+(\d+)\s+years?$/);
|
|
1034
1070
|
if (N) {
|
|
1035
|
-
const
|
|
1071
|
+
const s = parseInt(N[1], 10), L = new Date(Date.UTC(S - s, 0, 1, 0, 0, 0, 0)), P = new Date(R);
|
|
1036
1072
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1037
1073
|
}
|
|
1038
1074
|
return null;
|
|
@@ -1065,33 +1101,33 @@ class TR {
|
|
|
1065
1101
|
const e = [];
|
|
1066
1102
|
if (!(R.measures && R.measures.length > 0))
|
|
1067
1103
|
return [];
|
|
1068
|
-
const
|
|
1104
|
+
const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1069
1105
|
if (R.dimensions)
|
|
1070
1106
|
for (const D of R.dimensions) {
|
|
1071
|
-
const [I, N] = D.split("."),
|
|
1072
|
-
if (
|
|
1107
|
+
const [I, N] = D.split("."), s = t.get(I);
|
|
1108
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1073
1109
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1074
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I),
|
|
1075
|
-
if (
|
|
1076
|
-
e.push(
|
|
1110
|
+
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), o = P.joinKeys.find((r) => r.targetColumn === N);
|
|
1111
|
+
if (o && o.sourceColumnObj)
|
|
1112
|
+
e.push(o.sourceColumnObj);
|
|
1077
1113
|
else {
|
|
1078
1114
|
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(N)}`;
|
|
1079
1115
|
e.push(r);
|
|
1080
1116
|
}
|
|
1081
1117
|
} else {
|
|
1082
|
-
const P =
|
|
1083
|
-
e.push(
|
|
1118
|
+
const P = s.dimensions[N], o = f(P.sql, A);
|
|
1119
|
+
e.push(o);
|
|
1084
1120
|
}
|
|
1085
1121
|
}
|
|
1086
1122
|
if (R.timeDimensions)
|
|
1087
1123
|
for (const D of R.timeDimensions) {
|
|
1088
|
-
const [I, N] = D.dimension.split("."),
|
|
1089
|
-
if (
|
|
1124
|
+
const [I, N] = D.dimension.split("."), s = t.get(I);
|
|
1125
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1090
1126
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1091
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I),
|
|
1092
|
-
if (
|
|
1127
|
+
const P = S.preAggregationCTEs.find((r) => r.cube.name === I), o = P.joinKeys.find((r) => r.targetColumn === N);
|
|
1128
|
+
if (o && o.sourceColumnObj) {
|
|
1093
1129
|
const r = this.buildTimeDimensionExpression(
|
|
1094
|
-
|
|
1130
|
+
o.sourceColumnObj,
|
|
1095
1131
|
D.granularity,
|
|
1096
1132
|
A
|
|
1097
1133
|
);
|
|
@@ -1101,12 +1137,12 @@ class TR {
|
|
|
1101
1137
|
e.push(r);
|
|
1102
1138
|
}
|
|
1103
1139
|
} else {
|
|
1104
|
-
const P =
|
|
1140
|
+
const P = s.dimensions[N], o = this.buildTimeDimensionExpression(
|
|
1105
1141
|
P.sql,
|
|
1106
1142
|
D.granularity,
|
|
1107
1143
|
A
|
|
1108
1144
|
);
|
|
1109
|
-
e.push(
|
|
1145
|
+
e.push(o);
|
|
1110
1146
|
}
|
|
1111
1147
|
}
|
|
1112
1148
|
return e;
|
|
@@ -1124,15 +1160,15 @@ class TR {
|
|
|
1124
1160
|
for (const [e, O] of Object.entries(E.order)) {
|
|
1125
1161
|
if (!S.includes(e))
|
|
1126
1162
|
throw new Error(`Cannot order by '${e}': field is not selected in the query`);
|
|
1127
|
-
const
|
|
1128
|
-
A.push(
|
|
1163
|
+
const t = O === "desc" ? wT(_.identifier(e)) : KE(_.identifier(e));
|
|
1164
|
+
A.push(t);
|
|
1129
1165
|
}
|
|
1130
1166
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
1131
1167
|
const e = new Set(Object.keys(E.order || {})), O = [...E.timeDimensions].sort(
|
|
1132
|
-
(
|
|
1168
|
+
(t, D) => t.dimension.localeCompare(D.dimension)
|
|
1133
1169
|
);
|
|
1134
|
-
for (const
|
|
1135
|
-
e.has(
|
|
1170
|
+
for (const t of O)
|
|
1171
|
+
e.has(t.dimension) || A.push(KE(_.identifier(t.dimension)));
|
|
1136
1172
|
}
|
|
1137
1173
|
return A;
|
|
1138
1174
|
}
|
|
@@ -1144,9 +1180,9 @@ class TR {
|
|
|
1144
1180
|
const A = [], S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1145
1181
|
if (R.measures && A.push(...R.measures), R.dimensions)
|
|
1146
1182
|
for (const e of R.dimensions) {
|
|
1147
|
-
const [O,
|
|
1183
|
+
const [O, t] = e.split("."), D = S.get(O);
|
|
1148
1184
|
if (D) {
|
|
1149
|
-
const I = D.dimensions[
|
|
1185
|
+
const I = D.dimensions[t];
|
|
1150
1186
|
I && I.type === "number" && A.push(e);
|
|
1151
1187
|
}
|
|
1152
1188
|
}
|
|
@@ -1173,7 +1209,7 @@ class TR {
|
|
|
1173
1209
|
return S;
|
|
1174
1210
|
}
|
|
1175
1211
|
}
|
|
1176
|
-
class
|
|
1212
|
+
class AR {
|
|
1177
1213
|
/**
|
|
1178
1214
|
* Analyze a semantic query to determine which cubes are involved
|
|
1179
1215
|
*/
|
|
@@ -1247,12 +1283,12 @@ class RR {
|
|
|
1247
1283
|
const S = this.analyzeCubeUsage(R), e = Array.from(S);
|
|
1248
1284
|
if (e.length === 0)
|
|
1249
1285
|
throw new Error("No cubes found in query");
|
|
1250
|
-
const O = this.choosePrimaryCube(e, R, E),
|
|
1251
|
-
if (!
|
|
1286
|
+
const O = this.choosePrimaryCube(e, R, E), t = E.get(O);
|
|
1287
|
+
if (!t)
|
|
1252
1288
|
throw new Error(`Primary cube '${O}' not found`);
|
|
1253
1289
|
if (e.length === 1)
|
|
1254
1290
|
return {
|
|
1255
|
-
primaryCube:
|
|
1291
|
+
primaryCube: t,
|
|
1256
1292
|
joinCubes: [],
|
|
1257
1293
|
// Empty for single cube
|
|
1258
1294
|
selections: {},
|
|
@@ -1262,9 +1298,9 @@ class RR {
|
|
|
1262
1298
|
groupByFields: []
|
|
1263
1299
|
// Will be built by QueryBuilder
|
|
1264
1300
|
};
|
|
1265
|
-
const D = this.buildJoinPlan(E,
|
|
1301
|
+
const D = this.buildJoinPlan(E, t, e, A), I = this.planPreAggregationCTEs(E, t, D, R);
|
|
1266
1302
|
return {
|
|
1267
|
-
primaryCube:
|
|
1303
|
+
primaryCube: t,
|
|
1268
1304
|
joinCubes: D,
|
|
1269
1305
|
selections: {},
|
|
1270
1306
|
// Will be built by QueryBuilder
|
|
@@ -1285,8 +1321,8 @@ class RR {
|
|
|
1285
1321
|
for (const O of S)
|
|
1286
1322
|
e.set(O, (e.get(O) || 0) + 1);
|
|
1287
1323
|
if (e.size > 0) {
|
|
1288
|
-
const O = Math.max(...e.values()),
|
|
1289
|
-
for (const D of
|
|
1324
|
+
const O = Math.max(...e.values()), t = [...e.entries()].filter(([, D]) => D === O).map(([D]) => D).sort();
|
|
1325
|
+
for (const D of t)
|
|
1290
1326
|
if (this.canReachAllCubes(D, E, A))
|
|
1291
1327
|
return D;
|
|
1292
1328
|
}
|
|
@@ -1295,12 +1331,12 @@ class RR {
|
|
|
1295
1331
|
const S = /* @__PURE__ */ new Map();
|
|
1296
1332
|
for (const e of E)
|
|
1297
1333
|
if (this.canReachAllCubes(e, E, A)) {
|
|
1298
|
-
const O = A.get(e),
|
|
1299
|
-
S.set(e,
|
|
1334
|
+
const O = A.get(e), t = O?.joins ? Object.keys(O.joins).length : 0;
|
|
1335
|
+
S.set(e, t);
|
|
1300
1336
|
}
|
|
1301
1337
|
if (S.size > 0) {
|
|
1302
1338
|
const e = Math.max(...S.values());
|
|
1303
|
-
return [...S.entries()].filter(([,
|
|
1339
|
+
return [...S.entries()].filter(([, t]) => t === e).map(([t]) => t).sort()[0];
|
|
1304
1340
|
}
|
|
1305
1341
|
}
|
|
1306
1342
|
return [...E].sort()[0];
|
|
@@ -1321,36 +1357,56 @@ class RR {
|
|
|
1321
1357
|
* Build join plan for multi-cube query
|
|
1322
1358
|
* Supports both direct joins and transitive joins through intermediate cubes
|
|
1323
1359
|
*/
|
|
1324
|
-
buildJoinPlan(E, R, A) {
|
|
1325
|
-
const
|
|
1326
|
-
for (const
|
|
1327
|
-
if (
|
|
1360
|
+
buildJoinPlan(E, R, A, S) {
|
|
1361
|
+
const e = [], O = /* @__PURE__ */ new Set([R.name]), t = A.filter((D) => D !== R.name);
|
|
1362
|
+
for (const D of t) {
|
|
1363
|
+
if (O.has(D))
|
|
1328
1364
|
continue;
|
|
1329
|
-
const
|
|
1330
|
-
if (!
|
|
1331
|
-
throw new Error(`No join path found from '${R.name}' to '${
|
|
1332
|
-
for (const { toCube:
|
|
1333
|
-
if (
|
|
1365
|
+
const I = this.findJoinPath(E, R.name, D, O);
|
|
1366
|
+
if (!I || I.length === 0)
|
|
1367
|
+
throw new Error(`No join path found from '${R.name}' to '${D}'`);
|
|
1368
|
+
for (const { toCube: N, joinDef: s } of I) {
|
|
1369
|
+
if (O.has(N))
|
|
1334
1370
|
continue;
|
|
1335
|
-
const
|
|
1336
|
-
if (!
|
|
1337
|
-
throw new Error(`Cube '${
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1371
|
+
const L = E.get(N);
|
|
1372
|
+
if (!L)
|
|
1373
|
+
throw new Error(`Cube '${N}' not found`);
|
|
1374
|
+
if (s.relationship === "belongsToMany" && s.through) {
|
|
1375
|
+
const P = TR(s, S.securityContext);
|
|
1376
|
+
e.push({
|
|
1377
|
+
cube: L,
|
|
1378
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1379
|
+
joinType: P.junctionJoins[1].joinType,
|
|
1380
|
+
// Use the target join type
|
|
1381
|
+
joinCondition: P.junctionJoins[1].condition,
|
|
1382
|
+
// Target join condition
|
|
1383
|
+
junctionTable: {
|
|
1384
|
+
table: s.through.table,
|
|
1385
|
+
alias: `junction_${N.toLowerCase()}`,
|
|
1386
|
+
joinType: P.junctionJoins[0].joinType,
|
|
1387
|
+
joinCondition: P.junctionJoins[0].condition,
|
|
1388
|
+
securitySql: s.through.securitySql
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1391
|
+
} else {
|
|
1392
|
+
const P = this.buildJoinCondition(
|
|
1393
|
+
s,
|
|
1394
|
+
null,
|
|
1395
|
+
// No source alias needed - use the actual column
|
|
1396
|
+
null
|
|
1397
|
+
// No target alias needed - use the actual column
|
|
1398
|
+
), o = HT(s.relationship, s.sqlJoinType);
|
|
1399
|
+
e.push({
|
|
1400
|
+
cube: L,
|
|
1401
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1402
|
+
joinType: o,
|
|
1403
|
+
joinCondition: P
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
O.add(N);
|
|
1351
1407
|
}
|
|
1352
1408
|
}
|
|
1353
|
-
return
|
|
1409
|
+
return e;
|
|
1354
1410
|
}
|
|
1355
1411
|
/**
|
|
1356
1412
|
* Build join condition from new array-based join definition
|
|
@@ -1358,8 +1414,8 @@ class RR {
|
|
|
1358
1414
|
buildJoinCondition(E, R, A) {
|
|
1359
1415
|
const S = [];
|
|
1360
1416
|
for (const e of E.on) {
|
|
1361
|
-
const O = R ? _`${_.identifier(R)}.${_.identifier(e.source.name)}` : e.source,
|
|
1362
|
-
S.push(D(O,
|
|
1417
|
+
const O = R ? _`${_.identifier(R)}.${_.identifier(e.source.name)}` : e.source, t = A ? _`${_.identifier(A)}.${_.identifier(e.target.name)}` : e.target, D = e.as || w;
|
|
1418
|
+
S.push(D(O, t));
|
|
1363
1419
|
}
|
|
1364
1420
|
return m(...S);
|
|
1365
1421
|
}
|
|
@@ -1374,14 +1430,14 @@ class RR {
|
|
|
1374
1430
|
{ cube: R, path: [] }
|
|
1375
1431
|
], O = /* @__PURE__ */ new Set([R, ...S]);
|
|
1376
1432
|
for (; e.length > 0; ) {
|
|
1377
|
-
const { cube:
|
|
1433
|
+
const { cube: t, path: D } = e.shift(), I = E.get(t);
|
|
1378
1434
|
if (I?.joins)
|
|
1379
1435
|
for (const [, N] of Object.entries(I.joins)) {
|
|
1380
1436
|
const L = wE(N.targetCube).name;
|
|
1381
1437
|
if (O.has(L))
|
|
1382
1438
|
continue;
|
|
1383
1439
|
const P = [...D, {
|
|
1384
|
-
fromCube:
|
|
1440
|
+
fromCube: t,
|
|
1385
1441
|
toCube: L,
|
|
1386
1442
|
joinDef: N
|
|
1387
1443
|
}];
|
|
@@ -1394,21 +1450,23 @@ class RR {
|
|
|
1394
1450
|
}
|
|
1395
1451
|
/**
|
|
1396
1452
|
* Plan pre-aggregation CTEs for hasMany relationships to prevent fan-out
|
|
1453
|
+
* Note: belongsToMany relationships handle fan-out differently through their junction table structure
|
|
1454
|
+
* and don't require CTEs - the two-hop join with the junction table provides natural grouping
|
|
1397
1455
|
*/
|
|
1398
1456
|
planPreAggregationCTEs(E, R, A, S) {
|
|
1399
1457
|
const e = [];
|
|
1400
1458
|
if (!S.measures || S.measures.length === 0)
|
|
1401
1459
|
return e;
|
|
1402
1460
|
for (const O of A) {
|
|
1403
|
-
const
|
|
1404
|
-
if (!
|
|
1461
|
+
const t = this.findHasManyJoinDef(R, O.cube.name);
|
|
1462
|
+
if (!t)
|
|
1405
1463
|
continue;
|
|
1406
1464
|
const D = S.measures ? S.measures.filter(
|
|
1407
1465
|
(L) => L.startsWith(O.cube.name + ".")
|
|
1408
1466
|
) : [], I = this.extractMeasuresFromFilters(S, O.cube.name), N = [.../* @__PURE__ */ new Set([...D, ...I])];
|
|
1409
1467
|
if (N.length === 0)
|
|
1410
1468
|
continue;
|
|
1411
|
-
const
|
|
1469
|
+
const s = t.on.map((L) => ({
|
|
1412
1470
|
sourceColumn: L.source.name,
|
|
1413
1471
|
targetColumn: L.target.name,
|
|
1414
1472
|
sourceColumnObj: L.source,
|
|
@@ -1418,7 +1476,7 @@ class RR {
|
|
|
1418
1476
|
cube: O.cube,
|
|
1419
1477
|
alias: O.alias,
|
|
1420
1478
|
cteAlias: `${O.cube.name.toLowerCase()}_agg`,
|
|
1421
|
-
joinKeys:
|
|
1479
|
+
joinKeys: s,
|
|
1422
1480
|
measures: N
|
|
1423
1481
|
});
|
|
1424
1482
|
}
|
|
@@ -1440,7 +1498,7 @@ class OE {
|
|
|
1440
1498
|
constructor(E) {
|
|
1441
1499
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
1442
1500
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
1443
|
-
this.queryBuilder = new
|
|
1501
|
+
this.queryBuilder = new RR(this.databaseAdapter), this.queryPlanner = new AR();
|
|
1444
1502
|
}
|
|
1445
1503
|
queryBuilder;
|
|
1446
1504
|
queryPlanner;
|
|
@@ -1450,31 +1508,31 @@ class OE {
|
|
|
1450
1508
|
*/
|
|
1451
1509
|
async execute(E, R, A) {
|
|
1452
1510
|
try {
|
|
1453
|
-
const S =
|
|
1511
|
+
const S = yT(E, R);
|
|
1454
1512
|
if (!S.isValid)
|
|
1455
1513
|
throw new Error(`Query validation failed: ${S.errors.join(", ")}`);
|
|
1456
1514
|
const e = {
|
|
1457
1515
|
db: this.dbExecutor.db,
|
|
1458
1516
|
schema: this.dbExecutor.schema,
|
|
1459
1517
|
securityContext: A
|
|
1460
|
-
}, O = this.queryPlanner.createQueryPlan(E, R, e),
|
|
1518
|
+
}, O = this.queryPlanner.createQueryPlan(E, R, e), t = this.buildUnifiedQuery(O, R, e), D = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(t, D), N = Array.isArray(I) ? I.map((L) => {
|
|
1461
1519
|
const P = { ...L };
|
|
1462
1520
|
if (R.timeDimensions) {
|
|
1463
|
-
for (const
|
|
1464
|
-
if (
|
|
1465
|
-
let r = P[
|
|
1521
|
+
for (const o of R.timeDimensions)
|
|
1522
|
+
if (o.dimension in P) {
|
|
1523
|
+
let r = P[o.dimension];
|
|
1466
1524
|
if (typeof r == "string" && r.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
1467
|
-
const U = r.replace(" ", "T"),
|
|
1468
|
-
r = new Date(
|
|
1525
|
+
const U = r.replace(" ", "T"), a = !U.endsWith("Z") && !U.includes("+") ? U + "Z" : U;
|
|
1526
|
+
r = new Date(a);
|
|
1469
1527
|
}
|
|
1470
|
-
r = this.databaseAdapter.convertTimeDimensionResult(r), P[
|
|
1528
|
+
r = this.databaseAdapter.convertTimeDimensionResult(r), P[o.dimension] = r;
|
|
1471
1529
|
}
|
|
1472
1530
|
}
|
|
1473
1531
|
return P;
|
|
1474
|
-
}) : [I],
|
|
1532
|
+
}) : [I], s = this.generateAnnotations(O, R);
|
|
1475
1533
|
return {
|
|
1476
1534
|
data: N,
|
|
1477
|
-
annotation:
|
|
1535
|
+
annotation: s
|
|
1478
1536
|
};
|
|
1479
1537
|
} catch (S) {
|
|
1480
1538
|
throw new Error(`Query execution failed: ${S instanceof Error ? S.message : "Unknown error"}`);
|
|
@@ -1491,57 +1549,57 @@ class OE {
|
|
|
1491
1549
|
* Build pre-aggregation CTE for hasMany relationships
|
|
1492
1550
|
*/
|
|
1493
1551
|
buildPreAggregationCTE(E, R, A, S) {
|
|
1494
|
-
const e = E.cube, O = e.sql(A),
|
|
1552
|
+
const e = E.cube, O = e.sql(A), t = {};
|
|
1495
1553
|
for (const r of E.joinKeys)
|
|
1496
1554
|
if (r.targetColumnObj) {
|
|
1497
|
-
|
|
1498
|
-
for (const [U,
|
|
1499
|
-
|
|
1555
|
+
t[r.targetColumn] = r.targetColumnObj;
|
|
1556
|
+
for (const [U, a] of Object.entries(e.dimensions || {}))
|
|
1557
|
+
a.sql === r.targetColumnObj && U !== r.targetColumn && (t[U] = _`${r.targetColumnObj}`.as(U));
|
|
1500
1558
|
}
|
|
1501
1559
|
for (const r of E.measures) {
|
|
1502
1560
|
const [, U] = r.split(".");
|
|
1503
1561
|
if (e.measures && e.measures[U]) {
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1562
|
+
const a = e.measures[U], l = this.queryBuilder.buildMeasureExpression(a, A);
|
|
1563
|
+
t[U] = _`${l}`.as(U);
|
|
1506
1564
|
}
|
|
1507
1565
|
}
|
|
1508
1566
|
const D = e.name;
|
|
1509
1567
|
if (R.dimensions)
|
|
1510
1568
|
for (const r of R.dimensions) {
|
|
1511
|
-
const [U,
|
|
1512
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1513
|
-
const l = e.dimensions[
|
|
1514
|
-
|
|
1569
|
+
const [U, a] = r.split(".");
|
|
1570
|
+
if (U === D && e.dimensions && e.dimensions[a]) {
|
|
1571
|
+
const l = e.dimensions[a], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A);
|
|
1572
|
+
t[a] = _`${c}`.as(a);
|
|
1515
1573
|
}
|
|
1516
1574
|
}
|
|
1517
1575
|
if (R.timeDimensions)
|
|
1518
1576
|
for (const r of R.timeDimensions) {
|
|
1519
|
-
const [U,
|
|
1520
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1521
|
-
const l = e.dimensions[
|
|
1522
|
-
|
|
1577
|
+
const [U, a] = r.dimension.split(".");
|
|
1578
|
+
if (U === D && e.dimensions && e.dimensions[a]) {
|
|
1579
|
+
const l = e.dimensions[a], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, r.granularity, A);
|
|
1580
|
+
t[a] = _`${c}`.as(a);
|
|
1523
1581
|
}
|
|
1524
1582
|
}
|
|
1525
|
-
if (Object.keys(
|
|
1583
|
+
if (Object.keys(t).length === 0)
|
|
1526
1584
|
return null;
|
|
1527
|
-
let I = A.db.select(
|
|
1585
|
+
let I = A.db.select(t).from(O.from);
|
|
1528
1586
|
const N = S ? {
|
|
1529
1587
|
...S,
|
|
1530
1588
|
preAggregationCTEs: S.preAggregationCTEs?.filter((r) => r.cube.name !== e.name)
|
|
1531
|
-
} : void 0,
|
|
1589
|
+
} : void 0, s = this.queryBuilder.buildWhereConditions(e, R, A, N), L = [];
|
|
1532
1590
|
if (R.timeDimensions)
|
|
1533
1591
|
for (const r of R.timeDimensions) {
|
|
1534
|
-
const [U,
|
|
1535
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1536
|
-
const l = e.dimensions[
|
|
1592
|
+
const [U, a] = r.dimension.split(".");
|
|
1593
|
+
if (U === D && e.dimensions && e.dimensions[a] && r.dateRange) {
|
|
1594
|
+
const l = e.dimensions[a], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), H = this.queryBuilder.buildDateRangeCondition(c, r.dateRange);
|
|
1537
1595
|
H && L.push(H);
|
|
1538
1596
|
}
|
|
1539
1597
|
}
|
|
1540
1598
|
if (R.filters) {
|
|
1541
1599
|
for (const r of R.filters)
|
|
1542
1600
|
if (!("and" in r) && !("or" in r) && "member" in r && "operator" in r) {
|
|
1543
|
-
const U = r, [
|
|
1544
|
-
if (
|
|
1601
|
+
const U = r, [a, l] = U.member.split(".");
|
|
1602
|
+
if (a === D && e.dimensions && e.dimensions[l]) {
|
|
1545
1603
|
const c = e.dimensions[l];
|
|
1546
1604
|
if (U.operator === "inDateRange") {
|
|
1547
1605
|
const H = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), u = this.queryBuilder.buildDateRangeCondition(H, U.values);
|
|
@@ -1551,30 +1609,30 @@ class OE {
|
|
|
1551
1609
|
}
|
|
1552
1610
|
}
|
|
1553
1611
|
const P = [];
|
|
1554
|
-
if (O.where && P.push(O.where), P.push(...
|
|
1612
|
+
if (O.where && P.push(O.where), P.push(...s, ...L), P.length > 0) {
|
|
1555
1613
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1556
1614
|
I = I.where(r);
|
|
1557
1615
|
}
|
|
1558
|
-
const
|
|
1616
|
+
const o = [];
|
|
1559
1617
|
for (const r of E.joinKeys)
|
|
1560
|
-
r.targetColumnObj &&
|
|
1618
|
+
r.targetColumnObj && o.push(r.targetColumnObj);
|
|
1561
1619
|
if (R.dimensions)
|
|
1562
1620
|
for (const r of R.dimensions) {
|
|
1563
|
-
const [U,
|
|
1564
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1565
|
-
const l = e.dimensions[
|
|
1566
|
-
|
|
1621
|
+
const [U, a] = r.split(".");
|
|
1622
|
+
if (U === D && e.dimensions && e.dimensions[a]) {
|
|
1623
|
+
const l = e.dimensions[a], c = f(l.sql, A);
|
|
1624
|
+
o.push(c);
|
|
1567
1625
|
}
|
|
1568
1626
|
}
|
|
1569
1627
|
if (R.timeDimensions)
|
|
1570
1628
|
for (const r of R.timeDimensions) {
|
|
1571
|
-
const [U,
|
|
1572
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1573
|
-
const l = e.dimensions[
|
|
1574
|
-
|
|
1629
|
+
const [U, a] = r.dimension.split(".");
|
|
1630
|
+
if (U === D && e.dimensions && e.dimensions[a]) {
|
|
1631
|
+
const l = e.dimensions[a], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, r.granularity, A);
|
|
1632
|
+
o.push(c);
|
|
1575
1633
|
}
|
|
1576
1634
|
}
|
|
1577
|
-
return
|
|
1635
|
+
return o.length > 0 && (I = I.groupBy(...o)), A.db.$with(E.cteAlias).as(I);
|
|
1578
1636
|
}
|
|
1579
1637
|
// Removed unused getActualJoinTargetColumn method
|
|
1580
1638
|
/**
|
|
@@ -1586,8 +1644,8 @@ class OE {
|
|
|
1586
1644
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
1587
1645
|
const e = [];
|
|
1588
1646
|
for (const O of S.joinKeys) {
|
|
1589
|
-
const
|
|
1590
|
-
e.push(
|
|
1647
|
+
const t = O.sourceColumnObj || _.identifier(O.sourceColumn), D = _`${_.identifier(R)}.${_.identifier(O.targetColumn)}`;
|
|
1648
|
+
e.push(w(t, D));
|
|
1591
1649
|
}
|
|
1592
1650
|
return e.length === 1 ? e[0] : m(...e);
|
|
1593
1651
|
}
|
|
@@ -1610,9 +1668,9 @@ class OE {
|
|
|
1610
1668
|
if (E.preAggregationCTEs)
|
|
1611
1669
|
for (const r of E.preAggregationCTEs) {
|
|
1612
1670
|
const U = r.cube.name;
|
|
1613
|
-
for (const
|
|
1614
|
-
if (D[
|
|
1615
|
-
const [, l] =
|
|
1671
|
+
for (const a of r.measures)
|
|
1672
|
+
if (D[a]) {
|
|
1673
|
+
const [, l] = a.split("."), c = this.getCubesFromPlan(E).get(U);
|
|
1616
1674
|
if (c && c.measures && c.measures[l]) {
|
|
1617
1675
|
const H = c.measures[l], u = _`${_.identifier(r.cteAlias)}.${_.identifier(l)}`;
|
|
1618
1676
|
let p;
|
|
@@ -1637,20 +1695,20 @@ class OE {
|
|
|
1637
1695
|
default:
|
|
1638
1696
|
p = W(u);
|
|
1639
1697
|
}
|
|
1640
|
-
D[
|
|
1698
|
+
D[a] = _`${p}`.as(a);
|
|
1641
1699
|
}
|
|
1642
1700
|
}
|
|
1643
|
-
for (const
|
|
1644
|
-
const [l, c] =
|
|
1701
|
+
for (const a in D) {
|
|
1702
|
+
const [l, c] = a.split(".");
|
|
1645
1703
|
if (l === U) {
|
|
1646
|
-
const H = this.getCubesFromPlan(E).get(U), u = H && H.dimensions?.[c], p =
|
|
1704
|
+
const H = this.getCubesFromPlan(E).get(U), u = H && H.dimensions?.[c], p = a.startsWith(U + ".");
|
|
1647
1705
|
if (u || p) {
|
|
1648
|
-
let
|
|
1649
|
-
if (!
|
|
1706
|
+
let y = r.joinKeys.find((TE) => TE.targetColumn === c);
|
|
1707
|
+
if (!y && H?.dimensions?.[c]) {
|
|
1650
1708
|
const TE = H.dimensions[c].sql;
|
|
1651
|
-
|
|
1709
|
+
y = r.joinKeys.find(($T) => $T.targetColumnObj === TE);
|
|
1652
1710
|
}
|
|
1653
|
-
|
|
1711
|
+
y ? D[a] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(a) : p && H?.dimensions?.[c] && (D[a] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(a));
|
|
1654
1712
|
}
|
|
1655
1713
|
}
|
|
1656
1714
|
}
|
|
@@ -1701,21 +1759,21 @@ class OE {
|
|
|
1701
1759
|
} catch {
|
|
1702
1760
|
}
|
|
1703
1761
|
}
|
|
1704
|
-
let
|
|
1705
|
-
U ? (
|
|
1762
|
+
let a, l;
|
|
1763
|
+
U ? (a = _`${_.identifier(U)}`, l = this.buildCTEJoinCondition(r, U, E)) : (a = r.cube.sql(A).from, l = r.joinCondition);
|
|
1706
1764
|
try {
|
|
1707
1765
|
switch (r.joinType || "left") {
|
|
1708
1766
|
case "left":
|
|
1709
|
-
N = N.leftJoin(
|
|
1767
|
+
N = N.leftJoin(a, l);
|
|
1710
1768
|
break;
|
|
1711
1769
|
case "inner":
|
|
1712
|
-
N = N.innerJoin(
|
|
1770
|
+
N = N.innerJoin(a, l);
|
|
1713
1771
|
break;
|
|
1714
1772
|
case "right":
|
|
1715
|
-
N = N.rightJoin(
|
|
1773
|
+
N = N.rightJoin(a, l);
|
|
1716
1774
|
break;
|
|
1717
1775
|
case "full":
|
|
1718
|
-
N = N.fullJoin(
|
|
1776
|
+
N = N.fullJoin(a, l);
|
|
1719
1777
|
break;
|
|
1720
1778
|
}
|
|
1721
1779
|
} catch {
|
|
@@ -1725,10 +1783,10 @@ class OE {
|
|
|
1725
1783
|
for (const r of E.joinCubes) {
|
|
1726
1784
|
if (e.get(r.cube.name))
|
|
1727
1785
|
continue;
|
|
1728
|
-
const
|
|
1729
|
-
|
|
1786
|
+
const a = r.cube.sql(A);
|
|
1787
|
+
a.where && I.push(a.where);
|
|
1730
1788
|
}
|
|
1731
|
-
const
|
|
1789
|
+
const s = this.queryBuilder.buildWhereConditions(
|
|
1732
1790
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1733
1791
|
// Single cube
|
|
1734
1792
|
R,
|
|
@@ -1736,7 +1794,7 @@ class OE {
|
|
|
1736
1794
|
E
|
|
1737
1795
|
// Pass the queryPlan to handle CTE scenarios
|
|
1738
1796
|
);
|
|
1739
|
-
if (
|
|
1797
|
+
if (s.length > 0 && I.push(...s), I.length > 0) {
|
|
1740
1798
|
const r = I.length === 1 ? I[0] : m(...I);
|
|
1741
1799
|
N = N.where(r);
|
|
1742
1800
|
}
|
|
@@ -1761,8 +1819,8 @@ class OE {
|
|
|
1761
1819
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1762
1820
|
N = N.having(r);
|
|
1763
1821
|
}
|
|
1764
|
-
const
|
|
1765
|
-
return
|
|
1822
|
+
const o = this.queryBuilder.buildOrderBy(R);
|
|
1823
|
+
return o.length > 0 && (N = N.orderBy(...o)), N = this.queryBuilder.applyLimitAndOffset(N, R), N;
|
|
1766
1824
|
}
|
|
1767
1825
|
/**
|
|
1768
1826
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -1795,10 +1853,10 @@ class OE {
|
|
|
1795
1853
|
db: this.dbExecutor.db,
|
|
1796
1854
|
schema: this.dbExecutor.schema,
|
|
1797
1855
|
securityContext: A
|
|
1798
|
-
}, e = this.queryPlanner.createQueryPlan(E, R, S),
|
|
1856
|
+
}, e = this.queryPlanner.createQueryPlan(E, R, S), t = this.buildUnifiedQuery(e, R, S).toSQL();
|
|
1799
1857
|
return {
|
|
1800
|
-
sql:
|
|
1801
|
-
params:
|
|
1858
|
+
sql: t.sql,
|
|
1859
|
+
params: t.params
|
|
1802
1860
|
};
|
|
1803
1861
|
}
|
|
1804
1862
|
/**
|
|
@@ -1806,40 +1864,40 @@ class OE {
|
|
|
1806
1864
|
*/
|
|
1807
1865
|
generateAnnotations(E, R) {
|
|
1808
1866
|
const A = {}, S = {}, e = {}, O = [E.primaryCube];
|
|
1809
|
-
if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((
|
|
1810
|
-
for (const
|
|
1811
|
-
const [D, I] =
|
|
1867
|
+
if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((t) => t.cube)), R.measures)
|
|
1868
|
+
for (const t of R.measures) {
|
|
1869
|
+
const [D, I] = t.split("."), N = O.find((s) => s.name === D);
|
|
1812
1870
|
if (N && N.measures[I]) {
|
|
1813
|
-
const
|
|
1814
|
-
A[
|
|
1815
|
-
title:
|
|
1816
|
-
shortTitle:
|
|
1817
|
-
type:
|
|
1871
|
+
const s = N.measures[I];
|
|
1872
|
+
A[t] = {
|
|
1873
|
+
title: s.title || I,
|
|
1874
|
+
shortTitle: s.title || I,
|
|
1875
|
+
type: s.type
|
|
1818
1876
|
};
|
|
1819
1877
|
}
|
|
1820
1878
|
}
|
|
1821
1879
|
if (R.dimensions)
|
|
1822
|
-
for (const
|
|
1823
|
-
const [D, I] =
|
|
1880
|
+
for (const t of R.dimensions) {
|
|
1881
|
+
const [D, I] = t.split("."), N = O.find((s) => s.name === D);
|
|
1824
1882
|
if (N && N.dimensions[I]) {
|
|
1825
|
-
const
|
|
1826
|
-
S[
|
|
1827
|
-
title:
|
|
1828
|
-
shortTitle:
|
|
1829
|
-
type:
|
|
1883
|
+
const s = N.dimensions[I];
|
|
1884
|
+
S[t] = {
|
|
1885
|
+
title: s.title || I,
|
|
1886
|
+
shortTitle: s.title || I,
|
|
1887
|
+
type: s.type
|
|
1830
1888
|
};
|
|
1831
1889
|
}
|
|
1832
1890
|
}
|
|
1833
1891
|
if (R.timeDimensions)
|
|
1834
|
-
for (const
|
|
1835
|
-
const [D, I] =
|
|
1892
|
+
for (const t of R.timeDimensions) {
|
|
1893
|
+
const [D, I] = t.dimension.split("."), N = O.find((s) => s.name === D);
|
|
1836
1894
|
if (N && N.dimensions && N.dimensions[I]) {
|
|
1837
|
-
const
|
|
1838
|
-
e[
|
|
1839
|
-
title:
|
|
1840
|
-
shortTitle:
|
|
1841
|
-
type:
|
|
1842
|
-
granularity:
|
|
1895
|
+
const s = N.dimensions[I];
|
|
1896
|
+
e[t.dimension] = {
|
|
1897
|
+
title: s.title || I,
|
|
1898
|
+
shortTitle: s.title || I,
|
|
1899
|
+
type: s.type,
|
|
1900
|
+
granularity: t.granularity
|
|
1843
1901
|
};
|
|
1844
1902
|
}
|
|
1845
1903
|
}
|
|
@@ -1851,13 +1909,13 @@ class OE {
|
|
|
1851
1909
|
};
|
|
1852
1910
|
}
|
|
1853
1911
|
}
|
|
1854
|
-
const C = (T) => T.flatMap(
|
|
1912
|
+
const C = (T) => T.flatMap(SR), SR = (T) => Z(IR(T)).map(eR), eR = (T) => T.replace(/ +/g, " ").trim(), IR = (T) => ({
|
|
1855
1913
|
type: "mandatory_block",
|
|
1856
|
-
items:
|
|
1857
|
-
}),
|
|
1914
|
+
items: VE(T, 0)[0]
|
|
1915
|
+
}), VE = (T, E, R) => {
|
|
1858
1916
|
const A = [];
|
|
1859
1917
|
for (; T[E]; ) {
|
|
1860
|
-
const [S, e] =
|
|
1918
|
+
const [S, e] = NR(T, E);
|
|
1861
1919
|
if (A.push(S), E = e, T[E] === "|")
|
|
1862
1920
|
E++;
|
|
1863
1921
|
else if (T[E] === "}" || T[E] === "]") {
|
|
@@ -1872,44 +1930,44 @@ const C = (T) => T.flatMap(AR), AR = (T) => Q(eR(T)).map(SR), SR = (T) => T.repl
|
|
|
1872
1930
|
throw new Error(`Unexpected "${T[E]}"`);
|
|
1873
1931
|
}
|
|
1874
1932
|
return [A, E];
|
|
1875
|
-
},
|
|
1933
|
+
}, NR = (T, E) => {
|
|
1876
1934
|
const R = [];
|
|
1877
1935
|
for (; ; ) {
|
|
1878
|
-
const [A, S] =
|
|
1936
|
+
const [A, S] = sR(T, E);
|
|
1879
1937
|
if (A)
|
|
1880
1938
|
R.push(A), E = S;
|
|
1881
1939
|
else
|
|
1882
1940
|
break;
|
|
1883
1941
|
}
|
|
1884
1942
|
return R.length === 1 ? [R[0], E] : [{ type: "concatenation", items: R }, E];
|
|
1885
|
-
},
|
|
1943
|
+
}, sR = (T, E) => {
|
|
1886
1944
|
if (T[E] === "{")
|
|
1887
|
-
return sR(T, E + 1);
|
|
1888
|
-
if (T[E] === "[")
|
|
1889
1945
|
return tR(T, E + 1);
|
|
1946
|
+
if (T[E] === "[")
|
|
1947
|
+
return CR(T, E + 1);
|
|
1890
1948
|
{
|
|
1891
1949
|
let R = "";
|
|
1892
1950
|
for (; T[E] && /[A-Za-z0-9_ ]/.test(T[E]); )
|
|
1893
1951
|
R += T[E], E++;
|
|
1894
1952
|
return [R, E];
|
|
1895
1953
|
}
|
|
1896
|
-
}, sR = (T, E) => {
|
|
1897
|
-
const [R, A] = hE(T, E, "}");
|
|
1898
|
-
return [{ type: "mandatory_block", items: R }, A];
|
|
1899
1954
|
}, tR = (T, E) => {
|
|
1900
|
-
const [R, A] =
|
|
1955
|
+
const [R, A] = VE(T, E, "}");
|
|
1956
|
+
return [{ type: "mandatory_block", items: R }, A];
|
|
1957
|
+
}, CR = (T, E) => {
|
|
1958
|
+
const [R, A] = VE(T, E, "]");
|
|
1901
1959
|
return [{ type: "optional_block", items: R }, A];
|
|
1902
|
-
},
|
|
1960
|
+
}, Z = (T) => {
|
|
1903
1961
|
if (typeof T == "string")
|
|
1904
1962
|
return [T];
|
|
1905
1963
|
if (T.type === "concatenation")
|
|
1906
|
-
return T.items.map(
|
|
1964
|
+
return T.items.map(Z).reduce(LR, [""]);
|
|
1907
1965
|
if (T.type === "mandatory_block")
|
|
1908
|
-
return T.items.flatMap(
|
|
1966
|
+
return T.items.flatMap(Z);
|
|
1909
1967
|
if (T.type === "optional_block")
|
|
1910
|
-
return ["", ...T.items.flatMap(
|
|
1968
|
+
return ["", ...T.items.flatMap(Z)];
|
|
1911
1969
|
throw new Error(`Unknown node type: ${T}`);
|
|
1912
|
-
},
|
|
1970
|
+
}, LR = (T, E) => {
|
|
1913
1971
|
const R = [];
|
|
1914
1972
|
for (const A of T)
|
|
1915
1973
|
for (const S of E)
|
|
@@ -1920,19 +1978,19 @@ var i;
|
|
|
1920
1978
|
(function(T) {
|
|
1921
1979
|
T.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", T.IDENTIFIER = "IDENTIFIER", T.STRING = "STRING", T.VARIABLE = "VARIABLE", T.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", T.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", T.RESERVED_KEYWORD = "RESERVED_KEYWORD", T.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", T.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", T.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", T.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", T.RESERVED_CLAUSE = "RESERVED_CLAUSE", T.RESERVED_SELECT = "RESERVED_SELECT", T.RESERVED_JOIN = "RESERVED_JOIN", T.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", T.ARRAY_KEYWORD = "ARRAY_KEYWORD", T.CASE = "CASE", T.END = "END", T.WHEN = "WHEN", T.ELSE = "ELSE", T.THEN = "THEN", T.LIMIT = "LIMIT", T.BETWEEN = "BETWEEN", T.AND = "AND", T.OR = "OR", T.XOR = "XOR", T.OPERATOR = "OPERATOR", T.COMMA = "COMMA", T.ASTERISK = "ASTERISK", T.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", T.OPEN_PAREN = "OPEN_PAREN", T.CLOSE_PAREN = "CLOSE_PAREN", T.LINE_COMMENT = "LINE_COMMENT", T.BLOCK_COMMENT = "BLOCK_COMMENT", T.DISABLE_COMMENT = "DISABLE_COMMENT", T.NUMBER = "NUMBER", T.NAMED_PARAMETER = "NAMED_PARAMETER", T.QUOTED_PARAMETER = "QUOTED_PARAMETER", T.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", T.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", T.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", T.DELIMITER = "DELIMITER", T.EOF = "EOF";
|
|
1922
1980
|
})(i = i || (i = {}));
|
|
1923
|
-
const
|
|
1981
|
+
const uT = (T) => ({
|
|
1924
1982
|
type: i.EOF,
|
|
1925
1983
|
raw: "«EOF»",
|
|
1926
1984
|
text: "«EOF»",
|
|
1927
1985
|
start: T
|
|
1928
|
-
}),
|
|
1986
|
+
}), x = uT(1 / 0), g = (T) => (E) => E.type === T.type && E.text === T.text, X = {
|
|
1929
1987
|
ARRAY: g({ text: "ARRAY", type: i.RESERVED_DATA_TYPE }),
|
|
1930
1988
|
BY: g({ text: "BY", type: i.RESERVED_KEYWORD }),
|
|
1931
1989
|
SET: g({ text: "SET", type: i.RESERVED_CLAUSE }),
|
|
1932
1990
|
STRUCT: g({ text: "STRUCT", type: i.RESERVED_DATA_TYPE }),
|
|
1933
1991
|
WINDOW: g({ text: "WINDOW", type: i.RESERVED_CLAUSE }),
|
|
1934
1992
|
VALUES: g({ text: "VALUES", type: i.RESERVED_CLAUSE })
|
|
1935
|
-
},
|
|
1993
|
+
}, BT = (T) => T === i.RESERVED_DATA_TYPE || T === i.RESERVED_KEYWORD || T === i.RESERVED_FUNCTION_NAME || T === i.RESERVED_KEYWORD_PHRASE || T === i.RESERVED_DATA_TYPE_PHRASE || T === i.RESERVED_CLAUSE || T === i.RESERVED_SELECT || T === i.RESERVED_SET_OPERATION || T === i.RESERVED_JOIN || T === i.ARRAY_KEYWORD || T === i.CASE || T === i.END || T === i.WHEN || T === i.ELSE || T === i.THEN || T === i.LIMIT || T === i.BETWEEN || T === i.AND || T === i.OR || T === i.XOR, _R = (T) => T === i.AND || T === i.OR || T === i.XOR, rR = [
|
|
1936
1994
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
1937
1995
|
"KEYS.NEW_KEYSET",
|
|
1938
1996
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -2476,7 +2534,7 @@ const HT = (T) => ({
|
|
|
2476
2534
|
// pivot
|
|
2477
2535
|
"PIVOT",
|
|
2478
2536
|
"UNPIVOT"
|
|
2479
|
-
],
|
|
2537
|
+
], nR = [
|
|
2480
2538
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
|
|
2481
2539
|
"ALL",
|
|
2482
2540
|
"AND",
|
|
@@ -2584,7 +2642,7 @@ const HT = (T) => ({
|
|
|
2584
2642
|
"CASCADE",
|
|
2585
2643
|
"RESTRICT",
|
|
2586
2644
|
"DETERMINISTIC"
|
|
2587
|
-
],
|
|
2645
|
+
], DR = [
|
|
2588
2646
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
|
|
2589
2647
|
"ARRAY",
|
|
2590
2648
|
"BOOL",
|
|
@@ -2609,7 +2667,7 @@ const HT = (T) => ({
|
|
|
2609
2667
|
"STRUCT",
|
|
2610
2668
|
"TIME",
|
|
2611
2669
|
"TIMEZONE"
|
|
2612
|
-
],
|
|
2670
|
+
], iR = C(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), PR = C([
|
|
2613
2671
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
2614
2672
|
"WITH [RECURSIVE]",
|
|
2615
2673
|
"FROM",
|
|
@@ -2728,7 +2786,7 @@ const HT = (T) => ({
|
|
|
2728
2786
|
"ASSERT",
|
|
2729
2787
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
2730
2788
|
"EXPORT DATA"
|
|
2731
|
-
]),
|
|
2789
|
+
]), oR = C([
|
|
2732
2790
|
"UNION {ALL | DISTINCT}",
|
|
2733
2791
|
"EXCEPT DISTINCT",
|
|
2734
2792
|
"INTERSECT DISTINCT"
|
|
@@ -2736,7 +2794,7 @@ const HT = (T) => ({
|
|
|
2736
2794
|
"JOIN",
|
|
2737
2795
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
2738
2796
|
"{INNER | CROSS} JOIN"
|
|
2739
|
-
]),
|
|
2797
|
+
]), MR = C([
|
|
2740
2798
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
2741
2799
|
"TABLESAMPLE SYSTEM",
|
|
2742
2800
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -2747,18 +2805,18 @@ const HT = (T) => ({
|
|
|
2747
2805
|
"{ROWS | RANGE} BETWEEN",
|
|
2748
2806
|
// comparison operator
|
|
2749
2807
|
"IS [NOT] DISTINCT FROM"
|
|
2750
|
-
]),
|
|
2808
|
+
]), UR = C([]), GR = {
|
|
2751
2809
|
name: "bigquery",
|
|
2752
2810
|
tokenizerOptions: {
|
|
2753
|
-
reservedSelect:
|
|
2754
|
-
reservedClauses: [...
|
|
2755
|
-
reservedSetOperations:
|
|
2811
|
+
reservedSelect: iR,
|
|
2812
|
+
reservedClauses: [...PR, ...NE, ...xE],
|
|
2813
|
+
reservedSetOperations: oR,
|
|
2756
2814
|
reservedJoins: aR,
|
|
2757
|
-
reservedKeywordPhrases:
|
|
2758
|
-
reservedDataTypePhrases:
|
|
2759
|
-
reservedKeywords:
|
|
2760
|
-
reservedDataTypes:
|
|
2761
|
-
reservedFunctionNames:
|
|
2815
|
+
reservedKeywordPhrases: MR,
|
|
2816
|
+
reservedDataTypePhrases: UR,
|
|
2817
|
+
reservedKeywords: nR,
|
|
2818
|
+
reservedDataTypes: DR,
|
|
2819
|
+
reservedFunctionNames: rR,
|
|
2762
2820
|
extraParens: ["[]"],
|
|
2763
2821
|
stringTypes: [
|
|
2764
2822
|
// The triple-quoted strings are listed first, so they get matched first.
|
|
@@ -2776,27 +2834,27 @@ const HT = (T) => ({
|
|
|
2776
2834
|
variableTypes: [{ regex: String.raw`@@\w+` }],
|
|
2777
2835
|
lineCommentTypes: ["--", "#"],
|
|
2778
2836
|
operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
|
|
2779
|
-
postProcess:
|
|
2837
|
+
postProcess: cR
|
|
2780
2838
|
},
|
|
2781
2839
|
formatOptions: {
|
|
2782
2840
|
onelineClauses: [...xE, ...NE],
|
|
2783
2841
|
tabularOnelineClauses: NE
|
|
2784
2842
|
}
|
|
2785
2843
|
};
|
|
2786
|
-
function GR(T) {
|
|
2787
|
-
return cR(lR(T));
|
|
2788
|
-
}
|
|
2789
2844
|
function cR(T) {
|
|
2790
|
-
|
|
2791
|
-
return T.map((R) => R.text === "OFFSET" && E.text === "[" ? (E = R, Object.assign(Object.assign({}, R), { type: i.RESERVED_FUNCTION_NAME })) : (E = R, R));
|
|
2845
|
+
return lR(HR(T));
|
|
2792
2846
|
}
|
|
2793
2847
|
function lR(T) {
|
|
2848
|
+
let E = x;
|
|
2849
|
+
return T.map((R) => R.text === "OFFSET" && E.text === "[" ? (E = R, Object.assign(Object.assign({}, R), { type: i.RESERVED_FUNCTION_NAME })) : (E = R, R));
|
|
2850
|
+
}
|
|
2851
|
+
function HR(T) {
|
|
2794
2852
|
var E;
|
|
2795
2853
|
const R = [];
|
|
2796
2854
|
for (let A = 0; A < T.length; A++) {
|
|
2797
2855
|
const S = T[A];
|
|
2798
2856
|
if ((X.ARRAY(S) || X.STRUCT(S)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
2799
|
-
const e =
|
|
2857
|
+
const e = uR(T, A + 1), O = T.slice(A, e + 1);
|
|
2800
2858
|
R.push({
|
|
2801
2859
|
type: i.IDENTIFIER,
|
|
2802
2860
|
raw: O.map(vE("raw")).join(""),
|
|
@@ -2809,7 +2867,7 @@ function lR(T) {
|
|
|
2809
2867
|
return R;
|
|
2810
2868
|
}
|
|
2811
2869
|
const vE = (T) => (E) => E.type === i.IDENTIFIER || E.type === i.COMMA ? E[T] + " " : E[T];
|
|
2812
|
-
function
|
|
2870
|
+
function uR(T, E) {
|
|
2813
2871
|
let R = 0;
|
|
2814
2872
|
for (let A = E; A < T.length; A++) {
|
|
2815
2873
|
const S = T[A];
|
|
@@ -2818,7 +2876,7 @@ function HR(T, E) {
|
|
|
2818
2876
|
}
|
|
2819
2877
|
return T.length - 1;
|
|
2820
2878
|
}
|
|
2821
|
-
const
|
|
2879
|
+
const BR = [
|
|
2822
2880
|
// https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
|
|
2823
2881
|
"ARRAY_AGG",
|
|
2824
2882
|
"AVG",
|
|
@@ -3138,7 +3196,7 @@ const uR = [
|
|
|
3138
3196
|
"RATIO_TO_REPORT",
|
|
3139
3197
|
// Type casting
|
|
3140
3198
|
"CAST"
|
|
3141
|
-
],
|
|
3199
|
+
], FR = [
|
|
3142
3200
|
// https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
|
|
3143
3201
|
"ACTIVATE",
|
|
3144
3202
|
"ADD",
|
|
@@ -3539,7 +3597,7 @@ const uR = [
|
|
|
3539
3597
|
"XMLNAMESPACES",
|
|
3540
3598
|
"YEAR",
|
|
3541
3599
|
"YEARS"
|
|
3542
|
-
],
|
|
3600
|
+
], YR = [
|
|
3543
3601
|
// https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
|
|
3544
3602
|
"ARRAY",
|
|
3545
3603
|
"BIGINT",
|
|
@@ -3581,7 +3639,7 @@ const uR = [
|
|
|
3581
3639
|
"VARBINARY",
|
|
3582
3640
|
"VARCHAR",
|
|
3583
3641
|
"VARGRAPHIC"
|
|
3584
|
-
],
|
|
3642
|
+
], mR = C(["SELECT [ALL | DISTINCT]"]), pR = C([
|
|
3585
3643
|
// queries
|
|
3586
3644
|
"WITH",
|
|
3587
3645
|
"FROM",
|
|
@@ -3815,7 +3873,7 @@ const uR = [
|
|
|
3815
3873
|
"TRANSFER OWNERSHIP OF",
|
|
3816
3874
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
3817
3875
|
"WHILE"
|
|
3818
|
-
]),
|
|
3876
|
+
]), dR = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), hR = C([
|
|
3819
3877
|
"JOIN",
|
|
3820
3878
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3821
3879
|
"{INNER | CROSS} JOIN"
|
|
@@ -3824,18 +3882,18 @@ const uR = [
|
|
|
3824
3882
|
"ON UPDATE",
|
|
3825
3883
|
"SET NULL",
|
|
3826
3884
|
"{ROWS | RANGE} BETWEEN"
|
|
3827
|
-
]),
|
|
3885
|
+
]), fR = C([]), WR = {
|
|
3828
3886
|
name: "db2",
|
|
3829
3887
|
tokenizerOptions: {
|
|
3830
|
-
reservedSelect:
|
|
3831
|
-
reservedClauses: [...
|
|
3832
|
-
reservedSetOperations:
|
|
3833
|
-
reservedJoins:
|
|
3888
|
+
reservedSelect: mR,
|
|
3889
|
+
reservedClauses: [...pR, ...QE, ...sE],
|
|
3890
|
+
reservedSetOperations: dR,
|
|
3891
|
+
reservedJoins: hR,
|
|
3834
3892
|
reservedKeywordPhrases: VR,
|
|
3835
|
-
reservedDataTypePhrases:
|
|
3836
|
-
reservedKeywords:
|
|
3837
|
-
reservedDataTypes:
|
|
3838
|
-
reservedFunctionNames:
|
|
3893
|
+
reservedDataTypePhrases: fR,
|
|
3894
|
+
reservedKeywords: FR,
|
|
3895
|
+
reservedDataTypes: YR,
|
|
3896
|
+
reservedFunctionNames: BR,
|
|
3839
3897
|
extraParens: ["[]"],
|
|
3840
3898
|
stringTypes: [
|
|
3841
3899
|
{ quote: "''-qq", prefixes: ["G", "N", "U&"] },
|
|
@@ -3869,7 +3927,7 @@ const uR = [
|
|
|
3869
3927
|
onelineClauses: [...QE, ...sE],
|
|
3870
3928
|
tabularOnelineClauses: sE
|
|
3871
3929
|
}
|
|
3872
|
-
},
|
|
3930
|
+
}, XR = [
|
|
3873
3931
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
3874
3932
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
3875
3933
|
"ARRAY_AGG",
|
|
@@ -4203,7 +4261,7 @@ const uR = [
|
|
|
4203
4261
|
"ROW_NUMBER",
|
|
4204
4262
|
// Type casting
|
|
4205
4263
|
"CAST"
|
|
4206
|
-
],
|
|
4264
|
+
], bR = [
|
|
4207
4265
|
// https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
|
|
4208
4266
|
// TODO: This list likely contains all keywords, not only the reserved ones,
|
|
4209
4267
|
// try to filter it down to just the reserved keywords.
|
|
@@ -4699,7 +4757,7 @@ const uR = [
|
|
|
4699
4757
|
"YEARS",
|
|
4700
4758
|
"YES",
|
|
4701
4759
|
"ZONE"
|
|
4702
|
-
],
|
|
4760
|
+
], yR = [
|
|
4703
4761
|
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
|
|
4704
4762
|
"ARRAY",
|
|
4705
4763
|
"BIGINT",
|
|
@@ -4735,7 +4793,7 @@ const uR = [
|
|
|
4735
4793
|
"VARCHAR",
|
|
4736
4794
|
"VARGRAPHIC",
|
|
4737
4795
|
"XML"
|
|
4738
|
-
], KR = C(["SELECT [ALL | DISTINCT]"]),
|
|
4796
|
+
], KR = C(["SELECT [ALL | DISTINCT]"]), $R = C([
|
|
4739
4797
|
// queries
|
|
4740
4798
|
"WITH [RECURSIVE]",
|
|
4741
4799
|
"INTO",
|
|
@@ -4861,28 +4919,28 @@ const uR = [
|
|
|
4861
4919
|
"TAG",
|
|
4862
4920
|
"TRANSFER OWNERSHIP OF",
|
|
4863
4921
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
4864
|
-
]),
|
|
4922
|
+
]), gR = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), JR = C([
|
|
4865
4923
|
"JOIN",
|
|
4866
4924
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4867
4925
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
4868
4926
|
"{INNER | CROSS} JOIN"
|
|
4869
|
-
]),
|
|
4927
|
+
]), wR = C([
|
|
4870
4928
|
"ON DELETE",
|
|
4871
4929
|
"ON UPDATE",
|
|
4872
4930
|
"SET NULL",
|
|
4873
4931
|
"{ROWS | RANGE} BETWEEN"
|
|
4874
|
-
]),
|
|
4932
|
+
]), xR = C([]), vR = {
|
|
4875
4933
|
name: "db2i",
|
|
4876
4934
|
tokenizerOptions: {
|
|
4877
4935
|
reservedSelect: KR,
|
|
4878
|
-
reservedClauses: [
|
|
4879
|
-
reservedSetOperations:
|
|
4880
|
-
reservedJoins:
|
|
4881
|
-
reservedKeywordPhrases:
|
|
4882
|
-
reservedDataTypePhrases:
|
|
4883
|
-
reservedKeywords:
|
|
4884
|
-
reservedDataTypes:
|
|
4885
|
-
reservedFunctionNames:
|
|
4936
|
+
reservedClauses: [...$R, ...ZE, ...tE],
|
|
4937
|
+
reservedSetOperations: gR,
|
|
4938
|
+
reservedJoins: JR,
|
|
4939
|
+
reservedKeywordPhrases: wR,
|
|
4940
|
+
reservedDataTypePhrases: xR,
|
|
4941
|
+
reservedKeywords: bR,
|
|
4942
|
+
reservedDataTypes: yR,
|
|
4943
|
+
reservedFunctionNames: XR,
|
|
4886
4944
|
nestedBlockComments: !0,
|
|
4887
4945
|
extraParens: ["[]"],
|
|
4888
4946
|
stringTypes: [
|
|
@@ -4899,7 +4957,7 @@ const uR = [
|
|
|
4899
4957
|
onelineClauses: [...ZE, ...tE],
|
|
4900
4958
|
tabularOnelineClauses: tE
|
|
4901
4959
|
}
|
|
4902
|
-
},
|
|
4960
|
+
}, QR = [
|
|
4903
4961
|
// Functions from DuckDB (excluding those that start with an underscore):
|
|
4904
4962
|
// SELECT DISTINCT upper(function_name) AS function_name
|
|
4905
4963
|
// FROM duckdb_functions()
|
|
@@ -5562,7 +5620,7 @@ const uR = [
|
|
|
5562
5620
|
// 'NULL', we really prefer treating it as keyword
|
|
5563
5621
|
"RANK",
|
|
5564
5622
|
"ROW_NUMBER"
|
|
5565
|
-
],
|
|
5623
|
+
], ZR = [
|
|
5566
5624
|
// Keywords from DuckDB:
|
|
5567
5625
|
// SELECT upper(keyword_name)
|
|
5568
5626
|
// FROM duckdb_keywords()
|
|
@@ -5644,7 +5702,7 @@ const uR = [
|
|
|
5644
5702
|
"WHERE",
|
|
5645
5703
|
"WINDOW",
|
|
5646
5704
|
"WITH"
|
|
5647
|
-
],
|
|
5705
|
+
], qR = [
|
|
5648
5706
|
// Types from DuckDB:
|
|
5649
5707
|
// SELECT DISTINCT upper(type_name)
|
|
5650
5708
|
// FROM duckdb_types()
|
|
@@ -5724,7 +5782,7 @@ const uR = [
|
|
|
5724
5782
|
"UUID",
|
|
5725
5783
|
"VARBINARY",
|
|
5726
5784
|
"VARCHAR"
|
|
5727
|
-
],
|
|
5785
|
+
], jR = C(["SELECT [ALL | DISTINCT]"]), kR = C([
|
|
5728
5786
|
// queries
|
|
5729
5787
|
"WITH [RECURSIVE]",
|
|
5730
5788
|
"FROM",
|
|
@@ -5828,11 +5886,11 @@ const uR = [
|
|
|
5828
5886
|
"PREPARE",
|
|
5829
5887
|
"EXECUTE",
|
|
5830
5888
|
"DEALLOCATE [PREPARE]"
|
|
5831
|
-
]),
|
|
5889
|
+
]), zR = C([
|
|
5832
5890
|
"UNION [ALL | BY NAME]",
|
|
5833
5891
|
"EXCEPT [ALL]",
|
|
5834
5892
|
"INTERSECT [ALL]"
|
|
5835
|
-
]),
|
|
5893
|
+
]), EA = C([
|
|
5836
5894
|
"JOIN",
|
|
5837
5895
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5838
5896
|
"{INNER | CROSS} JOIN",
|
|
@@ -5841,23 +5899,23 @@ const uR = [
|
|
|
5841
5899
|
"POSITIONAL JOIN",
|
|
5842
5900
|
"ANTI JOIN",
|
|
5843
5901
|
"SEMI JOIN"
|
|
5844
|
-
]),
|
|
5902
|
+
]), TA = C([
|
|
5845
5903
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
5846
5904
|
"SIMILAR TO",
|
|
5847
5905
|
"IS [NOT] DISTINCT FROM"
|
|
5848
|
-
]),
|
|
5906
|
+
]), RA = C(["TIMESTAMP WITH TIME ZONE"]), AA = {
|
|
5849
5907
|
name: "duckdb",
|
|
5850
5908
|
tokenizerOptions: {
|
|
5851
|
-
reservedSelect:
|
|
5909
|
+
reservedSelect: jR,
|
|
5852
5910
|
reservedClauses: [...kR, ...qE, ...CE],
|
|
5853
|
-
reservedSetOperations:
|
|
5854
|
-
reservedJoins:
|
|
5855
|
-
reservedKeywordPhrases:
|
|
5856
|
-
reservedDataTypePhrases:
|
|
5911
|
+
reservedSetOperations: zR,
|
|
5912
|
+
reservedJoins: EA,
|
|
5913
|
+
reservedKeywordPhrases: TA,
|
|
5914
|
+
reservedDataTypePhrases: RA,
|
|
5857
5915
|
supportsXor: !0,
|
|
5858
|
-
reservedKeywords:
|
|
5859
|
-
reservedDataTypes:
|
|
5860
|
-
reservedFunctionNames:
|
|
5916
|
+
reservedKeywords: ZR,
|
|
5917
|
+
reservedDataTypes: qR,
|
|
5918
|
+
reservedFunctionNames: QR,
|
|
5861
5919
|
nestedBlockComments: !0,
|
|
5862
5920
|
extraParens: ["[]", "{}"],
|
|
5863
5921
|
underscoresInNumbers: !0,
|
|
@@ -5921,7 +5979,7 @@ const uR = [
|
|
|
5921
5979
|
onelineClauses: [...qE, ...CE],
|
|
5922
5980
|
tabularOnelineClauses: CE
|
|
5923
5981
|
}
|
|
5924
|
-
},
|
|
5982
|
+
}, SA = [
|
|
5925
5983
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
|
|
5926
5984
|
// math
|
|
5927
5985
|
"ABS",
|
|
@@ -6129,7 +6187,7 @@ const uR = [
|
|
|
6129
6187
|
"CUME_DIST",
|
|
6130
6188
|
"PERCENT_RANK",
|
|
6131
6189
|
"NTILE"
|
|
6132
|
-
],
|
|
6190
|
+
], eA = [
|
|
6133
6191
|
// https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
|
|
6134
6192
|
// Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
|
|
6135
6193
|
"ADD",
|
|
@@ -6444,7 +6502,7 @@ const uR = [
|
|
|
6444
6502
|
"JSONFILE",
|
|
6445
6503
|
"INPUTFORMAT",
|
|
6446
6504
|
"OUTPUTFORMAT"
|
|
6447
|
-
],
|
|
6505
|
+
], IA = [
|
|
6448
6506
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
|
|
6449
6507
|
"ARRAY",
|
|
6450
6508
|
"BIGINT",
|
|
@@ -6465,7 +6523,7 @@ const uR = [
|
|
|
6465
6523
|
"STRUCT",
|
|
6466
6524
|
"TIMESTAMP",
|
|
6467
6525
|
"VARCHAR"
|
|
6468
|
-
],
|
|
6526
|
+
], OA = C(["SELECT [ALL | DISTINCT]"]), NA = C([
|
|
6469
6527
|
// queries
|
|
6470
6528
|
"WITH",
|
|
6471
6529
|
"FROM",
|
|
@@ -6499,7 +6557,7 @@ const uR = [
|
|
|
6499
6557
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
6500
6558
|
"LOAD DATA [LOCAL] INPATH",
|
|
6501
6559
|
"[OVERWRITE] INTO TABLE"
|
|
6502
|
-
]),
|
|
6560
|
+
]), jE = C([
|
|
6503
6561
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
6504
6562
|
]), LE = C([
|
|
6505
6563
|
// - create:
|
|
@@ -6526,24 +6584,24 @@ const uR = [
|
|
|
6526
6584
|
"STORED AS",
|
|
6527
6585
|
"STORED BY",
|
|
6528
6586
|
"ROW FORMAT"
|
|
6529
|
-
]),
|
|
6587
|
+
]), sA = C(["UNION [ALL | DISTINCT]"]), tA = C([
|
|
6530
6588
|
"JOIN",
|
|
6531
6589
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6532
6590
|
"{INNER | CROSS} JOIN",
|
|
6533
6591
|
// non-standard joins
|
|
6534
6592
|
"LEFT SEMI JOIN"
|
|
6535
|
-
]),
|
|
6593
|
+
]), CA = C(["{ROWS | RANGE} BETWEEN"]), LA = C([]), _A = {
|
|
6536
6594
|
name: "hive",
|
|
6537
6595
|
tokenizerOptions: {
|
|
6538
|
-
reservedSelect:
|
|
6539
|
-
reservedClauses: [...
|
|
6540
|
-
reservedSetOperations:
|
|
6541
|
-
reservedJoins:
|
|
6542
|
-
reservedKeywordPhrases:
|
|
6543
|
-
reservedDataTypePhrases:
|
|
6544
|
-
reservedKeywords:
|
|
6545
|
-
reservedDataTypes:
|
|
6546
|
-
reservedFunctionNames:
|
|
6596
|
+
reservedSelect: OA,
|
|
6597
|
+
reservedClauses: [...NA, ...jE, ...LE],
|
|
6598
|
+
reservedSetOperations: sA,
|
|
6599
|
+
reservedJoins: tA,
|
|
6600
|
+
reservedKeywordPhrases: CA,
|
|
6601
|
+
reservedDataTypePhrases: LA,
|
|
6602
|
+
reservedKeywords: eA,
|
|
6603
|
+
reservedDataTypes: IA,
|
|
6604
|
+
reservedFunctionNames: SA,
|
|
6547
6605
|
extraParens: ["[]"],
|
|
6548
6606
|
stringTypes: ['""-bs', "''-bs"],
|
|
6549
6607
|
identTypes: ["``"],
|
|
@@ -6551,20 +6609,20 @@ const uR = [
|
|
|
6551
6609
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||"]
|
|
6552
6610
|
},
|
|
6553
6611
|
formatOptions: {
|
|
6554
|
-
onelineClauses: [...
|
|
6612
|
+
onelineClauses: [...jE, ...LE],
|
|
6555
6613
|
tabularOnelineClauses: LE
|
|
6556
6614
|
}
|
|
6557
6615
|
};
|
|
6558
6616
|
function EE(T) {
|
|
6559
6617
|
return T.map((E, R) => {
|
|
6560
|
-
const A = T[R + 1] ||
|
|
6618
|
+
const A = T[R + 1] || x;
|
|
6561
6619
|
if (X.SET(E) && A.text === "(")
|
|
6562
6620
|
return Object.assign(Object.assign({}, E), { type: i.RESERVED_FUNCTION_NAME });
|
|
6563
|
-
const S = T[R - 1] ||
|
|
6621
|
+
const S = T[R - 1] || x;
|
|
6564
6622
|
return X.VALUES(E) && S.text === "=" ? Object.assign(Object.assign({}, E), { type: i.RESERVED_FUNCTION_NAME }) : E;
|
|
6565
6623
|
});
|
|
6566
6624
|
}
|
|
6567
|
-
const
|
|
6625
|
+
const rA = [
|
|
6568
6626
|
// https://mariadb.com/kb/en/reserved-words/
|
|
6569
6627
|
"ACCESSIBLE",
|
|
6570
6628
|
"ADD",
|
|
@@ -6781,7 +6839,7 @@ const _A = [
|
|
|
6781
6839
|
"XOR",
|
|
6782
6840
|
"YEAR_MONTH",
|
|
6783
6841
|
"ZEROFILL"
|
|
6784
|
-
],
|
|
6842
|
+
], nA = [
|
|
6785
6843
|
// https://mariadb.com/kb/en/data-types/
|
|
6786
6844
|
"BIGINT",
|
|
6787
6845
|
"BINARY",
|
|
@@ -6832,7 +6890,7 @@ const _A = [
|
|
|
6832
6890
|
"YEAR"
|
|
6833
6891
|
// 'NUMBER', // ?? In oracle mode only
|
|
6834
6892
|
// 'SET' // handled as special-case in postProcess
|
|
6835
|
-
],
|
|
6893
|
+
], DA = [
|
|
6836
6894
|
// https://mariadb.com/kb/en/information-schema-sql_functions-table/
|
|
6837
6895
|
"ADDDATE",
|
|
6838
6896
|
"ADD_MONTHS",
|
|
@@ -7070,7 +7128,7 @@ const _A = [
|
|
|
7070
7128
|
// CASE expression shorthands
|
|
7071
7129
|
"COALESCE",
|
|
7072
7130
|
"NULLIF"
|
|
7073
|
-
],
|
|
7131
|
+
], iA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), PA = C([
|
|
7074
7132
|
// queries
|
|
7075
7133
|
"WITH [RECURSIVE]",
|
|
7076
7134
|
"FROM",
|
|
@@ -7092,7 +7150,7 @@ const _A = [
|
|
|
7092
7150
|
"SET",
|
|
7093
7151
|
// other
|
|
7094
7152
|
"RETURNING"
|
|
7095
|
-
]),
|
|
7153
|
+
]), kE = C([
|
|
7096
7154
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
7097
7155
|
]), _E = C([
|
|
7098
7156
|
// - create:
|
|
@@ -7301,7 +7359,7 @@ const _A = [
|
|
|
7301
7359
|
"XA RECOVER",
|
|
7302
7360
|
"XA ROLLBACK",
|
|
7303
7361
|
"XA START"
|
|
7304
|
-
]),
|
|
7362
|
+
]), oA = C([
|
|
7305
7363
|
"UNION [ALL | DISTINCT]",
|
|
7306
7364
|
"EXCEPT [ALL | DISTINCT]",
|
|
7307
7365
|
"INTERSECT [ALL | DISTINCT]",
|
|
@@ -7314,24 +7372,24 @@ const _A = [
|
|
|
7314
7372
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7315
7373
|
// non-standard joins
|
|
7316
7374
|
"STRAIGHT_JOIN"
|
|
7317
|
-
]),
|
|
7375
|
+
]), MA = C([
|
|
7318
7376
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7319
7377
|
"CHARACTER SET",
|
|
7320
7378
|
"{ROWS | RANGE} BETWEEN",
|
|
7321
7379
|
"IDENTIFIED BY"
|
|
7322
|
-
]),
|
|
7380
|
+
]), UA = C([]), GA = {
|
|
7323
7381
|
name: "mariadb",
|
|
7324
7382
|
tokenizerOptions: {
|
|
7325
|
-
reservedSelect:
|
|
7326
|
-
reservedClauses: [...
|
|
7327
|
-
reservedSetOperations:
|
|
7383
|
+
reservedSelect: iA,
|
|
7384
|
+
reservedClauses: [...PA, ...kE, ..._E],
|
|
7385
|
+
reservedSetOperations: oA,
|
|
7328
7386
|
reservedJoins: aA,
|
|
7329
|
-
reservedKeywordPhrases:
|
|
7330
|
-
reservedDataTypePhrases:
|
|
7387
|
+
reservedKeywordPhrases: MA,
|
|
7388
|
+
reservedDataTypePhrases: UA,
|
|
7331
7389
|
supportsXor: !0,
|
|
7332
|
-
reservedKeywords:
|
|
7333
|
-
reservedDataTypes:
|
|
7334
|
-
reservedFunctionNames:
|
|
7390
|
+
reservedKeywords: rA,
|
|
7391
|
+
reservedDataTypes: nA,
|
|
7392
|
+
reservedFunctionNames: DA,
|
|
7335
7393
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
7336
7394
|
stringTypes: [
|
|
7337
7395
|
'""-qq-bs',
|
|
@@ -7367,10 +7425,10 @@ const _A = [
|
|
|
7367
7425
|
postProcess: EE
|
|
7368
7426
|
},
|
|
7369
7427
|
formatOptions: {
|
|
7370
|
-
onelineClauses: [...
|
|
7428
|
+
onelineClauses: [...kE, ..._E],
|
|
7371
7429
|
tabularOnelineClauses: _E
|
|
7372
7430
|
}
|
|
7373
|
-
},
|
|
7431
|
+
}, cA = [
|
|
7374
7432
|
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
|
|
7375
7433
|
"ACCESSIBLE",
|
|
7376
7434
|
"ADD",
|
|
@@ -7601,7 +7659,7 @@ const _A = [
|
|
|
7601
7659
|
"YEAR_MONTH",
|
|
7602
7660
|
"ZEROFILL"
|
|
7603
7661
|
// (R)
|
|
7604
|
-
],
|
|
7662
|
+
], lA = [
|
|
7605
7663
|
// https://dev.mysql.com/doc/refman/8.0/en/data-types.html
|
|
7606
7664
|
"BIGINT",
|
|
7607
7665
|
"BINARY",
|
|
@@ -7653,7 +7711,7 @@ const _A = [
|
|
|
7653
7711
|
"VARYING",
|
|
7654
7712
|
"YEAR"
|
|
7655
7713
|
// 'SET' // handled as special-case in postProcess
|
|
7656
|
-
],
|
|
7714
|
+
], HA = [
|
|
7657
7715
|
// https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
|
|
7658
7716
|
"ABS",
|
|
7659
7717
|
"ACOS",
|
|
@@ -8076,7 +8134,7 @@ const _A = [
|
|
|
8076
8134
|
// 'XOR',
|
|
8077
8135
|
"YEAR",
|
|
8078
8136
|
"YEARWEEK"
|
|
8079
|
-
],
|
|
8137
|
+
], uA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), BA = C([
|
|
8080
8138
|
// queries
|
|
8081
8139
|
"WITH [RECURSIVE]",
|
|
8082
8140
|
"FROM",
|
|
@@ -8277,7 +8335,7 @@ const _A = [
|
|
|
8277
8335
|
"REPEAT",
|
|
8278
8336
|
"RETURN",
|
|
8279
8337
|
"WHILE"
|
|
8280
|
-
]),
|
|
8338
|
+
]), FA = C(["UNION [ALL | DISTINCT]"]), YA = C([
|
|
8281
8339
|
"JOIN",
|
|
8282
8340
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8283
8341
|
"{INNER | CROSS} JOIN",
|
|
@@ -8285,24 +8343,24 @@ const _A = [
|
|
|
8285
8343
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8286
8344
|
// non-standard joins
|
|
8287
8345
|
"STRAIGHT_JOIN"
|
|
8288
|
-
]),
|
|
8346
|
+
]), mA = C([
|
|
8289
8347
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8290
8348
|
"CHARACTER SET",
|
|
8291
8349
|
"{ROWS | RANGE} BETWEEN",
|
|
8292
8350
|
"IDENTIFIED BY"
|
|
8293
|
-
]),
|
|
8351
|
+
]), pA = C([]), dA = {
|
|
8294
8352
|
name: "mysql",
|
|
8295
8353
|
tokenizerOptions: {
|
|
8296
|
-
reservedSelect:
|
|
8297
|
-
reservedClauses: [...
|
|
8298
|
-
reservedSetOperations:
|
|
8299
|
-
reservedJoins:
|
|
8300
|
-
reservedKeywordPhrases:
|
|
8301
|
-
reservedDataTypePhrases:
|
|
8354
|
+
reservedSelect: uA,
|
|
8355
|
+
reservedClauses: [...BA, ...zE, ...rE],
|
|
8356
|
+
reservedSetOperations: FA,
|
|
8357
|
+
reservedJoins: YA,
|
|
8358
|
+
reservedKeywordPhrases: mA,
|
|
8359
|
+
reservedDataTypePhrases: pA,
|
|
8302
8360
|
supportsXor: !0,
|
|
8303
|
-
reservedKeywords:
|
|
8304
|
-
reservedDataTypes:
|
|
8305
|
-
reservedFunctionNames:
|
|
8361
|
+
reservedKeywords: cA,
|
|
8362
|
+
reservedDataTypes: lA,
|
|
8363
|
+
reservedFunctionNames: HA,
|
|
8306
8364
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
8307
8365
|
stringTypes: [
|
|
8308
8366
|
'""-qq-bs',
|
|
@@ -8343,7 +8401,7 @@ const _A = [
|
|
|
8343
8401
|
onelineClauses: [...zE, ...rE],
|
|
8344
8402
|
tabularOnelineClauses: rE
|
|
8345
8403
|
}
|
|
8346
|
-
},
|
|
8404
|
+
}, hA = [
|
|
8347
8405
|
// https://docs.pingcap.com/tidb/stable/keywords
|
|
8348
8406
|
"ADD",
|
|
8349
8407
|
"ALL",
|
|
@@ -8582,7 +8640,7 @@ const _A = [
|
|
|
8582
8640
|
"VARYING",
|
|
8583
8641
|
"YEAR"
|
|
8584
8642
|
// 'SET' // handled as special-case in postProcess
|
|
8585
|
-
],
|
|
8643
|
+
], fA = [
|
|
8586
8644
|
// https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
|
|
8587
8645
|
// https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
|
|
8588
8646
|
// + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
|
|
@@ -8908,7 +8966,7 @@ const _A = [
|
|
|
8908
8966
|
// 'XOR',
|
|
8909
8967
|
"YEAR",
|
|
8910
8968
|
"YEARWEEK"
|
|
8911
|
-
],
|
|
8969
|
+
], WA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), XA = C([
|
|
8912
8970
|
// queries
|
|
8913
8971
|
"WITH [RECURSIVE]",
|
|
8914
8972
|
"FROM",
|
|
@@ -9043,7 +9101,7 @@ const _A = [
|
|
|
9043
9101
|
"UNLOCK TABLES",
|
|
9044
9102
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
9045
9103
|
"USE"
|
|
9046
|
-
]),
|
|
9104
|
+
]), bA = C(["UNION [ALL | DISTINCT]"]), yA = C([
|
|
9047
9105
|
"JOIN",
|
|
9048
9106
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9049
9107
|
"{INNER | CROSS} JOIN",
|
|
@@ -9056,19 +9114,19 @@ const _A = [
|
|
|
9056
9114
|
"CHARACTER SET",
|
|
9057
9115
|
"{ROWS | RANGE} BETWEEN",
|
|
9058
9116
|
"IDENTIFIED BY"
|
|
9059
|
-
]),
|
|
9117
|
+
]), $A = C([]), gA = {
|
|
9060
9118
|
name: "tidb",
|
|
9061
9119
|
tokenizerOptions: {
|
|
9062
|
-
reservedSelect:
|
|
9063
|
-
reservedClauses: [...
|
|
9064
|
-
reservedSetOperations:
|
|
9065
|
-
reservedJoins:
|
|
9120
|
+
reservedSelect: WA,
|
|
9121
|
+
reservedClauses: [...XA, ...ET, ...nE],
|
|
9122
|
+
reservedSetOperations: bA,
|
|
9123
|
+
reservedJoins: yA,
|
|
9066
9124
|
reservedKeywordPhrases: KA,
|
|
9067
|
-
reservedDataTypePhrases:
|
|
9125
|
+
reservedDataTypePhrases: $A,
|
|
9068
9126
|
supportsXor: !0,
|
|
9069
|
-
reservedKeywords:
|
|
9127
|
+
reservedKeywords: hA,
|
|
9070
9128
|
reservedDataTypes: VA,
|
|
9071
|
-
reservedFunctionNames:
|
|
9129
|
+
reservedFunctionNames: fA,
|
|
9072
9130
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
9073
9131
|
stringTypes: [
|
|
9074
9132
|
'""-qq-bs',
|
|
@@ -9109,7 +9167,7 @@ const _A = [
|
|
|
9109
9167
|
onelineClauses: [...ET, ...nE],
|
|
9110
9168
|
tabularOnelineClauses: nE
|
|
9111
9169
|
}
|
|
9112
|
-
},
|
|
9170
|
+
}, JA = [
|
|
9113
9171
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
9114
9172
|
"ABORT",
|
|
9115
9173
|
"ABS",
|
|
@@ -9339,7 +9397,7 @@ const _A = [
|
|
|
9339
9397
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
9340
9398
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
9341
9399
|
"CAST"
|
|
9342
|
-
],
|
|
9400
|
+
], wA = [
|
|
9343
9401
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
9344
9402
|
"ADVISE",
|
|
9345
9403
|
"ALL",
|
|
@@ -9545,7 +9603,7 @@ const _A = [
|
|
|
9545
9603
|
"WITHIN",
|
|
9546
9604
|
"WORK",
|
|
9547
9605
|
"XOR"
|
|
9548
|
-
],
|
|
9606
|
+
], xA = [
|
|
9549
9607
|
// N1QL does not support any way of declaring types for columns.
|
|
9550
9608
|
// It does not support the CREATE TABLE statement nor the CAST() expression.
|
|
9551
9609
|
//
|
|
@@ -9554,7 +9612,7 @@ const _A = [
|
|
|
9554
9612
|
// which it actually doesn't use.
|
|
9555
9613
|
//
|
|
9556
9614
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
9557
|
-
],
|
|
9615
|
+
], vA = C(["SELECT [ALL | DISTINCT]"]), QA = C([
|
|
9558
9616
|
// queries
|
|
9559
9617
|
"WITH",
|
|
9560
9618
|
"FROM",
|
|
@@ -9621,19 +9679,19 @@ const _A = [
|
|
|
9621
9679
|
"SET CURRENT SCHEMA",
|
|
9622
9680
|
"SHOW",
|
|
9623
9681
|
"USE [PRIMARY] KEYS"
|
|
9624
|
-
]),
|
|
9682
|
+
]), ZA = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), qA = C(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), jA = C(["{ROWS | RANGE | GROUPS} BETWEEN"]), kA = C([]), zA = {
|
|
9625
9683
|
name: "n1ql",
|
|
9626
9684
|
tokenizerOptions: {
|
|
9627
|
-
reservedSelect:
|
|
9628
|
-
reservedClauses: [...
|
|
9629
|
-
reservedSetOperations:
|
|
9630
|
-
reservedJoins:
|
|
9631
|
-
reservedKeywordPhrases:
|
|
9685
|
+
reservedSelect: vA,
|
|
9686
|
+
reservedClauses: [...QA, ...TT],
|
|
9687
|
+
reservedSetOperations: ZA,
|
|
9688
|
+
reservedJoins: qA,
|
|
9689
|
+
reservedKeywordPhrases: jA,
|
|
9632
9690
|
reservedDataTypePhrases: kA,
|
|
9633
9691
|
supportsXor: !0,
|
|
9634
|
-
reservedKeywords:
|
|
9635
|
-
reservedDataTypes:
|
|
9636
|
-
reservedFunctionNames:
|
|
9692
|
+
reservedKeywords: wA,
|
|
9693
|
+
reservedDataTypes: xA,
|
|
9694
|
+
reservedFunctionNames: JA,
|
|
9637
9695
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
9638
9696
|
// but we support them anyway as all other SQL dialects do,
|
|
9639
9697
|
// which simplifies writing tests that are shared between all dialects.
|
|
@@ -9647,7 +9705,7 @@ const _A = [
|
|
|
9647
9705
|
formatOptions: {
|
|
9648
9706
|
onelineClauses: TT
|
|
9649
9707
|
}
|
|
9650
|
-
},
|
|
9708
|
+
}, ES = [
|
|
9651
9709
|
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
|
|
9652
9710
|
// 'A',
|
|
9653
9711
|
"ADD",
|
|
@@ -9952,7 +10010,7 @@ const _A = [
|
|
|
9952
10010
|
"WRITE",
|
|
9953
10011
|
"YEAR",
|
|
9954
10012
|
"ZONE"
|
|
9955
|
-
],
|
|
10013
|
+
], TS = [
|
|
9956
10014
|
// https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
|
|
9957
10015
|
"ARRAY",
|
|
9958
10016
|
"BFILE_BASE",
|
|
@@ -9990,7 +10048,7 @@ const _A = [
|
|
|
9990
10048
|
"UROWID",
|
|
9991
10049
|
"VARCHAR",
|
|
9992
10050
|
"VARCHAR2"
|
|
9993
|
-
],
|
|
10051
|
+
], RS = [
|
|
9994
10052
|
// https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
|
|
9995
10053
|
// numeric
|
|
9996
10054
|
"ABS",
|
|
@@ -10255,7 +10313,7 @@ const _A = [
|
|
|
10255
10313
|
"PRESENTNNV",
|
|
10256
10314
|
"PRESENTV",
|
|
10257
10315
|
"PREVIOUS"
|
|
10258
|
-
],
|
|
10316
|
+
], AS = C(["SELECT [ALL | DISTINCT | UNIQUE]"]), SS = C([
|
|
10259
10317
|
// queries
|
|
10260
10318
|
"WITH",
|
|
10261
10319
|
"FROM",
|
|
@@ -10309,7 +10367,7 @@ const _A = [
|
|
|
10309
10367
|
"EXCEPTION",
|
|
10310
10368
|
"LOOP",
|
|
10311
10369
|
"START WITH"
|
|
10312
|
-
]),
|
|
10370
|
+
]), eS = C(["UNION [ALL]", "MINUS", "INTERSECT"]), IS = C([
|
|
10313
10371
|
"JOIN",
|
|
10314
10372
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10315
10373
|
"{INNER | CROSS} JOIN",
|
|
@@ -10317,23 +10375,23 @@ const _A = [
|
|
|
10317
10375
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10318
10376
|
// non-standard joins
|
|
10319
10377
|
"{CROSS | OUTER} APPLY"
|
|
10320
|
-
]),
|
|
10378
|
+
]), OS = C([
|
|
10321
10379
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10322
10380
|
"ON COMMIT",
|
|
10323
10381
|
"{ROWS | RANGE} BETWEEN"
|
|
10324
|
-
]),
|
|
10382
|
+
]), NS = C([]), sS = {
|
|
10325
10383
|
name: "plsql",
|
|
10326
10384
|
tokenizerOptions: {
|
|
10327
|
-
reservedSelect:
|
|
10328
|
-
reservedClauses: [...
|
|
10329
|
-
reservedSetOperations:
|
|
10330
|
-
reservedJoins:
|
|
10331
|
-
reservedKeywordPhrases:
|
|
10332
|
-
reservedDataTypePhrases:
|
|
10385
|
+
reservedSelect: AS,
|
|
10386
|
+
reservedClauses: [...SS, ...RT, ...DE],
|
|
10387
|
+
reservedSetOperations: eS,
|
|
10388
|
+
reservedJoins: IS,
|
|
10389
|
+
reservedKeywordPhrases: OS,
|
|
10390
|
+
reservedDataTypePhrases: NS,
|
|
10333
10391
|
supportsXor: !0,
|
|
10334
|
-
reservedKeywords:
|
|
10335
|
-
reservedDataTypes:
|
|
10336
|
-
reservedFunctionNames:
|
|
10392
|
+
reservedKeywords: ES,
|
|
10393
|
+
reservedDataTypes: TS,
|
|
10394
|
+
reservedFunctionNames: RS,
|
|
10337
10395
|
stringTypes: [
|
|
10338
10396
|
{ quote: "''-qq", prefixes: ["N"] },
|
|
10339
10397
|
{ quote: "q''", prefixes: ["N"] }
|
|
@@ -10358,7 +10416,7 @@ const _A = [
|
|
|
10358
10416
|
"@",
|
|
10359
10417
|
"||"
|
|
10360
10418
|
],
|
|
10361
|
-
postProcess:
|
|
10419
|
+
postProcess: tS
|
|
10362
10420
|
},
|
|
10363
10421
|
formatOptions: {
|
|
10364
10422
|
alwaysDenseOperators: ["@"],
|
|
@@ -10366,11 +10424,11 @@ const _A = [
|
|
|
10366
10424
|
tabularOnelineClauses: DE
|
|
10367
10425
|
}
|
|
10368
10426
|
};
|
|
10369
|
-
function
|
|
10370
|
-
let E =
|
|
10371
|
-
return T.map((R) => X.SET(R) && X.BY(E) ? Object.assign(Object.assign({}, R), { type: i.RESERVED_KEYWORD }) : (
|
|
10427
|
+
function tS(T) {
|
|
10428
|
+
let E = x;
|
|
10429
|
+
return T.map((R) => X.SET(R) && X.BY(E) ? Object.assign(Object.assign({}, R), { type: i.RESERVED_KEYWORD }) : (BT(R.type) && (E = R), R));
|
|
10372
10430
|
}
|
|
10373
|
-
const
|
|
10431
|
+
const CS = [
|
|
10374
10432
|
// https://www.postgresql.org/docs/14/functions.html
|
|
10375
10433
|
//
|
|
10376
10434
|
// https://www.postgresql.org/docs/14/functions-math.html
|
|
@@ -11054,7 +11112,7 @@ const tS = [
|
|
|
11054
11112
|
"PG_MCV_LIST_ITEMS",
|
|
11055
11113
|
// cast
|
|
11056
11114
|
"CAST"
|
|
11057
|
-
],
|
|
11115
|
+
], LS = [
|
|
11058
11116
|
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
|
|
11059
11117
|
"ALL",
|
|
11060
11118
|
"ANALYSE",
|
|
@@ -11173,7 +11231,7 @@ const tS = [
|
|
|
11173
11231
|
"WITHOUT",
|
|
11174
11232
|
"YEAR"
|
|
11175
11233
|
// requires AS
|
|
11176
|
-
],
|
|
11234
|
+
], _S = [
|
|
11177
11235
|
// https://www.postgresql.org/docs/current/datatype.html
|
|
11178
11236
|
"ARRAY",
|
|
11179
11237
|
"BIGINT",
|
|
@@ -11207,7 +11265,7 @@ const tS = [
|
|
|
11207
11265
|
"VARCHAR",
|
|
11208
11266
|
"XML",
|
|
11209
11267
|
"ZONE"
|
|
11210
|
-
],
|
|
11268
|
+
], rS = C(["SELECT [ALL | DISTINCT]"]), nS = C([
|
|
11211
11269
|
// queries
|
|
11212
11270
|
"WITH [RECURSIVE]",
|
|
11213
11271
|
"FROM",
|
|
@@ -11430,17 +11488,17 @@ const tS = [
|
|
|
11430
11488
|
"START TRANSACTION",
|
|
11431
11489
|
"UNLISTEN",
|
|
11432
11490
|
"VACUUM"
|
|
11433
|
-
]),
|
|
11491
|
+
]), DS = C([
|
|
11434
11492
|
"UNION [ALL | DISTINCT]",
|
|
11435
11493
|
"EXCEPT [ALL | DISTINCT]",
|
|
11436
11494
|
"INTERSECT [ALL | DISTINCT]"
|
|
11437
|
-
]),
|
|
11495
|
+
]), iS = C([
|
|
11438
11496
|
"JOIN",
|
|
11439
11497
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11440
11498
|
"{INNER | CROSS} JOIN",
|
|
11441
11499
|
"NATURAL [INNER] JOIN",
|
|
11442
11500
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
11443
|
-
]),
|
|
11501
|
+
]), PS = C([
|
|
11444
11502
|
"PRIMARY KEY",
|
|
11445
11503
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
11446
11504
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -11451,21 +11509,21 @@ const tS = [
|
|
|
11451
11509
|
"IS [NOT] DISTINCT FROM",
|
|
11452
11510
|
"NULLS {FIRST | LAST}",
|
|
11453
11511
|
"WITH ORDINALITY"
|
|
11454
|
-
]),
|
|
11512
|
+
]), oS = C([
|
|
11455
11513
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
11456
11514
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
11457
11515
|
]), aS = {
|
|
11458
11516
|
name: "postgresql",
|
|
11459
11517
|
tokenizerOptions: {
|
|
11460
|
-
reservedSelect:
|
|
11461
|
-
reservedClauses: [...
|
|
11462
|
-
reservedSetOperations:
|
|
11463
|
-
reservedJoins:
|
|
11464
|
-
reservedKeywordPhrases:
|
|
11465
|
-
reservedDataTypePhrases:
|
|
11466
|
-
reservedKeywords:
|
|
11467
|
-
reservedDataTypes:
|
|
11468
|
-
reservedFunctionNames:
|
|
11518
|
+
reservedSelect: rS,
|
|
11519
|
+
reservedClauses: [...nS, ...AT, ...iE],
|
|
11520
|
+
reservedSetOperations: DS,
|
|
11521
|
+
reservedJoins: iS,
|
|
11522
|
+
reservedKeywordPhrases: PS,
|
|
11523
|
+
reservedDataTypePhrases: oS,
|
|
11524
|
+
reservedKeywords: LS,
|
|
11525
|
+
reservedDataTypes: _S,
|
|
11526
|
+
reservedFunctionNames: CS,
|
|
11469
11527
|
nestedBlockComments: !0,
|
|
11470
11528
|
extraParens: ["[]"],
|
|
11471
11529
|
underscoresInNumbers: !0,
|
|
@@ -11580,7 +11638,7 @@ const tS = [
|
|
|
11580
11638
|
onelineClauses: [...AT, ...iE],
|
|
11581
11639
|
tabularOnelineClauses: iE
|
|
11582
11640
|
}
|
|
11583
|
-
},
|
|
11641
|
+
}, MS = [
|
|
11584
11642
|
// https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
|
|
11585
11643
|
"ANY_VALUE",
|
|
11586
11644
|
"APPROXIMATE PERCENTILE_DISC",
|
|
@@ -11926,7 +11984,7 @@ const tS = [
|
|
|
11926
11984
|
"SLICE_NUM",
|
|
11927
11985
|
"USER",
|
|
11928
11986
|
"VERSION"
|
|
11929
|
-
],
|
|
11987
|
+
], US = [
|
|
11930
11988
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
|
|
11931
11989
|
"AES128",
|
|
11932
11990
|
"AES256",
|
|
@@ -12115,7 +12173,7 @@ const tS = [
|
|
|
12115
12173
|
* SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
|
|
12116
12174
|
* SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
|
|
12117
12175
|
*/
|
|
12118
|
-
],
|
|
12176
|
+
], GS = [
|
|
12119
12177
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
|
|
12120
12178
|
"ARRAY",
|
|
12121
12179
|
"BIGINT",
|
|
@@ -12136,7 +12194,7 @@ const tS = [
|
|
|
12136
12194
|
"TEXT",
|
|
12137
12195
|
"VARBYTE",
|
|
12138
12196
|
"VARCHAR"
|
|
12139
|
-
],
|
|
12197
|
+
], cS = C(["SELECT [ALL | DISTINCT]"]), lS = C([
|
|
12140
12198
|
// queries
|
|
12141
12199
|
"WITH [RECURSIVE]",
|
|
12142
12200
|
"FROM",
|
|
@@ -12247,13 +12305,13 @@ const tS = [
|
|
|
12247
12305
|
"START TRANSACTION",
|
|
12248
12306
|
"UNLOAD",
|
|
12249
12307
|
"VACUUM"
|
|
12250
|
-
]),
|
|
12308
|
+
]), HS = C(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), uS = C([
|
|
12251
12309
|
"JOIN",
|
|
12252
12310
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12253
12311
|
"{INNER | CROSS} JOIN",
|
|
12254
12312
|
"NATURAL [INNER] JOIN",
|
|
12255
12313
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12256
|
-
]),
|
|
12314
|
+
]), BS = C([
|
|
12257
12315
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12258
12316
|
"NULL AS",
|
|
12259
12317
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12261,18 +12319,18 @@ const tS = [
|
|
|
12261
12319
|
"HIVE METASTORE",
|
|
12262
12320
|
// in window specifications
|
|
12263
12321
|
"{ROWS | RANGE} BETWEEN"
|
|
12264
|
-
]),
|
|
12322
|
+
]), FS = C([]), YS = {
|
|
12265
12323
|
name: "redshift",
|
|
12266
12324
|
tokenizerOptions: {
|
|
12267
|
-
reservedSelect:
|
|
12268
|
-
reservedClauses: [...
|
|
12269
|
-
reservedSetOperations:
|
|
12270
|
-
reservedJoins:
|
|
12271
|
-
reservedKeywordPhrases:
|
|
12272
|
-
reservedDataTypePhrases:
|
|
12273
|
-
reservedKeywords:
|
|
12274
|
-
reservedDataTypes:
|
|
12275
|
-
reservedFunctionNames:
|
|
12325
|
+
reservedSelect: cS,
|
|
12326
|
+
reservedClauses: [...lS, ...ST, ...PE],
|
|
12327
|
+
reservedSetOperations: HS,
|
|
12328
|
+
reservedJoins: uS,
|
|
12329
|
+
reservedKeywordPhrases: BS,
|
|
12330
|
+
reservedDataTypePhrases: FS,
|
|
12331
|
+
reservedKeywords: US,
|
|
12332
|
+
reservedDataTypes: GS,
|
|
12333
|
+
reservedFunctionNames: MS,
|
|
12276
12334
|
extraParens: ["[]"],
|
|
12277
12335
|
stringTypes: ["''-qq"],
|
|
12278
12336
|
identTypes: ['""-qq'],
|
|
@@ -12299,7 +12357,7 @@ const tS = [
|
|
|
12299
12357
|
onelineClauses: [...ST, ...PE],
|
|
12300
12358
|
tabularOnelineClauses: PE
|
|
12301
12359
|
}
|
|
12302
|
-
},
|
|
12360
|
+
}, mS = [
|
|
12303
12361
|
// https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
|
|
12304
12362
|
"ADD",
|
|
12305
12363
|
"AFTER",
|
|
@@ -12566,7 +12624,7 @@ const tS = [
|
|
|
12566
12624
|
"UNSIGNED",
|
|
12567
12625
|
"VARIABLES",
|
|
12568
12626
|
"YEAR_MONTH"
|
|
12569
|
-
],
|
|
12627
|
+
], pS = [
|
|
12570
12628
|
// https://spark.apache.org/docs/latest/sql-ref-datatypes.html
|
|
12571
12629
|
"ARRAY",
|
|
12572
12630
|
"BIGINT",
|
|
@@ -12596,7 +12654,7 @@ const tS = [
|
|
|
12596
12654
|
"TINYINT",
|
|
12597
12655
|
"VARCHAR"
|
|
12598
12656
|
// No varchar type in Spark, only STRING. Added for the sake of tests
|
|
12599
|
-
],
|
|
12657
|
+
], dS = [
|
|
12600
12658
|
// http://spark.apache.org/docs/latest/sql-ref-functions.html
|
|
12601
12659
|
//
|
|
12602
12660
|
// http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
|
|
@@ -12917,7 +12975,7 @@ const tS = [
|
|
|
12917
12975
|
// Shorthand functions to use in place of CASE expression
|
|
12918
12976
|
"COALESCE",
|
|
12919
12977
|
"NULLIF"
|
|
12920
|
-
],
|
|
12978
|
+
], hS = C(["SELECT [ALL | DISTINCT]"]), VS = C([
|
|
12921
12979
|
// queries
|
|
12922
12980
|
"WITH",
|
|
12923
12981
|
"FROM",
|
|
@@ -12942,7 +13000,7 @@ const tS = [
|
|
|
12942
13000
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
12943
13001
|
"LOAD DATA [LOCAL] INPATH",
|
|
12944
13002
|
"[OVERWRITE] INTO TABLE"
|
|
12945
|
-
]), eT = C(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]),
|
|
13003
|
+
]), eT = C(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), oE = C([
|
|
12946
13004
|
// - create:
|
|
12947
13005
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
12948
13006
|
// - drop table:
|
|
@@ -12998,11 +13056,11 @@ const tS = [
|
|
|
12998
13056
|
"SHOW TBLPROPERTIES",
|
|
12999
13057
|
"SHOW VIEWS",
|
|
13000
13058
|
"UNCACHE TABLE"
|
|
13001
|
-
]),
|
|
13059
|
+
]), fS = C([
|
|
13002
13060
|
"UNION [ALL | DISTINCT]",
|
|
13003
13061
|
"EXCEPT [ALL | DISTINCT]",
|
|
13004
13062
|
"INTERSECT [ALL | DISTINCT]"
|
|
13005
|
-
]),
|
|
13063
|
+
]), WS = C([
|
|
13006
13064
|
"JOIN",
|
|
13007
13065
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13008
13066
|
"{INNER | CROSS} JOIN",
|
|
@@ -13011,24 +13069,24 @@ const tS = [
|
|
|
13011
13069
|
// non-standard-joins
|
|
13012
13070
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
13013
13071
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
13014
|
-
]),
|
|
13072
|
+
]), XS = C([
|
|
13015
13073
|
"ON DELETE",
|
|
13016
13074
|
"ON UPDATE",
|
|
13017
13075
|
"CURRENT ROW",
|
|
13018
13076
|
"{ROWS | RANGE} BETWEEN"
|
|
13019
|
-
]),
|
|
13077
|
+
]), bS = C([]), yS = {
|
|
13020
13078
|
name: "spark",
|
|
13021
13079
|
tokenizerOptions: {
|
|
13022
|
-
reservedSelect:
|
|
13023
|
-
reservedClauses: [...VS, ...eT, ...
|
|
13024
|
-
reservedSetOperations:
|
|
13025
|
-
reservedJoins:
|
|
13026
|
-
reservedKeywordPhrases:
|
|
13027
|
-
reservedDataTypePhrases:
|
|
13080
|
+
reservedSelect: hS,
|
|
13081
|
+
reservedClauses: [...VS, ...eT, ...oE],
|
|
13082
|
+
reservedSetOperations: fS,
|
|
13083
|
+
reservedJoins: WS,
|
|
13084
|
+
reservedKeywordPhrases: XS,
|
|
13085
|
+
reservedDataTypePhrases: bS,
|
|
13028
13086
|
supportsXor: !0,
|
|
13029
|
-
reservedKeywords:
|
|
13030
|
-
reservedDataTypes:
|
|
13031
|
-
reservedFunctionNames:
|
|
13087
|
+
reservedKeywords: mS,
|
|
13088
|
+
reservedDataTypes: pS,
|
|
13089
|
+
reservedFunctionNames: dS,
|
|
13032
13090
|
extraParens: ["[]"],
|
|
13033
13091
|
stringTypes: [
|
|
13034
13092
|
"''-bs",
|
|
@@ -13043,17 +13101,17 @@ const tS = [
|
|
|
13043
13101
|
postProcess: KS
|
|
13044
13102
|
},
|
|
13045
13103
|
formatOptions: {
|
|
13046
|
-
onelineClauses: [...eT, ...
|
|
13047
|
-
tabularOnelineClauses:
|
|
13104
|
+
onelineClauses: [...eT, ...oE],
|
|
13105
|
+
tabularOnelineClauses: oE
|
|
13048
13106
|
}
|
|
13049
13107
|
};
|
|
13050
13108
|
function KS(T) {
|
|
13051
13109
|
return T.map((E, R) => {
|
|
13052
|
-
const A = T[R - 1] ||
|
|
13110
|
+
const A = T[R - 1] || x, S = T[R + 1] || x;
|
|
13053
13111
|
return X.WINDOW(E) && S.type === i.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: i.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === i.RESERVED_KEYWORD && !(A.text === "COLLECTION" && S.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: i.IDENTIFIER, text: E.raw }) : E;
|
|
13054
13112
|
});
|
|
13055
13113
|
}
|
|
13056
|
-
const
|
|
13114
|
+
const $S = [
|
|
13057
13115
|
// https://www.sqlite.org/lang_corefunc.html
|
|
13058
13116
|
"ABS",
|
|
13059
13117
|
"CHANGES",
|
|
@@ -13177,7 +13235,7 @@ const yS = [
|
|
|
13177
13235
|
"JSON_TREE",
|
|
13178
13236
|
// cast
|
|
13179
13237
|
"CAST"
|
|
13180
|
-
],
|
|
13238
|
+
], gS = [
|
|
13181
13239
|
// https://www.sqlite.org/lang_keywords.html
|
|
13182
13240
|
// Note: The keywords listed on that URL are not all reserved keywords.
|
|
13183
13241
|
// We'll need to clean up this list to only include reserved keywords.
|
|
@@ -13330,7 +13388,7 @@ const yS = [
|
|
|
13330
13388
|
"WINDOW",
|
|
13331
13389
|
"WITH",
|
|
13332
13390
|
"WITHOUT"
|
|
13333
|
-
],
|
|
13391
|
+
], JS = [
|
|
13334
13392
|
// SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
|
|
13335
13393
|
// Here we just list some common ones as SQL Formatter
|
|
13336
13394
|
// is only able to detect a predefined list of data types.
|
|
@@ -13351,7 +13409,7 @@ const yS = [
|
|
|
13351
13409
|
"TEXT",
|
|
13352
13410
|
"VARCHAR",
|
|
13353
13411
|
"VARYING CHARACTER"
|
|
13354
|
-
],
|
|
13412
|
+
], wS = C(["SELECT [ALL | DISTINCT]"]), xS = C([
|
|
13355
13413
|
// queries
|
|
13356
13414
|
"WITH [RECURSIVE]",
|
|
13357
13415
|
"FROM",
|
|
@@ -13372,7 +13430,7 @@ const yS = [
|
|
|
13372
13430
|
"SET",
|
|
13373
13431
|
// other:
|
|
13374
13432
|
"RETURNING"
|
|
13375
|
-
]), IT = C(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]),
|
|
13433
|
+
]), IT = C(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), aE = C([
|
|
13376
13434
|
// - create:
|
|
13377
13435
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
13378
13436
|
// - update:
|
|
@@ -13391,28 +13449,28 @@ const yS = [
|
|
|
13391
13449
|
"RENAME TO",
|
|
13392
13450
|
// - set schema
|
|
13393
13451
|
"SET SCHEMA"
|
|
13394
|
-
]),
|
|
13452
|
+
]), vS = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), QS = C([
|
|
13395
13453
|
"JOIN",
|
|
13396
13454
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13397
13455
|
"{INNER | CROSS} JOIN",
|
|
13398
13456
|
"NATURAL [INNER] JOIN",
|
|
13399
13457
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13400
|
-
]),
|
|
13458
|
+
]), ZS = C([
|
|
13401
13459
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13402
13460
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
13403
13461
|
"DO UPDATE"
|
|
13404
|
-
]),
|
|
13462
|
+
]), qS = C([]), jS = {
|
|
13405
13463
|
name: "sqlite",
|
|
13406
13464
|
tokenizerOptions: {
|
|
13407
|
-
reservedSelect:
|
|
13408
|
-
reservedClauses: [...
|
|
13409
|
-
reservedSetOperations:
|
|
13410
|
-
reservedJoins:
|
|
13411
|
-
reservedKeywordPhrases:
|
|
13412
|
-
reservedDataTypePhrases:
|
|
13413
|
-
reservedKeywords:
|
|
13414
|
-
reservedDataTypes:
|
|
13415
|
-
reservedFunctionNames:
|
|
13465
|
+
reservedSelect: wS,
|
|
13466
|
+
reservedClauses: [...xS, ...IT, ...aE],
|
|
13467
|
+
reservedSetOperations: vS,
|
|
13468
|
+
reservedJoins: QS,
|
|
13469
|
+
reservedKeywordPhrases: ZS,
|
|
13470
|
+
reservedDataTypePhrases: qS,
|
|
13471
|
+
reservedKeywords: gS,
|
|
13472
|
+
reservedDataTypes: JS,
|
|
13473
|
+
reservedFunctionNames: $S,
|
|
13416
13474
|
stringTypes: [
|
|
13417
13475
|
"''-qq",
|
|
13418
13476
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -13425,8 +13483,8 @@ const yS = [
|
|
|
13425
13483
|
operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
|
|
13426
13484
|
},
|
|
13427
13485
|
formatOptions: {
|
|
13428
|
-
onelineClauses: [...IT, ...
|
|
13429
|
-
tabularOnelineClauses:
|
|
13486
|
+
onelineClauses: [...IT, ...aE],
|
|
13487
|
+
tabularOnelineClauses: aE
|
|
13430
13488
|
}
|
|
13431
13489
|
}, kS = [
|
|
13432
13490
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
|
|
@@ -13525,7 +13583,7 @@ const yS = [
|
|
|
13525
13583
|
"ASIN",
|
|
13526
13584
|
"ACOS",
|
|
13527
13585
|
"ATAN"
|
|
13528
|
-
],
|
|
13586
|
+
], zS = [
|
|
13529
13587
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
|
|
13530
13588
|
"ALL",
|
|
13531
13589
|
"ALLOCATE",
|
|
@@ -13723,7 +13781,7 @@ const yS = [
|
|
|
13723
13781
|
"WITHIN",
|
|
13724
13782
|
"WITHOUT",
|
|
13725
13783
|
"YEAR"
|
|
13726
|
-
],
|
|
13784
|
+
], Ee = [
|
|
13727
13785
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
|
|
13728
13786
|
"ARRAY",
|
|
13729
13787
|
"BIGINT",
|
|
@@ -13763,7 +13821,7 @@ const yS = [
|
|
|
13763
13821
|
"TIMESTAMP",
|
|
13764
13822
|
"VARBINARY",
|
|
13765
13823
|
"VARCHAR"
|
|
13766
|
-
],
|
|
13824
|
+
], Te = C(["SELECT [ALL | DISTINCT]"]), Re = C([
|
|
13767
13825
|
// queries
|
|
13768
13826
|
"WITH [RECURSIVE]",
|
|
13769
13827
|
"FROM",
|
|
@@ -13807,30 +13865,30 @@ const yS = [
|
|
|
13807
13865
|
"TRUNCATE TABLE",
|
|
13808
13866
|
// other
|
|
13809
13867
|
"SET SCHEMA"
|
|
13810
|
-
]),
|
|
13868
|
+
]), Ae = C([
|
|
13811
13869
|
"UNION [ALL | DISTINCT]",
|
|
13812
13870
|
"EXCEPT [ALL | DISTINCT]",
|
|
13813
13871
|
"INTERSECT [ALL | DISTINCT]"
|
|
13814
|
-
]),
|
|
13872
|
+
]), Se = C([
|
|
13815
13873
|
"JOIN",
|
|
13816
13874
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13817
13875
|
"{INNER | CROSS} JOIN",
|
|
13818
13876
|
"NATURAL [INNER] JOIN",
|
|
13819
13877
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13820
|
-
]),
|
|
13878
|
+
]), ee = C([
|
|
13821
13879
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13822
13880
|
"{ROWS | RANGE} BETWEEN"
|
|
13823
|
-
]),
|
|
13881
|
+
]), Ie = C([]), Oe = {
|
|
13824
13882
|
name: "sql",
|
|
13825
13883
|
tokenizerOptions: {
|
|
13826
|
-
reservedSelect:
|
|
13827
|
-
reservedClauses: [...
|
|
13828
|
-
reservedSetOperations:
|
|
13829
|
-
reservedJoins:
|
|
13830
|
-
reservedKeywordPhrases:
|
|
13831
|
-
reservedDataTypePhrases:
|
|
13832
|
-
reservedKeywords:
|
|
13833
|
-
reservedDataTypes:
|
|
13884
|
+
reservedSelect: Te,
|
|
13885
|
+
reservedClauses: [...Re, ...OT, ...ME],
|
|
13886
|
+
reservedSetOperations: Ae,
|
|
13887
|
+
reservedJoins: Se,
|
|
13888
|
+
reservedKeywordPhrases: ee,
|
|
13889
|
+
reservedDataTypePhrases: Ie,
|
|
13890
|
+
reservedKeywords: zS,
|
|
13891
|
+
reservedDataTypes: Ee,
|
|
13834
13892
|
reservedFunctionNames: kS,
|
|
13835
13893
|
stringTypes: [
|
|
13836
13894
|
{ quote: "''-qq-bs", prefixes: ["N", "U&"] },
|
|
@@ -13844,7 +13902,7 @@ const yS = [
|
|
|
13844
13902
|
onelineClauses: [...OT, ...ME],
|
|
13845
13903
|
tabularOnelineClauses: ME
|
|
13846
13904
|
}
|
|
13847
|
-
},
|
|
13905
|
+
}, Ne = [
|
|
13848
13906
|
// https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
|
|
13849
13907
|
// rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
|
|
13850
13908
|
// rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
|
|
@@ -14278,7 +14336,7 @@ const yS = [
|
|
|
14278
14336
|
"NEXT",
|
|
14279
14337
|
"PERMUTE",
|
|
14280
14338
|
"PREV"
|
|
14281
|
-
],
|
|
14339
|
+
], se = [
|
|
14282
14340
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
|
|
14283
14341
|
"ABSENT",
|
|
14284
14342
|
"ADD",
|
|
@@ -14515,7 +14573,7 @@ const yS = [
|
|
|
14515
14573
|
"WRAPPER",
|
|
14516
14574
|
"WRITE",
|
|
14517
14575
|
"ZONE"
|
|
14518
|
-
],
|
|
14576
|
+
], te = [
|
|
14519
14577
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
|
|
14520
14578
|
// or https://trino.io/docs/current/language/types.html
|
|
14521
14579
|
"BIGINT",
|
|
@@ -14554,7 +14612,7 @@ const yS = [
|
|
|
14554
14612
|
"CODEPOINTS",
|
|
14555
14613
|
"FUNCTION",
|
|
14556
14614
|
"JSONPATH"
|
|
14557
|
-
],
|
|
14615
|
+
], Ce = C(["SELECT [ALL | DISTINCT]"]), Le = C([
|
|
14558
14616
|
// queries
|
|
14559
14617
|
"WITH [RECURSIVE]",
|
|
14560
14618
|
"FROM",
|
|
@@ -14640,32 +14698,32 @@ const yS = [
|
|
|
14640
14698
|
"SHOW ROLE GRANTS",
|
|
14641
14699
|
"SHOW FUNCTIONS",
|
|
14642
14700
|
"SHOW SESSION"
|
|
14643
|
-
]),
|
|
14701
|
+
]), _e = C([
|
|
14644
14702
|
"UNION [ALL | DISTINCT]",
|
|
14645
14703
|
"EXCEPT [ALL | DISTINCT]",
|
|
14646
14704
|
"INTERSECT [ALL | DISTINCT]"
|
|
14647
|
-
]),
|
|
14705
|
+
]), re = C([
|
|
14648
14706
|
"JOIN",
|
|
14649
14707
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14650
14708
|
"{INNER | CROSS} JOIN",
|
|
14651
14709
|
"NATURAL [INNER] JOIN",
|
|
14652
14710
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14653
|
-
]),
|
|
14711
|
+
]), ne = C([
|
|
14654
14712
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14655
14713
|
// comparison operator
|
|
14656
14714
|
"IS [NOT] DISTINCT FROM"
|
|
14657
|
-
]),
|
|
14715
|
+
]), De = C([]), ie = {
|
|
14658
14716
|
name: "trino",
|
|
14659
14717
|
tokenizerOptions: {
|
|
14660
|
-
reservedSelect:
|
|
14661
|
-
reservedClauses: [...
|
|
14662
|
-
reservedSetOperations:
|
|
14663
|
-
reservedJoins:
|
|
14664
|
-
reservedKeywordPhrases:
|
|
14665
|
-
reservedDataTypePhrases:
|
|
14666
|
-
reservedKeywords:
|
|
14667
|
-
reservedDataTypes:
|
|
14668
|
-
reservedFunctionNames:
|
|
14718
|
+
reservedSelect: Ce,
|
|
14719
|
+
reservedClauses: [...Le, ...NT, ...UE],
|
|
14720
|
+
reservedSetOperations: _e,
|
|
14721
|
+
reservedJoins: re,
|
|
14722
|
+
reservedKeywordPhrases: ne,
|
|
14723
|
+
reservedDataTypePhrases: De,
|
|
14724
|
+
reservedKeywords: se,
|
|
14725
|
+
reservedDataTypes: te,
|
|
14726
|
+
reservedFunctionNames: Ne,
|
|
14669
14727
|
// Trino also supports {- ... -} parenthesis.
|
|
14670
14728
|
// The formatting of these currently works out as a result of { and -
|
|
14671
14729
|
// not getting a space added in-between.
|
|
@@ -14697,7 +14755,7 @@ const yS = [
|
|
|
14697
14755
|
onelineClauses: [...NT, ...UE],
|
|
14698
14756
|
tabularOnelineClauses: UE
|
|
14699
14757
|
}
|
|
14700
|
-
},
|
|
14758
|
+
}, Pe = [
|
|
14701
14759
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
14702
14760
|
// aggregate
|
|
14703
14761
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -15002,7 +15060,7 @@ const yS = [
|
|
|
15002
15060
|
// Shorthand functions to use in place of CASE expression
|
|
15003
15061
|
"COALESCE",
|
|
15004
15062
|
"NULLIF"
|
|
15005
|
-
],
|
|
15063
|
+
], oe = [
|
|
15006
15064
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
15007
15065
|
// standard
|
|
15008
15066
|
"ADD",
|
|
@@ -15210,7 +15268,7 @@ const yS = [
|
|
|
15210
15268
|
"TIMESTAMP",
|
|
15211
15269
|
"VARBINARY",
|
|
15212
15270
|
"VARCHAR"
|
|
15213
|
-
],
|
|
15271
|
+
], Me = C(["SELECT [ALL | DISTINCT]"]), Ue = C([
|
|
15214
15272
|
// queries
|
|
15215
15273
|
"WITH",
|
|
15216
15274
|
"INTO",
|
|
@@ -15415,27 +15473,27 @@ const yS = [
|
|
|
15415
15473
|
"XACT_ABORT",
|
|
15416
15474
|
"XML INDEX",
|
|
15417
15475
|
"XML SCHEMA COLLECTION"
|
|
15418
|
-
]),
|
|
15476
|
+
]), Ge = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), ce = C([
|
|
15419
15477
|
"JOIN",
|
|
15420
15478
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15421
15479
|
"{INNER | CROSS} JOIN",
|
|
15422
15480
|
// non-standard joins
|
|
15423
15481
|
"{CROSS | OUTER} APPLY"
|
|
15424
|
-
]),
|
|
15482
|
+
]), le = C([
|
|
15425
15483
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
15426
15484
|
"{ROWS | RANGE} BETWEEN"
|
|
15427
|
-
]),
|
|
15485
|
+
]), He = C([]), ue = {
|
|
15428
15486
|
name: "transactsql",
|
|
15429
15487
|
tokenizerOptions: {
|
|
15430
|
-
reservedSelect:
|
|
15431
|
-
reservedClauses: [...
|
|
15432
|
-
reservedSetOperations:
|
|
15433
|
-
reservedJoins:
|
|
15434
|
-
reservedKeywordPhrases:
|
|
15435
|
-
reservedDataTypePhrases:
|
|
15436
|
-
reservedKeywords:
|
|
15488
|
+
reservedSelect: Me,
|
|
15489
|
+
reservedClauses: [...Ue, ...sT, ...GE],
|
|
15490
|
+
reservedSetOperations: Ge,
|
|
15491
|
+
reservedJoins: ce,
|
|
15492
|
+
reservedKeywordPhrases: le,
|
|
15493
|
+
reservedDataTypePhrases: He,
|
|
15494
|
+
reservedKeywords: oe,
|
|
15437
15495
|
reservedDataTypes: ae,
|
|
15438
|
-
reservedFunctionNames:
|
|
15496
|
+
reservedFunctionNames: Pe,
|
|
15439
15497
|
nestedBlockComments: !0,
|
|
15440
15498
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
15441
15499
|
identTypes: ['""-qq', "[]"],
|
|
@@ -15468,7 +15526,7 @@ const yS = [
|
|
|
15468
15526
|
onelineClauses: [...sT, ...GE],
|
|
15469
15527
|
tabularOnelineClauses: GE
|
|
15470
15528
|
}
|
|
15471
|
-
},
|
|
15529
|
+
}, Be = [
|
|
15472
15530
|
// List of all keywords taken from:
|
|
15473
15531
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
|
|
15474
15532
|
// Then filtered down to reserved keywords by running
|
|
@@ -15681,7 +15739,7 @@ const yS = [
|
|
|
15681
15739
|
"XOR",
|
|
15682
15740
|
"YEAR_MONTH",
|
|
15683
15741
|
"ZEROFILL"
|
|
15684
|
-
],
|
|
15742
|
+
], Fe = [
|
|
15685
15743
|
// https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
|
|
15686
15744
|
"BIGINT",
|
|
15687
15745
|
"BINARY",
|
|
@@ -15730,7 +15788,7 @@ const yS = [
|
|
|
15730
15788
|
"VARCHAR",
|
|
15731
15789
|
"VARCHARACTER",
|
|
15732
15790
|
"YEAR"
|
|
15733
|
-
],
|
|
15791
|
+
], Ye = [
|
|
15734
15792
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
|
|
15735
15793
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
|
|
15736
15794
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
|
|
@@ -16010,7 +16068,7 @@ const yS = [
|
|
|
16010
16068
|
"WEEKDAY",
|
|
16011
16069
|
"WEEKOFYEAR",
|
|
16012
16070
|
"YEAR"
|
|
16013
|
-
],
|
|
16071
|
+
], me = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), pe = C([
|
|
16014
16072
|
// queries
|
|
16015
16073
|
"WITH",
|
|
16016
16074
|
"FROM",
|
|
@@ -16211,12 +16269,12 @@ const yS = [
|
|
|
16211
16269
|
"REPEAT",
|
|
16212
16270
|
"RETURN",
|
|
16213
16271
|
"WHILE"
|
|
16214
|
-
]),
|
|
16272
|
+
]), de = C([
|
|
16215
16273
|
"UNION [ALL | DISTINCT]",
|
|
16216
16274
|
"EXCEPT",
|
|
16217
16275
|
"INTERSECT",
|
|
16218
16276
|
"MINUS"
|
|
16219
|
-
]),
|
|
16277
|
+
]), he = C([
|
|
16220
16278
|
"JOIN",
|
|
16221
16279
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16222
16280
|
"{INNER | CROSS} JOIN",
|
|
@@ -16229,18 +16287,18 @@ const yS = [
|
|
|
16229
16287
|
"CHARACTER SET",
|
|
16230
16288
|
"{ROWS | RANGE} BETWEEN",
|
|
16231
16289
|
"IDENTIFIED BY"
|
|
16232
|
-
]),
|
|
16290
|
+
]), fe = C([]), We = {
|
|
16233
16291
|
name: "singlestoredb",
|
|
16234
16292
|
tokenizerOptions: {
|
|
16235
|
-
reservedSelect:
|
|
16236
|
-
reservedClauses: [...
|
|
16237
|
-
reservedSetOperations:
|
|
16238
|
-
reservedJoins:
|
|
16293
|
+
reservedSelect: me,
|
|
16294
|
+
reservedClauses: [...pe, ...tT, ...cE],
|
|
16295
|
+
reservedSetOperations: de,
|
|
16296
|
+
reservedJoins: he,
|
|
16239
16297
|
reservedKeywordPhrases: Ve,
|
|
16240
|
-
reservedDataTypePhrases:
|
|
16241
|
-
reservedKeywords:
|
|
16242
|
-
reservedDataTypes:
|
|
16243
|
-
reservedFunctionNames:
|
|
16298
|
+
reservedDataTypePhrases: fe,
|
|
16299
|
+
reservedKeywords: Be,
|
|
16300
|
+
reservedDataTypes: Fe,
|
|
16301
|
+
reservedFunctionNames: Ye,
|
|
16244
16302
|
// TODO: support _binary"some string" prefix
|
|
16245
16303
|
stringTypes: [
|
|
16246
16304
|
'""-qq-bs',
|
|
@@ -16280,7 +16338,7 @@ const yS = [
|
|
|
16280
16338
|
onelineClauses: [...tT, ...cE],
|
|
16281
16339
|
tabularOnelineClauses: cE
|
|
16282
16340
|
}
|
|
16283
|
-
},
|
|
16341
|
+
}, Xe = [
|
|
16284
16342
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
16285
16343
|
//
|
|
16286
16344
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -16888,7 +16946,7 @@ const yS = [
|
|
|
16888
16946
|
"QUARTER",
|
|
16889
16947
|
"ZEROIFNULL",
|
|
16890
16948
|
"ZIPF"
|
|
16891
|
-
],
|
|
16949
|
+
], be = [
|
|
16892
16950
|
// https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
|
|
16893
16951
|
//
|
|
16894
16952
|
// run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
|
|
@@ -16985,7 +17043,7 @@ const yS = [
|
|
|
16985
17043
|
"WITH",
|
|
16986
17044
|
// These are definitely keywords, but haven't found a definite list in the docs
|
|
16987
17045
|
"COMMENT"
|
|
16988
|
-
],
|
|
17046
|
+
], ye = [
|
|
16989
17047
|
"NUMBER",
|
|
16990
17048
|
"DECIMAL",
|
|
16991
17049
|
"NUMERIC",
|
|
@@ -17022,7 +17080,7 @@ const yS = [
|
|
|
17022
17080
|
"ARRAY",
|
|
17023
17081
|
"GEOGRAPHY",
|
|
17024
17082
|
"GEOMETRY"
|
|
17025
|
-
], Ke = C(["SELECT [ALL | DISTINCT]"]),
|
|
17083
|
+
], Ke = C(["SELECT [ALL | DISTINCT]"]), $e = C([
|
|
17026
17084
|
// queries
|
|
17027
17085
|
"WITH [RECURSIVE]",
|
|
17028
17086
|
"FROM",
|
|
@@ -17294,25 +17352,25 @@ const yS = [
|
|
|
17294
17352
|
"USE SCHEMA",
|
|
17295
17353
|
"USE SECONDARY ROLES",
|
|
17296
17354
|
"USE WAREHOUSE"
|
|
17297
|
-
]),
|
|
17355
|
+
]), ge = C(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), Je = C([
|
|
17298
17356
|
"[INNER] JOIN",
|
|
17299
17357
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17300
17358
|
"{CROSS | NATURAL} JOIN"
|
|
17301
|
-
]),
|
|
17359
|
+
]), we = C([
|
|
17302
17360
|
"{ROWS | RANGE} BETWEEN",
|
|
17303
17361
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17304
|
-
]),
|
|
17362
|
+
]), xe = C([]), ve = {
|
|
17305
17363
|
name: "snowflake",
|
|
17306
17364
|
tokenizerOptions: {
|
|
17307
17365
|
reservedSelect: Ke,
|
|
17308
|
-
reservedClauses: [
|
|
17309
|
-
reservedSetOperations:
|
|
17310
|
-
reservedJoins:
|
|
17311
|
-
reservedKeywordPhrases:
|
|
17312
|
-
reservedDataTypePhrases:
|
|
17313
|
-
reservedKeywords:
|
|
17314
|
-
reservedDataTypes:
|
|
17315
|
-
reservedFunctionNames:
|
|
17366
|
+
reservedClauses: [...$e, ...CT, ...lE],
|
|
17367
|
+
reservedSetOperations: ge,
|
|
17368
|
+
reservedJoins: Je,
|
|
17369
|
+
reservedKeywordPhrases: we,
|
|
17370
|
+
reservedDataTypePhrases: xe,
|
|
17371
|
+
reservedKeywords: be,
|
|
17372
|
+
reservedDataTypes: ye,
|
|
17373
|
+
reservedFunctionNames: Xe,
|
|
17316
17374
|
stringTypes: ["$$", "''-qq-bs"],
|
|
17317
17375
|
identTypes: ['""-qq'],
|
|
17318
17376
|
variableTypes: [
|
|
@@ -17345,49 +17403,49 @@ const yS = [
|
|
|
17345
17403
|
onelineClauses: [...CT, ...lE],
|
|
17346
17404
|
tabularOnelineClauses: lE
|
|
17347
17405
|
}
|
|
17348
|
-
},
|
|
17406
|
+
}, Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17349
17407
|
__proto__: null,
|
|
17350
|
-
bigquery:
|
|
17351
|
-
db2:
|
|
17352
|
-
db2i:
|
|
17353
|
-
duckdb:
|
|
17354
|
-
hive:
|
|
17355
|
-
mariadb:
|
|
17356
|
-
mysql:
|
|
17357
|
-
n1ql:
|
|
17358
|
-
plsql:
|
|
17408
|
+
bigquery: GR,
|
|
17409
|
+
db2: WR,
|
|
17410
|
+
db2i: vR,
|
|
17411
|
+
duckdb: AA,
|
|
17412
|
+
hive: _A,
|
|
17413
|
+
mariadb: GA,
|
|
17414
|
+
mysql: dA,
|
|
17415
|
+
n1ql: zA,
|
|
17416
|
+
plsql: sS,
|
|
17359
17417
|
postgresql: aS,
|
|
17360
|
-
redshift:
|
|
17361
|
-
singlestoredb:
|
|
17362
|
-
snowflake:
|
|
17363
|
-
spark:
|
|
17364
|
-
sql:
|
|
17365
|
-
sqlite:
|
|
17366
|
-
tidb:
|
|
17367
|
-
transactsql:
|
|
17368
|
-
trino:
|
|
17369
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
17418
|
+
redshift: YS,
|
|
17419
|
+
singlestoredb: We,
|
|
17420
|
+
snowflake: ve,
|
|
17421
|
+
spark: yS,
|
|
17422
|
+
sql: Oe,
|
|
17423
|
+
sqlite: jS,
|
|
17424
|
+
tidb: gA,
|
|
17425
|
+
transactsql: ue,
|
|
17426
|
+
trino: ie
|
|
17427
|
+
}, Symbol.toStringTag, { value: "Module" })), Q = (T) => T[T.length - 1], FT = (T) => T.sort((E, R) => R.length - E.length || E.localeCompare(R)), q = (T) => T.replace(/\s+/gu, " "), HE = (T) => /\n/.test(T), d = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), LT = /\s+/uy, b = (T) => new RegExp(`(?:${T})`, "uy"), Ze = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), qe = (T) => T + "(?:-" + T + ")*", je = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(Ze).join("|")}${E ? "" : "|"})`, ke = (T) => new RegExp(`(?:${T.map(d).join("|")}).*?(?=\r
|
|
17370
17428
|
|\r|
|
|
17371
17429
|
|$)`, "uy"), _T = (T, E = []) => {
|
|
17372
17430
|
const R = T === "open" ? 0 : 1, A = ["()", ...E].map((S) => S[R]);
|
|
17373
17431
|
return b(A.map(d).join("|"));
|
|
17374
|
-
}, rT = (T) => b(`${
|
|
17432
|
+
}, rT = (T) => b(`${FT(T).map(d).join("|")}`), ze = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", h = (T, E = {}) => {
|
|
17375
17433
|
if (T.length === 0)
|
|
17376
17434
|
return /^\b$/u;
|
|
17377
|
-
const R =
|
|
17435
|
+
const R = ze(E), A = FT(T).map(d).join("|").replace(/ /gu, "\\s+");
|
|
17378
17436
|
return new RegExp(`(?:${A})${R}\\b`, "iuy");
|
|
17379
17437
|
}, uE = (T, E) => {
|
|
17380
17438
|
if (!T.length)
|
|
17381
17439
|
return;
|
|
17382
17440
|
const R = T.map(d).join("|");
|
|
17383
17441
|
return b(`(?:${R})(?:${E})`);
|
|
17384
|
-
},
|
|
17442
|
+
}, EI = () => {
|
|
17385
17443
|
const T = {
|
|
17386
17444
|
"<": ">",
|
|
17387
17445
|
"[": "]",
|
|
17388
17446
|
"(": ")",
|
|
17389
17447
|
"{": "}"
|
|
17390
|
-
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([O,
|
|
17448
|
+
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([O, t]) => E.replace(/{left}/g, d(O)).replace(/{right}/g, d(t))), A = d(Object.keys(T).join(""));
|
|
17391
17449
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
|
|
17392
17450
|
}, nT = {
|
|
17393
17451
|
// - backtick quoted (using `` to escape)
|
|
@@ -17413,16 +17471,16 @@ const yS = [
|
|
|
17413
17471
|
// Hive and Spark variables: ${name}
|
|
17414
17472
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
17415
17473
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
17416
|
-
"q''":
|
|
17417
|
-
},
|
|
17418
|
-
const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = d(T ?? ""),
|
|
17419
|
-
return R ?
|
|
17474
|
+
"q''": EI()
|
|
17475
|
+
}, YT = (T) => typeof T == "string" ? nT[T] : "regex" in T ? T.regex : je(T) + nT[T.quote], TI = (T) => b(T.map((E) => "regex" in E ? E.regex : YT(E)).join("|")), mT = (T) => T.map(YT).join("|"), DT = (T) => b(mT(T)), RI = (T = {}) => b(pT(T)), pT = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
|
|
17476
|
+
const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = d(T ?? ""), t = d(E ?? ""), D = A ? `[${S}${e}${O}][${S}${e}${t}]*` : `[${S}${O}][${S}${e}${t}]*`;
|
|
17477
|
+
return R ? qe(D) : D;
|
|
17420
17478
|
};
|
|
17421
|
-
function
|
|
17479
|
+
function dT(T, E) {
|
|
17422
17480
|
const R = T.slice(0, E).split(/\n/);
|
|
17423
17481
|
return { line: R.length, col: R[R.length - 1].length + 1 };
|
|
17424
17482
|
}
|
|
17425
|
-
class
|
|
17483
|
+
class AI {
|
|
17426
17484
|
constructor(E, R) {
|
|
17427
17485
|
this.rules = E, this.dialectName = R, this.input = "", this.index = 0;
|
|
17428
17486
|
}
|
|
@@ -17448,7 +17506,7 @@ class RI {
|
|
|
17448
17506
|
return R;
|
|
17449
17507
|
}
|
|
17450
17508
|
createParseError() {
|
|
17451
|
-
const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } =
|
|
17509
|
+
const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } = dT(this.input, this.index);
|
|
17452
17510
|
return new Error(`Parse error: Unexpected "${E}" at line ${R} column ${A}.
|
|
17453
17511
|
${this.dialectInfo()}`);
|
|
17454
17512
|
}
|
|
@@ -17484,8 +17542,8 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
|
|
|
17484
17542
|
}
|
|
17485
17543
|
}
|
|
17486
17544
|
}
|
|
17487
|
-
const iT = /\/\*/uy,
|
|
17488
|
-
class
|
|
17545
|
+
const iT = /\/\*/uy, SI = /[\s\S]/uy, eI = /\*\//uy;
|
|
17546
|
+
class II {
|
|
17489
17547
|
constructor() {
|
|
17490
17548
|
this.lastIndex = 0;
|
|
17491
17549
|
}
|
|
@@ -17498,9 +17556,9 @@ class eI {
|
|
|
17498
17556
|
for (; S > 0; )
|
|
17499
17557
|
if (A = this.matchSection(iT, E))
|
|
17500
17558
|
R += A, S++;
|
|
17501
|
-
else if (A = this.matchSection(
|
|
17559
|
+
else if (A = this.matchSection(eI, E))
|
|
17502
17560
|
R += A, S--;
|
|
17503
|
-
else if (A = this.matchSection(
|
|
17561
|
+
else if (A = this.matchSection(SI, E))
|
|
17504
17562
|
R += A;
|
|
17505
17563
|
else
|
|
17506
17564
|
return null;
|
|
@@ -17512,7 +17570,7 @@ class eI {
|
|
|
17512
17570
|
return A && (this.lastIndex += A[0].length), A ? A[0] : null;
|
|
17513
17571
|
}
|
|
17514
17572
|
}
|
|
17515
|
-
class
|
|
17573
|
+
class OI {
|
|
17516
17574
|
constructor(E, R) {
|
|
17517
17575
|
this.cfg = E, this.dialectName = R, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
|
|
17518
17576
|
}
|
|
@@ -17521,7 +17579,7 @@ class II {
|
|
|
17521
17579
|
...this.rulesBeforeParams,
|
|
17522
17580
|
...this.buildParamRules(this.cfg, R),
|
|
17523
17581
|
...this.rulesAfterParams
|
|
17524
|
-
], S = new
|
|
17582
|
+
], S = new AI(A, this.dialectName).tokenize(E);
|
|
17525
17583
|
return this.cfg.postProcess ? this.cfg.postProcess(S) : S;
|
|
17526
17584
|
}
|
|
17527
17585
|
// These rules can be cached as they only depend on
|
|
@@ -17535,7 +17593,7 @@ class II {
|
|
|
17535
17593
|
},
|
|
17536
17594
|
{
|
|
17537
17595
|
type: i.BLOCK_COMMENT,
|
|
17538
|
-
regex: E.nestedBlockComments ? new
|
|
17596
|
+
regex: E.nestedBlockComments ? new II() : /(\/\*[^]*?\*\/)/uy
|
|
17539
17597
|
},
|
|
17540
17598
|
{
|
|
17541
17599
|
type: i.LINE_COMMENT,
|
|
@@ -17553,12 +17611,12 @@ class II {
|
|
|
17553
17611
|
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
17554
17612
|
{
|
|
17555
17613
|
type: i.RESERVED_KEYWORD_PHRASE,
|
|
17556
|
-
regex:
|
|
17614
|
+
regex: h((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
17557
17615
|
text: B
|
|
17558
17616
|
},
|
|
17559
17617
|
{
|
|
17560
17618
|
type: i.RESERVED_DATA_TYPE_PHRASE,
|
|
17561
|
-
regex:
|
|
17619
|
+
regex: h((S = E.reservedDataTypePhrases) !== null && S !== void 0 ? S : [], E.identChars),
|
|
17562
17620
|
text: B
|
|
17563
17621
|
},
|
|
17564
17622
|
{
|
|
@@ -17583,17 +17641,17 @@ class II {
|
|
|
17583
17641
|
},
|
|
17584
17642
|
{
|
|
17585
17643
|
type: i.RESERVED_CLAUSE,
|
|
17586
|
-
regex:
|
|
17644
|
+
regex: h(E.reservedClauses, E.identChars),
|
|
17587
17645
|
text: B
|
|
17588
17646
|
},
|
|
17589
17647
|
{
|
|
17590
17648
|
type: i.RESERVED_SELECT,
|
|
17591
|
-
regex:
|
|
17649
|
+
regex: h(E.reservedSelect, E.identChars),
|
|
17592
17650
|
text: B
|
|
17593
17651
|
},
|
|
17594
17652
|
{
|
|
17595
17653
|
type: i.RESERVED_SET_OPERATION,
|
|
17596
|
-
regex:
|
|
17654
|
+
regex: h(E.reservedSetOperations, E.identChars),
|
|
17597
17655
|
text: B
|
|
17598
17656
|
},
|
|
17599
17657
|
{
|
|
@@ -17613,7 +17671,7 @@ class II {
|
|
|
17613
17671
|
},
|
|
17614
17672
|
{
|
|
17615
17673
|
type: i.RESERVED_JOIN,
|
|
17616
|
-
regex:
|
|
17674
|
+
regex: h(E.reservedJoins, E.identChars),
|
|
17617
17675
|
text: B
|
|
17618
17676
|
},
|
|
17619
17677
|
{
|
|
@@ -17639,17 +17697,17 @@ class II {
|
|
|
17639
17697
|
] : [],
|
|
17640
17698
|
{
|
|
17641
17699
|
type: i.RESERVED_FUNCTION_NAME,
|
|
17642
|
-
regex:
|
|
17700
|
+
regex: h(E.reservedFunctionNames, E.identChars),
|
|
17643
17701
|
text: B
|
|
17644
17702
|
},
|
|
17645
17703
|
{
|
|
17646
17704
|
type: i.RESERVED_DATA_TYPE,
|
|
17647
|
-
regex:
|
|
17705
|
+
regex: h(E.reservedDataTypes, E.identChars),
|
|
17648
17706
|
text: B
|
|
17649
17707
|
},
|
|
17650
17708
|
{
|
|
17651
17709
|
type: i.RESERVED_KEYWORD,
|
|
17652
|
-
regex:
|
|
17710
|
+
regex: h(E.reservedKeywords, E.identChars),
|
|
17653
17711
|
text: B
|
|
17654
17712
|
}
|
|
17655
17713
|
]);
|
|
@@ -17661,12 +17719,12 @@ class II {
|
|
|
17661
17719
|
return this.validRules([
|
|
17662
17720
|
{
|
|
17663
17721
|
type: i.VARIABLE,
|
|
17664
|
-
regex: E.variableTypes ?
|
|
17722
|
+
regex: E.variableTypes ? TI(E.variableTypes) : void 0
|
|
17665
17723
|
},
|
|
17666
17724
|
{ type: i.STRING, regex: DT(E.stringTypes) },
|
|
17667
17725
|
{
|
|
17668
17726
|
type: i.IDENTIFIER,
|
|
17669
|
-
regex:
|
|
17727
|
+
regex: RI(E.identChars)
|
|
17670
17728
|
},
|
|
17671
17729
|
{ type: i.DELIMITER, regex: /[;]/uy },
|
|
17672
17730
|
{ type: i.COMMA, regex: /[,]/y },
|
|
@@ -17705,24 +17763,24 @@ class II {
|
|
|
17705
17763
|
// These rules can't be blindly cached as the paramTypesOverrides object
|
|
17706
17764
|
// can differ on each invocation of the format() function.
|
|
17707
17765
|
buildParamRules(E, R) {
|
|
17708
|
-
var A, S, e, O,
|
|
17766
|
+
var A, S, e, O, t;
|
|
17709
17767
|
const D = {
|
|
17710
17768
|
named: R?.named || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
|
|
17711
17769
|
quoted: R?.quoted || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.quoted) || [],
|
|
17712
17770
|
numbered: R?.numbered || ((e = E.paramTypes) === null || e === void 0 ? void 0 : e.numbered) || [],
|
|
17713
17771
|
positional: typeof R?.positional == "boolean" ? R.positional : (O = E.paramTypes) === null || O === void 0 ? void 0 : O.positional,
|
|
17714
|
-
custom: R?.custom || ((
|
|
17772
|
+
custom: R?.custom || ((t = E.paramTypes) === null || t === void 0 ? void 0 : t.custom) || []
|
|
17715
17773
|
};
|
|
17716
17774
|
return this.validRules([
|
|
17717
17775
|
{
|
|
17718
17776
|
type: i.NAMED_PARAMETER,
|
|
17719
|
-
regex: uE(D.named,
|
|
17777
|
+
regex: uE(D.named, pT(E.paramChars || E.identChars)),
|
|
17720
17778
|
key: (I) => I.slice(1)
|
|
17721
17779
|
},
|
|
17722
17780
|
{
|
|
17723
17781
|
type: i.QUOTED_PARAMETER,
|
|
17724
|
-
regex: uE(D.quoted,
|
|
17725
|
-
key: (I) => (({ tokenKey: N, quoteChar:
|
|
17782
|
+
regex: uE(D.quoted, mT(E.identTypes)),
|
|
17783
|
+
key: (I) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(d("\\" + s), "gu"), s))({
|
|
17726
17784
|
tokenKey: I.slice(2, -1),
|
|
17727
17785
|
quoteChar: I.slice(-1)
|
|
17728
17786
|
})
|
|
@@ -17741,7 +17799,7 @@ class II {
|
|
|
17741
17799
|
return {
|
|
17742
17800
|
type: i.CUSTOM_PARAMETER,
|
|
17743
17801
|
regex: b(I.regex),
|
|
17744
|
-
key: (N = I.key) !== null && N !== void 0 ? N : ((
|
|
17802
|
+
key: (N = I.key) !== null && N !== void 0 ? N : ((s) => s)
|
|
17745
17803
|
};
|
|
17746
17804
|
})
|
|
17747
17805
|
]);
|
|
@@ -17751,13 +17809,13 @@ class II {
|
|
|
17751
17809
|
return E.filter((R) => !!R.regex);
|
|
17752
17810
|
}
|
|
17753
17811
|
}
|
|
17754
|
-
const B = (T) =>
|
|
17812
|
+
const B = (T) => q(T.toUpperCase()), PT = /* @__PURE__ */ new Map(), NI = (T) => {
|
|
17755
17813
|
let E = PT.get(T);
|
|
17756
|
-
return E || (E =
|
|
17757
|
-
},
|
|
17758
|
-
tokenizer: new
|
|
17759
|
-
formatOptions:
|
|
17760
|
-
}),
|
|
17814
|
+
return E || (E = sI(T), PT.set(T, E)), E;
|
|
17815
|
+
}, sI = (T) => ({
|
|
17816
|
+
tokenizer: new OI(T.tokenizerOptions, T.name),
|
|
17817
|
+
formatOptions: tI(T.formatOptions)
|
|
17818
|
+
}), tI = (T) => {
|
|
17761
17819
|
var E;
|
|
17762
17820
|
return {
|
|
17763
17821
|
alwaysDenseOperators: T.alwaysDenseOperators || [],
|
|
@@ -17765,13 +17823,13 @@ const B = (T) => Z(T.toUpperCase()), PT = /* @__PURE__ */ new Map(), OI = (T) =>
|
|
|
17765
17823
|
tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((R) => [R, !0]))
|
|
17766
17824
|
};
|
|
17767
17825
|
};
|
|
17768
|
-
function
|
|
17826
|
+
function CI(T) {
|
|
17769
17827
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
|
|
17770
17828
|
}
|
|
17771
17829
|
function J(T) {
|
|
17772
17830
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
|
|
17773
17831
|
}
|
|
17774
|
-
class
|
|
17832
|
+
class LI {
|
|
17775
17833
|
constructor(E) {
|
|
17776
17834
|
this.params = E, this.index = 0;
|
|
17777
17835
|
}
|
|
@@ -17794,24 +17852,24 @@ class CI {
|
|
|
17794
17852
|
this.index = E;
|
|
17795
17853
|
}
|
|
17796
17854
|
}
|
|
17797
|
-
function
|
|
17855
|
+
function _I(T) {
|
|
17798
17856
|
return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
|
|
17799
17857
|
}
|
|
17800
|
-
var
|
|
17801
|
-
function
|
|
17802
|
-
return
|
|
17858
|
+
var j = { exports: {} }, rI = j.exports, oT;
|
|
17859
|
+
function nI() {
|
|
17860
|
+
return oT || (oT = 1, (function(T) {
|
|
17803
17861
|
(function(E, R) {
|
|
17804
17862
|
T.exports ? T.exports = R() : E.nearley = R();
|
|
17805
|
-
})(
|
|
17806
|
-
function E(I, N,
|
|
17807
|
-
return this.id = ++E.highestId, this.name = I, this.symbols = N, this.postprocess =
|
|
17863
|
+
})(rI, function() {
|
|
17864
|
+
function E(I, N, s) {
|
|
17865
|
+
return this.id = ++E.highestId, this.name = I, this.symbols = N, this.postprocess = s, this;
|
|
17808
17866
|
}
|
|
17809
17867
|
E.highestId = 0, E.prototype.toString = function(I) {
|
|
17810
17868
|
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
17869
|
return this.name + " → " + N;
|
|
17812
17870
|
};
|
|
17813
|
-
function R(I, N,
|
|
17814
|
-
this.rule = I, this.dot = N, this.reference =
|
|
17871
|
+
function R(I, N, s, L) {
|
|
17872
|
+
this.rule = I, this.dot = N, this.reference = s, this.data = [], this.wantedBy = L, this.isComplete = this.dot === I.symbols.length;
|
|
17815
17873
|
}
|
|
17816
17874
|
R.prototype.toString = function() {
|
|
17817
17875
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
@@ -17831,58 +17889,58 @@ function rI() {
|
|
|
17831
17889
|
this.grammar = I, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
17832
17890
|
}
|
|
17833
17891
|
A.prototype.process = function(I) {
|
|
17834
|
-
for (var N = this.states,
|
|
17835
|
-
var
|
|
17836
|
-
if (
|
|
17837
|
-
if (
|
|
17838
|
-
for (var r =
|
|
17839
|
-
var
|
|
17840
|
-
this.complete(
|
|
17892
|
+
for (var N = this.states, s = this.wants, L = this.completed, P = 0; P < N.length; P++) {
|
|
17893
|
+
var o = N[P];
|
|
17894
|
+
if (o.isComplete) {
|
|
17895
|
+
if (o.finish(), o.data !== O.fail) {
|
|
17896
|
+
for (var r = o.wantedBy, U = r.length; U--; ) {
|
|
17897
|
+
var a = r[U];
|
|
17898
|
+
this.complete(a, o);
|
|
17841
17899
|
}
|
|
17842
|
-
if (
|
|
17843
|
-
var l =
|
|
17844
|
-
(this.completed[l] = this.completed[l] || []).push(
|
|
17900
|
+
if (o.reference === this.index) {
|
|
17901
|
+
var l = o.rule.name;
|
|
17902
|
+
(this.completed[l] = this.completed[l] || []).push(o);
|
|
17845
17903
|
}
|
|
17846
17904
|
}
|
|
17847
17905
|
} else {
|
|
17848
|
-
var l =
|
|
17906
|
+
var l = o.rule.symbols[o.dot];
|
|
17849
17907
|
if (typeof l != "string") {
|
|
17850
|
-
this.scannable.push(
|
|
17908
|
+
this.scannable.push(o);
|
|
17851
17909
|
continue;
|
|
17852
17910
|
}
|
|
17853
|
-
if (
|
|
17854
|
-
if (
|
|
17911
|
+
if (s[l]) {
|
|
17912
|
+
if (s[l].push(o), L.hasOwnProperty(l))
|
|
17855
17913
|
for (var c = L[l], U = 0; U < c.length; U++) {
|
|
17856
17914
|
var H = c[U];
|
|
17857
|
-
this.complete(
|
|
17915
|
+
this.complete(o, H);
|
|
17858
17916
|
}
|
|
17859
17917
|
} else
|
|
17860
|
-
|
|
17918
|
+
s[l] = [o], this.predict(l);
|
|
17861
17919
|
}
|
|
17862
17920
|
}
|
|
17863
17921
|
}, A.prototype.predict = function(I) {
|
|
17864
|
-
for (var N = this.grammar.byName[I] || [],
|
|
17865
|
-
var L = N[
|
|
17866
|
-
this.states.push(
|
|
17922
|
+
for (var N = this.grammar.byName[I] || [], s = 0; s < N.length; s++) {
|
|
17923
|
+
var L = N[s], P = this.wants[I], o = new R(L, 0, this.index, P);
|
|
17924
|
+
this.states.push(o);
|
|
17867
17925
|
}
|
|
17868
17926
|
}, A.prototype.complete = function(I, N) {
|
|
17869
|
-
var
|
|
17870
|
-
this.states.push(
|
|
17927
|
+
var s = I.nextState(N);
|
|
17928
|
+
this.states.push(s);
|
|
17871
17929
|
};
|
|
17872
17930
|
function S(I, N) {
|
|
17873
17931
|
this.rules = I, this.start = N || this.rules[0].name;
|
|
17874
|
-
var
|
|
17932
|
+
var s = this.byName = {};
|
|
17875
17933
|
this.rules.forEach(function(L) {
|
|
17876
|
-
|
|
17934
|
+
s.hasOwnProperty(L.name) || (s[L.name] = []), s[L.name].push(L);
|
|
17877
17935
|
});
|
|
17878
17936
|
}
|
|
17879
17937
|
S.fromCompiled = function(L, N) {
|
|
17880
|
-
var
|
|
17938
|
+
var s = L.Lexer;
|
|
17881
17939
|
L.ParserStart && (N = L.ParserStart, L = L.ParserRules);
|
|
17882
|
-
var L = L.map(function(
|
|
17883
|
-
return new E(
|
|
17940
|
+
var L = L.map(function(o) {
|
|
17941
|
+
return new E(o.name, o.symbols, o.postprocess);
|
|
17884
17942
|
}), P = new S(L, N);
|
|
17885
|
-
return P.lexer =
|
|
17943
|
+
return P.lexer = s, P;
|
|
17886
17944
|
};
|
|
17887
17945
|
function e() {
|
|
17888
17946
|
this.reset("");
|
|
@@ -17901,119 +17959,119 @@ function rI() {
|
|
|
17901
17959
|
col: this.index - this.lastLineBreak
|
|
17902
17960
|
};
|
|
17903
17961
|
}, e.prototype.formatError = function(I, N) {
|
|
17904
|
-
var
|
|
17905
|
-
if (typeof
|
|
17906
|
-
var L =
|
|
17962
|
+
var s = this.buffer;
|
|
17963
|
+
if (typeof s == "string") {
|
|
17964
|
+
var L = s.split(`
|
|
17907
17965
|
`).slice(
|
|
17908
17966
|
Math.max(0, this.line - 5),
|
|
17909
17967
|
this.line
|
|
17910
|
-
), P =
|
|
17968
|
+
), P = s.indexOf(`
|
|
17911
17969
|
`, this.index);
|
|
17912
|
-
P === -1 && (P =
|
|
17913
|
-
var
|
|
17914
|
-
return N += " at line " + this.line + " col " +
|
|
17970
|
+
P === -1 && (P = s.length);
|
|
17971
|
+
var o = this.index - this.lastLineBreak, r = String(this.line).length;
|
|
17972
|
+
return N += " at line " + this.line + " col " + o + `:
|
|
17915
17973
|
|
|
17916
|
-
`, N += L.map(function(
|
|
17917
|
-
return U(this.line - L.length + l + 1, r) + " " +
|
|
17974
|
+
`, N += L.map(function(a, l) {
|
|
17975
|
+
return U(this.line - L.length + l + 1, r) + " " + a;
|
|
17918
17976
|
}, this).join(`
|
|
17919
17977
|
`), N += `
|
|
17920
|
-
` + U("", r +
|
|
17978
|
+
` + U("", r + o) + `^
|
|
17921
17979
|
`, N;
|
|
17922
17980
|
} else
|
|
17923
17981
|
return N + " at index " + (this.index - 1);
|
|
17924
|
-
function U(
|
|
17925
|
-
var c = String(
|
|
17982
|
+
function U(a, l) {
|
|
17983
|
+
var c = String(a);
|
|
17926
17984
|
return Array(l - c.length + 1).join(" ") + c;
|
|
17927
17985
|
}
|
|
17928
17986
|
};
|
|
17929
|
-
function O(I, N,
|
|
17987
|
+
function O(I, N, s) {
|
|
17930
17988
|
if (I instanceof S)
|
|
17931
|
-
var L = I,
|
|
17989
|
+
var L = I, s = N;
|
|
17932
17990
|
else
|
|
17933
17991
|
var L = S.fromCompiled(I, N);
|
|
17934
17992
|
this.grammar = L, this.options = {
|
|
17935
17993
|
keepHistory: !1,
|
|
17936
17994
|
lexer: L.lexer || new e()
|
|
17937
17995
|
};
|
|
17938
|
-
for (var P in
|
|
17939
|
-
this.options[P] =
|
|
17996
|
+
for (var P in s || {})
|
|
17997
|
+
this.options[P] = s[P];
|
|
17940
17998
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
17941
|
-
var
|
|
17942
|
-
this.table = [
|
|
17999
|
+
var o = new A(L, 0);
|
|
18000
|
+
this.table = [o], o.wants[L.start] = [], o.predict(L.start), o.process(), this.current = 0;
|
|
17943
18001
|
}
|
|
17944
18002
|
O.fail = {}, O.prototype.feed = function(I) {
|
|
17945
18003
|
var N = this.lexer;
|
|
17946
18004
|
N.reset(I, this.lexerState);
|
|
17947
|
-
for (var
|
|
18005
|
+
for (var s; ; ) {
|
|
17948
18006
|
try {
|
|
17949
|
-
if (
|
|
18007
|
+
if (s = N.next(), !s)
|
|
17950
18008
|
break;
|
|
17951
|
-
} catch (
|
|
18009
|
+
} catch (y) {
|
|
17952
18010
|
var r = new A(this.grammar, this.current + 1);
|
|
17953
18011
|
this.table.push(r);
|
|
17954
|
-
var L = new Error(this.reportLexerError(
|
|
17955
|
-
throw L.offset = this.current, L.token =
|
|
18012
|
+
var L = new Error(this.reportLexerError(y));
|
|
18013
|
+
throw L.offset = this.current, L.token = y.token, L;
|
|
17956
18014
|
}
|
|
17957
18015
|
var P = this.table[this.current];
|
|
17958
18016
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
17959
|
-
var
|
|
18017
|
+
var o = this.current + 1, r = new A(this.grammar, o);
|
|
17960
18018
|
this.table.push(r);
|
|
17961
|
-
for (var U =
|
|
18019
|
+
for (var U = s.text !== void 0 ? s.text : s.value, a = N.constructor === e ? s.value : s, l = P.scannable, c = l.length; c--; ) {
|
|
17962
18020
|
var H = l[c], u = H.rule.symbols[H.dot];
|
|
17963
|
-
if (u.test ? u.test(
|
|
17964
|
-
var p = H.nextState({ data:
|
|
18021
|
+
if (u.test ? u.test(a) : u.type ? u.type === s.type : u.literal === U) {
|
|
18022
|
+
var p = H.nextState({ data: a, token: s, isToken: !0, reference: o - 1 });
|
|
17965
18023
|
r.states.push(p);
|
|
17966
18024
|
}
|
|
17967
18025
|
}
|
|
17968
18026
|
if (r.process(), r.states.length === 0) {
|
|
17969
|
-
var L = new Error(this.reportError(
|
|
17970
|
-
throw L.offset = this.current, L.token =
|
|
18027
|
+
var L = new Error(this.reportError(s));
|
|
18028
|
+
throw L.offset = this.current, L.token = s, L;
|
|
17971
18029
|
}
|
|
17972
18030
|
this.options.keepHistory && (P.lexerState = N.save()), this.current++;
|
|
17973
18031
|
}
|
|
17974
18032
|
return P && (this.lexerState = N.save()), this.results = this.finish(), this;
|
|
17975
18033
|
}, O.prototype.reportLexerError = function(I) {
|
|
17976
|
-
var N,
|
|
17977
|
-
return L ? (N = "input " + JSON.stringify(L.text[0]) + " (lexer error)",
|
|
18034
|
+
var N, s, L = I.token;
|
|
18035
|
+
return L ? (N = "input " + JSON.stringify(L.text[0]) + " (lexer error)", s = this.lexer.formatError(L, "Syntax error")) : (N = "input (lexer error)", s = I.message), this.reportErrorCommon(s, N);
|
|
17978
18036
|
}, O.prototype.reportError = function(I) {
|
|
17979
|
-
var N = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I),
|
|
17980
|
-
return this.reportErrorCommon(
|
|
18037
|
+
var N = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), s = this.lexer.formatError(I, "Syntax error");
|
|
18038
|
+
return this.reportErrorCommon(s, N);
|
|
17981
18039
|
}, O.prototype.reportErrorCommon = function(I, N) {
|
|
17982
|
-
var
|
|
17983
|
-
|
|
17984
|
-
var L = this.table.length - 2, P = this.table[L],
|
|
17985
|
-
var
|
|
17986
|
-
return
|
|
18040
|
+
var s = [];
|
|
18041
|
+
s.push(I);
|
|
18042
|
+
var L = this.table.length - 2, P = this.table[L], o = P.states.filter(function(U) {
|
|
18043
|
+
var a = U.rule.symbols[U.dot];
|
|
18044
|
+
return a && typeof a != "string";
|
|
17987
18045
|
});
|
|
17988
|
-
if (
|
|
17989
|
-
|
|
17990
|
-
`), this.displayStateStack(P.states,
|
|
18046
|
+
if (o.length === 0)
|
|
18047
|
+
s.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
|
|
18048
|
+
`), this.displayStateStack(P.states, s);
|
|
17991
18049
|
else {
|
|
17992
|
-
|
|
18050
|
+
s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
17993
18051
|
`);
|
|
17994
|
-
var r =
|
|
18052
|
+
var r = o.map(function(U) {
|
|
17995
18053
|
return this.buildFirstStateStack(U, []) || [U];
|
|
17996
18054
|
}, this);
|
|
17997
18055
|
r.forEach(function(U) {
|
|
17998
|
-
var
|
|
17999
|
-
|
|
18056
|
+
var a = U[0], l = a.rule.symbols[a.dot], c = this.getSymbolDisplay(l);
|
|
18057
|
+
s.push("A " + c + " based on:"), this.displayStateStack(U, s);
|
|
18000
18058
|
}, this);
|
|
18001
18059
|
}
|
|
18002
|
-
return
|
|
18060
|
+
return s.push(""), s.join(`
|
|
18003
18061
|
`);
|
|
18004
18062
|
}, O.prototype.displayStateStack = function(I, N) {
|
|
18005
|
-
for (var
|
|
18006
|
-
var
|
|
18007
|
-
r ===
|
|
18063
|
+
for (var s, L = 0, P = 0; P < I.length; P++) {
|
|
18064
|
+
var o = I[P], r = o.rule.toString(o.dot);
|
|
18065
|
+
r === s ? L++ : (L > 0 && N.push(" ^ " + L + " more lines identical to this"), L = 0, N.push(" " + r)), s = r;
|
|
18008
18066
|
}
|
|
18009
18067
|
}, O.prototype.getSymbolDisplay = function(I) {
|
|
18010
|
-
return
|
|
18068
|
+
return t(I);
|
|
18011
18069
|
}, O.prototype.buildFirstStateStack = function(I, N) {
|
|
18012
18070
|
if (N.indexOf(I) !== -1)
|
|
18013
18071
|
return null;
|
|
18014
18072
|
if (I.wantedBy.length === 0)
|
|
18015
18073
|
return [I];
|
|
18016
|
-
var
|
|
18074
|
+
var s = I.wantedBy[0], L = [I].concat(N), P = this.buildFirstStateStack(s, L);
|
|
18017
18075
|
return P === null ? null : [I].concat(P);
|
|
18018
18076
|
}, O.prototype.save = function() {
|
|
18019
18077
|
var I = this.table[this.current];
|
|
@@ -18026,14 +18084,14 @@ function rI() {
|
|
|
18026
18084
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
18027
18085
|
this.restore(this.table[I]);
|
|
18028
18086
|
}, O.prototype.finish = function() {
|
|
18029
|
-
var I = [], N = this.grammar.start,
|
|
18030
|
-
return
|
|
18087
|
+
var I = [], N = this.grammar.start, s = this.table[this.table.length - 1];
|
|
18088
|
+
return s.states.forEach(function(L) {
|
|
18031
18089
|
L.rule.name === N && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== O.fail && I.push(L);
|
|
18032
18090
|
}), I.map(function(L) {
|
|
18033
18091
|
return L.data;
|
|
18034
18092
|
});
|
|
18035
18093
|
};
|
|
18036
|
-
function
|
|
18094
|
+
function t(I) {
|
|
18037
18095
|
var N = typeof I;
|
|
18038
18096
|
if (N === "string")
|
|
18039
18097
|
return I;
|
|
@@ -18071,58 +18129,58 @@ function rI() {
|
|
|
18071
18129
|
Rule: E
|
|
18072
18130
|
};
|
|
18073
18131
|
});
|
|
18074
|
-
})(
|
|
18132
|
+
})(j)), j.exports;
|
|
18075
18133
|
}
|
|
18076
|
-
var
|
|
18077
|
-
const
|
|
18078
|
-
function
|
|
18079
|
-
return T.map(
|
|
18134
|
+
var DI = nI();
|
|
18135
|
+
const iI = /* @__PURE__ */ _I(DI);
|
|
18136
|
+
function PI(T) {
|
|
18137
|
+
return T.map(oI).map(aI).map(MI).map(UI).map(GI);
|
|
18080
18138
|
}
|
|
18081
|
-
const
|
|
18082
|
-
if (
|
|
18083
|
-
const A =
|
|
18139
|
+
const oI = (T, E, R) => {
|
|
18140
|
+
if (BT(T.type)) {
|
|
18141
|
+
const A = cI(R, E);
|
|
18084
18142
|
if (A && A.type === i.PROPERTY_ACCESS_OPERATOR)
|
|
18085
18143
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18086
|
-
const S =
|
|
18144
|
+
const S = v(R, E);
|
|
18087
18145
|
if (S && S.type === i.PROPERTY_ACCESS_OPERATOR)
|
|
18088
18146
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18089
18147
|
}
|
|
18090
18148
|
return T;
|
|
18091
18149
|
}, aI = (T, E, R) => {
|
|
18092
18150
|
if (T.type === i.RESERVED_FUNCTION_NAME) {
|
|
18093
|
-
const A =
|
|
18094
|
-
if (!A || !
|
|
18151
|
+
const A = v(R, E);
|
|
18152
|
+
if (!A || !hT(A))
|
|
18095
18153
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18096
18154
|
}
|
|
18097
18155
|
return T;
|
|
18098
|
-
},
|
|
18156
|
+
}, MI = (T, E, R) => {
|
|
18099
18157
|
if (T.type === i.RESERVED_DATA_TYPE) {
|
|
18100
|
-
const A =
|
|
18101
|
-
if (A &&
|
|
18158
|
+
const A = v(R, E);
|
|
18159
|
+
if (A && hT(A))
|
|
18102
18160
|
return Object.assign(Object.assign({}, T), { type: i.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
18103
18161
|
}
|
|
18104
18162
|
return T;
|
|
18105
|
-
},
|
|
18163
|
+
}, UI = (T, E, R) => {
|
|
18106
18164
|
if (T.type === i.IDENTIFIER) {
|
|
18107
|
-
const A =
|
|
18165
|
+
const A = v(R, E);
|
|
18108
18166
|
if (A && VT(A))
|
|
18109
18167
|
return Object.assign(Object.assign({}, T), { type: i.ARRAY_IDENTIFIER });
|
|
18110
18168
|
}
|
|
18111
18169
|
return T;
|
|
18112
|
-
},
|
|
18170
|
+
}, GI = (T, E, R) => {
|
|
18113
18171
|
if (T.type === i.RESERVED_DATA_TYPE) {
|
|
18114
|
-
const A =
|
|
18172
|
+
const A = v(R, E);
|
|
18115
18173
|
if (A && VT(A))
|
|
18116
18174
|
return Object.assign(Object.assign({}, T), { type: i.ARRAY_KEYWORD });
|
|
18117
18175
|
}
|
|
18118
18176
|
return T;
|
|
18119
|
-
},
|
|
18177
|
+
}, cI = (T, E) => v(T, E, -1), v = (T, E, R = 1) => {
|
|
18120
18178
|
let A = 1;
|
|
18121
|
-
for (; T[E + A * R] &&
|
|
18179
|
+
for (; T[E + A * R] && lI(T[E + A * R]); )
|
|
18122
18180
|
A++;
|
|
18123
18181
|
return T[E + A * R];
|
|
18124
|
-
},
|
|
18125
|
-
class
|
|
18182
|
+
}, hT = (T) => T.type === i.OPEN_PAREN && T.text === "(", VT = (T) => T.type === i.OPEN_PAREN && T.text === "[", lI = (T) => T.type === i.BLOCK_COMMENT || T.type === i.LINE_COMMENT;
|
|
18183
|
+
class fT {
|
|
18126
18184
|
constructor(E) {
|
|
18127
18185
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
18128
18186
|
}
|
|
@@ -18135,7 +18193,7 @@ class hT {
|
|
|
18135
18193
|
save() {
|
|
18136
18194
|
}
|
|
18137
18195
|
formatError(E) {
|
|
18138
|
-
const { line: R, col: A } =
|
|
18196
|
+
const { line: R, col: A } = dT(this.input, E.start);
|
|
18139
18197
|
return `Parse error at token: ${E.text} at line ${R} column ${A}`;
|
|
18140
18198
|
}
|
|
18141
18199
|
has(E) {
|
|
@@ -18149,16 +18207,16 @@ var M;
|
|
|
18149
18207
|
function BE(T) {
|
|
18150
18208
|
return T[0];
|
|
18151
18209
|
}
|
|
18152
|
-
const G = new
|
|
18210
|
+
const G = new fT((T) => []), V = ([[T]]) => T, F = (T) => ({
|
|
18153
18211
|
type: M.keyword,
|
|
18154
18212
|
tokenType: T.type,
|
|
18155
18213
|
text: T.text,
|
|
18156
18214
|
raw: T.raw
|
|
18157
|
-
}),
|
|
18215
|
+
}), aT = (T) => ({
|
|
18158
18216
|
type: M.data_type,
|
|
18159
18217
|
text: T.text,
|
|
18160
18218
|
raw: T.raw
|
|
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),
|
|
18219
|
+
}), 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), HI = (T, { leading: E, trailing: R }) => {
|
|
18162
18220
|
if (E?.length) {
|
|
18163
18221
|
const [A, ...S] = T;
|
|
18164
18222
|
T = [Y(A, { leading: E }), ...S];
|
|
@@ -18168,7 +18226,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18168
18226
|
T = [...A, Y(S, { trailing: R })];
|
|
18169
18227
|
}
|
|
18170
18228
|
return T;
|
|
18171
|
-
},
|
|
18229
|
+
}, uI = {
|
|
18172
18230
|
Lexer: G,
|
|
18173
18231
|
ParserRules: [
|
|
18174
18232
|
{ name: "main$ebnf$1", symbols: [] },
|
|
@@ -18205,7 +18263,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18205
18263
|
{ name: "clause$subexpression$1", symbols: ["select_clause"] },
|
|
18206
18264
|
{ name: "clause$subexpression$1", symbols: ["other_clause"] },
|
|
18207
18265
|
{ name: "clause$subexpression$1", symbols: ["set_operation"] },
|
|
18208
|
-
{ name: "clause", symbols: ["clause$subexpression$1"], postprocess:
|
|
18266
|
+
{ name: "clause", symbols: ["clause$subexpression$1"], postprocess: V },
|
|
18209
18267
|
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
|
|
18210
18268
|
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
18211
18269
|
{ name: "limit_clause$ebnf$1$subexpression$1", symbols: [G.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
|
|
@@ -18316,23 +18374,23 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18316
18374
|
},
|
|
18317
18375
|
{ name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
|
|
18318
18376
|
{ name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
|
|
18319
|
-
{ name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess:
|
|
18377
|
+
{ name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess: V },
|
|
18320
18378
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
18321
18379
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["logic_operator"] },
|
|
18322
18380
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comma"] },
|
|
18323
18381
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comment"] },
|
|
18324
18382
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["other_keyword"] },
|
|
18325
|
-
{ name: "asteriskless_free_form_sql", symbols: ["asteriskless_free_form_sql$subexpression$1"], postprocess:
|
|
18383
|
+
{ name: "asteriskless_free_form_sql", symbols: ["asteriskless_free_form_sql$subexpression$1"], postprocess: V },
|
|
18326
18384
|
{ name: "expression$subexpression$1", symbols: ["andless_expression"] },
|
|
18327
18385
|
{ name: "expression$subexpression$1", symbols: ["logic_operator"] },
|
|
18328
|
-
{ name: "expression", symbols: ["expression$subexpression$1"], postprocess:
|
|
18386
|
+
{ name: "expression", symbols: ["expression$subexpression$1"], postprocess: V },
|
|
18329
18387
|
{ name: "andless_expression$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
18330
18388
|
{ name: "andless_expression$subexpression$1", symbols: ["asterisk"] },
|
|
18331
|
-
{ name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess:
|
|
18389
|
+
{ name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess: V },
|
|
18332
18390
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["atomic_expression"] },
|
|
18333
18391
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["between_predicate"] },
|
|
18334
18392
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["case_expression"] },
|
|
18335
|
-
{ name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess:
|
|
18393
|
+
{ name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess: V },
|
|
18336
18394
|
{ name: "atomic_expression$subexpression$1", symbols: ["array_subscript"] },
|
|
18337
18395
|
{ name: "atomic_expression$subexpression$1", symbols: ["function_call"] },
|
|
18338
18396
|
{ name: "atomic_expression$subexpression$1", symbols: ["property_access"] },
|
|
@@ -18345,7 +18403,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18345
18403
|
{ name: "atomic_expression$subexpression$1", symbols: ["literal"] },
|
|
18346
18404
|
{ name: "atomic_expression$subexpression$1", symbols: ["data_type"] },
|
|
18347
18405
|
{ name: "atomic_expression$subexpression$1", symbols: ["keyword"] },
|
|
18348
|
-
{ name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess:
|
|
18406
|
+
{ name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess: V },
|
|
18349
18407
|
{
|
|
18350
18408
|
name: "array_subscript",
|
|
18351
18409
|
symbols: [G.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
|
|
@@ -18433,7 +18491,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18433
18491
|
postprocess: ([T, E, R, A, S, e, O]) => ({
|
|
18434
18492
|
type: M.between_predicate,
|
|
18435
18493
|
betweenKw: F(T),
|
|
18436
|
-
expr1:
|
|
18494
|
+
expr1: HI(R, { leading: E, trailing: A }),
|
|
18437
18495
|
andKw: F(S),
|
|
18438
18496
|
expr2: [Y(O, { leading: e })]
|
|
18439
18497
|
})
|
|
@@ -18505,14 +18563,14 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18505
18563
|
{
|
|
18506
18564
|
name: "data_type",
|
|
18507
18565
|
symbols: ["data_type$subexpression$1"],
|
|
18508
|
-
postprocess: ([[T]]) =>
|
|
18566
|
+
postprocess: ([[T]]) => aT(T)
|
|
18509
18567
|
},
|
|
18510
18568
|
{
|
|
18511
18569
|
name: "data_type",
|
|
18512
18570
|
symbols: [G.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
18513
18571
|
postprocess: ([T, E, R]) => ({
|
|
18514
18572
|
type: M.parameterized_data_type,
|
|
18515
|
-
dataType: Y(
|
|
18573
|
+
dataType: Y(aT(T), { trailing: E }),
|
|
18516
18574
|
parenthesis: R
|
|
18517
18575
|
})
|
|
18518
18576
|
},
|
|
@@ -18565,13 +18623,13 @@ const G = new hT((T) => []), h = ([[T]]) => T, F = (T) => ({
|
|
|
18565
18623
|
}
|
|
18566
18624
|
],
|
|
18567
18625
|
ParserStart: "main"
|
|
18568
|
-
}, { Parser:
|
|
18569
|
-
function
|
|
18626
|
+
}, { Parser: BI, Grammar: FI } = iI;
|
|
18627
|
+
function YI(T) {
|
|
18570
18628
|
let E = {};
|
|
18571
|
-
const R = new
|
|
18572
|
-
...
|
|
18573
|
-
|
|
18574
|
-
]), A = new
|
|
18629
|
+
const R = new fT((S) => [
|
|
18630
|
+
...PI(T.tokenize(S, E)),
|
|
18631
|
+
uT(S.length)
|
|
18632
|
+
]), A = new BI(FI.fromCompiled(uI), { lexer: R });
|
|
18575
18633
|
return {
|
|
18576
18634
|
parse: (S, e) => {
|
|
18577
18635
|
E = e;
|
|
@@ -18587,7 +18645,7 @@ var n;
|
|
|
18587
18645
|
(function(T) {
|
|
18588
18646
|
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";
|
|
18589
18647
|
})(n = n || (n = {}));
|
|
18590
|
-
class
|
|
18648
|
+
class WT {
|
|
18591
18649
|
constructor(E) {
|
|
18592
18650
|
this.indentation = E, this.items = [];
|
|
18593
18651
|
}
|
|
@@ -18623,16 +18681,16 @@ class fT {
|
|
|
18623
18681
|
}
|
|
18624
18682
|
}
|
|
18625
18683
|
trimHorizontalWhitespace() {
|
|
18626
|
-
for (;
|
|
18684
|
+
for (; mI(Q(this.items)); )
|
|
18627
18685
|
this.items.pop();
|
|
18628
18686
|
}
|
|
18629
18687
|
trimWhitespace() {
|
|
18630
|
-
for (;
|
|
18688
|
+
for (; pI(Q(this.items)); )
|
|
18631
18689
|
this.items.pop();
|
|
18632
18690
|
}
|
|
18633
18691
|
addNewline(E) {
|
|
18634
18692
|
if (this.items.length > 0)
|
|
18635
|
-
switch (
|
|
18693
|
+
switch (Q(this.items)) {
|
|
18636
18694
|
case n.NEWLINE:
|
|
18637
18695
|
this.items.pop(), this.items.push(E);
|
|
18638
18696
|
break;
|
|
@@ -18674,7 +18732,7 @@ class fT {
|
|
|
18674
18732
|
}
|
|
18675
18733
|
}
|
|
18676
18734
|
}
|
|
18677
|
-
const
|
|
18735
|
+
const mI = (T) => T === n.SPACE || T === n.SINGLE_INDENT, pI = (T) => T === n.SPACE || T === n.SINGLE_INDENT || T === n.NEWLINE;
|
|
18678
18736
|
function MT(T, E) {
|
|
18679
18737
|
if (E === "standard")
|
|
18680
18738
|
return T;
|
|
@@ -18682,10 +18740,10 @@ function MT(T, E) {
|
|
|
18682
18740
|
return T.length >= 10 && T.includes(" ") && ([T, ...R] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...R].join(" ");
|
|
18683
18741
|
}
|
|
18684
18742
|
function UT(T) {
|
|
18685
|
-
return
|
|
18743
|
+
return _R(T) || T === i.RESERVED_CLAUSE || T === i.RESERVED_SELECT || T === i.RESERVED_SET_OPERATION || T === i.RESERVED_JOIN || T === i.LIMIT;
|
|
18686
18744
|
}
|
|
18687
|
-
const FE = "top-level",
|
|
18688
|
-
class
|
|
18745
|
+
const FE = "top-level", dI = "block-level";
|
|
18746
|
+
class XT {
|
|
18689
18747
|
/**
|
|
18690
18748
|
* @param {string} indent A string to indent with
|
|
18691
18749
|
*/
|
|
@@ -18714,14 +18772,14 @@ class WT {
|
|
|
18714
18772
|
* Increases indentation by one block-level indent.
|
|
18715
18773
|
*/
|
|
18716
18774
|
increaseBlockLevel() {
|
|
18717
|
-
this.indentTypes.push(
|
|
18775
|
+
this.indentTypes.push(dI);
|
|
18718
18776
|
}
|
|
18719
18777
|
/**
|
|
18720
18778
|
* Decreases indentation by one top-level indent.
|
|
18721
18779
|
* Does nothing when the previous indent is not top-level.
|
|
18722
18780
|
*/
|
|
18723
18781
|
decreaseTopLevel() {
|
|
18724
|
-
this.indentTypes.length > 0 &&
|
|
18782
|
+
this.indentTypes.length > 0 && Q(this.indentTypes) === FE && this.indentTypes.pop();
|
|
18725
18783
|
}
|
|
18726
18784
|
/**
|
|
18727
18785
|
* Decreases indentation by one block-level indent.
|
|
@@ -18733,9 +18791,9 @@ class WT {
|
|
|
18733
18791
|
;
|
|
18734
18792
|
}
|
|
18735
18793
|
}
|
|
18736
|
-
class
|
|
18794
|
+
class hI extends WT {
|
|
18737
18795
|
constructor(E) {
|
|
18738
|
-
super(new
|
|
18796
|
+
super(new XT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
18739
18797
|
}
|
|
18740
18798
|
add(...E) {
|
|
18741
18799
|
if (E.forEach((R) => this.addToLength(R)), this.length > this.expressionWidth)
|
|
@@ -18928,7 +18986,7 @@ class z {
|
|
|
18928
18986
|
// first line starts with /* or /**
|
|
18929
18987
|
/^\/\*\*?$/.test(R[0]) && // intermediate lines start with *
|
|
18930
18988
|
R.slice(1, R.length - 1).every((A) => /^\s*\*/.test(A)) && // last line ends with */
|
|
18931
|
-
/^\s*\*\/$/.test(
|
|
18989
|
+
/^\s*\*\/$/.test(Q(R))
|
|
18932
18990
|
);
|
|
18933
18991
|
}
|
|
18934
18992
|
// Breaks up block comment to multiple lines.
|
|
@@ -18977,7 +19035,7 @@ class z {
|
|
|
18977
19035
|
cfg: this.cfg,
|
|
18978
19036
|
dialectCfg: this.dialectCfg,
|
|
18979
19037
|
params: this.params,
|
|
18980
|
-
layout: new
|
|
19038
|
+
layout: new hI(this.cfg.expressionWidth),
|
|
18981
19039
|
inline: !0
|
|
18982
19040
|
}).format(E);
|
|
18983
19041
|
} catch (A) {
|
|
@@ -19019,7 +19077,7 @@ class z {
|
|
|
19019
19077
|
showNonTabularKw(E) {
|
|
19020
19078
|
switch (this.cfg.keywordCase) {
|
|
19021
19079
|
case "preserve":
|
|
19022
|
-
return
|
|
19080
|
+
return q(E.raw);
|
|
19023
19081
|
case "upper":
|
|
19024
19082
|
return E.text;
|
|
19025
19083
|
case "lower":
|
|
@@ -19033,7 +19091,7 @@ class z {
|
|
|
19033
19091
|
showNonTabularFunctionKw(E) {
|
|
19034
19092
|
switch (this.cfg.functionCase) {
|
|
19035
19093
|
case "preserve":
|
|
19036
|
-
return
|
|
19094
|
+
return q(E.raw);
|
|
19037
19095
|
case "upper":
|
|
19038
19096
|
return E.text;
|
|
19039
19097
|
case "lower":
|
|
@@ -19055,7 +19113,7 @@ class z {
|
|
|
19055
19113
|
showDataType(E) {
|
|
19056
19114
|
switch (this.cfg.dataTypeCase) {
|
|
19057
19115
|
case "preserve":
|
|
19058
|
-
return
|
|
19116
|
+
return q(E.raw);
|
|
19059
19117
|
case "upper":
|
|
19060
19118
|
return E.text;
|
|
19061
19119
|
case "lower":
|
|
@@ -19065,7 +19123,7 @@ class z {
|
|
|
19065
19123
|
}
|
|
19066
19124
|
class VI {
|
|
19067
19125
|
constructor(E, R) {
|
|
19068
|
-
this.dialect = E, this.cfg = R, this.params = new
|
|
19126
|
+
this.dialect = E, this.cfg = R, this.params = new LI(this.cfg.params);
|
|
19069
19127
|
}
|
|
19070
19128
|
/**
|
|
19071
19129
|
* Formats an SQL query.
|
|
@@ -19077,7 +19135,7 @@ class VI {
|
|
|
19077
19135
|
return this.formatAst(R).trimEnd();
|
|
19078
19136
|
}
|
|
19079
19137
|
parse(E) {
|
|
19080
|
-
return
|
|
19138
|
+
return YI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
|
|
19081
19139
|
}
|
|
19082
19140
|
formatAst(E) {
|
|
19083
19141
|
return E.map((R) => this.formatStatement(R)).join(`
|
|
@@ -19088,14 +19146,14 @@ class VI {
|
|
|
19088
19146
|
cfg: this.cfg,
|
|
19089
19147
|
dialectCfg: this.dialect.formatOptions,
|
|
19090
19148
|
params: this.params,
|
|
19091
|
-
layout: new
|
|
19149
|
+
layout: new WT(new XT(CI(this.cfg)))
|
|
19092
19150
|
}).format(E.children);
|
|
19093
19151
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(n.NEWLINE, ";") : R.add(n.NO_NEWLINE, ";")), R.toString();
|
|
19094
19152
|
}
|
|
19095
19153
|
}
|
|
19096
19154
|
class k extends Error {
|
|
19097
19155
|
}
|
|
19098
|
-
function
|
|
19156
|
+
function fI(T) {
|
|
19099
19157
|
const E = [
|
|
19100
19158
|
"multilineLists",
|
|
19101
19159
|
"newlineBeforeOpenParen",
|
|
@@ -19109,17 +19167,17 @@ function hI(T) {
|
|
|
19109
19167
|
throw new k(`${R} config is no more supported.`);
|
|
19110
19168
|
if (T.expressionWidth <= 0)
|
|
19111
19169
|
throw new k(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
19112
|
-
if (T.params && !
|
|
19170
|
+
if (T.params && !WI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !XI(T.paramTypes))
|
|
19113
19171
|
throw new k("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
19114
19172
|
return T;
|
|
19115
19173
|
}
|
|
19116
|
-
function
|
|
19174
|
+
function WI(T) {
|
|
19117
19175
|
return (T instanceof Array ? T : Object.values(T)).every((R) => typeof R == "string");
|
|
19118
19176
|
}
|
|
19119
|
-
function
|
|
19177
|
+
function XI(T) {
|
|
19120
19178
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
19121
19179
|
}
|
|
19122
|
-
var
|
|
19180
|
+
var bI = function(T, E) {
|
|
19123
19181
|
var R = {};
|
|
19124
19182
|
for (var A in T) Object.prototype.hasOwnProperty.call(T, A) && E.indexOf(A) < 0 && (R[A] = T[A]);
|
|
19125
19183
|
if (T != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -19127,7 +19185,7 @@ var XI = function(T, E) {
|
|
|
19127
19185
|
E.indexOf(A[S]) < 0 && Object.prototype.propertyIsEnumerable.call(T, A[S]) && (R[A[S]] = T[A[S]]);
|
|
19128
19186
|
return R;
|
|
19129
19187
|
};
|
|
19130
|
-
const
|
|
19188
|
+
const bT = {
|
|
19131
19189
|
bigquery: "bigquery",
|
|
19132
19190
|
db2: "db2",
|
|
19133
19191
|
db2i: "db2i",
|
|
@@ -19148,7 +19206,7 @@ const XT = {
|
|
|
19148
19206
|
tsql: "transactsql",
|
|
19149
19207
|
singlestoredb: "singlestoredb",
|
|
19150
19208
|
snowflake: "snowflake"
|
|
19151
|
-
},
|
|
19209
|
+
}, yI = Object.keys(bT), KI = {
|
|
19152
19210
|
tabWidth: 2,
|
|
19153
19211
|
useTabs: !1,
|
|
19154
19212
|
keywordCase: "preserve",
|
|
@@ -19161,21 +19219,21 @@ const XT = {
|
|
|
19161
19219
|
linesBetweenQueries: 1,
|
|
19162
19220
|
denseOperators: !1,
|
|
19163
19221
|
newlineBeforeSemicolon: !1
|
|
19164
|
-
},
|
|
19165
|
-
if (typeof E.language == "string" && !
|
|
19222
|
+
}, $I = (T, E = {}) => {
|
|
19223
|
+
if (typeof E.language == "string" && !yI.includes(E.language))
|
|
19166
19224
|
throw new k(`Unsupported SQL dialect: ${E.language}`);
|
|
19167
|
-
const R =
|
|
19168
|
-
return
|
|
19169
|
-
},
|
|
19170
|
-
var { dialect: R } = E, A =
|
|
19225
|
+
const R = bT[E.language || "sql"];
|
|
19226
|
+
return gI(T, Object.assign(Object.assign({}, E), { dialect: Qe[R] }));
|
|
19227
|
+
}, gI = (T, E) => {
|
|
19228
|
+
var { dialect: R } = E, A = bI(E, ["dialect"]);
|
|
19171
19229
|
if (typeof T != "string")
|
|
19172
19230
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
|
|
19173
|
-
const S =
|
|
19174
|
-
return new VI(
|
|
19231
|
+
const S = fI(Object.assign(Object.assign({}, KI), A));
|
|
19232
|
+
return new VI(NI(R), S).format(T);
|
|
19175
19233
|
};
|
|
19176
19234
|
function GT(T, E) {
|
|
19177
19235
|
try {
|
|
19178
|
-
return
|
|
19236
|
+
return $I(T, {
|
|
19179
19237
|
language: {
|
|
19180
19238
|
postgres: "postgresql",
|
|
19181
19239
|
mysql: "mysql",
|
|
@@ -19308,9 +19366,9 @@ class fE {
|
|
|
19308
19366
|
*/
|
|
19309
19367
|
generateCubeMetadata(E) {
|
|
19310
19368
|
const R = Object.keys(E.measures), A = Object.keys(E.dimensions), S = new Array(R.length), e = new Array(A.length);
|
|
19311
|
-
for (let
|
|
19312
|
-
const D = R[
|
|
19313
|
-
S[
|
|
19369
|
+
for (let t = 0; t < R.length; t++) {
|
|
19370
|
+
const D = R[t], I = E.measures[D];
|
|
19371
|
+
S[t] = {
|
|
19314
19372
|
name: `${E.name}.${D}`,
|
|
19315
19373
|
title: I.title || D,
|
|
19316
19374
|
shortTitle: I.title || D,
|
|
@@ -19320,9 +19378,9 @@ class fE {
|
|
|
19320
19378
|
description: I.description
|
|
19321
19379
|
};
|
|
19322
19380
|
}
|
|
19323
|
-
for (let
|
|
19324
|
-
const D = A[
|
|
19325
|
-
e[
|
|
19381
|
+
for (let t = 0; t < A.length; t++) {
|
|
19382
|
+
const D = A[t], I = E.dimensions[D];
|
|
19383
|
+
e[t] = {
|
|
19326
19384
|
name: `${E.name}.${D}`,
|
|
19327
19385
|
title: I.title || D,
|
|
19328
19386
|
shortTitle: I.title || D,
|
|
@@ -19334,12 +19392,12 @@ class fE {
|
|
|
19334
19392
|
}
|
|
19335
19393
|
const O = [];
|
|
19336
19394
|
if (E.joins)
|
|
19337
|
-
for (const [,
|
|
19338
|
-
const D = typeof
|
|
19395
|
+
for (const [, t] of Object.entries(E.joins)) {
|
|
19396
|
+
const D = typeof t.targetCube == "function" ? t.targetCube() : t.targetCube;
|
|
19339
19397
|
O.push({
|
|
19340
19398
|
targetCube: D.name,
|
|
19341
|
-
relationship:
|
|
19342
|
-
joinFields:
|
|
19399
|
+
relationship: t.relationship,
|
|
19400
|
+
joinFields: t.on.map((I) => ({
|
|
19343
19401
|
sourceField: this.getColumnName(I.source),
|
|
19344
19402
|
targetField: this.getColumnName(I.target)
|
|
19345
19403
|
}))
|
|
@@ -19365,9 +19423,9 @@ class fE {
|
|
|
19365
19423
|
throw new Error(`Cube '${E}' not found`);
|
|
19366
19424
|
if (!this.dbExecutor)
|
|
19367
19425
|
throw new Error("Database executor not configured");
|
|
19368
|
-
const O = await new OE(this.dbExecutor).generateSQL(S, R, A),
|
|
19426
|
+
const O = await new OE(this.dbExecutor).generateSQL(S, R, A), t = this.dbExecutor.getEngineType();
|
|
19369
19427
|
return {
|
|
19370
|
-
sql: GT(O.sql,
|
|
19428
|
+
sql: GT(O.sql, t),
|
|
19371
19429
|
params: O.params
|
|
19372
19430
|
};
|
|
19373
19431
|
}
|
|
@@ -19420,10 +19478,10 @@ class fE {
|
|
|
19420
19478
|
* Ensures all referenced cubes and fields exist
|
|
19421
19479
|
*/
|
|
19422
19480
|
validateQuery(E) {
|
|
19423
|
-
return
|
|
19481
|
+
return yT(this.cubes, E);
|
|
19424
19482
|
}
|
|
19425
19483
|
}
|
|
19426
|
-
function
|
|
19484
|
+
function yT(T, E) {
|
|
19427
19485
|
const R = [], A = /* @__PURE__ */ new Set();
|
|
19428
19486
|
if (E.measures)
|
|
19429
19487
|
for (const S of E.measures) {
|
|
@@ -19433,12 +19491,12 @@ function bT(T, E) {
|
|
|
19433
19491
|
continue;
|
|
19434
19492
|
}
|
|
19435
19493
|
A.add(e);
|
|
19436
|
-
const
|
|
19437
|
-
if (!
|
|
19494
|
+
const t = T.get(e);
|
|
19495
|
+
if (!t) {
|
|
19438
19496
|
R.push(`Cube '${e}' not found (referenced in measure '${S}')`);
|
|
19439
19497
|
continue;
|
|
19440
19498
|
}
|
|
19441
|
-
|
|
19499
|
+
t.measures[O] || R.push(`Measure '${O}' not found on cube '${e}'`);
|
|
19442
19500
|
}
|
|
19443
19501
|
if (E.dimensions)
|
|
19444
19502
|
for (const S of E.dimensions) {
|
|
@@ -19448,12 +19506,12 @@ function bT(T, E) {
|
|
|
19448
19506
|
continue;
|
|
19449
19507
|
}
|
|
19450
19508
|
A.add(e);
|
|
19451
|
-
const
|
|
19452
|
-
if (!
|
|
19509
|
+
const t = T.get(e);
|
|
19510
|
+
if (!t) {
|
|
19453
19511
|
R.push(`Cube '${e}' not found (referenced in dimension '${S}')`);
|
|
19454
19512
|
continue;
|
|
19455
19513
|
}
|
|
19456
|
-
|
|
19514
|
+
t.dimensions[O] || R.push(`Dimension '${O}' not found on cube '${e}'`);
|
|
19457
19515
|
}
|
|
19458
19516
|
if (E.timeDimensions)
|
|
19459
19517
|
for (const S of E.timeDimensions) {
|
|
@@ -19463,12 +19521,12 @@ function bT(T, E) {
|
|
|
19463
19521
|
continue;
|
|
19464
19522
|
}
|
|
19465
19523
|
A.add(e);
|
|
19466
|
-
const
|
|
19467
|
-
if (!
|
|
19524
|
+
const t = T.get(e);
|
|
19525
|
+
if (!t) {
|
|
19468
19526
|
R.push(`Cube '${e}' not found (referenced in timeDimension '${S.dimension}')`);
|
|
19469
19527
|
continue;
|
|
19470
19528
|
}
|
|
19471
|
-
|
|
19529
|
+
t.dimensions[O] || R.push(`TimeDimension '${O}' not found on cube '${e}' (must be a dimension with time type)`);
|
|
19472
19530
|
}
|
|
19473
19531
|
if (E.filters)
|
|
19474
19532
|
for (const S of E.filters)
|
|
@@ -19480,8 +19538,8 @@ function bT(T, E) {
|
|
|
19480
19538
|
}
|
|
19481
19539
|
function KT(T, E, R, A) {
|
|
19482
19540
|
if ("and" in T || "or" in T) {
|
|
19483
|
-
const
|
|
19484
|
-
for (const D of
|
|
19541
|
+
const t = T.and || T.or || [];
|
|
19542
|
+
for (const D of t)
|
|
19485
19543
|
KT(D, E, R, A);
|
|
19486
19544
|
return;
|
|
19487
19545
|
}
|
|
@@ -19502,17 +19560,17 @@ function KT(T, E, R, A) {
|
|
|
19502
19560
|
}
|
|
19503
19561
|
!O.dimensions[e] && !O.measures[e] && R.push(`Filter field '${e}' not found on cube '${S}' (must be a dimension or measure)`);
|
|
19504
19562
|
}
|
|
19505
|
-
function
|
|
19563
|
+
function QI(T) {
|
|
19506
19564
|
return new fE(T);
|
|
19507
19565
|
}
|
|
19508
|
-
const
|
|
19509
|
-
function
|
|
19566
|
+
const JI = new fE(), ZI = JI;
|
|
19567
|
+
function qI(T) {
|
|
19510
19568
|
return new fE({
|
|
19511
19569
|
drizzle: T.drizzle,
|
|
19512
19570
|
schema: T.schema
|
|
19513
19571
|
});
|
|
19514
19572
|
}
|
|
19515
|
-
const
|
|
19573
|
+
const jI = {
|
|
19516
19574
|
/**
|
|
19517
19575
|
* Create a simple query builder
|
|
19518
19576
|
*/
|
|
@@ -19619,26 +19677,26 @@ const qI = {
|
|
|
19619
19677
|
}
|
|
19620
19678
|
};
|
|
19621
19679
|
export {
|
|
19622
|
-
|
|
19680
|
+
hE as BaseDatabaseExecutor,
|
|
19623
19681
|
lT as MySQLExecutor,
|
|
19624
|
-
|
|
19625
|
-
|
|
19682
|
+
qT as PostgresExecutor,
|
|
19683
|
+
RR as QueryBuilder,
|
|
19626
19684
|
OE as QueryExecutor,
|
|
19627
|
-
|
|
19685
|
+
AR as QueryPlanner,
|
|
19628
19686
|
kT as SQLiteExecutor,
|
|
19629
19687
|
fE as SemanticLayerCompiler,
|
|
19630
|
-
|
|
19688
|
+
jI as SemanticLayerUtils,
|
|
19631
19689
|
JE as createDatabaseExecutor,
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19690
|
+
qI as createDrizzleSemanticLayer,
|
|
19691
|
+
xI as createMultiCubeContext,
|
|
19692
|
+
jT as createMySQLExecutor,
|
|
19635
19693
|
$E as createPostgresExecutor,
|
|
19636
19694
|
gE as createSQLiteExecutor,
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19695
|
+
QI as createSemanticLayer,
|
|
19696
|
+
ZI as defaultSemanticLayer,
|
|
19697
|
+
vI as defineCube,
|
|
19698
|
+
HT as getJoinType,
|
|
19641
19699
|
wE as resolveCubeReference,
|
|
19642
19700
|
f as resolveSqlExpression,
|
|
19643
|
-
|
|
19701
|
+
JI as semanticLayer
|
|
19644
19702
|
};
|