drizzle-cube 0.1.35 → 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-Ce33cdy6.js → compiler-CiUqnN3l.js} +1056 -970
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +35 -39
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/client/chunks/{components-D3Bl_BuN.js → components-BeCaouWH.js} +2 -38
- package/dist/client/chunks/{components-D3Bl_BuN.js.map → components-BeCaouWH.js.map} +1 -1
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.d.ts +41 -3
- package/dist/server/index.js +1076 -990
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as _, count as RE, sum as
|
|
1
|
+
import { sql as _, 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":
|
|
@@ -626,27 +626,66 @@ function ER(T, E) {
|
|
|
626
626
|
case "hasMany":
|
|
627
627
|
return "left";
|
|
628
628
|
// Parent may have no children
|
|
629
|
+
case "belongsToMany":
|
|
630
|
+
return "left";
|
|
631
|
+
// Many-to-many through junction table
|
|
629
632
|
default:
|
|
630
633
|
return "left";
|
|
631
634
|
}
|
|
632
635
|
}
|
|
633
|
-
function
|
|
636
|
+
function f(T, E) {
|
|
634
637
|
return typeof T == "function" ? T(E) : T;
|
|
635
638
|
}
|
|
636
|
-
function
|
|
639
|
+
function xI(T, E, R) {
|
|
637
640
|
return {
|
|
638
641
|
...T,
|
|
639
642
|
cubes: E,
|
|
640
643
|
currentCube: R
|
|
641
644
|
};
|
|
642
645
|
}
|
|
643
|
-
function
|
|
646
|
+
function vI(T, E) {
|
|
644
647
|
return {
|
|
645
648
|
name: T,
|
|
646
649
|
...E
|
|
647
650
|
};
|
|
648
651
|
}
|
|
649
|
-
|
|
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 {
|
|
650
689
|
constructor(E) {
|
|
651
690
|
this.databaseAdapter = E;
|
|
652
691
|
}
|
|
@@ -658,26 +697,26 @@ class TR {
|
|
|
658
697
|
const S = {}, e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
659
698
|
if (R.dimensions)
|
|
660
699
|
for (const O of R.dimensions) {
|
|
661
|
-
const [
|
|
700
|
+
const [t, D] = O.split("."), I = e.get(t);
|
|
662
701
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
663
|
-
const
|
|
702
|
+
const N = I.dimensions[D], s = f(N.sql, A);
|
|
664
703
|
S[O] = _`${s}`.as(O);
|
|
665
704
|
}
|
|
666
705
|
}
|
|
667
706
|
if (R.measures)
|
|
668
707
|
for (const O of R.measures) {
|
|
669
|
-
const [
|
|
708
|
+
const [t, D] = O.split("."), I = e.get(t);
|
|
670
709
|
if (I && I.measures && I.measures[D]) {
|
|
671
|
-
const
|
|
710
|
+
const N = I.measures[D], s = this.buildMeasureExpression(N, A);
|
|
672
711
|
S[O] = _`${s}`.as(O);
|
|
673
712
|
}
|
|
674
713
|
}
|
|
675
714
|
if (R.timeDimensions)
|
|
676
715
|
for (const O of R.timeDimensions) {
|
|
677
|
-
const [
|
|
716
|
+
const [t, D] = O.dimension.split("."), I = e.get(t);
|
|
678
717
|
if (I && I.dimensions && I.dimensions[D]) {
|
|
679
|
-
const
|
|
680
|
-
|
|
718
|
+
const N = I.dimensions[D], s = this.buildTimeDimensionExpression(
|
|
719
|
+
N.sql,
|
|
681
720
|
O.granularity,
|
|
682
721
|
A
|
|
683
722
|
);
|
|
@@ -691,24 +730,24 @@ class TR {
|
|
|
691
730
|
*/
|
|
692
731
|
buildHavingMeasureExpression(E, R, A, S, e) {
|
|
693
732
|
if (e && e.preAggregationCTEs) {
|
|
694
|
-
const O = e.preAggregationCTEs.find((
|
|
733
|
+
const O = e.preAggregationCTEs.find((t) => t.cube.name === E);
|
|
695
734
|
if (O && O.measures.includes(`${E}.${R}`)) {
|
|
696
|
-
const
|
|
735
|
+
const t = _`${_.identifier(O.cteAlias)}.${_.identifier(R)}`;
|
|
697
736
|
switch (A.type) {
|
|
698
737
|
case "count":
|
|
699
738
|
case "countDistinct":
|
|
700
739
|
case "sum":
|
|
701
|
-
return
|
|
740
|
+
return W(t);
|
|
702
741
|
case "avg":
|
|
703
|
-
return this.databaseAdapter.buildAvg(
|
|
742
|
+
return this.databaseAdapter.buildAvg(t);
|
|
704
743
|
case "min":
|
|
705
|
-
return mE(
|
|
744
|
+
return mE(t);
|
|
706
745
|
case "max":
|
|
707
|
-
return YE(
|
|
746
|
+
return YE(t);
|
|
708
747
|
case "number":
|
|
709
|
-
return
|
|
748
|
+
return W(t);
|
|
710
749
|
default:
|
|
711
|
-
return
|
|
750
|
+
return W(t);
|
|
712
751
|
}
|
|
713
752
|
}
|
|
714
753
|
}
|
|
@@ -718,7 +757,7 @@ class TR {
|
|
|
718
757
|
* Build measure expression with aggregation and filters
|
|
719
758
|
*/
|
|
720
759
|
buildMeasureExpression(E, R) {
|
|
721
|
-
let A =
|
|
760
|
+
let A = f(E.sql, R);
|
|
722
761
|
if (E.filters && E.filters.length > 0) {
|
|
723
762
|
const S = E.filters.map((e) => e(R)).filter(Boolean);
|
|
724
763
|
if (S.length > 0) {
|
|
@@ -732,9 +771,9 @@ class TR {
|
|
|
732
771
|
case "count":
|
|
733
772
|
return RE(A);
|
|
734
773
|
case "countDistinct":
|
|
735
|
-
return
|
|
774
|
+
return gT(A);
|
|
736
775
|
case "sum":
|
|
737
|
-
return
|
|
776
|
+
return W(A);
|
|
738
777
|
case "avg":
|
|
739
778
|
return this.databaseAdapter.buildAvg(A);
|
|
740
779
|
case "min":
|
|
@@ -751,8 +790,8 @@ class TR {
|
|
|
751
790
|
* Build time dimension expression with granularity using database adapter
|
|
752
791
|
*/
|
|
753
792
|
buildTimeDimensionExpression(E, R, A) {
|
|
754
|
-
const S =
|
|
755
|
-
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof
|
|
793
|
+
const S = f(E, A);
|
|
794
|
+
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof JT ? S : _`${S}`;
|
|
756
795
|
}
|
|
757
796
|
/**
|
|
758
797
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -761,17 +800,17 @@ class TR {
|
|
|
761
800
|
buildWhereConditions(E, R, A, S) {
|
|
762
801
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
763
802
|
if (R.filters && R.filters.length > 0)
|
|
764
|
-
for (const
|
|
765
|
-
const D = this.processFilter(
|
|
803
|
+
for (const t of R.filters) {
|
|
804
|
+
const D = this.processFilter(t, O, A, "where", S);
|
|
766
805
|
D && e.push(D);
|
|
767
806
|
}
|
|
768
807
|
if (R.timeDimensions)
|
|
769
|
-
for (const
|
|
770
|
-
const [D, I] =
|
|
771
|
-
if (
|
|
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) {
|
|
772
811
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((r) => r.cube.name === D))
|
|
773
812
|
continue;
|
|
774
|
-
const s =
|
|
813
|
+
const s = N.dimensions[I], L = f(s.sql, A), P = this.buildDateRangeCondition(L, t.dateRange);
|
|
775
814
|
P && e.push(P);
|
|
776
815
|
}
|
|
777
816
|
}
|
|
@@ -784,8 +823,8 @@ class TR {
|
|
|
784
823
|
buildHavingConditions(E, R, A, S) {
|
|
785
824
|
const e = [], O = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
786
825
|
if (R.filters && R.filters.length > 0)
|
|
787
|
-
for (const
|
|
788
|
-
const D = this.processFilter(
|
|
826
|
+
for (const t of R.filters) {
|
|
827
|
+
const D = this.processFilter(t, O, A, "having", S);
|
|
789
828
|
D && e.push(D);
|
|
790
829
|
}
|
|
791
830
|
return e;
|
|
@@ -798,28 +837,28 @@ class TR {
|
|
|
798
837
|
if ("and" in E || "or" in E) {
|
|
799
838
|
const P = E;
|
|
800
839
|
if (P.and) {
|
|
801
|
-
const
|
|
802
|
-
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;
|
|
803
842
|
}
|
|
804
843
|
if (P.or) {
|
|
805
|
-
const
|
|
806
|
-
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;
|
|
807
846
|
}
|
|
808
847
|
}
|
|
809
|
-
const O = E, [
|
|
848
|
+
const O = E, [t, D] = O.member.split("."), I = R.get(t);
|
|
810
849
|
if (!I) return null;
|
|
811
|
-
const
|
|
850
|
+
const N = I.dimensions[D], s = I.measures[D], L = N || s;
|
|
812
851
|
if (!L) return null;
|
|
813
|
-
if (S === "where" &&
|
|
814
|
-
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name ===
|
|
852
|
+
if (S === "where" && N) {
|
|
853
|
+
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((r) => r.cube.name === t))
|
|
815
854
|
return null;
|
|
816
|
-
const P =
|
|
855
|
+
const P = f(N.sql, A);
|
|
817
856
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
818
857
|
} else {
|
|
819
858
|
if (S === "where" && s)
|
|
820
859
|
return null;
|
|
821
860
|
if (S === "having" && s) {
|
|
822
|
-
const P = this.buildHavingMeasureExpression(
|
|
861
|
+
const P = this.buildHavingMeasureExpression(t, D, s, A, e);
|
|
823
862
|
return this.buildFilterCondition(P, O.operator, O.values, L);
|
|
824
863
|
}
|
|
825
864
|
}
|
|
@@ -831,7 +870,7 @@ class TR {
|
|
|
831
870
|
buildFilterCondition(E, R, A, S) {
|
|
832
871
|
if (!A || A.length === 0)
|
|
833
872
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
834
|
-
const e = A.filter((
|
|
873
|
+
const e = A.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
|
|
835
874
|
if (e.length === 0 && !["set", "notSet"].includes(R))
|
|
836
875
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
837
876
|
const O = e[0];
|
|
@@ -839,17 +878,17 @@ class TR {
|
|
|
839
878
|
case "equals":
|
|
840
879
|
if (e.length > 1) {
|
|
841
880
|
if (S?.type === "time") {
|
|
842
|
-
const
|
|
843
|
-
return SE(E,
|
|
881
|
+
const t = e.map((D) => this.normalizeDate(D) || D);
|
|
882
|
+
return SE(E, t);
|
|
844
883
|
}
|
|
845
884
|
return SE(E, e);
|
|
846
885
|
} else if (e.length === 1) {
|
|
847
|
-
const
|
|
848
|
-
return
|
|
886
|
+
const t = S?.type === "time" && this.normalizeDate(O) || O;
|
|
887
|
+
return w(E, t);
|
|
849
888
|
}
|
|
850
889
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
851
890
|
case "notEquals":
|
|
852
|
-
return e.length > 1 ?
|
|
891
|
+
return e.length > 1 ? yE(E, e) : e.length === 1 ? XE(E, O) : null;
|
|
853
892
|
case "contains":
|
|
854
893
|
return this.databaseAdapter.buildStringCondition(E, "contains", O);
|
|
855
894
|
case "notContains":
|
|
@@ -861,36 +900,36 @@ class TR {
|
|
|
861
900
|
case "gt":
|
|
862
901
|
return IE(E, O);
|
|
863
902
|
case "gte":
|
|
864
|
-
return
|
|
903
|
+
return K(E, O);
|
|
865
904
|
case "lt":
|
|
866
905
|
return eE(E, O);
|
|
867
906
|
case "lte":
|
|
868
907
|
return $(E, O);
|
|
869
908
|
case "set":
|
|
870
|
-
return
|
|
909
|
+
return WE(E);
|
|
871
910
|
case "notSet":
|
|
872
911
|
return bE(E);
|
|
873
912
|
case "inDateRange":
|
|
874
913
|
if (e.length >= 2) {
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
914
|
+
const t = this.normalizeDate(e[0]), D = this.normalizeDate(e[1]);
|
|
915
|
+
if (t && D)
|
|
877
916
|
return m(
|
|
878
|
-
|
|
917
|
+
K(E, t),
|
|
879
918
|
$(E, D)
|
|
880
919
|
);
|
|
881
920
|
}
|
|
882
921
|
return null;
|
|
883
922
|
case "beforeDate": {
|
|
884
|
-
const
|
|
885
|
-
return
|
|
923
|
+
const t = this.normalizeDate(O);
|
|
924
|
+
return t ? eE(E, t) : null;
|
|
886
925
|
}
|
|
887
926
|
case "afterDate": {
|
|
888
|
-
const
|
|
889
|
-
return
|
|
927
|
+
const t = this.normalizeDate(O);
|
|
928
|
+
return t ? IE(E, t) : null;
|
|
890
929
|
}
|
|
891
930
|
case "between":
|
|
892
931
|
return e.length >= 2 ? m(
|
|
893
|
-
|
|
932
|
+
K(E, e[0]),
|
|
894
933
|
$(E, e[1])
|
|
895
934
|
) : null;
|
|
896
935
|
case "notBetween":
|
|
@@ -901,7 +940,7 @@ class TR {
|
|
|
901
940
|
case "in":
|
|
902
941
|
return e.length > 0 ? SE(E, e) : null;
|
|
903
942
|
case "notIn":
|
|
904
|
-
return e.length > 0 ?
|
|
943
|
+
return e.length > 0 ? yE(E, e) : null;
|
|
905
944
|
case "like":
|
|
906
945
|
return this.databaseAdapter.buildStringCondition(E, "like", O);
|
|
907
946
|
case "notLike":
|
|
@@ -915,11 +954,11 @@ class TR {
|
|
|
915
954
|
case "isEmpty":
|
|
916
955
|
return AE(
|
|
917
956
|
bE(E),
|
|
918
|
-
|
|
957
|
+
w(E, "")
|
|
919
958
|
);
|
|
920
959
|
case "isNotEmpty":
|
|
921
960
|
return m(
|
|
922
|
-
|
|
961
|
+
WE(E),
|
|
923
962
|
XE(E, "")
|
|
924
963
|
);
|
|
925
964
|
default:
|
|
@@ -934,7 +973,7 @@ class TR {
|
|
|
934
973
|
if (Array.isArray(R) && R.length >= 2) {
|
|
935
974
|
const A = this.normalizeDate(R[0]), S = this.normalizeDate(R[1]);
|
|
936
975
|
return !A || !S ? null : m(
|
|
937
|
-
|
|
976
|
+
K(E, A),
|
|
938
977
|
$(E, S)
|
|
939
978
|
);
|
|
940
979
|
}
|
|
@@ -942,7 +981,7 @@ class TR {
|
|
|
942
981
|
const A = this.parseRelativeDateRange(R);
|
|
943
982
|
if (A)
|
|
944
983
|
return m(
|
|
945
|
-
|
|
984
|
+
K(E, A.start),
|
|
946
985
|
$(E, A.end)
|
|
947
986
|
);
|
|
948
987
|
const S = this.normalizeDate(R);
|
|
@@ -951,7 +990,7 @@ class TR {
|
|
|
951
990
|
e.setUTCHours(0, 0, 0, 0);
|
|
952
991
|
const O = new Date(S);
|
|
953
992
|
return O.setUTCHours(23, 59, 59, 999), m(
|
|
954
|
-
|
|
993
|
+
K(E, e),
|
|
955
994
|
$(E, O)
|
|
956
995
|
);
|
|
957
996
|
}
|
|
@@ -962,7 +1001,7 @@ class TR {
|
|
|
962
1001
|
* Handles all 14 DATE_RANGE_OPTIONS from the client
|
|
963
1002
|
*/
|
|
964
1003
|
parseRelativeDateRange(E) {
|
|
965
|
-
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();
|
|
966
1005
|
if (A === "today") {
|
|
967
1006
|
const s = new Date(R);
|
|
968
1007
|
s.setUTCHours(0, 0, 0, 0);
|
|
@@ -976,7 +1015,7 @@ class TR {
|
|
|
976
1015
|
return L.setUTCDate(O - 1), L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
|
|
977
1016
|
}
|
|
978
1017
|
if (A === "this week") {
|
|
979
|
-
const s =
|
|
1018
|
+
const s = t === 0 ? -6 : 1 - t, L = new Date(R);
|
|
980
1019
|
L.setUTCDate(O + s), L.setUTCHours(0, 0, 0, 0);
|
|
981
1020
|
const P = new Date(L);
|
|
982
1021
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
@@ -1001,7 +1040,7 @@ class TR {
|
|
|
1001
1040
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1002
1041
|
}
|
|
1003
1042
|
if (A === "last week") {
|
|
1004
|
-
const s =
|
|
1043
|
+
const s = t === 0 ? -13 : -6 - t, L = new Date(R);
|
|
1005
1044
|
L.setUTCDate(O + s), L.setUTCHours(0, 0, 0, 0);
|
|
1006
1045
|
const P = new Date(L);
|
|
1007
1046
|
return P.setUTCDate(L.getUTCDate() + 6), P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
@@ -1011,8 +1050,8 @@ class TR {
|
|
|
1011
1050
|
return { start: s, end: L };
|
|
1012
1051
|
}
|
|
1013
1052
|
if (A === "last quarter") {
|
|
1014
|
-
const s = Math.floor(e / 3), L = s === 0 ? 3 : s - 1, P = s === 0 ? S - 1 : S,
|
|
1015
|
-
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 };
|
|
1016
1055
|
}
|
|
1017
1056
|
if (A === "last year") {
|
|
1018
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));
|
|
@@ -1027,9 +1066,9 @@ class TR {
|
|
|
1027
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);
|
|
1028
1067
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1029
1068
|
}
|
|
1030
|
-
const
|
|
1031
|
-
if (
|
|
1032
|
-
const s = parseInt(
|
|
1069
|
+
const N = A.match(/^last\s+(\d+)\s+years?$/);
|
|
1070
|
+
if (N) {
|
|
1071
|
+
const s = parseInt(N[1], 10), L = new Date(Date.UTC(S - s, 0, 1, 0, 0, 0, 0)), P = new Date(R);
|
|
1033
1072
|
return P.setUTCHours(23, 59, 59, 999), { start: L, end: P };
|
|
1034
1073
|
}
|
|
1035
1074
|
return null;
|
|
@@ -1062,48 +1101,48 @@ class TR {
|
|
|
1062
1101
|
const e = [];
|
|
1063
1102
|
if (!(R.measures && R.measures.length > 0))
|
|
1064
1103
|
return [];
|
|
1065
|
-
const
|
|
1104
|
+
const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1066
1105
|
if (R.dimensions)
|
|
1067
1106
|
for (const D of R.dimensions) {
|
|
1068
|
-
const [I,
|
|
1069
|
-
if (s && s.dimensions && s.dimensions[
|
|
1107
|
+
const [I, N] = D.split("."), s = t.get(I);
|
|
1108
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1070
1109
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1071
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I),
|
|
1072
|
-
if (
|
|
1073
|
-
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);
|
|
1074
1113
|
else {
|
|
1075
|
-
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(
|
|
1114
|
+
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(N)}`;
|
|
1076
1115
|
e.push(r);
|
|
1077
1116
|
}
|
|
1078
1117
|
} else {
|
|
1079
|
-
const P = s.dimensions[
|
|
1080
|
-
e.push(
|
|
1118
|
+
const P = s.dimensions[N], o = f(P.sql, A);
|
|
1119
|
+
e.push(o);
|
|
1081
1120
|
}
|
|
1082
1121
|
}
|
|
1083
1122
|
if (R.timeDimensions)
|
|
1084
1123
|
for (const D of R.timeDimensions) {
|
|
1085
|
-
const [I,
|
|
1086
|
-
if (s && s.dimensions && s.dimensions[
|
|
1124
|
+
const [I, N] = D.dimension.split("."), s = t.get(I);
|
|
1125
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1087
1126
|
if (S?.preAggregationCTEs?.some((P) => P.cube.name === I)) {
|
|
1088
|
-
const P = S.preAggregationCTEs.find((r) => r.cube.name === I),
|
|
1089
|
-
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) {
|
|
1090
1129
|
const r = this.buildTimeDimensionExpression(
|
|
1091
|
-
|
|
1130
|
+
o.sourceColumnObj,
|
|
1092
1131
|
D.granularity,
|
|
1093
1132
|
A
|
|
1094
1133
|
);
|
|
1095
1134
|
e.push(r);
|
|
1096
1135
|
} else {
|
|
1097
|
-
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(
|
|
1136
|
+
const r = _`${_.identifier(P.cteAlias)}.${_.identifier(N)}`;
|
|
1098
1137
|
e.push(r);
|
|
1099
1138
|
}
|
|
1100
1139
|
} else {
|
|
1101
|
-
const P = s.dimensions[
|
|
1140
|
+
const P = s.dimensions[N], o = this.buildTimeDimensionExpression(
|
|
1102
1141
|
P.sql,
|
|
1103
1142
|
D.granularity,
|
|
1104
1143
|
A
|
|
1105
1144
|
);
|
|
1106
|
-
e.push(
|
|
1145
|
+
e.push(o);
|
|
1107
1146
|
}
|
|
1108
1147
|
}
|
|
1109
1148
|
return e;
|
|
@@ -1121,15 +1160,15 @@ class TR {
|
|
|
1121
1160
|
for (const [e, O] of Object.entries(E.order)) {
|
|
1122
1161
|
if (!S.includes(e))
|
|
1123
1162
|
throw new Error(`Cannot order by '${e}': field is not selected in the query`);
|
|
1124
|
-
const
|
|
1125
|
-
A.push(
|
|
1163
|
+
const t = O === "desc" ? wT(_.identifier(e)) : KE(_.identifier(e));
|
|
1164
|
+
A.push(t);
|
|
1126
1165
|
}
|
|
1127
1166
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
1128
1167
|
const e = new Set(Object.keys(E.order || {})), O = [...E.timeDimensions].sort(
|
|
1129
|
-
(
|
|
1168
|
+
(t, D) => t.dimension.localeCompare(D.dimension)
|
|
1130
1169
|
);
|
|
1131
|
-
for (const
|
|
1132
|
-
e.has(
|
|
1170
|
+
for (const t of O)
|
|
1171
|
+
e.has(t.dimension) || A.push(KE(_.identifier(t.dimension)));
|
|
1133
1172
|
}
|
|
1134
1173
|
return A;
|
|
1135
1174
|
}
|
|
@@ -1141,9 +1180,9 @@ class TR {
|
|
|
1141
1180
|
const A = [], S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1142
1181
|
if (R.measures && A.push(...R.measures), R.dimensions)
|
|
1143
1182
|
for (const e of R.dimensions) {
|
|
1144
|
-
const [O,
|
|
1183
|
+
const [O, t] = e.split("."), D = S.get(O);
|
|
1145
1184
|
if (D) {
|
|
1146
|
-
const I = D.dimensions[
|
|
1185
|
+
const I = D.dimensions[t];
|
|
1147
1186
|
I && I.type === "number" && A.push(e);
|
|
1148
1187
|
}
|
|
1149
1188
|
}
|
|
@@ -1170,7 +1209,7 @@ class TR {
|
|
|
1170
1209
|
return S;
|
|
1171
1210
|
}
|
|
1172
1211
|
}
|
|
1173
|
-
class
|
|
1212
|
+
class AR {
|
|
1174
1213
|
/**
|
|
1175
1214
|
* Analyze a semantic query to determine which cubes are involved
|
|
1176
1215
|
*/
|
|
@@ -1244,12 +1283,12 @@ class RR {
|
|
|
1244
1283
|
const S = this.analyzeCubeUsage(R), e = Array.from(S);
|
|
1245
1284
|
if (e.length === 0)
|
|
1246
1285
|
throw new Error("No cubes found in query");
|
|
1247
|
-
const O = this.choosePrimaryCube(e, R, E),
|
|
1248
|
-
if (!
|
|
1286
|
+
const O = this.choosePrimaryCube(e, R, E), t = E.get(O);
|
|
1287
|
+
if (!t)
|
|
1249
1288
|
throw new Error(`Primary cube '${O}' not found`);
|
|
1250
1289
|
if (e.length === 1)
|
|
1251
1290
|
return {
|
|
1252
|
-
primaryCube:
|
|
1291
|
+
primaryCube: t,
|
|
1253
1292
|
joinCubes: [],
|
|
1254
1293
|
// Empty for single cube
|
|
1255
1294
|
selections: {},
|
|
@@ -1259,9 +1298,9 @@ class RR {
|
|
|
1259
1298
|
groupByFields: []
|
|
1260
1299
|
// Will be built by QueryBuilder
|
|
1261
1300
|
};
|
|
1262
|
-
const D = this.buildJoinPlan(E,
|
|
1301
|
+
const D = this.buildJoinPlan(E, t, e, A), I = this.planPreAggregationCTEs(E, t, D, R);
|
|
1263
1302
|
return {
|
|
1264
|
-
primaryCube:
|
|
1303
|
+
primaryCube: t,
|
|
1265
1304
|
joinCubes: D,
|
|
1266
1305
|
selections: {},
|
|
1267
1306
|
// Will be built by QueryBuilder
|
|
@@ -1282,8 +1321,8 @@ class RR {
|
|
|
1282
1321
|
for (const O of S)
|
|
1283
1322
|
e.set(O, (e.get(O) || 0) + 1);
|
|
1284
1323
|
if (e.size > 0) {
|
|
1285
|
-
const O = Math.max(...e.values()),
|
|
1286
|
-
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)
|
|
1287
1326
|
if (this.canReachAllCubes(D, E, A))
|
|
1288
1327
|
return D;
|
|
1289
1328
|
}
|
|
@@ -1292,12 +1331,12 @@ class RR {
|
|
|
1292
1331
|
const S = /* @__PURE__ */ new Map();
|
|
1293
1332
|
for (const e of E)
|
|
1294
1333
|
if (this.canReachAllCubes(e, E, A)) {
|
|
1295
|
-
const O = A.get(e),
|
|
1296
|
-
S.set(e,
|
|
1334
|
+
const O = A.get(e), t = O?.joins ? Object.keys(O.joins).length : 0;
|
|
1335
|
+
S.set(e, t);
|
|
1297
1336
|
}
|
|
1298
1337
|
if (S.size > 0) {
|
|
1299
1338
|
const e = Math.max(...S.values());
|
|
1300
|
-
return [...S.entries()].filter(([,
|
|
1339
|
+
return [...S.entries()].filter(([, t]) => t === e).map(([t]) => t).sort()[0];
|
|
1301
1340
|
}
|
|
1302
1341
|
}
|
|
1303
1342
|
return [...E].sort()[0];
|
|
@@ -1318,36 +1357,56 @@ class RR {
|
|
|
1318
1357
|
* Build join plan for multi-cube query
|
|
1319
1358
|
* Supports both direct joins and transitive joins through intermediate cubes
|
|
1320
1359
|
*/
|
|
1321
|
-
buildJoinPlan(E, R, A) {
|
|
1322
|
-
const
|
|
1323
|
-
for (const
|
|
1324
|
-
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))
|
|
1325
1364
|
continue;
|
|
1326
|
-
const
|
|
1327
|
-
if (!
|
|
1328
|
-
throw new Error(`No join path found from '${R.name}' to '${
|
|
1329
|
-
for (const { toCube:
|
|
1330
|
-
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))
|
|
1331
1370
|
continue;
|
|
1332
|
-
const
|
|
1333
|
-
if (!
|
|
1334
|
-
throw new Error(`Cube '${
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
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);
|
|
1348
1407
|
}
|
|
1349
1408
|
}
|
|
1350
|
-
return
|
|
1409
|
+
return e;
|
|
1351
1410
|
}
|
|
1352
1411
|
/**
|
|
1353
1412
|
* Build join condition from new array-based join definition
|
|
@@ -1355,8 +1414,8 @@ class RR {
|
|
|
1355
1414
|
buildJoinCondition(E, R, A) {
|
|
1356
1415
|
const S = [];
|
|
1357
1416
|
for (const e of E.on) {
|
|
1358
|
-
const O = R ? _`${_.identifier(R)}.${_.identifier(e.source.name)}` : e.source,
|
|
1359
|
-
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));
|
|
1360
1419
|
}
|
|
1361
1420
|
return m(...S);
|
|
1362
1421
|
}
|
|
@@ -1371,16 +1430,16 @@ class RR {
|
|
|
1371
1430
|
{ cube: R, path: [] }
|
|
1372
1431
|
], O = /* @__PURE__ */ new Set([R, ...S]);
|
|
1373
1432
|
for (; e.length > 0; ) {
|
|
1374
|
-
const { cube:
|
|
1433
|
+
const { cube: t, path: D } = e.shift(), I = E.get(t);
|
|
1375
1434
|
if (I?.joins)
|
|
1376
|
-
for (const [,
|
|
1377
|
-
const L = wE(
|
|
1435
|
+
for (const [, N] of Object.entries(I.joins)) {
|
|
1436
|
+
const L = wE(N.targetCube).name;
|
|
1378
1437
|
if (O.has(L))
|
|
1379
1438
|
continue;
|
|
1380
1439
|
const P = [...D, {
|
|
1381
|
-
fromCube:
|
|
1440
|
+
fromCube: t,
|
|
1382
1441
|
toCube: L,
|
|
1383
|
-
joinDef:
|
|
1442
|
+
joinDef: N
|
|
1384
1443
|
}];
|
|
1385
1444
|
if (L === A)
|
|
1386
1445
|
return P;
|
|
@@ -1391,21 +1450,23 @@ class RR {
|
|
|
1391
1450
|
}
|
|
1392
1451
|
/**
|
|
1393
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
|
|
1394
1455
|
*/
|
|
1395
1456
|
planPreAggregationCTEs(E, R, A, S) {
|
|
1396
1457
|
const e = [];
|
|
1397
1458
|
if (!S.measures || S.measures.length === 0)
|
|
1398
1459
|
return e;
|
|
1399
1460
|
for (const O of A) {
|
|
1400
|
-
const
|
|
1401
|
-
if (!
|
|
1461
|
+
const t = this.findHasManyJoinDef(R, O.cube.name);
|
|
1462
|
+
if (!t)
|
|
1402
1463
|
continue;
|
|
1403
1464
|
const D = S.measures ? S.measures.filter(
|
|
1404
1465
|
(L) => L.startsWith(O.cube.name + ".")
|
|
1405
|
-
) : [], I = this.extractMeasuresFromFilters(S, O.cube.name),
|
|
1406
|
-
if (
|
|
1466
|
+
) : [], I = this.extractMeasuresFromFilters(S, O.cube.name), N = [.../* @__PURE__ */ new Set([...D, ...I])];
|
|
1467
|
+
if (N.length === 0)
|
|
1407
1468
|
continue;
|
|
1408
|
-
const s =
|
|
1469
|
+
const s = t.on.map((L) => ({
|
|
1409
1470
|
sourceColumn: L.source.name,
|
|
1410
1471
|
targetColumn: L.target.name,
|
|
1411
1472
|
sourceColumnObj: L.source,
|
|
@@ -1416,7 +1477,7 @@ class RR {
|
|
|
1416
1477
|
alias: O.alias,
|
|
1417
1478
|
cteAlias: `${O.cube.name.toLowerCase()}_agg`,
|
|
1418
1479
|
joinKeys: s,
|
|
1419
|
-
measures:
|
|
1480
|
+
measures: N
|
|
1420
1481
|
});
|
|
1421
1482
|
}
|
|
1422
1483
|
return e;
|
|
@@ -1437,7 +1498,7 @@ class OE {
|
|
|
1437
1498
|
constructor(E) {
|
|
1438
1499
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
1439
1500
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
1440
|
-
this.queryBuilder = new
|
|
1501
|
+
this.queryBuilder = new RR(this.databaseAdapter), this.queryPlanner = new AR();
|
|
1441
1502
|
}
|
|
1442
1503
|
queryBuilder;
|
|
1443
1504
|
queryPlanner;
|
|
@@ -1447,30 +1508,30 @@ class OE {
|
|
|
1447
1508
|
*/
|
|
1448
1509
|
async execute(E, R, A) {
|
|
1449
1510
|
try {
|
|
1450
|
-
const S =
|
|
1511
|
+
const S = yT(E, R);
|
|
1451
1512
|
if (!S.isValid)
|
|
1452
1513
|
throw new Error(`Query validation failed: ${S.errors.join(", ")}`);
|
|
1453
1514
|
const e = {
|
|
1454
1515
|
db: this.dbExecutor.db,
|
|
1455
1516
|
schema: this.dbExecutor.schema,
|
|
1456
1517
|
securityContext: A
|
|
1457
|
-
}, 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) => {
|
|
1458
1519
|
const P = { ...L };
|
|
1459
1520
|
if (R.timeDimensions) {
|
|
1460
|
-
for (const
|
|
1461
|
-
if (
|
|
1462
|
-
let r = P[
|
|
1521
|
+
for (const o of R.timeDimensions)
|
|
1522
|
+
if (o.dimension in P) {
|
|
1523
|
+
let r = P[o.dimension];
|
|
1463
1524
|
if (typeof r == "string" && r.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
1464
|
-
const U = r.replace(" ", "T"),
|
|
1465
|
-
r = new Date(
|
|
1525
|
+
const U = r.replace(" ", "T"), a = !U.endsWith("Z") && !U.includes("+") ? U + "Z" : U;
|
|
1526
|
+
r = new Date(a);
|
|
1466
1527
|
}
|
|
1467
|
-
r = this.databaseAdapter.convertTimeDimensionResult(r), P[
|
|
1528
|
+
r = this.databaseAdapter.convertTimeDimensionResult(r), P[o.dimension] = r;
|
|
1468
1529
|
}
|
|
1469
1530
|
}
|
|
1470
1531
|
return P;
|
|
1471
1532
|
}) : [I], s = this.generateAnnotations(O, R);
|
|
1472
1533
|
return {
|
|
1473
|
-
data:
|
|
1534
|
+
data: N,
|
|
1474
1535
|
annotation: s
|
|
1475
1536
|
};
|
|
1476
1537
|
} catch (S) {
|
|
@@ -1488,61 +1549,61 @@ class OE {
|
|
|
1488
1549
|
* Build pre-aggregation CTE for hasMany relationships
|
|
1489
1550
|
*/
|
|
1490
1551
|
buildPreAggregationCTE(E, R, A, S) {
|
|
1491
|
-
const e = E.cube, O = e.sql(A),
|
|
1552
|
+
const e = E.cube, O = e.sql(A), t = {};
|
|
1492
1553
|
for (const r of E.joinKeys)
|
|
1493
1554
|
if (r.targetColumnObj) {
|
|
1494
|
-
|
|
1495
|
-
for (const [U,
|
|
1496
|
-
|
|
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));
|
|
1497
1558
|
}
|
|
1498
1559
|
for (const r of E.measures) {
|
|
1499
1560
|
const [, U] = r.split(".");
|
|
1500
1561
|
if (e.measures && e.measures[U]) {
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1562
|
+
const a = e.measures[U], l = this.queryBuilder.buildMeasureExpression(a, A);
|
|
1563
|
+
t[U] = _`${l}`.as(U);
|
|
1503
1564
|
}
|
|
1504
1565
|
}
|
|
1505
1566
|
const D = e.name;
|
|
1506
1567
|
if (R.dimensions)
|
|
1507
1568
|
for (const r of R.dimensions) {
|
|
1508
|
-
const [U,
|
|
1509
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1510
|
-
const
|
|
1511
|
-
|
|
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);
|
|
1512
1573
|
}
|
|
1513
1574
|
}
|
|
1514
1575
|
if (R.timeDimensions)
|
|
1515
1576
|
for (const r of R.timeDimensions) {
|
|
1516
|
-
const [U,
|
|
1517
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1518
|
-
const
|
|
1519
|
-
|
|
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);
|
|
1520
1581
|
}
|
|
1521
1582
|
}
|
|
1522
|
-
if (Object.keys(
|
|
1583
|
+
if (Object.keys(t).length === 0)
|
|
1523
1584
|
return null;
|
|
1524
|
-
let I = A.db.select(
|
|
1525
|
-
const
|
|
1585
|
+
let I = A.db.select(t).from(O.from);
|
|
1586
|
+
const N = S ? {
|
|
1526
1587
|
...S,
|
|
1527
1588
|
preAggregationCTEs: S.preAggregationCTEs?.filter((r) => r.cube.name !== e.name)
|
|
1528
|
-
} : void 0, s = this.queryBuilder.buildWhereConditions(e, R, A,
|
|
1589
|
+
} : void 0, s = this.queryBuilder.buildWhereConditions(e, R, A, N), L = [];
|
|
1529
1590
|
if (R.timeDimensions)
|
|
1530
1591
|
for (const r of R.timeDimensions) {
|
|
1531
|
-
const [U,
|
|
1532
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1533
|
-
const
|
|
1534
|
-
|
|
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);
|
|
1595
|
+
H && L.push(H);
|
|
1535
1596
|
}
|
|
1536
1597
|
}
|
|
1537
1598
|
if (R.filters) {
|
|
1538
1599
|
for (const r of R.filters)
|
|
1539
1600
|
if (!("and" in r) && !("or" in r) && "member" in r && "operator" in r) {
|
|
1540
|
-
const U = r, [
|
|
1541
|
-
if (
|
|
1542
|
-
const
|
|
1601
|
+
const U = r, [a, l] = U.member.split(".");
|
|
1602
|
+
if (a === D && e.dimensions && e.dimensions[l]) {
|
|
1603
|
+
const c = e.dimensions[l];
|
|
1543
1604
|
if (U.operator === "inDateRange") {
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1605
|
+
const H = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), u = this.queryBuilder.buildDateRangeCondition(H, U.values);
|
|
1606
|
+
u && L.push(u);
|
|
1546
1607
|
}
|
|
1547
1608
|
}
|
|
1548
1609
|
}
|
|
@@ -1552,26 +1613,26 @@ class OE {
|
|
|
1552
1613
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1553
1614
|
I = I.where(r);
|
|
1554
1615
|
}
|
|
1555
|
-
const
|
|
1616
|
+
const o = [];
|
|
1556
1617
|
for (const r of E.joinKeys)
|
|
1557
|
-
r.targetColumnObj &&
|
|
1618
|
+
r.targetColumnObj && o.push(r.targetColumnObj);
|
|
1558
1619
|
if (R.dimensions)
|
|
1559
1620
|
for (const r of R.dimensions) {
|
|
1560
|
-
const [U,
|
|
1561
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1562
|
-
const
|
|
1563
|
-
|
|
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);
|
|
1564
1625
|
}
|
|
1565
1626
|
}
|
|
1566
1627
|
if (R.timeDimensions)
|
|
1567
1628
|
for (const r of R.timeDimensions) {
|
|
1568
|
-
const [U,
|
|
1569
|
-
if (U === D && e.dimensions && e.dimensions[
|
|
1570
|
-
const
|
|
1571
|
-
|
|
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);
|
|
1572
1633
|
}
|
|
1573
1634
|
}
|
|
1574
|
-
return
|
|
1635
|
+
return o.length > 0 && (I = I.groupBy(...o)), A.db.$with(E.cteAlias).as(I);
|
|
1575
1636
|
}
|
|
1576
1637
|
// Removed unused getActualJoinTargetColumn method
|
|
1577
1638
|
/**
|
|
@@ -1583,8 +1644,8 @@ class OE {
|
|
|
1583
1644
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
1584
1645
|
const e = [];
|
|
1585
1646
|
for (const O of S.joinKeys) {
|
|
1586
|
-
const
|
|
1587
|
-
e.push(
|
|
1647
|
+
const t = O.sourceColumnObj || _.identifier(O.sourceColumn), D = _`${_.identifier(R)}.${_.identifier(O.targetColumn)}`;
|
|
1648
|
+
e.push(w(t, D));
|
|
1588
1649
|
}
|
|
1589
1650
|
return e.length === 1 ? e[0] : m(...e);
|
|
1590
1651
|
}
|
|
@@ -1607,98 +1668,123 @@ class OE {
|
|
|
1607
1668
|
if (E.preAggregationCTEs)
|
|
1608
1669
|
for (const r of E.preAggregationCTEs) {
|
|
1609
1670
|
const U = r.cube.name;
|
|
1610
|
-
for (const
|
|
1611
|
-
if (D[
|
|
1612
|
-
const [,
|
|
1613
|
-
if (
|
|
1614
|
-
const
|
|
1671
|
+
for (const a of r.measures)
|
|
1672
|
+
if (D[a]) {
|
|
1673
|
+
const [, l] = a.split("."), c = this.getCubesFromPlan(E).get(U);
|
|
1674
|
+
if (c && c.measures && c.measures[l]) {
|
|
1675
|
+
const H = c.measures[l], u = _`${_.identifier(r.cteAlias)}.${_.identifier(l)}`;
|
|
1615
1676
|
let p;
|
|
1616
|
-
switch (
|
|
1677
|
+
switch (H.type) {
|
|
1617
1678
|
case "count":
|
|
1618
1679
|
case "countDistinct":
|
|
1619
1680
|
case "sum":
|
|
1620
|
-
p =
|
|
1681
|
+
p = W(u);
|
|
1621
1682
|
break;
|
|
1622
1683
|
case "avg":
|
|
1623
|
-
p = this.databaseAdapter.buildAvg(
|
|
1684
|
+
p = this.databaseAdapter.buildAvg(u);
|
|
1624
1685
|
break;
|
|
1625
1686
|
case "min":
|
|
1626
|
-
p = mE(
|
|
1687
|
+
p = mE(u);
|
|
1627
1688
|
break;
|
|
1628
1689
|
case "max":
|
|
1629
|
-
p = YE(
|
|
1690
|
+
p = YE(u);
|
|
1630
1691
|
break;
|
|
1631
1692
|
case "number":
|
|
1632
|
-
p =
|
|
1693
|
+
p = W(u);
|
|
1633
1694
|
break;
|
|
1634
1695
|
default:
|
|
1635
|
-
p =
|
|
1696
|
+
p = W(u);
|
|
1636
1697
|
}
|
|
1637
|
-
D[
|
|
1698
|
+
D[a] = _`${p}`.as(a);
|
|
1638
1699
|
}
|
|
1639
1700
|
}
|
|
1640
|
-
for (const
|
|
1641
|
-
const [
|
|
1642
|
-
if (
|
|
1643
|
-
const
|
|
1644
|
-
if (
|
|
1645
|
-
let
|
|
1646
|
-
if (!
|
|
1647
|
-
const TE =
|
|
1648
|
-
|
|
1701
|
+
for (const a in D) {
|
|
1702
|
+
const [l, c] = a.split(".");
|
|
1703
|
+
if (l === U) {
|
|
1704
|
+
const H = this.getCubesFromPlan(E).get(U), u = H && H.dimensions?.[c], p = a.startsWith(U + ".");
|
|
1705
|
+
if (u || p) {
|
|
1706
|
+
let y = r.joinKeys.find((TE) => TE.targetColumn === c);
|
|
1707
|
+
if (!y && H?.dimensions?.[c]) {
|
|
1708
|
+
const TE = H.dimensions[c].sql;
|
|
1709
|
+
y = r.joinKeys.find(($T) => $T.targetColumnObj === TE);
|
|
1649
1710
|
}
|
|
1650
|
-
|
|
1711
|
+
y ? D[a] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(a) : p && H?.dimensions?.[c] && (D[a] = _`${_.identifier(r.cteAlias)}.${_.identifier(c)}`.as(a));
|
|
1651
1712
|
}
|
|
1652
1713
|
}
|
|
1653
1714
|
}
|
|
1654
1715
|
}
|
|
1655
|
-
|
|
1656
|
-
|
|
1716
|
+
const I = [];
|
|
1717
|
+
let N = A.db.select(D).from(O.from);
|
|
1718
|
+
if (S.length > 0 && (N = A.db.with(...S).select(D).from(O.from)), O.joins)
|
|
1657
1719
|
for (const r of O.joins)
|
|
1658
1720
|
switch (r.type || "left") {
|
|
1659
1721
|
case "left":
|
|
1660
|
-
|
|
1722
|
+
N = N.leftJoin(r.table, r.on);
|
|
1661
1723
|
break;
|
|
1662
1724
|
case "inner":
|
|
1663
|
-
|
|
1725
|
+
N = N.innerJoin(r.table, r.on);
|
|
1664
1726
|
break;
|
|
1665
1727
|
case "right":
|
|
1666
|
-
|
|
1728
|
+
N = N.rightJoin(r.table, r.on);
|
|
1667
1729
|
break;
|
|
1668
1730
|
case "full":
|
|
1669
|
-
|
|
1731
|
+
N = N.fullJoin(r.table, r.on);
|
|
1670
1732
|
break;
|
|
1671
1733
|
}
|
|
1672
1734
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
1673
1735
|
for (const r of E.joinCubes) {
|
|
1674
1736
|
const U = e.get(r.cube.name);
|
|
1675
|
-
|
|
1676
|
-
|
|
1737
|
+
if (r.junctionTable) {
|
|
1738
|
+
const c = r.junctionTable, H = [];
|
|
1739
|
+
if (c.securitySql) {
|
|
1740
|
+
const u = c.securitySql(A.securityContext);
|
|
1741
|
+
Array.isArray(u) ? H.push(...u) : H.push(u);
|
|
1742
|
+
}
|
|
1743
|
+
try {
|
|
1744
|
+
switch (c.joinType || "left") {
|
|
1745
|
+
case "left":
|
|
1746
|
+
N = N.leftJoin(c.table, c.joinCondition);
|
|
1747
|
+
break;
|
|
1748
|
+
case "inner":
|
|
1749
|
+
N = N.innerJoin(c.table, c.joinCondition);
|
|
1750
|
+
break;
|
|
1751
|
+
case "right":
|
|
1752
|
+
N = N.rightJoin(c.table, c.joinCondition);
|
|
1753
|
+
break;
|
|
1754
|
+
case "full":
|
|
1755
|
+
N = N.fullJoin(c.table, c.joinCondition);
|
|
1756
|
+
break;
|
|
1757
|
+
}
|
|
1758
|
+
H.length > 0 && I.push(...H);
|
|
1759
|
+
} catch {
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
let a, l;
|
|
1763
|
+
U ? (a = _`${_.identifier(U)}`, l = this.buildCTEJoinCondition(r, U, E)) : (a = r.cube.sql(A).from, l = r.joinCondition);
|
|
1677
1764
|
try {
|
|
1678
1765
|
switch (r.joinType || "left") {
|
|
1679
1766
|
case "left":
|
|
1680
|
-
|
|
1767
|
+
N = N.leftJoin(a, l);
|
|
1681
1768
|
break;
|
|
1682
1769
|
case "inner":
|
|
1683
|
-
|
|
1770
|
+
N = N.innerJoin(a, l);
|
|
1684
1771
|
break;
|
|
1685
1772
|
case "right":
|
|
1686
|
-
|
|
1773
|
+
N = N.rightJoin(a, l);
|
|
1687
1774
|
break;
|
|
1688
1775
|
case "full":
|
|
1689
|
-
|
|
1776
|
+
N = N.fullJoin(a, l);
|
|
1690
1777
|
break;
|
|
1691
1778
|
}
|
|
1692
1779
|
} catch {
|
|
1693
1780
|
}
|
|
1694
1781
|
}
|
|
1695
|
-
|
|
1696
|
-
if (O.where && C.push(O.where), E.joinCubes && E.joinCubes.length > 0)
|
|
1782
|
+
if (O.where && I.push(O.where), E.joinCubes && E.joinCubes.length > 0)
|
|
1697
1783
|
for (const r of E.joinCubes) {
|
|
1698
1784
|
if (e.get(r.cube.name))
|
|
1699
1785
|
continue;
|
|
1700
|
-
const
|
|
1701
|
-
|
|
1786
|
+
const a = r.cube.sql(A);
|
|
1787
|
+
a.where && I.push(a.where);
|
|
1702
1788
|
}
|
|
1703
1789
|
const s = this.queryBuilder.buildWhereConditions(
|
|
1704
1790
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -1708,9 +1794,9 @@ class OE {
|
|
|
1708
1794
|
E
|
|
1709
1795
|
// Pass the queryPlan to handle CTE scenarios
|
|
1710
1796
|
);
|
|
1711
|
-
if (s.length > 0 &&
|
|
1712
|
-
const r =
|
|
1713
|
-
|
|
1797
|
+
if (s.length > 0 && I.push(...s), I.length > 0) {
|
|
1798
|
+
const r = I.length === 1 ? I[0] : m(...I);
|
|
1799
|
+
N = N.where(r);
|
|
1714
1800
|
}
|
|
1715
1801
|
const L = this.queryBuilder.buildGroupByFields(
|
|
1716
1802
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -1720,7 +1806,7 @@ class OE {
|
|
|
1720
1806
|
E
|
|
1721
1807
|
// Pass the queryPlan to handle CTE scenarios
|
|
1722
1808
|
);
|
|
1723
|
-
L.length > 0 && (
|
|
1809
|
+
L.length > 0 && (N = N.groupBy(...L));
|
|
1724
1810
|
const P = this.queryBuilder.buildHavingConditions(
|
|
1725
1811
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1726
1812
|
// Single cube
|
|
@@ -1731,10 +1817,10 @@ class OE {
|
|
|
1731
1817
|
);
|
|
1732
1818
|
if (P.length > 0) {
|
|
1733
1819
|
const r = P.length === 1 ? P[0] : m(...P);
|
|
1734
|
-
|
|
1820
|
+
N = N.having(r);
|
|
1735
1821
|
}
|
|
1736
|
-
const
|
|
1737
|
-
return
|
|
1822
|
+
const o = this.queryBuilder.buildOrderBy(R);
|
|
1823
|
+
return o.length > 0 && (N = N.orderBy(...o)), N = this.queryBuilder.applyLimitAndOffset(N, R), N;
|
|
1738
1824
|
}
|
|
1739
1825
|
/**
|
|
1740
1826
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -1767,10 +1853,10 @@ class OE {
|
|
|
1767
1853
|
db: this.dbExecutor.db,
|
|
1768
1854
|
schema: this.dbExecutor.schema,
|
|
1769
1855
|
securityContext: A
|
|
1770
|
-
}, e = this.queryPlanner.createQueryPlan(E, R, S),
|
|
1856
|
+
}, e = this.queryPlanner.createQueryPlan(E, R, S), t = this.buildUnifiedQuery(e, R, S).toSQL();
|
|
1771
1857
|
return {
|
|
1772
|
-
sql:
|
|
1773
|
-
params:
|
|
1858
|
+
sql: t.sql,
|
|
1859
|
+
params: t.params
|
|
1774
1860
|
};
|
|
1775
1861
|
}
|
|
1776
1862
|
/**
|
|
@@ -1778,12 +1864,12 @@ class OE {
|
|
|
1778
1864
|
*/
|
|
1779
1865
|
generateAnnotations(E, R) {
|
|
1780
1866
|
const A = {}, S = {}, e = {}, O = [E.primaryCube];
|
|
1781
|
-
if (E.joinCubes && E.joinCubes.length > 0 && O.push(...E.joinCubes.map((
|
|
1782
|
-
for (const
|
|
1783
|
-
const [D, I] =
|
|
1784
|
-
if (
|
|
1785
|
-
const s =
|
|
1786
|
-
A[
|
|
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);
|
|
1870
|
+
if (N && N.measures[I]) {
|
|
1871
|
+
const s = N.measures[I];
|
|
1872
|
+
A[t] = {
|
|
1787
1873
|
title: s.title || I,
|
|
1788
1874
|
shortTitle: s.title || I,
|
|
1789
1875
|
type: s.type
|
|
@@ -1791,11 +1877,11 @@ class OE {
|
|
|
1791
1877
|
}
|
|
1792
1878
|
}
|
|
1793
1879
|
if (R.dimensions)
|
|
1794
|
-
for (const
|
|
1795
|
-
const [D, I] =
|
|
1796
|
-
if (
|
|
1797
|
-
const s =
|
|
1798
|
-
S[
|
|
1880
|
+
for (const t of R.dimensions) {
|
|
1881
|
+
const [D, I] = t.split("."), N = O.find((s) => s.name === D);
|
|
1882
|
+
if (N && N.dimensions[I]) {
|
|
1883
|
+
const s = N.dimensions[I];
|
|
1884
|
+
S[t] = {
|
|
1799
1885
|
title: s.title || I,
|
|
1800
1886
|
shortTitle: s.title || I,
|
|
1801
1887
|
type: s.type
|
|
@@ -1803,15 +1889,15 @@ class OE {
|
|
|
1803
1889
|
}
|
|
1804
1890
|
}
|
|
1805
1891
|
if (R.timeDimensions)
|
|
1806
|
-
for (const
|
|
1807
|
-
const [D, I] =
|
|
1808
|
-
if (
|
|
1809
|
-
const s =
|
|
1810
|
-
e[
|
|
1892
|
+
for (const t of R.timeDimensions) {
|
|
1893
|
+
const [D, I] = t.dimension.split("."), N = O.find((s) => s.name === D);
|
|
1894
|
+
if (N && N.dimensions && N.dimensions[I]) {
|
|
1895
|
+
const s = N.dimensions[I];
|
|
1896
|
+
e[t.dimension] = {
|
|
1811
1897
|
title: s.title || I,
|
|
1812
1898
|
shortTitle: s.title || I,
|
|
1813
1899
|
type: s.type,
|
|
1814
|
-
granularity:
|
|
1900
|
+
granularity: t.granularity
|
|
1815
1901
|
};
|
|
1816
1902
|
}
|
|
1817
1903
|
}
|
|
@@ -1823,13 +1909,13 @@ class OE {
|
|
|
1823
1909
|
};
|
|
1824
1910
|
}
|
|
1825
1911
|
}
|
|
1826
|
-
const
|
|
1912
|
+
const C = (T) => T.flatMap(SR), SR = (T) => Z(IR(T)).map(eR), eR = (T) => T.replace(/ +/g, " ").trim(), IR = (T) => ({
|
|
1827
1913
|
type: "mandatory_block",
|
|
1828
|
-
items:
|
|
1829
|
-
}),
|
|
1914
|
+
items: VE(T, 0)[0]
|
|
1915
|
+
}), VE = (T, E, R) => {
|
|
1830
1916
|
const A = [];
|
|
1831
1917
|
for (; T[E]; ) {
|
|
1832
|
-
const [S, e] =
|
|
1918
|
+
const [S, e] = NR(T, E);
|
|
1833
1919
|
if (A.push(S), E = e, T[E] === "|")
|
|
1834
1920
|
E++;
|
|
1835
1921
|
else if (T[E] === "}" || T[E] === "]") {
|
|
@@ -1844,44 +1930,44 @@ const t = (T) => T.flatMap(AR), AR = (T) => Q(eR(T)).map(SR), SR = (T) => T.repl
|
|
|
1844
1930
|
throw new Error(`Unexpected "${T[E]}"`);
|
|
1845
1931
|
}
|
|
1846
1932
|
return [A, E];
|
|
1847
|
-
},
|
|
1933
|
+
}, NR = (T, E) => {
|
|
1848
1934
|
const R = [];
|
|
1849
1935
|
for (; ; ) {
|
|
1850
|
-
const [A, S] =
|
|
1936
|
+
const [A, S] = sR(T, E);
|
|
1851
1937
|
if (A)
|
|
1852
1938
|
R.push(A), E = S;
|
|
1853
1939
|
else
|
|
1854
1940
|
break;
|
|
1855
1941
|
}
|
|
1856
1942
|
return R.length === 1 ? [R[0], E] : [{ type: "concatenation", items: R }, E];
|
|
1857
|
-
},
|
|
1943
|
+
}, sR = (T, E) => {
|
|
1858
1944
|
if (T[E] === "{")
|
|
1859
|
-
return sR(T, E + 1);
|
|
1860
|
-
if (T[E] === "[")
|
|
1861
1945
|
return tR(T, E + 1);
|
|
1946
|
+
if (T[E] === "[")
|
|
1947
|
+
return CR(T, E + 1);
|
|
1862
1948
|
{
|
|
1863
1949
|
let R = "";
|
|
1864
1950
|
for (; T[E] && /[A-Za-z0-9_ ]/.test(T[E]); )
|
|
1865
1951
|
R += T[E], E++;
|
|
1866
1952
|
return [R, E];
|
|
1867
1953
|
}
|
|
1868
|
-
}, sR = (T, E) => {
|
|
1869
|
-
const [R, A] = hE(T, E, "}");
|
|
1870
|
-
return [{ type: "mandatory_block", items: R }, A];
|
|
1871
1954
|
}, tR = (T, E) => {
|
|
1872
|
-
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, "]");
|
|
1873
1959
|
return [{ type: "optional_block", items: R }, A];
|
|
1874
|
-
},
|
|
1960
|
+
}, Z = (T) => {
|
|
1875
1961
|
if (typeof T == "string")
|
|
1876
1962
|
return [T];
|
|
1877
1963
|
if (T.type === "concatenation")
|
|
1878
|
-
return T.items.map(
|
|
1964
|
+
return T.items.map(Z).reduce(LR, [""]);
|
|
1879
1965
|
if (T.type === "mandatory_block")
|
|
1880
|
-
return T.items.flatMap(
|
|
1966
|
+
return T.items.flatMap(Z);
|
|
1881
1967
|
if (T.type === "optional_block")
|
|
1882
|
-
return ["", ...T.items.flatMap(
|
|
1968
|
+
return ["", ...T.items.flatMap(Z)];
|
|
1883
1969
|
throw new Error(`Unknown node type: ${T}`);
|
|
1884
|
-
},
|
|
1970
|
+
}, LR = (T, E) => {
|
|
1885
1971
|
const R = [];
|
|
1886
1972
|
for (const A of T)
|
|
1887
1973
|
for (const S of E)
|
|
@@ -1892,19 +1978,19 @@ var i;
|
|
|
1892
1978
|
(function(T) {
|
|
1893
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";
|
|
1894
1980
|
})(i = i || (i = {}));
|
|
1895
|
-
const
|
|
1981
|
+
const uT = (T) => ({
|
|
1896
1982
|
type: i.EOF,
|
|
1897
1983
|
raw: "«EOF»",
|
|
1898
1984
|
text: "«EOF»",
|
|
1899
1985
|
start: T
|
|
1900
|
-
}),
|
|
1986
|
+
}), x = uT(1 / 0), g = (T) => (E) => E.type === T.type && E.text === T.text, X = {
|
|
1901
1987
|
ARRAY: g({ text: "ARRAY", type: i.RESERVED_DATA_TYPE }),
|
|
1902
1988
|
BY: g({ text: "BY", type: i.RESERVED_KEYWORD }),
|
|
1903
1989
|
SET: g({ text: "SET", type: i.RESERVED_CLAUSE }),
|
|
1904
1990
|
STRUCT: g({ text: "STRUCT", type: i.RESERVED_DATA_TYPE }),
|
|
1905
1991
|
WINDOW: g({ text: "WINDOW", type: i.RESERVED_CLAUSE }),
|
|
1906
1992
|
VALUES: g({ text: "VALUES", type: i.RESERVED_CLAUSE })
|
|
1907
|
-
},
|
|
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 = [
|
|
1908
1994
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
1909
1995
|
"KEYS.NEW_KEYSET",
|
|
1910
1996
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -2448,7 +2534,7 @@ const HT = (T) => ({
|
|
|
2448
2534
|
// pivot
|
|
2449
2535
|
"PIVOT",
|
|
2450
2536
|
"UNPIVOT"
|
|
2451
|
-
],
|
|
2537
|
+
], nR = [
|
|
2452
2538
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
|
|
2453
2539
|
"ALL",
|
|
2454
2540
|
"AND",
|
|
@@ -2556,7 +2642,7 @@ const HT = (T) => ({
|
|
|
2556
2642
|
"CASCADE",
|
|
2557
2643
|
"RESTRICT",
|
|
2558
2644
|
"DETERMINISTIC"
|
|
2559
|
-
],
|
|
2645
|
+
], DR = [
|
|
2560
2646
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
|
|
2561
2647
|
"ARRAY",
|
|
2562
2648
|
"BOOL",
|
|
@@ -2581,7 +2667,7 @@ const HT = (T) => ({
|
|
|
2581
2667
|
"STRUCT",
|
|
2582
2668
|
"TIME",
|
|
2583
2669
|
"TIMEZONE"
|
|
2584
|
-
],
|
|
2670
|
+
], iR = C(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), PR = C([
|
|
2585
2671
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
2586
2672
|
"WITH [RECURSIVE]",
|
|
2587
2673
|
"FROM",
|
|
@@ -2610,9 +2696,9 @@ const HT = (T) => ({
|
|
|
2610
2696
|
"WITH CONNECTION",
|
|
2611
2697
|
"WITH PARTITION COLUMNS",
|
|
2612
2698
|
"REMOTE WITH CONNECTION"
|
|
2613
|
-
]), xE =
|
|
2699
|
+
]), xE = C([
|
|
2614
2700
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
2615
|
-
]), NE =
|
|
2701
|
+
]), NE = C([
|
|
2616
2702
|
// - create:
|
|
2617
2703
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
2618
2704
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -2700,15 +2786,15 @@ const HT = (T) => ({
|
|
|
2700
2786
|
"ASSERT",
|
|
2701
2787
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
2702
2788
|
"EXPORT DATA"
|
|
2703
|
-
]),
|
|
2789
|
+
]), oR = C([
|
|
2704
2790
|
"UNION {ALL | DISTINCT}",
|
|
2705
2791
|
"EXCEPT DISTINCT",
|
|
2706
2792
|
"INTERSECT DISTINCT"
|
|
2707
|
-
]), aR =
|
|
2793
|
+
]), aR = C([
|
|
2708
2794
|
"JOIN",
|
|
2709
2795
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
2710
2796
|
"{INNER | CROSS} JOIN"
|
|
2711
|
-
]),
|
|
2797
|
+
]), MR = C([
|
|
2712
2798
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
2713
2799
|
"TABLESAMPLE SYSTEM",
|
|
2714
2800
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -2719,18 +2805,18 @@ const HT = (T) => ({
|
|
|
2719
2805
|
"{ROWS | RANGE} BETWEEN",
|
|
2720
2806
|
// comparison operator
|
|
2721
2807
|
"IS [NOT] DISTINCT FROM"
|
|
2722
|
-
]),
|
|
2808
|
+
]), UR = C([]), GR = {
|
|
2723
2809
|
name: "bigquery",
|
|
2724
2810
|
tokenizerOptions: {
|
|
2725
|
-
reservedSelect:
|
|
2726
|
-
reservedClauses: [...
|
|
2727
|
-
reservedSetOperations:
|
|
2811
|
+
reservedSelect: iR,
|
|
2812
|
+
reservedClauses: [...PR, ...NE, ...xE],
|
|
2813
|
+
reservedSetOperations: oR,
|
|
2728
2814
|
reservedJoins: aR,
|
|
2729
|
-
reservedKeywordPhrases:
|
|
2730
|
-
reservedDataTypePhrases:
|
|
2731
|
-
reservedKeywords:
|
|
2732
|
-
reservedDataTypes:
|
|
2733
|
-
reservedFunctionNames:
|
|
2815
|
+
reservedKeywordPhrases: MR,
|
|
2816
|
+
reservedDataTypePhrases: UR,
|
|
2817
|
+
reservedKeywords: nR,
|
|
2818
|
+
reservedDataTypes: DR,
|
|
2819
|
+
reservedFunctionNames: rR,
|
|
2734
2820
|
extraParens: ["[]"],
|
|
2735
2821
|
stringTypes: [
|
|
2736
2822
|
// The triple-quoted strings are listed first, so they get matched first.
|
|
@@ -2748,27 +2834,27 @@ const HT = (T) => ({
|
|
|
2748
2834
|
variableTypes: [{ regex: String.raw`@@\w+` }],
|
|
2749
2835
|
lineCommentTypes: ["--", "#"],
|
|
2750
2836
|
operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
|
|
2751
|
-
postProcess:
|
|
2837
|
+
postProcess: cR
|
|
2752
2838
|
},
|
|
2753
2839
|
formatOptions: {
|
|
2754
2840
|
onelineClauses: [...xE, ...NE],
|
|
2755
2841
|
tabularOnelineClauses: NE
|
|
2756
2842
|
}
|
|
2757
2843
|
};
|
|
2758
|
-
function GR(T) {
|
|
2759
|
-
return cR(lR(T));
|
|
2760
|
-
}
|
|
2761
2844
|
function cR(T) {
|
|
2762
|
-
|
|
2763
|
-
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));
|
|
2764
2846
|
}
|
|
2765
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) {
|
|
2766
2852
|
var E;
|
|
2767
2853
|
const R = [];
|
|
2768
2854
|
for (let A = 0; A < T.length; A++) {
|
|
2769
2855
|
const S = T[A];
|
|
2770
2856
|
if ((X.ARRAY(S) || X.STRUCT(S)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
2771
|
-
const e =
|
|
2857
|
+
const e = uR(T, A + 1), O = T.slice(A, e + 1);
|
|
2772
2858
|
R.push({
|
|
2773
2859
|
type: i.IDENTIFIER,
|
|
2774
2860
|
raw: O.map(vE("raw")).join(""),
|
|
@@ -2781,7 +2867,7 @@ function lR(T) {
|
|
|
2781
2867
|
return R;
|
|
2782
2868
|
}
|
|
2783
2869
|
const vE = (T) => (E) => E.type === i.IDENTIFIER || E.type === i.COMMA ? E[T] + " " : E[T];
|
|
2784
|
-
function
|
|
2870
|
+
function uR(T, E) {
|
|
2785
2871
|
let R = 0;
|
|
2786
2872
|
for (let A = E; A < T.length; A++) {
|
|
2787
2873
|
const S = T[A];
|
|
@@ -2790,7 +2876,7 @@ function HR(T, E) {
|
|
|
2790
2876
|
}
|
|
2791
2877
|
return T.length - 1;
|
|
2792
2878
|
}
|
|
2793
|
-
const
|
|
2879
|
+
const BR = [
|
|
2794
2880
|
// https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
|
|
2795
2881
|
"ARRAY_AGG",
|
|
2796
2882
|
"AVG",
|
|
@@ -3110,7 +3196,7 @@ const uR = [
|
|
|
3110
3196
|
"RATIO_TO_REPORT",
|
|
3111
3197
|
// Type casting
|
|
3112
3198
|
"CAST"
|
|
3113
|
-
],
|
|
3199
|
+
], FR = [
|
|
3114
3200
|
// https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
|
|
3115
3201
|
"ACTIVATE",
|
|
3116
3202
|
"ADD",
|
|
@@ -3511,7 +3597,7 @@ const uR = [
|
|
|
3511
3597
|
"XMLNAMESPACES",
|
|
3512
3598
|
"YEAR",
|
|
3513
3599
|
"YEARS"
|
|
3514
|
-
],
|
|
3600
|
+
], YR = [
|
|
3515
3601
|
// https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
|
|
3516
3602
|
"ARRAY",
|
|
3517
3603
|
"BIGINT",
|
|
@@ -3553,7 +3639,7 @@ const uR = [
|
|
|
3553
3639
|
"VARBINARY",
|
|
3554
3640
|
"VARCHAR",
|
|
3555
3641
|
"VARGRAPHIC"
|
|
3556
|
-
],
|
|
3642
|
+
], mR = C(["SELECT [ALL | DISTINCT]"]), pR = C([
|
|
3557
3643
|
// queries
|
|
3558
3644
|
"WITH",
|
|
3559
3645
|
"FROM",
|
|
@@ -3582,9 +3668,9 @@ const uR = [
|
|
|
3582
3668
|
"WHEN [NOT] MATCHED [THEN]",
|
|
3583
3669
|
"UPDATE SET",
|
|
3584
3670
|
"INSERT"
|
|
3585
|
-
]), QE =
|
|
3671
|
+
]), QE = C([
|
|
3586
3672
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3587
|
-
]), sE =
|
|
3673
|
+
]), sE = C([
|
|
3588
3674
|
// - create:
|
|
3589
3675
|
"CREATE [OR REPLACE] VIEW",
|
|
3590
3676
|
// - update:
|
|
@@ -3787,27 +3873,27 @@ const uR = [
|
|
|
3787
3873
|
"TRANSFER OWNERSHIP OF",
|
|
3788
3874
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
3789
3875
|
"WHILE"
|
|
3790
|
-
]),
|
|
3876
|
+
]), dR = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), hR = C([
|
|
3791
3877
|
"JOIN",
|
|
3792
3878
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3793
3879
|
"{INNER | CROSS} JOIN"
|
|
3794
|
-
]), VR =
|
|
3880
|
+
]), VR = C([
|
|
3795
3881
|
"ON DELETE",
|
|
3796
3882
|
"ON UPDATE",
|
|
3797
3883
|
"SET NULL",
|
|
3798
3884
|
"{ROWS | RANGE} BETWEEN"
|
|
3799
|
-
]),
|
|
3885
|
+
]), fR = C([]), WR = {
|
|
3800
3886
|
name: "db2",
|
|
3801
3887
|
tokenizerOptions: {
|
|
3802
|
-
reservedSelect:
|
|
3803
|
-
reservedClauses: [...
|
|
3804
|
-
reservedSetOperations:
|
|
3805
|
-
reservedJoins:
|
|
3888
|
+
reservedSelect: mR,
|
|
3889
|
+
reservedClauses: [...pR, ...QE, ...sE],
|
|
3890
|
+
reservedSetOperations: dR,
|
|
3891
|
+
reservedJoins: hR,
|
|
3806
3892
|
reservedKeywordPhrases: VR,
|
|
3807
|
-
reservedDataTypePhrases:
|
|
3808
|
-
reservedKeywords:
|
|
3809
|
-
reservedDataTypes:
|
|
3810
|
-
reservedFunctionNames:
|
|
3893
|
+
reservedDataTypePhrases: fR,
|
|
3894
|
+
reservedKeywords: FR,
|
|
3895
|
+
reservedDataTypes: YR,
|
|
3896
|
+
reservedFunctionNames: BR,
|
|
3811
3897
|
extraParens: ["[]"],
|
|
3812
3898
|
stringTypes: [
|
|
3813
3899
|
{ quote: "''-qq", prefixes: ["G", "N", "U&"] },
|
|
@@ -3841,7 +3927,7 @@ const uR = [
|
|
|
3841
3927
|
onelineClauses: [...QE, ...sE],
|
|
3842
3928
|
tabularOnelineClauses: sE
|
|
3843
3929
|
}
|
|
3844
|
-
},
|
|
3930
|
+
}, XR = [
|
|
3845
3931
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
3846
3932
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
3847
3933
|
"ARRAY_AGG",
|
|
@@ -4175,7 +4261,7 @@ const uR = [
|
|
|
4175
4261
|
"ROW_NUMBER",
|
|
4176
4262
|
// Type casting
|
|
4177
4263
|
"CAST"
|
|
4178
|
-
],
|
|
4264
|
+
], bR = [
|
|
4179
4265
|
// https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
|
|
4180
4266
|
// TODO: This list likely contains all keywords, not only the reserved ones,
|
|
4181
4267
|
// try to filter it down to just the reserved keywords.
|
|
@@ -4671,7 +4757,7 @@ const uR = [
|
|
|
4671
4757
|
"YEARS",
|
|
4672
4758
|
"YES",
|
|
4673
4759
|
"ZONE"
|
|
4674
|
-
],
|
|
4760
|
+
], yR = [
|
|
4675
4761
|
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
|
|
4676
4762
|
"ARRAY",
|
|
4677
4763
|
"BIGINT",
|
|
@@ -4707,7 +4793,7 @@ const uR = [
|
|
|
4707
4793
|
"VARCHAR",
|
|
4708
4794
|
"VARGRAPHIC",
|
|
4709
4795
|
"XML"
|
|
4710
|
-
], KR =
|
|
4796
|
+
], KR = C(["SELECT [ALL | DISTINCT]"]), $R = C([
|
|
4711
4797
|
// queries
|
|
4712
4798
|
"WITH [RECURSIVE]",
|
|
4713
4799
|
"INTO",
|
|
@@ -4737,7 +4823,7 @@ const uR = [
|
|
|
4737
4823
|
"INSERT",
|
|
4738
4824
|
// Data definition - table
|
|
4739
4825
|
"FOR SYSTEM NAME"
|
|
4740
|
-
]), ZE =
|
|
4826
|
+
]), ZE = C(["CREATE [OR REPLACE] TABLE"]), tE = C([
|
|
4741
4827
|
// - create:
|
|
4742
4828
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
4743
4829
|
// - update:
|
|
@@ -4833,28 +4919,28 @@ const uR = [
|
|
|
4833
4919
|
"TAG",
|
|
4834
4920
|
"TRANSFER OWNERSHIP OF",
|
|
4835
4921
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
4836
|
-
]),
|
|
4922
|
+
]), gR = C(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), JR = C([
|
|
4837
4923
|
"JOIN",
|
|
4838
4924
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4839
4925
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
4840
4926
|
"{INNER | CROSS} JOIN"
|
|
4841
|
-
]),
|
|
4927
|
+
]), wR = C([
|
|
4842
4928
|
"ON DELETE",
|
|
4843
4929
|
"ON UPDATE",
|
|
4844
4930
|
"SET NULL",
|
|
4845
4931
|
"{ROWS | RANGE} BETWEEN"
|
|
4846
|
-
]),
|
|
4932
|
+
]), xR = C([]), vR = {
|
|
4847
4933
|
name: "db2i",
|
|
4848
4934
|
tokenizerOptions: {
|
|
4849
4935
|
reservedSelect: KR,
|
|
4850
|
-
reservedClauses: [
|
|
4851
|
-
reservedSetOperations:
|
|
4852
|
-
reservedJoins:
|
|
4853
|
-
reservedKeywordPhrases:
|
|
4854
|
-
reservedDataTypePhrases:
|
|
4855
|
-
reservedKeywords:
|
|
4856
|
-
reservedDataTypes:
|
|
4857
|
-
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,
|
|
4858
4944
|
nestedBlockComments: !0,
|
|
4859
4945
|
extraParens: ["[]"],
|
|
4860
4946
|
stringTypes: [
|
|
@@ -4871,7 +4957,7 @@ const uR = [
|
|
|
4871
4957
|
onelineClauses: [...ZE, ...tE],
|
|
4872
4958
|
tabularOnelineClauses: tE
|
|
4873
4959
|
}
|
|
4874
|
-
},
|
|
4960
|
+
}, QR = [
|
|
4875
4961
|
// Functions from DuckDB (excluding those that start with an underscore):
|
|
4876
4962
|
// SELECT DISTINCT upper(function_name) AS function_name
|
|
4877
4963
|
// FROM duckdb_functions()
|
|
@@ -5534,7 +5620,7 @@ const uR = [
|
|
|
5534
5620
|
// 'NULL', we really prefer treating it as keyword
|
|
5535
5621
|
"RANK",
|
|
5536
5622
|
"ROW_NUMBER"
|
|
5537
|
-
],
|
|
5623
|
+
], ZR = [
|
|
5538
5624
|
// Keywords from DuckDB:
|
|
5539
5625
|
// SELECT upper(keyword_name)
|
|
5540
5626
|
// FROM duckdb_keywords()
|
|
@@ -5616,7 +5702,7 @@ const uR = [
|
|
|
5616
5702
|
"WHERE",
|
|
5617
5703
|
"WINDOW",
|
|
5618
5704
|
"WITH"
|
|
5619
|
-
],
|
|
5705
|
+
], qR = [
|
|
5620
5706
|
// Types from DuckDB:
|
|
5621
5707
|
// SELECT DISTINCT upper(type_name)
|
|
5622
5708
|
// FROM duckdb_types()
|
|
@@ -5696,7 +5782,7 @@ const uR = [
|
|
|
5696
5782
|
"UUID",
|
|
5697
5783
|
"VARBINARY",
|
|
5698
5784
|
"VARCHAR"
|
|
5699
|
-
],
|
|
5785
|
+
], jR = C(["SELECT [ALL | DISTINCT]"]), kR = C([
|
|
5700
5786
|
// queries
|
|
5701
5787
|
"WITH [RECURSIVE]",
|
|
5702
5788
|
"FROM",
|
|
@@ -5720,9 +5806,9 @@ const uR = [
|
|
|
5720
5806
|
"SET",
|
|
5721
5807
|
// other:
|
|
5722
5808
|
"RETURNING"
|
|
5723
|
-
]), qE =
|
|
5809
|
+
]), qE = C([
|
|
5724
5810
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
5725
|
-
]), CE =
|
|
5811
|
+
]), CE = C([
|
|
5726
5812
|
// TABLE
|
|
5727
5813
|
// - update:
|
|
5728
5814
|
"UPDATE",
|
|
@@ -5800,11 +5886,11 @@ const uR = [
|
|
|
5800
5886
|
"PREPARE",
|
|
5801
5887
|
"EXECUTE",
|
|
5802
5888
|
"DEALLOCATE [PREPARE]"
|
|
5803
|
-
]),
|
|
5889
|
+
]), zR = C([
|
|
5804
5890
|
"UNION [ALL | BY NAME]",
|
|
5805
5891
|
"EXCEPT [ALL]",
|
|
5806
5892
|
"INTERSECT [ALL]"
|
|
5807
|
-
]),
|
|
5893
|
+
]), EA = C([
|
|
5808
5894
|
"JOIN",
|
|
5809
5895
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5810
5896
|
"{INNER | CROSS} JOIN",
|
|
@@ -5813,23 +5899,23 @@ const uR = [
|
|
|
5813
5899
|
"POSITIONAL JOIN",
|
|
5814
5900
|
"ANTI JOIN",
|
|
5815
5901
|
"SEMI JOIN"
|
|
5816
|
-
]),
|
|
5902
|
+
]), TA = C([
|
|
5817
5903
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
5818
5904
|
"SIMILAR TO",
|
|
5819
5905
|
"IS [NOT] DISTINCT FROM"
|
|
5820
|
-
]),
|
|
5906
|
+
]), RA = C(["TIMESTAMP WITH TIME ZONE"]), AA = {
|
|
5821
5907
|
name: "duckdb",
|
|
5822
5908
|
tokenizerOptions: {
|
|
5823
|
-
reservedSelect:
|
|
5909
|
+
reservedSelect: jR,
|
|
5824
5910
|
reservedClauses: [...kR, ...qE, ...CE],
|
|
5825
|
-
reservedSetOperations:
|
|
5826
|
-
reservedJoins:
|
|
5827
|
-
reservedKeywordPhrases:
|
|
5828
|
-
reservedDataTypePhrases:
|
|
5911
|
+
reservedSetOperations: zR,
|
|
5912
|
+
reservedJoins: EA,
|
|
5913
|
+
reservedKeywordPhrases: TA,
|
|
5914
|
+
reservedDataTypePhrases: RA,
|
|
5829
5915
|
supportsXor: !0,
|
|
5830
|
-
reservedKeywords:
|
|
5831
|
-
reservedDataTypes:
|
|
5832
|
-
reservedFunctionNames:
|
|
5916
|
+
reservedKeywords: ZR,
|
|
5917
|
+
reservedDataTypes: qR,
|
|
5918
|
+
reservedFunctionNames: QR,
|
|
5833
5919
|
nestedBlockComments: !0,
|
|
5834
5920
|
extraParens: ["[]", "{}"],
|
|
5835
5921
|
underscoresInNumbers: !0,
|
|
@@ -5893,7 +5979,7 @@ const uR = [
|
|
|
5893
5979
|
onelineClauses: [...qE, ...CE],
|
|
5894
5980
|
tabularOnelineClauses: CE
|
|
5895
5981
|
}
|
|
5896
|
-
},
|
|
5982
|
+
}, SA = [
|
|
5897
5983
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
|
|
5898
5984
|
// math
|
|
5899
5985
|
"ABS",
|
|
@@ -6101,7 +6187,7 @@ const uR = [
|
|
|
6101
6187
|
"CUME_DIST",
|
|
6102
6188
|
"PERCENT_RANK",
|
|
6103
6189
|
"NTILE"
|
|
6104
|
-
],
|
|
6190
|
+
], eA = [
|
|
6105
6191
|
// https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
|
|
6106
6192
|
// Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
|
|
6107
6193
|
"ADD",
|
|
@@ -6416,7 +6502,7 @@ const uR = [
|
|
|
6416
6502
|
"JSONFILE",
|
|
6417
6503
|
"INPUTFORMAT",
|
|
6418
6504
|
"OUTPUTFORMAT"
|
|
6419
|
-
],
|
|
6505
|
+
], IA = [
|
|
6420
6506
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
|
|
6421
6507
|
"ARRAY",
|
|
6422
6508
|
"BIGINT",
|
|
@@ -6437,7 +6523,7 @@ const uR = [
|
|
|
6437
6523
|
"STRUCT",
|
|
6438
6524
|
"TIMESTAMP",
|
|
6439
6525
|
"VARCHAR"
|
|
6440
|
-
],
|
|
6526
|
+
], OA = C(["SELECT [ALL | DISTINCT]"]), NA = C([
|
|
6441
6527
|
// queries
|
|
6442
6528
|
"WITH",
|
|
6443
6529
|
"FROM",
|
|
@@ -6471,9 +6557,9 @@ const uR = [
|
|
|
6471
6557
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
6472
6558
|
"LOAD DATA [LOCAL] INPATH",
|
|
6473
6559
|
"[OVERWRITE] INTO TABLE"
|
|
6474
|
-
]),
|
|
6560
|
+
]), jE = C([
|
|
6475
6561
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
6476
|
-
]), LE =
|
|
6562
|
+
]), LE = C([
|
|
6477
6563
|
// - create:
|
|
6478
6564
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
6479
6565
|
// - update:
|
|
@@ -6498,24 +6584,24 @@ const uR = [
|
|
|
6498
6584
|
"STORED AS",
|
|
6499
6585
|
"STORED BY",
|
|
6500
6586
|
"ROW FORMAT"
|
|
6501
|
-
]),
|
|
6587
|
+
]), sA = C(["UNION [ALL | DISTINCT]"]), tA = C([
|
|
6502
6588
|
"JOIN",
|
|
6503
6589
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6504
6590
|
"{INNER | CROSS} JOIN",
|
|
6505
6591
|
// non-standard joins
|
|
6506
6592
|
"LEFT SEMI JOIN"
|
|
6507
|
-
]),
|
|
6593
|
+
]), CA = C(["{ROWS | RANGE} BETWEEN"]), LA = C([]), _A = {
|
|
6508
6594
|
name: "hive",
|
|
6509
6595
|
tokenizerOptions: {
|
|
6510
|
-
reservedSelect:
|
|
6511
|
-
reservedClauses: [...
|
|
6512
|
-
reservedSetOperations:
|
|
6513
|
-
reservedJoins:
|
|
6514
|
-
reservedKeywordPhrases:
|
|
6515
|
-
reservedDataTypePhrases:
|
|
6516
|
-
reservedKeywords:
|
|
6517
|
-
reservedDataTypes:
|
|
6518
|
-
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,
|
|
6519
6605
|
extraParens: ["[]"],
|
|
6520
6606
|
stringTypes: ['""-bs', "''-bs"],
|
|
6521
6607
|
identTypes: ["``"],
|
|
@@ -6523,20 +6609,20 @@ const uR = [
|
|
|
6523
6609
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||"]
|
|
6524
6610
|
},
|
|
6525
6611
|
formatOptions: {
|
|
6526
|
-
onelineClauses: [...
|
|
6612
|
+
onelineClauses: [...jE, ...LE],
|
|
6527
6613
|
tabularOnelineClauses: LE
|
|
6528
6614
|
}
|
|
6529
6615
|
};
|
|
6530
6616
|
function EE(T) {
|
|
6531
6617
|
return T.map((E, R) => {
|
|
6532
|
-
const A = T[R + 1] ||
|
|
6618
|
+
const A = T[R + 1] || x;
|
|
6533
6619
|
if (X.SET(E) && A.text === "(")
|
|
6534
6620
|
return Object.assign(Object.assign({}, E), { type: i.RESERVED_FUNCTION_NAME });
|
|
6535
|
-
const S = T[R - 1] ||
|
|
6621
|
+
const S = T[R - 1] || x;
|
|
6536
6622
|
return X.VALUES(E) && S.text === "=" ? Object.assign(Object.assign({}, E), { type: i.RESERVED_FUNCTION_NAME }) : E;
|
|
6537
6623
|
});
|
|
6538
6624
|
}
|
|
6539
|
-
const
|
|
6625
|
+
const rA = [
|
|
6540
6626
|
// https://mariadb.com/kb/en/reserved-words/
|
|
6541
6627
|
"ACCESSIBLE",
|
|
6542
6628
|
"ADD",
|
|
@@ -6753,7 +6839,7 @@ const _A = [
|
|
|
6753
6839
|
"XOR",
|
|
6754
6840
|
"YEAR_MONTH",
|
|
6755
6841
|
"ZEROFILL"
|
|
6756
|
-
],
|
|
6842
|
+
], nA = [
|
|
6757
6843
|
// https://mariadb.com/kb/en/data-types/
|
|
6758
6844
|
"BIGINT",
|
|
6759
6845
|
"BINARY",
|
|
@@ -6804,7 +6890,7 @@ const _A = [
|
|
|
6804
6890
|
"YEAR"
|
|
6805
6891
|
// 'NUMBER', // ?? In oracle mode only
|
|
6806
6892
|
// 'SET' // handled as special-case in postProcess
|
|
6807
|
-
],
|
|
6893
|
+
], DA = [
|
|
6808
6894
|
// https://mariadb.com/kb/en/information-schema-sql_functions-table/
|
|
6809
6895
|
"ADDDATE",
|
|
6810
6896
|
"ADD_MONTHS",
|
|
@@ -7042,7 +7128,7 @@ const _A = [
|
|
|
7042
7128
|
// CASE expression shorthands
|
|
7043
7129
|
"COALESCE",
|
|
7044
7130
|
"NULLIF"
|
|
7045
|
-
],
|
|
7131
|
+
], iA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), PA = C([
|
|
7046
7132
|
// queries
|
|
7047
7133
|
"WITH [RECURSIVE]",
|
|
7048
7134
|
"FROM",
|
|
@@ -7064,9 +7150,9 @@ const _A = [
|
|
|
7064
7150
|
"SET",
|
|
7065
7151
|
// other
|
|
7066
7152
|
"RETURNING"
|
|
7067
|
-
]),
|
|
7153
|
+
]), kE = C([
|
|
7068
7154
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
7069
|
-
]), _E =
|
|
7155
|
+
]), _E = C([
|
|
7070
7156
|
// - create:
|
|
7071
7157
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
7072
7158
|
// - update:
|
|
@@ -7273,12 +7359,12 @@ const _A = [
|
|
|
7273
7359
|
"XA RECOVER",
|
|
7274
7360
|
"XA ROLLBACK",
|
|
7275
7361
|
"XA START"
|
|
7276
|
-
]),
|
|
7362
|
+
]), oA = C([
|
|
7277
7363
|
"UNION [ALL | DISTINCT]",
|
|
7278
7364
|
"EXCEPT [ALL | DISTINCT]",
|
|
7279
7365
|
"INTERSECT [ALL | DISTINCT]",
|
|
7280
7366
|
"MINUS [ALL | DISTINCT]"
|
|
7281
|
-
]), aA =
|
|
7367
|
+
]), aA = C([
|
|
7282
7368
|
"JOIN",
|
|
7283
7369
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
7284
7370
|
"{INNER | CROSS} JOIN",
|
|
@@ -7286,24 +7372,24 @@ const _A = [
|
|
|
7286
7372
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7287
7373
|
// non-standard joins
|
|
7288
7374
|
"STRAIGHT_JOIN"
|
|
7289
|
-
]),
|
|
7375
|
+
]), MA = C([
|
|
7290
7376
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7291
7377
|
"CHARACTER SET",
|
|
7292
7378
|
"{ROWS | RANGE} BETWEEN",
|
|
7293
7379
|
"IDENTIFIED BY"
|
|
7294
|
-
]),
|
|
7380
|
+
]), UA = C([]), GA = {
|
|
7295
7381
|
name: "mariadb",
|
|
7296
7382
|
tokenizerOptions: {
|
|
7297
|
-
reservedSelect:
|
|
7298
|
-
reservedClauses: [...
|
|
7299
|
-
reservedSetOperations:
|
|
7383
|
+
reservedSelect: iA,
|
|
7384
|
+
reservedClauses: [...PA, ...kE, ..._E],
|
|
7385
|
+
reservedSetOperations: oA,
|
|
7300
7386
|
reservedJoins: aA,
|
|
7301
|
-
reservedKeywordPhrases:
|
|
7302
|
-
reservedDataTypePhrases:
|
|
7387
|
+
reservedKeywordPhrases: MA,
|
|
7388
|
+
reservedDataTypePhrases: UA,
|
|
7303
7389
|
supportsXor: !0,
|
|
7304
|
-
reservedKeywords:
|
|
7305
|
-
reservedDataTypes:
|
|
7306
|
-
reservedFunctionNames:
|
|
7390
|
+
reservedKeywords: rA,
|
|
7391
|
+
reservedDataTypes: nA,
|
|
7392
|
+
reservedFunctionNames: DA,
|
|
7307
7393
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
7308
7394
|
stringTypes: [
|
|
7309
7395
|
'""-qq-bs',
|
|
@@ -7339,10 +7425,10 @@ const _A = [
|
|
|
7339
7425
|
postProcess: EE
|
|
7340
7426
|
},
|
|
7341
7427
|
formatOptions: {
|
|
7342
|
-
onelineClauses: [...
|
|
7428
|
+
onelineClauses: [...kE, ..._E],
|
|
7343
7429
|
tabularOnelineClauses: _E
|
|
7344
7430
|
}
|
|
7345
|
-
},
|
|
7431
|
+
}, cA = [
|
|
7346
7432
|
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
|
|
7347
7433
|
"ACCESSIBLE",
|
|
7348
7434
|
"ADD",
|
|
@@ -7573,7 +7659,7 @@ const _A = [
|
|
|
7573
7659
|
"YEAR_MONTH",
|
|
7574
7660
|
"ZEROFILL"
|
|
7575
7661
|
// (R)
|
|
7576
|
-
],
|
|
7662
|
+
], lA = [
|
|
7577
7663
|
// https://dev.mysql.com/doc/refman/8.0/en/data-types.html
|
|
7578
7664
|
"BIGINT",
|
|
7579
7665
|
"BINARY",
|
|
@@ -7625,7 +7711,7 @@ const _A = [
|
|
|
7625
7711
|
"VARYING",
|
|
7626
7712
|
"YEAR"
|
|
7627
7713
|
// 'SET' // handled as special-case in postProcess
|
|
7628
|
-
],
|
|
7714
|
+
], HA = [
|
|
7629
7715
|
// https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
|
|
7630
7716
|
"ABS",
|
|
7631
7717
|
"ACOS",
|
|
@@ -8048,7 +8134,7 @@ const _A = [
|
|
|
8048
8134
|
// 'XOR',
|
|
8049
8135
|
"YEAR",
|
|
8050
8136
|
"YEARWEEK"
|
|
8051
|
-
],
|
|
8137
|
+
], uA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), BA = C([
|
|
8052
8138
|
// queries
|
|
8053
8139
|
"WITH [RECURSIVE]",
|
|
8054
8140
|
"FROM",
|
|
@@ -8068,7 +8154,7 @@ const _A = [
|
|
|
8068
8154
|
"ON DUPLICATE KEY UPDATE",
|
|
8069
8155
|
// - update:
|
|
8070
8156
|
"SET"
|
|
8071
|
-
]), zE =
|
|
8157
|
+
]), zE = C(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), rE = C([
|
|
8072
8158
|
// - create:
|
|
8073
8159
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8074
8160
|
// - update:
|
|
@@ -8249,7 +8335,7 @@ const _A = [
|
|
|
8249
8335
|
"REPEAT",
|
|
8250
8336
|
"RETURN",
|
|
8251
8337
|
"WHILE"
|
|
8252
|
-
]),
|
|
8338
|
+
]), FA = C(["UNION [ALL | DISTINCT]"]), YA = C([
|
|
8253
8339
|
"JOIN",
|
|
8254
8340
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8255
8341
|
"{INNER | CROSS} JOIN",
|
|
@@ -8257,24 +8343,24 @@ const _A = [
|
|
|
8257
8343
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8258
8344
|
// non-standard joins
|
|
8259
8345
|
"STRAIGHT_JOIN"
|
|
8260
|
-
]),
|
|
8346
|
+
]), mA = C([
|
|
8261
8347
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8262
8348
|
"CHARACTER SET",
|
|
8263
8349
|
"{ROWS | RANGE} BETWEEN",
|
|
8264
8350
|
"IDENTIFIED BY"
|
|
8265
|
-
]),
|
|
8351
|
+
]), pA = C([]), dA = {
|
|
8266
8352
|
name: "mysql",
|
|
8267
8353
|
tokenizerOptions: {
|
|
8268
|
-
reservedSelect:
|
|
8269
|
-
reservedClauses: [...
|
|
8270
|
-
reservedSetOperations:
|
|
8271
|
-
reservedJoins:
|
|
8272
|
-
reservedKeywordPhrases:
|
|
8273
|
-
reservedDataTypePhrases:
|
|
8354
|
+
reservedSelect: uA,
|
|
8355
|
+
reservedClauses: [...BA, ...zE, ...rE],
|
|
8356
|
+
reservedSetOperations: FA,
|
|
8357
|
+
reservedJoins: YA,
|
|
8358
|
+
reservedKeywordPhrases: mA,
|
|
8359
|
+
reservedDataTypePhrases: pA,
|
|
8274
8360
|
supportsXor: !0,
|
|
8275
|
-
reservedKeywords:
|
|
8276
|
-
reservedDataTypes:
|
|
8277
|
-
reservedFunctionNames:
|
|
8361
|
+
reservedKeywords: cA,
|
|
8362
|
+
reservedDataTypes: lA,
|
|
8363
|
+
reservedFunctionNames: HA,
|
|
8278
8364
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
8279
8365
|
stringTypes: [
|
|
8280
8366
|
'""-qq-bs',
|
|
@@ -8315,7 +8401,7 @@ const _A = [
|
|
|
8315
8401
|
onelineClauses: [...zE, ...rE],
|
|
8316
8402
|
tabularOnelineClauses: rE
|
|
8317
8403
|
}
|
|
8318
|
-
},
|
|
8404
|
+
}, hA = [
|
|
8319
8405
|
// https://docs.pingcap.com/tidb/stable/keywords
|
|
8320
8406
|
"ADD",
|
|
8321
8407
|
"ALL",
|
|
@@ -8554,7 +8640,7 @@ const _A = [
|
|
|
8554
8640
|
"VARYING",
|
|
8555
8641
|
"YEAR"
|
|
8556
8642
|
// 'SET' // handled as special-case in postProcess
|
|
8557
|
-
],
|
|
8643
|
+
], fA = [
|
|
8558
8644
|
// https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
|
|
8559
8645
|
// https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
|
|
8560
8646
|
// + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
|
|
@@ -8880,7 +8966,7 @@ const _A = [
|
|
|
8880
8966
|
// 'XOR',
|
|
8881
8967
|
"YEAR",
|
|
8882
8968
|
"YEARWEEK"
|
|
8883
|
-
], WA =
|
|
8969
|
+
], WA = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), XA = C([
|
|
8884
8970
|
// queries
|
|
8885
8971
|
"WITH [RECURSIVE]",
|
|
8886
8972
|
"FROM",
|
|
@@ -8900,7 +8986,7 @@ const _A = [
|
|
|
8900
8986
|
"ON DUPLICATE KEY UPDATE",
|
|
8901
8987
|
// - update:
|
|
8902
8988
|
"SET"
|
|
8903
|
-
]), ET =
|
|
8989
|
+
]), ET = C(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), nE = C([
|
|
8904
8990
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
8905
8991
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8906
8992
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -9015,7 +9101,7 @@ const _A = [
|
|
|
9015
9101
|
"UNLOCK TABLES",
|
|
9016
9102
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
9017
9103
|
"USE"
|
|
9018
|
-
]),
|
|
9104
|
+
]), bA = C(["UNION [ALL | DISTINCT]"]), yA = C([
|
|
9019
9105
|
"JOIN",
|
|
9020
9106
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9021
9107
|
"{INNER | CROSS} JOIN",
|
|
@@ -9023,24 +9109,24 @@ const _A = [
|
|
|
9023
9109
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9024
9110
|
// non-standard joins
|
|
9025
9111
|
"STRAIGHT_JOIN"
|
|
9026
|
-
]), KA =
|
|
9112
|
+
]), KA = C([
|
|
9027
9113
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9028
9114
|
"CHARACTER SET",
|
|
9029
9115
|
"{ROWS | RANGE} BETWEEN",
|
|
9030
9116
|
"IDENTIFIED BY"
|
|
9031
|
-
]),
|
|
9117
|
+
]), $A = C([]), gA = {
|
|
9032
9118
|
name: "tidb",
|
|
9033
9119
|
tokenizerOptions: {
|
|
9034
9120
|
reservedSelect: WA,
|
|
9035
|
-
reservedClauses: [...
|
|
9036
|
-
reservedSetOperations:
|
|
9037
|
-
reservedJoins:
|
|
9121
|
+
reservedClauses: [...XA, ...ET, ...nE],
|
|
9122
|
+
reservedSetOperations: bA,
|
|
9123
|
+
reservedJoins: yA,
|
|
9038
9124
|
reservedKeywordPhrases: KA,
|
|
9039
|
-
reservedDataTypePhrases:
|
|
9125
|
+
reservedDataTypePhrases: $A,
|
|
9040
9126
|
supportsXor: !0,
|
|
9041
|
-
reservedKeywords:
|
|
9127
|
+
reservedKeywords: hA,
|
|
9042
9128
|
reservedDataTypes: VA,
|
|
9043
|
-
reservedFunctionNames:
|
|
9129
|
+
reservedFunctionNames: fA,
|
|
9044
9130
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
9045
9131
|
stringTypes: [
|
|
9046
9132
|
'""-qq-bs',
|
|
@@ -9081,7 +9167,7 @@ const _A = [
|
|
|
9081
9167
|
onelineClauses: [...ET, ...nE],
|
|
9082
9168
|
tabularOnelineClauses: nE
|
|
9083
9169
|
}
|
|
9084
|
-
},
|
|
9170
|
+
}, JA = [
|
|
9085
9171
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
9086
9172
|
"ABORT",
|
|
9087
9173
|
"ABS",
|
|
@@ -9311,7 +9397,7 @@ const _A = [
|
|
|
9311
9397
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
9312
9398
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
9313
9399
|
"CAST"
|
|
9314
|
-
],
|
|
9400
|
+
], wA = [
|
|
9315
9401
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
9316
9402
|
"ADVISE",
|
|
9317
9403
|
"ALL",
|
|
@@ -9517,7 +9603,7 @@ const _A = [
|
|
|
9517
9603
|
"WITHIN",
|
|
9518
9604
|
"WORK",
|
|
9519
9605
|
"XOR"
|
|
9520
|
-
],
|
|
9606
|
+
], xA = [
|
|
9521
9607
|
// N1QL does not support any way of declaring types for columns.
|
|
9522
9608
|
// It does not support the CREATE TABLE statement nor the CAST() expression.
|
|
9523
9609
|
//
|
|
@@ -9526,7 +9612,7 @@ const _A = [
|
|
|
9526
9612
|
// which it actually doesn't use.
|
|
9527
9613
|
//
|
|
9528
9614
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
9529
|
-
],
|
|
9615
|
+
], vA = C(["SELECT [ALL | DISTINCT]"]), QA = C([
|
|
9530
9616
|
// queries
|
|
9531
9617
|
"WITH",
|
|
9532
9618
|
"FROM",
|
|
@@ -9553,7 +9639,7 @@ const _A = [
|
|
|
9553
9639
|
"NEST",
|
|
9554
9640
|
"UNNEST",
|
|
9555
9641
|
"RETURNING"
|
|
9556
|
-
]), TT =
|
|
9642
|
+
]), TT = C([
|
|
9557
9643
|
// - update:
|
|
9558
9644
|
"UPDATE",
|
|
9559
9645
|
// - delete:
|
|
@@ -9593,19 +9679,19 @@ const _A = [
|
|
|
9593
9679
|
"SET CURRENT SCHEMA",
|
|
9594
9680
|
"SHOW",
|
|
9595
9681
|
"USE [PRIMARY] KEYS"
|
|
9596
|
-
]),
|
|
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 = {
|
|
9597
9683
|
name: "n1ql",
|
|
9598
9684
|
tokenizerOptions: {
|
|
9599
|
-
reservedSelect:
|
|
9600
|
-
reservedClauses: [...
|
|
9601
|
-
reservedSetOperations:
|
|
9602
|
-
reservedJoins:
|
|
9603
|
-
reservedKeywordPhrases:
|
|
9685
|
+
reservedSelect: vA,
|
|
9686
|
+
reservedClauses: [...QA, ...TT],
|
|
9687
|
+
reservedSetOperations: ZA,
|
|
9688
|
+
reservedJoins: qA,
|
|
9689
|
+
reservedKeywordPhrases: jA,
|
|
9604
9690
|
reservedDataTypePhrases: kA,
|
|
9605
9691
|
supportsXor: !0,
|
|
9606
|
-
reservedKeywords:
|
|
9607
|
-
reservedDataTypes:
|
|
9608
|
-
reservedFunctionNames:
|
|
9692
|
+
reservedKeywords: wA,
|
|
9693
|
+
reservedDataTypes: xA,
|
|
9694
|
+
reservedFunctionNames: JA,
|
|
9609
9695
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
9610
9696
|
// but we support them anyway as all other SQL dialects do,
|
|
9611
9697
|
// which simplifies writing tests that are shared between all dialects.
|
|
@@ -9619,7 +9705,7 @@ const _A = [
|
|
|
9619
9705
|
formatOptions: {
|
|
9620
9706
|
onelineClauses: TT
|
|
9621
9707
|
}
|
|
9622
|
-
},
|
|
9708
|
+
}, ES = [
|
|
9623
9709
|
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
|
|
9624
9710
|
// 'A',
|
|
9625
9711
|
"ADD",
|
|
@@ -9924,7 +10010,7 @@ const _A = [
|
|
|
9924
10010
|
"WRITE",
|
|
9925
10011
|
"YEAR",
|
|
9926
10012
|
"ZONE"
|
|
9927
|
-
],
|
|
10013
|
+
], TS = [
|
|
9928
10014
|
// https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
|
|
9929
10015
|
"ARRAY",
|
|
9930
10016
|
"BFILE_BASE",
|
|
@@ -9962,7 +10048,7 @@ const _A = [
|
|
|
9962
10048
|
"UROWID",
|
|
9963
10049
|
"VARCHAR",
|
|
9964
10050
|
"VARCHAR2"
|
|
9965
|
-
],
|
|
10051
|
+
], RS = [
|
|
9966
10052
|
// https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
|
|
9967
10053
|
// numeric
|
|
9968
10054
|
"ABS",
|
|
@@ -10227,7 +10313,7 @@ const _A = [
|
|
|
10227
10313
|
"PRESENTNNV",
|
|
10228
10314
|
"PRESENTV",
|
|
10229
10315
|
"PREVIOUS"
|
|
10230
|
-
],
|
|
10316
|
+
], AS = C(["SELECT [ALL | DISTINCT | UNIQUE]"]), SS = C([
|
|
10231
10317
|
// queries
|
|
10232
10318
|
"WITH",
|
|
10233
10319
|
"FROM",
|
|
@@ -10251,9 +10337,9 @@ const _A = [
|
|
|
10251
10337
|
"UPDATE SET",
|
|
10252
10338
|
// other
|
|
10253
10339
|
"RETURNING"
|
|
10254
|
-
]), RT =
|
|
10340
|
+
]), RT = C([
|
|
10255
10341
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
10256
|
-
]), DE =
|
|
10342
|
+
]), DE = C([
|
|
10257
10343
|
// - create:
|
|
10258
10344
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
10259
10345
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -10281,7 +10367,7 @@ const _A = [
|
|
|
10281
10367
|
"EXCEPTION",
|
|
10282
10368
|
"LOOP",
|
|
10283
10369
|
"START WITH"
|
|
10284
|
-
]),
|
|
10370
|
+
]), eS = C(["UNION [ALL]", "MINUS", "INTERSECT"]), IS = C([
|
|
10285
10371
|
"JOIN",
|
|
10286
10372
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10287
10373
|
"{INNER | CROSS} JOIN",
|
|
@@ -10289,23 +10375,23 @@ const _A = [
|
|
|
10289
10375
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10290
10376
|
// non-standard joins
|
|
10291
10377
|
"{CROSS | OUTER} APPLY"
|
|
10292
|
-
]),
|
|
10378
|
+
]), OS = C([
|
|
10293
10379
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10294
10380
|
"ON COMMIT",
|
|
10295
10381
|
"{ROWS | RANGE} BETWEEN"
|
|
10296
|
-
]),
|
|
10382
|
+
]), NS = C([]), sS = {
|
|
10297
10383
|
name: "plsql",
|
|
10298
10384
|
tokenizerOptions: {
|
|
10299
|
-
reservedSelect:
|
|
10300
|
-
reservedClauses: [...
|
|
10301
|
-
reservedSetOperations:
|
|
10302
|
-
reservedJoins:
|
|
10303
|
-
reservedKeywordPhrases:
|
|
10304
|
-
reservedDataTypePhrases:
|
|
10385
|
+
reservedSelect: AS,
|
|
10386
|
+
reservedClauses: [...SS, ...RT, ...DE],
|
|
10387
|
+
reservedSetOperations: eS,
|
|
10388
|
+
reservedJoins: IS,
|
|
10389
|
+
reservedKeywordPhrases: OS,
|
|
10390
|
+
reservedDataTypePhrases: NS,
|
|
10305
10391
|
supportsXor: !0,
|
|
10306
|
-
reservedKeywords:
|
|
10307
|
-
reservedDataTypes:
|
|
10308
|
-
reservedFunctionNames:
|
|
10392
|
+
reservedKeywords: ES,
|
|
10393
|
+
reservedDataTypes: TS,
|
|
10394
|
+
reservedFunctionNames: RS,
|
|
10309
10395
|
stringTypes: [
|
|
10310
10396
|
{ quote: "''-qq", prefixes: ["N"] },
|
|
10311
10397
|
{ quote: "q''", prefixes: ["N"] }
|
|
@@ -10330,7 +10416,7 @@ const _A = [
|
|
|
10330
10416
|
"@",
|
|
10331
10417
|
"||"
|
|
10332
10418
|
],
|
|
10333
|
-
postProcess:
|
|
10419
|
+
postProcess: tS
|
|
10334
10420
|
},
|
|
10335
10421
|
formatOptions: {
|
|
10336
10422
|
alwaysDenseOperators: ["@"],
|
|
@@ -10338,11 +10424,11 @@ const _A = [
|
|
|
10338
10424
|
tabularOnelineClauses: DE
|
|
10339
10425
|
}
|
|
10340
10426
|
};
|
|
10341
|
-
function
|
|
10342
|
-
let E =
|
|
10343
|
-
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));
|
|
10344
10430
|
}
|
|
10345
|
-
const
|
|
10431
|
+
const CS = [
|
|
10346
10432
|
// https://www.postgresql.org/docs/14/functions.html
|
|
10347
10433
|
//
|
|
10348
10434
|
// https://www.postgresql.org/docs/14/functions-math.html
|
|
@@ -11026,7 +11112,7 @@ const tS = [
|
|
|
11026
11112
|
"PG_MCV_LIST_ITEMS",
|
|
11027
11113
|
// cast
|
|
11028
11114
|
"CAST"
|
|
11029
|
-
],
|
|
11115
|
+
], LS = [
|
|
11030
11116
|
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
|
|
11031
11117
|
"ALL",
|
|
11032
11118
|
"ANALYSE",
|
|
@@ -11145,7 +11231,7 @@ const tS = [
|
|
|
11145
11231
|
"WITHOUT",
|
|
11146
11232
|
"YEAR"
|
|
11147
11233
|
// requires AS
|
|
11148
|
-
],
|
|
11234
|
+
], _S = [
|
|
11149
11235
|
// https://www.postgresql.org/docs/current/datatype.html
|
|
11150
11236
|
"ARRAY",
|
|
11151
11237
|
"BIGINT",
|
|
@@ -11179,7 +11265,7 @@ const tS = [
|
|
|
11179
11265
|
"VARCHAR",
|
|
11180
11266
|
"XML",
|
|
11181
11267
|
"ZONE"
|
|
11182
|
-
],
|
|
11268
|
+
], rS = C(["SELECT [ALL | DISTINCT]"]), nS = C([
|
|
11183
11269
|
// queries
|
|
11184
11270
|
"WITH [RECURSIVE]",
|
|
11185
11271
|
"FROM",
|
|
@@ -11202,9 +11288,9 @@ const tS = [
|
|
|
11202
11288
|
"SET",
|
|
11203
11289
|
// other
|
|
11204
11290
|
"RETURNING"
|
|
11205
|
-
]), AT =
|
|
11291
|
+
]), AT = C([
|
|
11206
11292
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
11207
|
-
]), iE =
|
|
11293
|
+
]), iE = C([
|
|
11208
11294
|
// - create
|
|
11209
11295
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
11210
11296
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -11402,17 +11488,17 @@ const tS = [
|
|
|
11402
11488
|
"START TRANSACTION",
|
|
11403
11489
|
"UNLISTEN",
|
|
11404
11490
|
"VACUUM"
|
|
11405
|
-
]),
|
|
11491
|
+
]), DS = C([
|
|
11406
11492
|
"UNION [ALL | DISTINCT]",
|
|
11407
11493
|
"EXCEPT [ALL | DISTINCT]",
|
|
11408
11494
|
"INTERSECT [ALL | DISTINCT]"
|
|
11409
|
-
]),
|
|
11495
|
+
]), iS = C([
|
|
11410
11496
|
"JOIN",
|
|
11411
11497
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11412
11498
|
"{INNER | CROSS} JOIN",
|
|
11413
11499
|
"NATURAL [INNER] JOIN",
|
|
11414
11500
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
11415
|
-
]),
|
|
11501
|
+
]), PS = C([
|
|
11416
11502
|
"PRIMARY KEY",
|
|
11417
11503
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
11418
11504
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -11423,21 +11509,21 @@ const tS = [
|
|
|
11423
11509
|
"IS [NOT] DISTINCT FROM",
|
|
11424
11510
|
"NULLS {FIRST | LAST}",
|
|
11425
11511
|
"WITH ORDINALITY"
|
|
11426
|
-
]),
|
|
11512
|
+
]), oS = C([
|
|
11427
11513
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
11428
11514
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
11429
11515
|
]), aS = {
|
|
11430
11516
|
name: "postgresql",
|
|
11431
11517
|
tokenizerOptions: {
|
|
11432
|
-
reservedSelect:
|
|
11433
|
-
reservedClauses: [...
|
|
11434
|
-
reservedSetOperations:
|
|
11435
|
-
reservedJoins:
|
|
11436
|
-
reservedKeywordPhrases:
|
|
11437
|
-
reservedDataTypePhrases:
|
|
11438
|
-
reservedKeywords:
|
|
11439
|
-
reservedDataTypes:
|
|
11440
|
-
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,
|
|
11441
11527
|
nestedBlockComments: !0,
|
|
11442
11528
|
extraParens: ["[]"],
|
|
11443
11529
|
underscoresInNumbers: !0,
|
|
@@ -11552,7 +11638,7 @@ const tS = [
|
|
|
11552
11638
|
onelineClauses: [...AT, ...iE],
|
|
11553
11639
|
tabularOnelineClauses: iE
|
|
11554
11640
|
}
|
|
11555
|
-
},
|
|
11641
|
+
}, MS = [
|
|
11556
11642
|
// https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
|
|
11557
11643
|
"ANY_VALUE",
|
|
11558
11644
|
"APPROXIMATE PERCENTILE_DISC",
|
|
@@ -11898,7 +11984,7 @@ const tS = [
|
|
|
11898
11984
|
"SLICE_NUM",
|
|
11899
11985
|
"USER",
|
|
11900
11986
|
"VERSION"
|
|
11901
|
-
],
|
|
11987
|
+
], US = [
|
|
11902
11988
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
|
|
11903
11989
|
"AES128",
|
|
11904
11990
|
"AES256",
|
|
@@ -12087,7 +12173,7 @@ const tS = [
|
|
|
12087
12173
|
* SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
|
|
12088
12174
|
* SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
|
|
12089
12175
|
*/
|
|
12090
|
-
],
|
|
12176
|
+
], GS = [
|
|
12091
12177
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
|
|
12092
12178
|
"ARRAY",
|
|
12093
12179
|
"BIGINT",
|
|
@@ -12108,7 +12194,7 @@ const tS = [
|
|
|
12108
12194
|
"TEXT",
|
|
12109
12195
|
"VARBYTE",
|
|
12110
12196
|
"VARCHAR"
|
|
12111
|
-
],
|
|
12197
|
+
], cS = C(["SELECT [ALL | DISTINCT]"]), lS = C([
|
|
12112
12198
|
// queries
|
|
12113
12199
|
"WITH [RECURSIVE]",
|
|
12114
12200
|
"FROM",
|
|
@@ -12126,9 +12212,9 @@ const tS = [
|
|
|
12126
12212
|
"VALUES",
|
|
12127
12213
|
// - update:
|
|
12128
12214
|
"SET"
|
|
12129
|
-
]), ST =
|
|
12215
|
+
]), ST = C([
|
|
12130
12216
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
12131
|
-
]), PE =
|
|
12217
|
+
]), PE = C([
|
|
12132
12218
|
// - create:
|
|
12133
12219
|
"CREATE [OR REPLACE | MATERIALIZED] VIEW",
|
|
12134
12220
|
// - update:
|
|
@@ -12219,13 +12305,13 @@ const tS = [
|
|
|
12219
12305
|
"START TRANSACTION",
|
|
12220
12306
|
"UNLOAD",
|
|
12221
12307
|
"VACUUM"
|
|
12222
|
-
]),
|
|
12308
|
+
]), HS = C(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), uS = C([
|
|
12223
12309
|
"JOIN",
|
|
12224
12310
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12225
12311
|
"{INNER | CROSS} JOIN",
|
|
12226
12312
|
"NATURAL [INNER] JOIN",
|
|
12227
12313
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12228
|
-
]),
|
|
12314
|
+
]), BS = C([
|
|
12229
12315
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12230
12316
|
"NULL AS",
|
|
12231
12317
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12233,18 +12319,18 @@ const tS = [
|
|
|
12233
12319
|
"HIVE METASTORE",
|
|
12234
12320
|
// in window specifications
|
|
12235
12321
|
"{ROWS | RANGE} BETWEEN"
|
|
12236
|
-
]),
|
|
12322
|
+
]), FS = C([]), YS = {
|
|
12237
12323
|
name: "redshift",
|
|
12238
12324
|
tokenizerOptions: {
|
|
12239
|
-
reservedSelect:
|
|
12240
|
-
reservedClauses: [...
|
|
12241
|
-
reservedSetOperations:
|
|
12242
|
-
reservedJoins:
|
|
12243
|
-
reservedKeywordPhrases:
|
|
12244
|
-
reservedDataTypePhrases:
|
|
12245
|
-
reservedKeywords:
|
|
12246
|
-
reservedDataTypes:
|
|
12247
|
-
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,
|
|
12248
12334
|
extraParens: ["[]"],
|
|
12249
12335
|
stringTypes: ["''-qq"],
|
|
12250
12336
|
identTypes: ['""-qq'],
|
|
@@ -12271,7 +12357,7 @@ const tS = [
|
|
|
12271
12357
|
onelineClauses: [...ST, ...PE],
|
|
12272
12358
|
tabularOnelineClauses: PE
|
|
12273
12359
|
}
|
|
12274
|
-
},
|
|
12360
|
+
}, mS = [
|
|
12275
12361
|
// https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
|
|
12276
12362
|
"ADD",
|
|
12277
12363
|
"AFTER",
|
|
@@ -12538,7 +12624,7 @@ const tS = [
|
|
|
12538
12624
|
"UNSIGNED",
|
|
12539
12625
|
"VARIABLES",
|
|
12540
12626
|
"YEAR_MONTH"
|
|
12541
|
-
],
|
|
12627
|
+
], pS = [
|
|
12542
12628
|
// https://spark.apache.org/docs/latest/sql-ref-datatypes.html
|
|
12543
12629
|
"ARRAY",
|
|
12544
12630
|
"BIGINT",
|
|
@@ -12568,7 +12654,7 @@ const tS = [
|
|
|
12568
12654
|
"TINYINT",
|
|
12569
12655
|
"VARCHAR"
|
|
12570
12656
|
// No varchar type in Spark, only STRING. Added for the sake of tests
|
|
12571
|
-
],
|
|
12657
|
+
], dS = [
|
|
12572
12658
|
// http://spark.apache.org/docs/latest/sql-ref-functions.html
|
|
12573
12659
|
//
|
|
12574
12660
|
// http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
|
|
@@ -12889,7 +12975,7 @@ const tS = [
|
|
|
12889
12975
|
// Shorthand functions to use in place of CASE expression
|
|
12890
12976
|
"COALESCE",
|
|
12891
12977
|
"NULLIF"
|
|
12892
|
-
],
|
|
12978
|
+
], hS = C(["SELECT [ALL | DISTINCT]"]), VS = C([
|
|
12893
12979
|
// queries
|
|
12894
12980
|
"WITH",
|
|
12895
12981
|
"FROM",
|
|
@@ -12914,7 +13000,7 @@ const tS = [
|
|
|
12914
13000
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
12915
13001
|
"LOAD DATA [LOCAL] INPATH",
|
|
12916
13002
|
"[OVERWRITE] INTO TABLE"
|
|
12917
|
-
]), eT =
|
|
13003
|
+
]), eT = C(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), oE = C([
|
|
12918
13004
|
// - create:
|
|
12919
13005
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
12920
13006
|
// - drop table:
|
|
@@ -12970,11 +13056,11 @@ const tS = [
|
|
|
12970
13056
|
"SHOW TBLPROPERTIES",
|
|
12971
13057
|
"SHOW VIEWS",
|
|
12972
13058
|
"UNCACHE TABLE"
|
|
12973
|
-
]),
|
|
13059
|
+
]), fS = C([
|
|
12974
13060
|
"UNION [ALL | DISTINCT]",
|
|
12975
13061
|
"EXCEPT [ALL | DISTINCT]",
|
|
12976
13062
|
"INTERSECT [ALL | DISTINCT]"
|
|
12977
|
-
]), WS =
|
|
13063
|
+
]), WS = C([
|
|
12978
13064
|
"JOIN",
|
|
12979
13065
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12980
13066
|
"{INNER | CROSS} JOIN",
|
|
@@ -12983,24 +13069,24 @@ const tS = [
|
|
|
12983
13069
|
// non-standard-joins
|
|
12984
13070
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
12985
13071
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
12986
|
-
]),
|
|
13072
|
+
]), XS = C([
|
|
12987
13073
|
"ON DELETE",
|
|
12988
13074
|
"ON UPDATE",
|
|
12989
13075
|
"CURRENT ROW",
|
|
12990
13076
|
"{ROWS | RANGE} BETWEEN"
|
|
12991
|
-
]),
|
|
13077
|
+
]), bS = C([]), yS = {
|
|
12992
13078
|
name: "spark",
|
|
12993
13079
|
tokenizerOptions: {
|
|
12994
|
-
reservedSelect:
|
|
12995
|
-
reservedClauses: [...VS, ...eT, ...
|
|
12996
|
-
reservedSetOperations:
|
|
13080
|
+
reservedSelect: hS,
|
|
13081
|
+
reservedClauses: [...VS, ...eT, ...oE],
|
|
13082
|
+
reservedSetOperations: fS,
|
|
12997
13083
|
reservedJoins: WS,
|
|
12998
|
-
reservedKeywordPhrases:
|
|
12999
|
-
reservedDataTypePhrases:
|
|
13084
|
+
reservedKeywordPhrases: XS,
|
|
13085
|
+
reservedDataTypePhrases: bS,
|
|
13000
13086
|
supportsXor: !0,
|
|
13001
|
-
reservedKeywords:
|
|
13002
|
-
reservedDataTypes:
|
|
13003
|
-
reservedFunctionNames:
|
|
13087
|
+
reservedKeywords: mS,
|
|
13088
|
+
reservedDataTypes: pS,
|
|
13089
|
+
reservedFunctionNames: dS,
|
|
13004
13090
|
extraParens: ["[]"],
|
|
13005
13091
|
stringTypes: [
|
|
13006
13092
|
"''-bs",
|
|
@@ -13015,17 +13101,17 @@ const tS = [
|
|
|
13015
13101
|
postProcess: KS
|
|
13016
13102
|
},
|
|
13017
13103
|
formatOptions: {
|
|
13018
|
-
onelineClauses: [...eT, ...
|
|
13019
|
-
tabularOnelineClauses:
|
|
13104
|
+
onelineClauses: [...eT, ...oE],
|
|
13105
|
+
tabularOnelineClauses: oE
|
|
13020
13106
|
}
|
|
13021
13107
|
};
|
|
13022
13108
|
function KS(T) {
|
|
13023
13109
|
return T.map((E, R) => {
|
|
13024
|
-
const A = T[R - 1] ||
|
|
13110
|
+
const A = T[R - 1] || x, S = T[R + 1] || x;
|
|
13025
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;
|
|
13026
13112
|
});
|
|
13027
13113
|
}
|
|
13028
|
-
const
|
|
13114
|
+
const $S = [
|
|
13029
13115
|
// https://www.sqlite.org/lang_corefunc.html
|
|
13030
13116
|
"ABS",
|
|
13031
13117
|
"CHANGES",
|
|
@@ -13149,7 +13235,7 @@ const yS = [
|
|
|
13149
13235
|
"JSON_TREE",
|
|
13150
13236
|
// cast
|
|
13151
13237
|
"CAST"
|
|
13152
|
-
],
|
|
13238
|
+
], gS = [
|
|
13153
13239
|
// https://www.sqlite.org/lang_keywords.html
|
|
13154
13240
|
// Note: The keywords listed on that URL are not all reserved keywords.
|
|
13155
13241
|
// We'll need to clean up this list to only include reserved keywords.
|
|
@@ -13302,7 +13388,7 @@ const yS = [
|
|
|
13302
13388
|
"WINDOW",
|
|
13303
13389
|
"WITH",
|
|
13304
13390
|
"WITHOUT"
|
|
13305
|
-
],
|
|
13391
|
+
], JS = [
|
|
13306
13392
|
// SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
|
|
13307
13393
|
// Here we just list some common ones as SQL Formatter
|
|
13308
13394
|
// is only able to detect a predefined list of data types.
|
|
@@ -13323,7 +13409,7 @@ const yS = [
|
|
|
13323
13409
|
"TEXT",
|
|
13324
13410
|
"VARCHAR",
|
|
13325
13411
|
"VARYING CHARACTER"
|
|
13326
|
-
],
|
|
13412
|
+
], wS = C(["SELECT [ALL | DISTINCT]"]), xS = C([
|
|
13327
13413
|
// queries
|
|
13328
13414
|
"WITH [RECURSIVE]",
|
|
13329
13415
|
"FROM",
|
|
@@ -13344,7 +13430,7 @@ const yS = [
|
|
|
13344
13430
|
"SET",
|
|
13345
13431
|
// other:
|
|
13346
13432
|
"RETURNING"
|
|
13347
|
-
]), IT =
|
|
13433
|
+
]), IT = C(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), aE = C([
|
|
13348
13434
|
// - create:
|
|
13349
13435
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
13350
13436
|
// - update:
|
|
@@ -13363,28 +13449,28 @@ const yS = [
|
|
|
13363
13449
|
"RENAME TO",
|
|
13364
13450
|
// - set schema
|
|
13365
13451
|
"SET SCHEMA"
|
|
13366
|
-
]),
|
|
13452
|
+
]), vS = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), QS = C([
|
|
13367
13453
|
"JOIN",
|
|
13368
13454
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13369
13455
|
"{INNER | CROSS} JOIN",
|
|
13370
13456
|
"NATURAL [INNER] JOIN",
|
|
13371
13457
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13372
|
-
]),
|
|
13458
|
+
]), ZS = C([
|
|
13373
13459
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13374
13460
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
13375
13461
|
"DO UPDATE"
|
|
13376
|
-
]),
|
|
13462
|
+
]), qS = C([]), jS = {
|
|
13377
13463
|
name: "sqlite",
|
|
13378
13464
|
tokenizerOptions: {
|
|
13379
|
-
reservedSelect:
|
|
13380
|
-
reservedClauses: [...
|
|
13381
|
-
reservedSetOperations:
|
|
13382
|
-
reservedJoins:
|
|
13383
|
-
reservedKeywordPhrases:
|
|
13384
|
-
reservedDataTypePhrases:
|
|
13385
|
-
reservedKeywords:
|
|
13386
|
-
reservedDataTypes:
|
|
13387
|
-
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,
|
|
13388
13474
|
stringTypes: [
|
|
13389
13475
|
"''-qq",
|
|
13390
13476
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -13397,8 +13483,8 @@ const yS = [
|
|
|
13397
13483
|
operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
|
|
13398
13484
|
},
|
|
13399
13485
|
formatOptions: {
|
|
13400
|
-
onelineClauses: [...IT, ...
|
|
13401
|
-
tabularOnelineClauses:
|
|
13486
|
+
onelineClauses: [...IT, ...aE],
|
|
13487
|
+
tabularOnelineClauses: aE
|
|
13402
13488
|
}
|
|
13403
13489
|
}, kS = [
|
|
13404
13490
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
|
|
@@ -13497,7 +13583,7 @@ const yS = [
|
|
|
13497
13583
|
"ASIN",
|
|
13498
13584
|
"ACOS",
|
|
13499
13585
|
"ATAN"
|
|
13500
|
-
],
|
|
13586
|
+
], zS = [
|
|
13501
13587
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
|
|
13502
13588
|
"ALL",
|
|
13503
13589
|
"ALLOCATE",
|
|
@@ -13695,7 +13781,7 @@ const yS = [
|
|
|
13695
13781
|
"WITHIN",
|
|
13696
13782
|
"WITHOUT",
|
|
13697
13783
|
"YEAR"
|
|
13698
|
-
],
|
|
13784
|
+
], Ee = [
|
|
13699
13785
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
|
|
13700
13786
|
"ARRAY",
|
|
13701
13787
|
"BIGINT",
|
|
@@ -13735,7 +13821,7 @@ const yS = [
|
|
|
13735
13821
|
"TIMESTAMP",
|
|
13736
13822
|
"VARBINARY",
|
|
13737
13823
|
"VARCHAR"
|
|
13738
|
-
],
|
|
13824
|
+
], Te = C(["SELECT [ALL | DISTINCT]"]), Re = C([
|
|
13739
13825
|
// queries
|
|
13740
13826
|
"WITH [RECURSIVE]",
|
|
13741
13827
|
"FROM",
|
|
@@ -13754,7 +13840,7 @@ const yS = [
|
|
|
13754
13840
|
"VALUES",
|
|
13755
13841
|
// - update:
|
|
13756
13842
|
"SET"
|
|
13757
|
-
]), OT =
|
|
13843
|
+
]), OT = C(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), ME = C([
|
|
13758
13844
|
// - create:
|
|
13759
13845
|
"CREATE [RECURSIVE] VIEW",
|
|
13760
13846
|
// - update:
|
|
@@ -13779,30 +13865,30 @@ const yS = [
|
|
|
13779
13865
|
"TRUNCATE TABLE",
|
|
13780
13866
|
// other
|
|
13781
13867
|
"SET SCHEMA"
|
|
13782
|
-
]),
|
|
13868
|
+
]), Ae = C([
|
|
13783
13869
|
"UNION [ALL | DISTINCT]",
|
|
13784
13870
|
"EXCEPT [ALL | DISTINCT]",
|
|
13785
13871
|
"INTERSECT [ALL | DISTINCT]"
|
|
13786
|
-
]),
|
|
13872
|
+
]), Se = C([
|
|
13787
13873
|
"JOIN",
|
|
13788
13874
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13789
13875
|
"{INNER | CROSS} JOIN",
|
|
13790
13876
|
"NATURAL [INNER] JOIN",
|
|
13791
13877
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13792
|
-
]),
|
|
13878
|
+
]), ee = C([
|
|
13793
13879
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13794
13880
|
"{ROWS | RANGE} BETWEEN"
|
|
13795
|
-
]),
|
|
13881
|
+
]), Ie = C([]), Oe = {
|
|
13796
13882
|
name: "sql",
|
|
13797
13883
|
tokenizerOptions: {
|
|
13798
|
-
reservedSelect:
|
|
13799
|
-
reservedClauses: [...
|
|
13800
|
-
reservedSetOperations:
|
|
13801
|
-
reservedJoins:
|
|
13802
|
-
reservedKeywordPhrases:
|
|
13803
|
-
reservedDataTypePhrases:
|
|
13804
|
-
reservedKeywords:
|
|
13805
|
-
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,
|
|
13806
13892
|
reservedFunctionNames: kS,
|
|
13807
13893
|
stringTypes: [
|
|
13808
13894
|
{ quote: "''-qq-bs", prefixes: ["N", "U&"] },
|
|
@@ -13816,7 +13902,7 @@ const yS = [
|
|
|
13816
13902
|
onelineClauses: [...OT, ...ME],
|
|
13817
13903
|
tabularOnelineClauses: ME
|
|
13818
13904
|
}
|
|
13819
|
-
},
|
|
13905
|
+
}, Ne = [
|
|
13820
13906
|
// https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
|
|
13821
13907
|
// rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
|
|
13822
13908
|
// rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
|
|
@@ -14250,7 +14336,7 @@ const yS = [
|
|
|
14250
14336
|
"NEXT",
|
|
14251
14337
|
"PERMUTE",
|
|
14252
14338
|
"PREV"
|
|
14253
|
-
],
|
|
14339
|
+
], se = [
|
|
14254
14340
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
|
|
14255
14341
|
"ABSENT",
|
|
14256
14342
|
"ADD",
|
|
@@ -14487,7 +14573,7 @@ const yS = [
|
|
|
14487
14573
|
"WRAPPER",
|
|
14488
14574
|
"WRITE",
|
|
14489
14575
|
"ZONE"
|
|
14490
|
-
],
|
|
14576
|
+
], te = [
|
|
14491
14577
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
|
|
14492
14578
|
// or https://trino.io/docs/current/language/types.html
|
|
14493
14579
|
"BIGINT",
|
|
@@ -14526,7 +14612,7 @@ const yS = [
|
|
|
14526
14612
|
"CODEPOINTS",
|
|
14527
14613
|
"FUNCTION",
|
|
14528
14614
|
"JSONPATH"
|
|
14529
|
-
],
|
|
14615
|
+
], Ce = C(["SELECT [ALL | DISTINCT]"]), Le = C([
|
|
14530
14616
|
// queries
|
|
14531
14617
|
"WITH [RECURSIVE]",
|
|
14532
14618
|
"FROM",
|
|
@@ -14554,7 +14640,7 @@ const yS = [
|
|
|
14554
14640
|
"PATTERN",
|
|
14555
14641
|
"SUBSET",
|
|
14556
14642
|
"DEFINE"
|
|
14557
|
-
]), NT =
|
|
14643
|
+
]), NT = C(["CREATE TABLE [IF NOT EXISTS]"]), UE = C([
|
|
14558
14644
|
// - create:
|
|
14559
14645
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
14560
14646
|
// - update:
|
|
@@ -14612,32 +14698,32 @@ const yS = [
|
|
|
14612
14698
|
"SHOW ROLE GRANTS",
|
|
14613
14699
|
"SHOW FUNCTIONS",
|
|
14614
14700
|
"SHOW SESSION"
|
|
14615
|
-
]),
|
|
14701
|
+
]), _e = C([
|
|
14616
14702
|
"UNION [ALL | DISTINCT]",
|
|
14617
14703
|
"EXCEPT [ALL | DISTINCT]",
|
|
14618
14704
|
"INTERSECT [ALL | DISTINCT]"
|
|
14619
|
-
]),
|
|
14705
|
+
]), re = C([
|
|
14620
14706
|
"JOIN",
|
|
14621
14707
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14622
14708
|
"{INNER | CROSS} JOIN",
|
|
14623
14709
|
"NATURAL [INNER] JOIN",
|
|
14624
14710
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14625
|
-
]),
|
|
14711
|
+
]), ne = C([
|
|
14626
14712
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14627
14713
|
// comparison operator
|
|
14628
14714
|
"IS [NOT] DISTINCT FROM"
|
|
14629
|
-
]),
|
|
14715
|
+
]), De = C([]), ie = {
|
|
14630
14716
|
name: "trino",
|
|
14631
14717
|
tokenizerOptions: {
|
|
14632
|
-
reservedSelect:
|
|
14633
|
-
reservedClauses: [...
|
|
14634
|
-
reservedSetOperations:
|
|
14635
|
-
reservedJoins:
|
|
14636
|
-
reservedKeywordPhrases:
|
|
14637
|
-
reservedDataTypePhrases:
|
|
14638
|
-
reservedKeywords:
|
|
14639
|
-
reservedDataTypes:
|
|
14640
|
-
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,
|
|
14641
14727
|
// Trino also supports {- ... -} parenthesis.
|
|
14642
14728
|
// The formatting of these currently works out as a result of { and -
|
|
14643
14729
|
// not getting a space added in-between.
|
|
@@ -14669,7 +14755,7 @@ const yS = [
|
|
|
14669
14755
|
onelineClauses: [...NT, ...UE],
|
|
14670
14756
|
tabularOnelineClauses: UE
|
|
14671
14757
|
}
|
|
14672
|
-
},
|
|
14758
|
+
}, Pe = [
|
|
14673
14759
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
14674
14760
|
// aggregate
|
|
14675
14761
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -14974,7 +15060,7 @@ const yS = [
|
|
|
14974
15060
|
// Shorthand functions to use in place of CASE expression
|
|
14975
15061
|
"COALESCE",
|
|
14976
15062
|
"NULLIF"
|
|
14977
|
-
],
|
|
15063
|
+
], oe = [
|
|
14978
15064
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
14979
15065
|
// standard
|
|
14980
15066
|
"ADD",
|
|
@@ -15182,7 +15268,7 @@ const yS = [
|
|
|
15182
15268
|
"TIMESTAMP",
|
|
15183
15269
|
"VARBINARY",
|
|
15184
15270
|
"VARCHAR"
|
|
15185
|
-
],
|
|
15271
|
+
], Me = C(["SELECT [ALL | DISTINCT]"]), Ue = C([
|
|
15186
15272
|
// queries
|
|
15187
15273
|
"WITH",
|
|
15188
15274
|
"INTO",
|
|
@@ -15207,7 +15293,7 @@ const yS = [
|
|
|
15207
15293
|
"MERGE [INTO]",
|
|
15208
15294
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
15209
15295
|
"UPDATE SET"
|
|
15210
|
-
]), sT =
|
|
15296
|
+
]), sT = C(["CREATE TABLE"]), GE = C([
|
|
15211
15297
|
// - create:
|
|
15212
15298
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
15213
15299
|
// - update:
|
|
@@ -15387,27 +15473,27 @@ const yS = [
|
|
|
15387
15473
|
"XACT_ABORT",
|
|
15388
15474
|
"XML INDEX",
|
|
15389
15475
|
"XML SCHEMA COLLECTION"
|
|
15390
|
-
]),
|
|
15476
|
+
]), Ge = C(["UNION [ALL]", "EXCEPT", "INTERSECT"]), ce = C([
|
|
15391
15477
|
"JOIN",
|
|
15392
15478
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15393
15479
|
"{INNER | CROSS} JOIN",
|
|
15394
15480
|
// non-standard joins
|
|
15395
15481
|
"{CROSS | OUTER} APPLY"
|
|
15396
|
-
]),
|
|
15482
|
+
]), le = C([
|
|
15397
15483
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
15398
15484
|
"{ROWS | RANGE} BETWEEN"
|
|
15399
|
-
]),
|
|
15485
|
+
]), He = C([]), ue = {
|
|
15400
15486
|
name: "transactsql",
|
|
15401
15487
|
tokenizerOptions: {
|
|
15402
|
-
reservedSelect:
|
|
15403
|
-
reservedClauses: [...
|
|
15404
|
-
reservedSetOperations:
|
|
15405
|
-
reservedJoins:
|
|
15406
|
-
reservedKeywordPhrases:
|
|
15407
|
-
reservedDataTypePhrases:
|
|
15408
|
-
reservedKeywords:
|
|
15488
|
+
reservedSelect: Me,
|
|
15489
|
+
reservedClauses: [...Ue, ...sT, ...GE],
|
|
15490
|
+
reservedSetOperations: Ge,
|
|
15491
|
+
reservedJoins: ce,
|
|
15492
|
+
reservedKeywordPhrases: le,
|
|
15493
|
+
reservedDataTypePhrases: He,
|
|
15494
|
+
reservedKeywords: oe,
|
|
15409
15495
|
reservedDataTypes: ae,
|
|
15410
|
-
reservedFunctionNames:
|
|
15496
|
+
reservedFunctionNames: Pe,
|
|
15411
15497
|
nestedBlockComments: !0,
|
|
15412
15498
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
15413
15499
|
identTypes: ['""-qq', "[]"],
|
|
@@ -15440,7 +15526,7 @@ const yS = [
|
|
|
15440
15526
|
onelineClauses: [...sT, ...GE],
|
|
15441
15527
|
tabularOnelineClauses: GE
|
|
15442
15528
|
}
|
|
15443
|
-
},
|
|
15529
|
+
}, Be = [
|
|
15444
15530
|
// List of all keywords taken from:
|
|
15445
15531
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
|
|
15446
15532
|
// Then filtered down to reserved keywords by running
|
|
@@ -15653,7 +15739,7 @@ const yS = [
|
|
|
15653
15739
|
"XOR",
|
|
15654
15740
|
"YEAR_MONTH",
|
|
15655
15741
|
"ZEROFILL"
|
|
15656
|
-
],
|
|
15742
|
+
], Fe = [
|
|
15657
15743
|
// https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
|
|
15658
15744
|
"BIGINT",
|
|
15659
15745
|
"BINARY",
|
|
@@ -15702,7 +15788,7 @@ const yS = [
|
|
|
15702
15788
|
"VARCHAR",
|
|
15703
15789
|
"VARCHARACTER",
|
|
15704
15790
|
"YEAR"
|
|
15705
|
-
],
|
|
15791
|
+
], Ye = [
|
|
15706
15792
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
|
|
15707
15793
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
|
|
15708
15794
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
|
|
@@ -15982,7 +16068,7 @@ const yS = [
|
|
|
15982
16068
|
"WEEKDAY",
|
|
15983
16069
|
"WEEKOFYEAR",
|
|
15984
16070
|
"YEAR"
|
|
15985
|
-
],
|
|
16071
|
+
], me = C(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), pe = C([
|
|
15986
16072
|
// queries
|
|
15987
16073
|
"WITH",
|
|
15988
16074
|
"FROM",
|
|
@@ -16004,9 +16090,9 @@ const yS = [
|
|
|
16004
16090
|
// Data definition
|
|
16005
16091
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
16006
16092
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
16007
|
-
]), tT =
|
|
16093
|
+
]), tT = C([
|
|
16008
16094
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
16009
|
-
]), cE =
|
|
16095
|
+
]), cE = C([
|
|
16010
16096
|
// - create:
|
|
16011
16097
|
"CREATE VIEW",
|
|
16012
16098
|
// - update:
|
|
@@ -16183,36 +16269,36 @@ const yS = [
|
|
|
16183
16269
|
"REPEAT",
|
|
16184
16270
|
"RETURN",
|
|
16185
16271
|
"WHILE"
|
|
16186
|
-
]),
|
|
16272
|
+
]), de = C([
|
|
16187
16273
|
"UNION [ALL | DISTINCT]",
|
|
16188
16274
|
"EXCEPT",
|
|
16189
16275
|
"INTERSECT",
|
|
16190
16276
|
"MINUS"
|
|
16191
|
-
]),
|
|
16277
|
+
]), he = C([
|
|
16192
16278
|
"JOIN",
|
|
16193
16279
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16194
16280
|
"{INNER | CROSS} JOIN",
|
|
16195
16281
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
16196
16282
|
// non-standard joins
|
|
16197
16283
|
"STRAIGHT_JOIN"
|
|
16198
|
-
]), Ve =
|
|
16284
|
+
]), Ve = C([
|
|
16199
16285
|
"ON DELETE",
|
|
16200
16286
|
"ON UPDATE",
|
|
16201
16287
|
"CHARACTER SET",
|
|
16202
16288
|
"{ROWS | RANGE} BETWEEN",
|
|
16203
16289
|
"IDENTIFIED BY"
|
|
16204
|
-
]),
|
|
16290
|
+
]), fe = C([]), We = {
|
|
16205
16291
|
name: "singlestoredb",
|
|
16206
16292
|
tokenizerOptions: {
|
|
16207
|
-
reservedSelect:
|
|
16208
|
-
reservedClauses: [...
|
|
16209
|
-
reservedSetOperations:
|
|
16210
|
-
reservedJoins:
|
|
16293
|
+
reservedSelect: me,
|
|
16294
|
+
reservedClauses: [...pe, ...tT, ...cE],
|
|
16295
|
+
reservedSetOperations: de,
|
|
16296
|
+
reservedJoins: he,
|
|
16211
16297
|
reservedKeywordPhrases: Ve,
|
|
16212
|
-
reservedDataTypePhrases:
|
|
16213
|
-
reservedKeywords:
|
|
16214
|
-
reservedDataTypes:
|
|
16215
|
-
reservedFunctionNames:
|
|
16298
|
+
reservedDataTypePhrases: fe,
|
|
16299
|
+
reservedKeywords: Be,
|
|
16300
|
+
reservedDataTypes: Fe,
|
|
16301
|
+
reservedFunctionNames: Ye,
|
|
16216
16302
|
// TODO: support _binary"some string" prefix
|
|
16217
16303
|
stringTypes: [
|
|
16218
16304
|
'""-qq-bs',
|
|
@@ -16252,7 +16338,7 @@ const yS = [
|
|
|
16252
16338
|
onelineClauses: [...tT, ...cE],
|
|
16253
16339
|
tabularOnelineClauses: cE
|
|
16254
16340
|
}
|
|
16255
|
-
},
|
|
16341
|
+
}, Xe = [
|
|
16256
16342
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
16257
16343
|
//
|
|
16258
16344
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -16860,7 +16946,7 @@ const yS = [
|
|
|
16860
16946
|
"QUARTER",
|
|
16861
16947
|
"ZEROIFNULL",
|
|
16862
16948
|
"ZIPF"
|
|
16863
|
-
],
|
|
16949
|
+
], be = [
|
|
16864
16950
|
// https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
|
|
16865
16951
|
//
|
|
16866
16952
|
// run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
|
|
@@ -16957,7 +17043,7 @@ const yS = [
|
|
|
16957
17043
|
"WITH",
|
|
16958
17044
|
// These are definitely keywords, but haven't found a definite list in the docs
|
|
16959
17045
|
"COMMENT"
|
|
16960
|
-
],
|
|
17046
|
+
], ye = [
|
|
16961
17047
|
"NUMBER",
|
|
16962
17048
|
"DECIMAL",
|
|
16963
17049
|
"NUMERIC",
|
|
@@ -16994,7 +17080,7 @@ const yS = [
|
|
|
16994
17080
|
"ARRAY",
|
|
16995
17081
|
"GEOGRAPHY",
|
|
16996
17082
|
"GEOMETRY"
|
|
16997
|
-
], Ke =
|
|
17083
|
+
], Ke = C(["SELECT [ALL | DISTINCT]"]), $e = C([
|
|
16998
17084
|
// queries
|
|
16999
17085
|
"WITH [RECURSIVE]",
|
|
17000
17086
|
"FROM",
|
|
@@ -17022,10 +17108,10 @@ const yS = [
|
|
|
17022
17108
|
"WHEN MATCHED [AND]",
|
|
17023
17109
|
"THEN {UPDATE SET | DELETE}",
|
|
17024
17110
|
"WHEN NOT MATCHED THEN INSERT"
|
|
17025
|
-
]), CT =
|
|
17111
|
+
]), CT = C([
|
|
17026
17112
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
17027
17113
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
17028
|
-
]), lE =
|
|
17114
|
+
]), lE = C([
|
|
17029
17115
|
// - create:
|
|
17030
17116
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
17031
17117
|
// - update:
|
|
@@ -17266,25 +17352,25 @@ const yS = [
|
|
|
17266
17352
|
"USE SCHEMA",
|
|
17267
17353
|
"USE SECONDARY ROLES",
|
|
17268
17354
|
"USE WAREHOUSE"
|
|
17269
|
-
]),
|
|
17355
|
+
]), ge = C(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), Je = C([
|
|
17270
17356
|
"[INNER] JOIN",
|
|
17271
17357
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17272
17358
|
"{CROSS | NATURAL} JOIN"
|
|
17273
|
-
]),
|
|
17359
|
+
]), we = C([
|
|
17274
17360
|
"{ROWS | RANGE} BETWEEN",
|
|
17275
17361
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17276
|
-
]),
|
|
17362
|
+
]), xe = C([]), ve = {
|
|
17277
17363
|
name: "snowflake",
|
|
17278
17364
|
tokenizerOptions: {
|
|
17279
17365
|
reservedSelect: Ke,
|
|
17280
|
-
reservedClauses: [
|
|
17281
|
-
reservedSetOperations:
|
|
17282
|
-
reservedJoins:
|
|
17283
|
-
reservedKeywordPhrases:
|
|
17284
|
-
reservedDataTypePhrases:
|
|
17285
|
-
reservedKeywords:
|
|
17286
|
-
reservedDataTypes:
|
|
17287
|
-
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,
|
|
17288
17374
|
stringTypes: ["$$", "''-qq-bs"],
|
|
17289
17375
|
identTypes: ['""-qq'],
|
|
17290
17376
|
variableTypes: [
|
|
@@ -17317,49 +17403,49 @@ const yS = [
|
|
|
17317
17403
|
onelineClauses: [...CT, ...lE],
|
|
17318
17404
|
tabularOnelineClauses: lE
|
|
17319
17405
|
}
|
|
17320
|
-
},
|
|
17406
|
+
}, Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17321
17407
|
__proto__: null,
|
|
17322
|
-
bigquery:
|
|
17408
|
+
bigquery: GR,
|
|
17323
17409
|
db2: WR,
|
|
17324
|
-
db2i:
|
|
17325
|
-
duckdb:
|
|
17326
|
-
hive:
|
|
17327
|
-
mariadb:
|
|
17328
|
-
mysql:
|
|
17329
|
-
n1ql:
|
|
17330
|
-
plsql:
|
|
17410
|
+
db2i: vR,
|
|
17411
|
+
duckdb: AA,
|
|
17412
|
+
hive: _A,
|
|
17413
|
+
mariadb: GA,
|
|
17414
|
+
mysql: dA,
|
|
17415
|
+
n1ql: zA,
|
|
17416
|
+
plsql: sS,
|
|
17331
17417
|
postgresql: aS,
|
|
17332
|
-
redshift:
|
|
17418
|
+
redshift: YS,
|
|
17333
17419
|
singlestoredb: We,
|
|
17334
|
-
snowflake:
|
|
17335
|
-
spark:
|
|
17336
|
-
sql:
|
|
17337
|
-
sqlite:
|
|
17338
|
-
tidb:
|
|
17339
|
-
transactsql:
|
|
17340
|
-
trino:
|
|
17341
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
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
|
|
17342
17428
|
|\r|
|
|
17343
17429
|
|$)`, "uy"), _T = (T, E = []) => {
|
|
17344
17430
|
const R = T === "open" ? 0 : 1, A = ["()", ...E].map((S) => S[R]);
|
|
17345
17431
|
return b(A.map(d).join("|"));
|
|
17346
|
-
}, rT = (T) => b(`${
|
|
17432
|
+
}, rT = (T) => b(`${FT(T).map(d).join("|")}`), ze = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", h = (T, E = {}) => {
|
|
17347
17433
|
if (T.length === 0)
|
|
17348
17434
|
return /^\b$/u;
|
|
17349
|
-
const R =
|
|
17435
|
+
const R = ze(E), A = FT(T).map(d).join("|").replace(/ /gu, "\\s+");
|
|
17350
17436
|
return new RegExp(`(?:${A})${R}\\b`, "iuy");
|
|
17351
17437
|
}, uE = (T, E) => {
|
|
17352
17438
|
if (!T.length)
|
|
17353
17439
|
return;
|
|
17354
17440
|
const R = T.map(d).join("|");
|
|
17355
17441
|
return b(`(?:${R})(?:${E})`);
|
|
17356
|
-
},
|
|
17442
|
+
}, EI = () => {
|
|
17357
17443
|
const T = {
|
|
17358
17444
|
"<": ">",
|
|
17359
17445
|
"[": "]",
|
|
17360
17446
|
"(": ")",
|
|
17361
17447
|
"{": "}"
|
|
17362
|
-
}, 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(""));
|
|
17363
17449
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
|
|
17364
17450
|
}, nT = {
|
|
17365
17451
|
// - backtick quoted (using `` to escape)
|
|
@@ -17385,16 +17471,16 @@ const yS = [
|
|
|
17385
17471
|
// Hive and Spark variables: ${name}
|
|
17386
17472
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
17387
17473
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
17388
|
-
"q''":
|
|
17389
|
-
},
|
|
17390
|
-
const S = "\\p{Alphabetic}\\p{Mark}_", e = "\\p{Decimal_Number}", O = d(T ?? ""),
|
|
17391
|
-
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;
|
|
17392
17478
|
};
|
|
17393
|
-
function
|
|
17479
|
+
function dT(T, E) {
|
|
17394
17480
|
const R = T.slice(0, E).split(/\n/);
|
|
17395
17481
|
return { line: R.length, col: R[R.length - 1].length + 1 };
|
|
17396
17482
|
}
|
|
17397
|
-
class
|
|
17483
|
+
class AI {
|
|
17398
17484
|
constructor(E, R) {
|
|
17399
17485
|
this.rules = E, this.dialectName = R, this.input = "", this.index = 0;
|
|
17400
17486
|
}
|
|
@@ -17420,7 +17506,7 @@ class RI {
|
|
|
17420
17506
|
return R;
|
|
17421
17507
|
}
|
|
17422
17508
|
createParseError() {
|
|
17423
|
-
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);
|
|
17424
17510
|
return new Error(`Parse error: Unexpected "${E}" at line ${R} column ${A}.
|
|
17425
17511
|
${this.dialectInfo()}`);
|
|
17426
17512
|
}
|
|
@@ -17456,8 +17542,8 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
|
|
|
17456
17542
|
}
|
|
17457
17543
|
}
|
|
17458
17544
|
}
|
|
17459
|
-
const iT = /\/\*/uy,
|
|
17460
|
-
class
|
|
17545
|
+
const iT = /\/\*/uy, SI = /[\s\S]/uy, eI = /\*\//uy;
|
|
17546
|
+
class II {
|
|
17461
17547
|
constructor() {
|
|
17462
17548
|
this.lastIndex = 0;
|
|
17463
17549
|
}
|
|
@@ -17470,9 +17556,9 @@ class eI {
|
|
|
17470
17556
|
for (; S > 0; )
|
|
17471
17557
|
if (A = this.matchSection(iT, E))
|
|
17472
17558
|
R += A, S++;
|
|
17473
|
-
else if (A = this.matchSection(
|
|
17559
|
+
else if (A = this.matchSection(eI, E))
|
|
17474
17560
|
R += A, S--;
|
|
17475
|
-
else if (A = this.matchSection(
|
|
17561
|
+
else if (A = this.matchSection(SI, E))
|
|
17476
17562
|
R += A;
|
|
17477
17563
|
else
|
|
17478
17564
|
return null;
|
|
@@ -17484,7 +17570,7 @@ class eI {
|
|
|
17484
17570
|
return A && (this.lastIndex += A[0].length), A ? A[0] : null;
|
|
17485
17571
|
}
|
|
17486
17572
|
}
|
|
17487
|
-
class
|
|
17573
|
+
class OI {
|
|
17488
17574
|
constructor(E, R) {
|
|
17489
17575
|
this.cfg = E, this.dialectName = R, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
|
|
17490
17576
|
}
|
|
@@ -17493,7 +17579,7 @@ class II {
|
|
|
17493
17579
|
...this.rulesBeforeParams,
|
|
17494
17580
|
...this.buildParamRules(this.cfg, R),
|
|
17495
17581
|
...this.rulesAfterParams
|
|
17496
|
-
], S = new
|
|
17582
|
+
], S = new AI(A, this.dialectName).tokenize(E);
|
|
17497
17583
|
return this.cfg.postProcess ? this.cfg.postProcess(S) : S;
|
|
17498
17584
|
}
|
|
17499
17585
|
// These rules can be cached as they only depend on
|
|
@@ -17507,7 +17593,7 @@ class II {
|
|
|
17507
17593
|
},
|
|
17508
17594
|
{
|
|
17509
17595
|
type: i.BLOCK_COMMENT,
|
|
17510
|
-
regex: E.nestedBlockComments ? new
|
|
17596
|
+
regex: E.nestedBlockComments ? new II() : /(\/\*[^]*?\*\/)/uy
|
|
17511
17597
|
},
|
|
17512
17598
|
{
|
|
17513
17599
|
type: i.LINE_COMMENT,
|
|
@@ -17525,83 +17611,83 @@ class II {
|
|
|
17525
17611
|
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
17526
17612
|
{
|
|
17527
17613
|
type: i.RESERVED_KEYWORD_PHRASE,
|
|
17528
|
-
regex:
|
|
17529
|
-
text:
|
|
17614
|
+
regex: h((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
17615
|
+
text: B
|
|
17530
17616
|
},
|
|
17531
17617
|
{
|
|
17532
17618
|
type: i.RESERVED_DATA_TYPE_PHRASE,
|
|
17533
|
-
regex:
|
|
17534
|
-
text:
|
|
17619
|
+
regex: h((S = E.reservedDataTypePhrases) !== null && S !== void 0 ? S : [], E.identChars),
|
|
17620
|
+
text: B
|
|
17535
17621
|
},
|
|
17536
17622
|
{
|
|
17537
17623
|
type: i.CASE,
|
|
17538
17624
|
regex: /CASE\b/iuy,
|
|
17539
|
-
text:
|
|
17625
|
+
text: B
|
|
17540
17626
|
},
|
|
17541
17627
|
{
|
|
17542
17628
|
type: i.END,
|
|
17543
17629
|
regex: /END\b/iuy,
|
|
17544
|
-
text:
|
|
17630
|
+
text: B
|
|
17545
17631
|
},
|
|
17546
17632
|
{
|
|
17547
17633
|
type: i.BETWEEN,
|
|
17548
17634
|
regex: /BETWEEN\b/iuy,
|
|
17549
|
-
text:
|
|
17635
|
+
text: B
|
|
17550
17636
|
},
|
|
17551
17637
|
{
|
|
17552
17638
|
type: i.LIMIT,
|
|
17553
17639
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
17554
|
-
text:
|
|
17640
|
+
text: B
|
|
17555
17641
|
},
|
|
17556
17642
|
{
|
|
17557
17643
|
type: i.RESERVED_CLAUSE,
|
|
17558
|
-
regex:
|
|
17559
|
-
text:
|
|
17644
|
+
regex: h(E.reservedClauses, E.identChars),
|
|
17645
|
+
text: B
|
|
17560
17646
|
},
|
|
17561
17647
|
{
|
|
17562
17648
|
type: i.RESERVED_SELECT,
|
|
17563
|
-
regex:
|
|
17564
|
-
text:
|
|
17649
|
+
regex: h(E.reservedSelect, E.identChars),
|
|
17650
|
+
text: B
|
|
17565
17651
|
},
|
|
17566
17652
|
{
|
|
17567
17653
|
type: i.RESERVED_SET_OPERATION,
|
|
17568
|
-
regex:
|
|
17569
|
-
text:
|
|
17654
|
+
regex: h(E.reservedSetOperations, E.identChars),
|
|
17655
|
+
text: B
|
|
17570
17656
|
},
|
|
17571
17657
|
{
|
|
17572
17658
|
type: i.WHEN,
|
|
17573
17659
|
regex: /WHEN\b/iuy,
|
|
17574
|
-
text:
|
|
17660
|
+
text: B
|
|
17575
17661
|
},
|
|
17576
17662
|
{
|
|
17577
17663
|
type: i.ELSE,
|
|
17578
17664
|
regex: /ELSE\b/iuy,
|
|
17579
|
-
text:
|
|
17665
|
+
text: B
|
|
17580
17666
|
},
|
|
17581
17667
|
{
|
|
17582
17668
|
type: i.THEN,
|
|
17583
17669
|
regex: /THEN\b/iuy,
|
|
17584
|
-
text:
|
|
17670
|
+
text: B
|
|
17585
17671
|
},
|
|
17586
17672
|
{
|
|
17587
17673
|
type: i.RESERVED_JOIN,
|
|
17588
|
-
regex:
|
|
17589
|
-
text:
|
|
17674
|
+
regex: h(E.reservedJoins, E.identChars),
|
|
17675
|
+
text: B
|
|
17590
17676
|
},
|
|
17591
17677
|
{
|
|
17592
17678
|
type: i.AND,
|
|
17593
17679
|
regex: /AND\b/iuy,
|
|
17594
|
-
text:
|
|
17680
|
+
text: B
|
|
17595
17681
|
},
|
|
17596
17682
|
{
|
|
17597
17683
|
type: i.OR,
|
|
17598
17684
|
regex: /OR\b/iuy,
|
|
17599
|
-
text:
|
|
17685
|
+
text: B
|
|
17600
17686
|
},
|
|
17601
17687
|
{
|
|
17602
17688
|
type: i.XOR,
|
|
17603
17689
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
17604
|
-
text:
|
|
17690
|
+
text: B
|
|
17605
17691
|
},
|
|
17606
17692
|
...E.operatorKeyword ? [
|
|
17607
17693
|
{
|
|
@@ -17611,18 +17697,18 @@ class II {
|
|
|
17611
17697
|
] : [],
|
|
17612
17698
|
{
|
|
17613
17699
|
type: i.RESERVED_FUNCTION_NAME,
|
|
17614
|
-
regex:
|
|
17615
|
-
text:
|
|
17700
|
+
regex: h(E.reservedFunctionNames, E.identChars),
|
|
17701
|
+
text: B
|
|
17616
17702
|
},
|
|
17617
17703
|
{
|
|
17618
17704
|
type: i.RESERVED_DATA_TYPE,
|
|
17619
|
-
regex:
|
|
17620
|
-
text:
|
|
17705
|
+
regex: h(E.reservedDataTypes, E.identChars),
|
|
17706
|
+
text: B
|
|
17621
17707
|
},
|
|
17622
17708
|
{
|
|
17623
17709
|
type: i.RESERVED_KEYWORD,
|
|
17624
|
-
regex:
|
|
17625
|
-
text:
|
|
17710
|
+
regex: h(E.reservedKeywords, E.identChars),
|
|
17711
|
+
text: B
|
|
17626
17712
|
}
|
|
17627
17713
|
]);
|
|
17628
17714
|
}
|
|
@@ -17633,12 +17719,12 @@ class II {
|
|
|
17633
17719
|
return this.validRules([
|
|
17634
17720
|
{
|
|
17635
17721
|
type: i.VARIABLE,
|
|
17636
|
-
regex: E.variableTypes ?
|
|
17722
|
+
regex: E.variableTypes ? TI(E.variableTypes) : void 0
|
|
17637
17723
|
},
|
|
17638
17724
|
{ type: i.STRING, regex: DT(E.stringTypes) },
|
|
17639
17725
|
{
|
|
17640
17726
|
type: i.IDENTIFIER,
|
|
17641
|
-
regex:
|
|
17727
|
+
regex: RI(E.identChars)
|
|
17642
17728
|
},
|
|
17643
17729
|
{ type: i.DELIMITER, regex: /[;]/uy },
|
|
17644
17730
|
{ type: i.COMMA, regex: /[,]/y },
|
|
@@ -17677,24 +17763,24 @@ class II {
|
|
|
17677
17763
|
// These rules can't be blindly cached as the paramTypesOverrides object
|
|
17678
17764
|
// can differ on each invocation of the format() function.
|
|
17679
17765
|
buildParamRules(E, R) {
|
|
17680
|
-
var A, S, e, O,
|
|
17766
|
+
var A, S, e, O, t;
|
|
17681
17767
|
const D = {
|
|
17682
17768
|
named: R?.named || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
|
|
17683
17769
|
quoted: R?.quoted || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.quoted) || [],
|
|
17684
17770
|
numbered: R?.numbered || ((e = E.paramTypes) === null || e === void 0 ? void 0 : e.numbered) || [],
|
|
17685
17771
|
positional: typeof R?.positional == "boolean" ? R.positional : (O = E.paramTypes) === null || O === void 0 ? void 0 : O.positional,
|
|
17686
|
-
custom: R?.custom || ((
|
|
17772
|
+
custom: R?.custom || ((t = E.paramTypes) === null || t === void 0 ? void 0 : t.custom) || []
|
|
17687
17773
|
};
|
|
17688
17774
|
return this.validRules([
|
|
17689
17775
|
{
|
|
17690
17776
|
type: i.NAMED_PARAMETER,
|
|
17691
|
-
regex: uE(D.named,
|
|
17777
|
+
regex: uE(D.named, pT(E.paramChars || E.identChars)),
|
|
17692
17778
|
key: (I) => I.slice(1)
|
|
17693
17779
|
},
|
|
17694
17780
|
{
|
|
17695
17781
|
type: i.QUOTED_PARAMETER,
|
|
17696
|
-
regex: uE(D.quoted,
|
|
17697
|
-
key: (I) => (({ tokenKey:
|
|
17782
|
+
regex: uE(D.quoted, mT(E.identTypes)),
|
|
17783
|
+
key: (I) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(d("\\" + s), "gu"), s))({
|
|
17698
17784
|
tokenKey: I.slice(2, -1),
|
|
17699
17785
|
quoteChar: I.slice(-1)
|
|
17700
17786
|
})
|
|
@@ -17709,11 +17795,11 @@ class II {
|
|
|
17709
17795
|
regex: D.positional ? /[?]/y : void 0
|
|
17710
17796
|
},
|
|
17711
17797
|
...D.custom.map((I) => {
|
|
17712
|
-
var
|
|
17798
|
+
var N;
|
|
17713
17799
|
return {
|
|
17714
17800
|
type: i.CUSTOM_PARAMETER,
|
|
17715
17801
|
regex: b(I.regex),
|
|
17716
|
-
key: (
|
|
17802
|
+
key: (N = I.key) !== null && N !== void 0 ? N : ((s) => s)
|
|
17717
17803
|
};
|
|
17718
17804
|
})
|
|
17719
17805
|
]);
|
|
@@ -17723,13 +17809,13 @@ class II {
|
|
|
17723
17809
|
return E.filter((R) => !!R.regex);
|
|
17724
17810
|
}
|
|
17725
17811
|
}
|
|
17726
|
-
const
|
|
17812
|
+
const B = (T) => q(T.toUpperCase()), PT = /* @__PURE__ */ new Map(), NI = (T) => {
|
|
17727
17813
|
let E = PT.get(T);
|
|
17728
|
-
return E || (E =
|
|
17729
|
-
},
|
|
17730
|
-
tokenizer: new
|
|
17731
|
-
formatOptions:
|
|
17732
|
-
}),
|
|
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) => {
|
|
17733
17819
|
var E;
|
|
17734
17820
|
return {
|
|
17735
17821
|
alwaysDenseOperators: T.alwaysDenseOperators || [],
|
|
@@ -17737,13 +17823,13 @@ const H = (T) => Z(T.toUpperCase()), PT = /* @__PURE__ */ new Map(), OI = (T) =>
|
|
|
17737
17823
|
tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((R) => [R, !0]))
|
|
17738
17824
|
};
|
|
17739
17825
|
};
|
|
17740
|
-
function
|
|
17826
|
+
function CI(T) {
|
|
17741
17827
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
|
|
17742
17828
|
}
|
|
17743
17829
|
function J(T) {
|
|
17744
17830
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
|
|
17745
17831
|
}
|
|
17746
|
-
class
|
|
17832
|
+
class LI {
|
|
17747
17833
|
constructor(E) {
|
|
17748
17834
|
this.params = E, this.index = 0;
|
|
17749
17835
|
}
|
|
@@ -17766,101 +17852,101 @@ class CI {
|
|
|
17766
17852
|
this.index = E;
|
|
17767
17853
|
}
|
|
17768
17854
|
}
|
|
17769
|
-
function
|
|
17855
|
+
function _I(T) {
|
|
17770
17856
|
return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
|
|
17771
17857
|
}
|
|
17772
|
-
var
|
|
17773
|
-
function
|
|
17774
|
-
return
|
|
17858
|
+
var j = { exports: {} }, rI = j.exports, oT;
|
|
17859
|
+
function nI() {
|
|
17860
|
+
return oT || (oT = 1, (function(T) {
|
|
17775
17861
|
(function(E, R) {
|
|
17776
17862
|
T.exports ? T.exports = R() : E.nearley = R();
|
|
17777
|
-
})(
|
|
17778
|
-
function E(I,
|
|
17779
|
-
return this.id = ++E.highestId, this.name = I, this.symbols =
|
|
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;
|
|
17780
17866
|
}
|
|
17781
17867
|
E.highestId = 0, E.prototype.toString = function(I) {
|
|
17782
|
-
var
|
|
17783
|
-
return this.name + " → " +
|
|
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(" ");
|
|
17869
|
+
return this.name + " → " + N;
|
|
17784
17870
|
};
|
|
17785
|
-
function R(I,
|
|
17786
|
-
this.rule = I, this.dot =
|
|
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;
|
|
17787
17873
|
}
|
|
17788
17874
|
R.prototype.toString = function() {
|
|
17789
17875
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
17790
17876
|
}, R.prototype.nextState = function(I) {
|
|
17791
|
-
var
|
|
17792
|
-
return
|
|
17877
|
+
var N = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
17878
|
+
return N.left = this, N.right = I, N.isComplete && (N.data = N.build(), N.right = void 0), N;
|
|
17793
17879
|
}, R.prototype.build = function() {
|
|
17794
|
-
var I = [],
|
|
17880
|
+
var I = [], N = this;
|
|
17795
17881
|
do
|
|
17796
|
-
I.push(
|
|
17797
|
-
while (
|
|
17882
|
+
I.push(N.right.data), N = N.left;
|
|
17883
|
+
while (N.left);
|
|
17798
17884
|
return I.reverse(), I;
|
|
17799
17885
|
}, R.prototype.finish = function() {
|
|
17800
17886
|
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, O.fail));
|
|
17801
17887
|
};
|
|
17802
|
-
function A(I,
|
|
17803
|
-
this.grammar = I, this.index =
|
|
17888
|
+
function A(I, N) {
|
|
17889
|
+
this.grammar = I, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
17804
17890
|
}
|
|
17805
17891
|
A.prototype.process = function(I) {
|
|
17806
|
-
for (var
|
|
17807
|
-
var
|
|
17808
|
-
if (
|
|
17809
|
-
if (
|
|
17810
|
-
for (var r =
|
|
17811
|
-
var
|
|
17812
|
-
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);
|
|
17813
17899
|
}
|
|
17814
|
-
if (
|
|
17815
|
-
var
|
|
17816
|
-
(this.completed[
|
|
17900
|
+
if (o.reference === this.index) {
|
|
17901
|
+
var l = o.rule.name;
|
|
17902
|
+
(this.completed[l] = this.completed[l] || []).push(o);
|
|
17817
17903
|
}
|
|
17818
17904
|
}
|
|
17819
17905
|
} else {
|
|
17820
|
-
var
|
|
17821
|
-
if (typeof
|
|
17822
|
-
this.scannable.push(
|
|
17906
|
+
var l = o.rule.symbols[o.dot];
|
|
17907
|
+
if (typeof l != "string") {
|
|
17908
|
+
this.scannable.push(o);
|
|
17823
17909
|
continue;
|
|
17824
17910
|
}
|
|
17825
|
-
if (s[
|
|
17826
|
-
if (s[
|
|
17827
|
-
for (var
|
|
17828
|
-
var
|
|
17829
|
-
this.complete(
|
|
17911
|
+
if (s[l]) {
|
|
17912
|
+
if (s[l].push(o), L.hasOwnProperty(l))
|
|
17913
|
+
for (var c = L[l], U = 0; U < c.length; U++) {
|
|
17914
|
+
var H = c[U];
|
|
17915
|
+
this.complete(o, H);
|
|
17830
17916
|
}
|
|
17831
17917
|
} else
|
|
17832
|
-
s[
|
|
17918
|
+
s[l] = [o], this.predict(l);
|
|
17833
17919
|
}
|
|
17834
17920
|
}
|
|
17835
17921
|
}, A.prototype.predict = function(I) {
|
|
17836
|
-
for (var
|
|
17837
|
-
var L =
|
|
17838
|
-
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);
|
|
17839
17925
|
}
|
|
17840
|
-
}, A.prototype.complete = function(I,
|
|
17841
|
-
var s = I.nextState(
|
|
17926
|
+
}, A.prototype.complete = function(I, N) {
|
|
17927
|
+
var s = I.nextState(N);
|
|
17842
17928
|
this.states.push(s);
|
|
17843
17929
|
};
|
|
17844
|
-
function S(I,
|
|
17845
|
-
this.rules = I, this.start =
|
|
17930
|
+
function S(I, N) {
|
|
17931
|
+
this.rules = I, this.start = N || this.rules[0].name;
|
|
17846
17932
|
var s = this.byName = {};
|
|
17847
17933
|
this.rules.forEach(function(L) {
|
|
17848
17934
|
s.hasOwnProperty(L.name) || (s[L.name] = []), s[L.name].push(L);
|
|
17849
17935
|
});
|
|
17850
17936
|
}
|
|
17851
|
-
S.fromCompiled = function(L,
|
|
17937
|
+
S.fromCompiled = function(L, N) {
|
|
17852
17938
|
var s = L.Lexer;
|
|
17853
|
-
L.ParserStart && (
|
|
17854
|
-
var L = L.map(function(
|
|
17855
|
-
return new E(
|
|
17856
|
-
}), P = new S(L,
|
|
17939
|
+
L.ParserStart && (N = L.ParserStart, L = L.ParserRules);
|
|
17940
|
+
var L = L.map(function(o) {
|
|
17941
|
+
return new E(o.name, o.symbols, o.postprocess);
|
|
17942
|
+
}), P = new S(L, N);
|
|
17857
17943
|
return P.lexer = s, P;
|
|
17858
17944
|
};
|
|
17859
17945
|
function e() {
|
|
17860
17946
|
this.reset("");
|
|
17861
17947
|
}
|
|
17862
|
-
e.prototype.reset = function(I,
|
|
17863
|
-
this.buffer = I, this.index = 0, this.line =
|
|
17948
|
+
e.prototype.reset = function(I, N) {
|
|
17949
|
+
this.buffer = I, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
|
|
17864
17950
|
}, e.prototype.next = function() {
|
|
17865
17951
|
if (this.index < this.buffer.length) {
|
|
17866
17952
|
var I = this.buffer[this.index++];
|
|
@@ -17872,7 +17958,7 @@ function rI() {
|
|
|
17872
17958
|
line: this.line,
|
|
17873
17959
|
col: this.index - this.lastLineBreak
|
|
17874
17960
|
};
|
|
17875
|
-
}, e.prototype.formatError = function(I,
|
|
17961
|
+
}, e.prototype.formatError = function(I, N) {
|
|
17876
17962
|
var s = this.buffer;
|
|
17877
17963
|
if (typeof s == "string") {
|
|
17878
17964
|
var L = s.split(`
|
|
@@ -17882,27 +17968,27 @@ function rI() {
|
|
|
17882
17968
|
), P = s.indexOf(`
|
|
17883
17969
|
`, this.index);
|
|
17884
17970
|
P === -1 && (P = s.length);
|
|
17885
|
-
var
|
|
17886
|
-
return
|
|
17971
|
+
var o = this.index - this.lastLineBreak, r = String(this.line).length;
|
|
17972
|
+
return N += " at line " + this.line + " col " + o + `:
|
|
17887
17973
|
|
|
17888
|
-
`,
|
|
17889
|
-
return U(this.line - L.length +
|
|
17974
|
+
`, N += L.map(function(a, l) {
|
|
17975
|
+
return U(this.line - L.length + l + 1, r) + " " + a;
|
|
17890
17976
|
}, this).join(`
|
|
17891
|
-
`),
|
|
17892
|
-
` + U("", r +
|
|
17893
|
-
`,
|
|
17977
|
+
`), N += `
|
|
17978
|
+
` + U("", r + o) + `^
|
|
17979
|
+
`, N;
|
|
17894
17980
|
} else
|
|
17895
|
-
return
|
|
17896
|
-
function U(
|
|
17897
|
-
var
|
|
17898
|
-
return Array(
|
|
17981
|
+
return N + " at index " + (this.index - 1);
|
|
17982
|
+
function U(a, l) {
|
|
17983
|
+
var c = String(a);
|
|
17984
|
+
return Array(l - c.length + 1).join(" ") + c;
|
|
17899
17985
|
}
|
|
17900
17986
|
};
|
|
17901
|
-
function O(I,
|
|
17987
|
+
function O(I, N, s) {
|
|
17902
17988
|
if (I instanceof S)
|
|
17903
|
-
var L = I, s =
|
|
17989
|
+
var L = I, s = N;
|
|
17904
17990
|
else
|
|
17905
|
-
var L = S.fromCompiled(I,
|
|
17991
|
+
var L = S.fromCompiled(I, N);
|
|
17906
17992
|
this.grammar = L, this.options = {
|
|
17907
17993
|
keepHistory: !1,
|
|
17908
17994
|
lexer: L.lexer || new e()
|
|
@@ -17910,30 +17996,30 @@ function rI() {
|
|
|
17910
17996
|
for (var P in s || {})
|
|
17911
17997
|
this.options[P] = s[P];
|
|
17912
17998
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
17913
|
-
var
|
|
17914
|
-
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;
|
|
17915
18001
|
}
|
|
17916
18002
|
O.fail = {}, O.prototype.feed = function(I) {
|
|
17917
|
-
var
|
|
17918
|
-
|
|
18003
|
+
var N = this.lexer;
|
|
18004
|
+
N.reset(I, this.lexerState);
|
|
17919
18005
|
for (var s; ; ) {
|
|
17920
18006
|
try {
|
|
17921
|
-
if (s =
|
|
18007
|
+
if (s = N.next(), !s)
|
|
17922
18008
|
break;
|
|
17923
|
-
} catch (
|
|
18009
|
+
} catch (y) {
|
|
17924
18010
|
var r = new A(this.grammar, this.current + 1);
|
|
17925
18011
|
this.table.push(r);
|
|
17926
|
-
var L = new Error(this.reportLexerError(
|
|
17927
|
-
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;
|
|
17928
18014
|
}
|
|
17929
18015
|
var P = this.table[this.current];
|
|
17930
18016
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
17931
|
-
var
|
|
18017
|
+
var o = this.current + 1, r = new A(this.grammar, o);
|
|
17932
18018
|
this.table.push(r);
|
|
17933
|
-
for (var U = s.text !== void 0 ? s.text : s.value,
|
|
17934
|
-
var
|
|
17935
|
-
if (
|
|
17936
|
-
var p =
|
|
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--; ) {
|
|
18020
|
+
var H = l[c], u = H.rule.symbols[H.dot];
|
|
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 });
|
|
17937
18023
|
r.states.push(p);
|
|
17938
18024
|
}
|
|
17939
18025
|
}
|
|
@@ -17941,75 +18027,75 @@ function rI() {
|
|
|
17941
18027
|
var L = new Error(this.reportError(s));
|
|
17942
18028
|
throw L.offset = this.current, L.token = s, L;
|
|
17943
18029
|
}
|
|
17944
|
-
this.options.keepHistory && (P.lexerState =
|
|
18030
|
+
this.options.keepHistory && (P.lexerState = N.save()), this.current++;
|
|
17945
18031
|
}
|
|
17946
|
-
return P && (this.lexerState =
|
|
18032
|
+
return P && (this.lexerState = N.save()), this.results = this.finish(), this;
|
|
17947
18033
|
}, O.prototype.reportLexerError = function(I) {
|
|
17948
|
-
var
|
|
17949
|
-
return L ? (
|
|
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);
|
|
17950
18036
|
}, O.prototype.reportError = function(I) {
|
|
17951
|
-
var
|
|
17952
|
-
return this.reportErrorCommon(s,
|
|
17953
|
-
}, O.prototype.reportErrorCommon = function(I,
|
|
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);
|
|
18039
|
+
}, O.prototype.reportErrorCommon = function(I, N) {
|
|
17954
18040
|
var s = [];
|
|
17955
18041
|
s.push(I);
|
|
17956
|
-
var L = this.table.length - 2, P = this.table[L],
|
|
17957
|
-
var
|
|
17958
|
-
return
|
|
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";
|
|
17959
18045
|
});
|
|
17960
|
-
if (
|
|
17961
|
-
s.push("Unexpected " +
|
|
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:
|
|
17962
18048
|
`), this.displayStateStack(P.states, s);
|
|
17963
18049
|
else {
|
|
17964
|
-
s.push("Unexpected " +
|
|
18050
|
+
s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
17965
18051
|
`);
|
|
17966
|
-
var r =
|
|
18052
|
+
var r = o.map(function(U) {
|
|
17967
18053
|
return this.buildFirstStateStack(U, []) || [U];
|
|
17968
18054
|
}, this);
|
|
17969
18055
|
r.forEach(function(U) {
|
|
17970
|
-
var
|
|
17971
|
-
s.push("A " +
|
|
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);
|
|
17972
18058
|
}, this);
|
|
17973
18059
|
}
|
|
17974
18060
|
return s.push(""), s.join(`
|
|
17975
18061
|
`);
|
|
17976
|
-
}, O.prototype.displayStateStack = function(I,
|
|
18062
|
+
}, O.prototype.displayStateStack = function(I, N) {
|
|
17977
18063
|
for (var s, L = 0, P = 0; P < I.length; P++) {
|
|
17978
|
-
var
|
|
17979
|
-
r === s ? L++ : (L > 0 &&
|
|
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;
|
|
17980
18066
|
}
|
|
17981
18067
|
}, O.prototype.getSymbolDisplay = function(I) {
|
|
17982
|
-
return
|
|
17983
|
-
}, O.prototype.buildFirstStateStack = function(I,
|
|
17984
|
-
if (
|
|
18068
|
+
return t(I);
|
|
18069
|
+
}, O.prototype.buildFirstStateStack = function(I, N) {
|
|
18070
|
+
if (N.indexOf(I) !== -1)
|
|
17985
18071
|
return null;
|
|
17986
18072
|
if (I.wantedBy.length === 0)
|
|
17987
18073
|
return [I];
|
|
17988
|
-
var s = I.wantedBy[0], L = [I].concat(
|
|
18074
|
+
var s = I.wantedBy[0], L = [I].concat(N), P = this.buildFirstStateStack(s, L);
|
|
17989
18075
|
return P === null ? null : [I].concat(P);
|
|
17990
18076
|
}, O.prototype.save = function() {
|
|
17991
18077
|
var I = this.table[this.current];
|
|
17992
18078
|
return I.lexerState = this.lexerState, I;
|
|
17993
18079
|
}, O.prototype.restore = function(I) {
|
|
17994
|
-
var
|
|
17995
|
-
this.current =
|
|
18080
|
+
var N = I.index;
|
|
18081
|
+
this.current = N, this.table[N] = I, this.table.splice(N + 1), this.lexerState = I.lexerState, this.results = this.finish();
|
|
17996
18082
|
}, O.prototype.rewind = function(I) {
|
|
17997
18083
|
if (!this.options.keepHistory)
|
|
17998
18084
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
17999
18085
|
this.restore(this.table[I]);
|
|
18000
18086
|
}, O.prototype.finish = function() {
|
|
18001
|
-
var I = [],
|
|
18087
|
+
var I = [], N = this.grammar.start, s = this.table[this.table.length - 1];
|
|
18002
18088
|
return s.states.forEach(function(L) {
|
|
18003
|
-
L.rule.name ===
|
|
18089
|
+
L.rule.name === N && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== O.fail && I.push(L);
|
|
18004
18090
|
}), I.map(function(L) {
|
|
18005
18091
|
return L.data;
|
|
18006
18092
|
});
|
|
18007
18093
|
};
|
|
18008
|
-
function
|
|
18009
|
-
var
|
|
18010
|
-
if (
|
|
18094
|
+
function t(I) {
|
|
18095
|
+
var N = typeof I;
|
|
18096
|
+
if (N === "string")
|
|
18011
18097
|
return I;
|
|
18012
|
-
if (
|
|
18098
|
+
if (N === "object") {
|
|
18013
18099
|
if (I.literal)
|
|
18014
18100
|
return JSON.stringify(I.literal);
|
|
18015
18101
|
if (I instanceof RegExp)
|
|
@@ -18022,10 +18108,10 @@ function rI() {
|
|
|
18022
18108
|
}
|
|
18023
18109
|
}
|
|
18024
18110
|
function D(I) {
|
|
18025
|
-
var
|
|
18026
|
-
if (
|
|
18111
|
+
var N = typeof I;
|
|
18112
|
+
if (N === "string")
|
|
18027
18113
|
return I;
|
|
18028
|
-
if (
|
|
18114
|
+
if (N === "object") {
|
|
18029
18115
|
if (I.literal)
|
|
18030
18116
|
return JSON.stringify(I.literal);
|
|
18031
18117
|
if (I instanceof RegExp)
|
|
@@ -18043,58 +18129,58 @@ function rI() {
|
|
|
18043
18129
|
Rule: E
|
|
18044
18130
|
};
|
|
18045
18131
|
});
|
|
18046
|
-
})(
|
|
18132
|
+
})(j)), j.exports;
|
|
18047
18133
|
}
|
|
18048
|
-
var
|
|
18049
|
-
const
|
|
18050
|
-
function
|
|
18051
|
-
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);
|
|
18052
18138
|
}
|
|
18053
|
-
const
|
|
18054
|
-
if (
|
|
18055
|
-
const A =
|
|
18139
|
+
const oI = (T, E, R) => {
|
|
18140
|
+
if (BT(T.type)) {
|
|
18141
|
+
const A = cI(R, E);
|
|
18056
18142
|
if (A && A.type === i.PROPERTY_ACCESS_OPERATOR)
|
|
18057
18143
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18058
|
-
const S =
|
|
18144
|
+
const S = v(R, E);
|
|
18059
18145
|
if (S && S.type === i.PROPERTY_ACCESS_OPERATOR)
|
|
18060
18146
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18061
18147
|
}
|
|
18062
18148
|
return T;
|
|
18063
18149
|
}, aI = (T, E, R) => {
|
|
18064
18150
|
if (T.type === i.RESERVED_FUNCTION_NAME) {
|
|
18065
|
-
const A =
|
|
18066
|
-
if (!A || !
|
|
18151
|
+
const A = v(R, E);
|
|
18152
|
+
if (!A || !hT(A))
|
|
18067
18153
|
return Object.assign(Object.assign({}, T), { type: i.IDENTIFIER, text: T.raw });
|
|
18068
18154
|
}
|
|
18069
18155
|
return T;
|
|
18070
|
-
},
|
|
18156
|
+
}, MI = (T, E, R) => {
|
|
18071
18157
|
if (T.type === i.RESERVED_DATA_TYPE) {
|
|
18072
|
-
const A =
|
|
18073
|
-
if (A &&
|
|
18158
|
+
const A = v(R, E);
|
|
18159
|
+
if (A && hT(A))
|
|
18074
18160
|
return Object.assign(Object.assign({}, T), { type: i.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
18075
18161
|
}
|
|
18076
18162
|
return T;
|
|
18077
|
-
},
|
|
18163
|
+
}, UI = (T, E, R) => {
|
|
18078
18164
|
if (T.type === i.IDENTIFIER) {
|
|
18079
|
-
const A =
|
|
18165
|
+
const A = v(R, E);
|
|
18080
18166
|
if (A && VT(A))
|
|
18081
18167
|
return Object.assign(Object.assign({}, T), { type: i.ARRAY_IDENTIFIER });
|
|
18082
18168
|
}
|
|
18083
18169
|
return T;
|
|
18084
|
-
},
|
|
18170
|
+
}, GI = (T, E, R) => {
|
|
18085
18171
|
if (T.type === i.RESERVED_DATA_TYPE) {
|
|
18086
|
-
const A =
|
|
18172
|
+
const A = v(R, E);
|
|
18087
18173
|
if (A && VT(A))
|
|
18088
18174
|
return Object.assign(Object.assign({}, T), { type: i.ARRAY_KEYWORD });
|
|
18089
18175
|
}
|
|
18090
18176
|
return T;
|
|
18091
|
-
},
|
|
18177
|
+
}, cI = (T, E) => v(T, E, -1), v = (T, E, R = 1) => {
|
|
18092
18178
|
let A = 1;
|
|
18093
|
-
for (; T[E + A * R] &&
|
|
18179
|
+
for (; T[E + A * R] && lI(T[E + A * R]); )
|
|
18094
18180
|
A++;
|
|
18095
18181
|
return T[E + A * R];
|
|
18096
|
-
},
|
|
18097
|
-
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 {
|
|
18098
18184
|
constructor(E) {
|
|
18099
18185
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
18100
18186
|
}
|
|
@@ -18107,7 +18193,7 @@ class hT {
|
|
|
18107
18193
|
save() {
|
|
18108
18194
|
}
|
|
18109
18195
|
formatError(E) {
|
|
18110
|
-
const { line: R, col: A } =
|
|
18196
|
+
const { line: R, col: A } = dT(this.input, E.start);
|
|
18111
18197
|
return `Parse error at token: ${E.text} at line ${R} column ${A}`;
|
|
18112
18198
|
}
|
|
18113
18199
|
has(E) {
|
|
@@ -18121,26 +18207,26 @@ var M;
|
|
|
18121
18207
|
function BE(T) {
|
|
18122
18208
|
return T[0];
|
|
18123
18209
|
}
|
|
18124
|
-
const G = new
|
|
18210
|
+
const G = new fT((T) => []), V = ([[T]]) => T, F = (T) => ({
|
|
18125
18211
|
type: M.keyword,
|
|
18126
18212
|
tokenType: T.type,
|
|
18127
18213
|
text: T.text,
|
|
18128
18214
|
raw: T.raw
|
|
18129
|
-
}),
|
|
18215
|
+
}), aT = (T) => ({
|
|
18130
18216
|
type: M.data_type,
|
|
18131
18217
|
text: T.text,
|
|
18132
18218
|
raw: T.raw
|
|
18133
|
-
}),
|
|
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 }) => {
|
|
18134
18220
|
if (E?.length) {
|
|
18135
18221
|
const [A, ...S] = T;
|
|
18136
|
-
T = [
|
|
18222
|
+
T = [Y(A, { leading: E }), ...S];
|
|
18137
18223
|
}
|
|
18138
18224
|
if (R?.length) {
|
|
18139
18225
|
const A = T.slice(0, -1), S = T[T.length - 1];
|
|
18140
|
-
T = [...A,
|
|
18226
|
+
T = [...A, Y(S, { trailing: R })];
|
|
18141
18227
|
}
|
|
18142
18228
|
return T;
|
|
18143
|
-
},
|
|
18229
|
+
}, uI = {
|
|
18144
18230
|
Lexer: G,
|
|
18145
18231
|
ParserRules: [
|
|
18146
18232
|
{ name: "main$ebnf$1", symbols: [] },
|
|
@@ -18177,7 +18263,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18177
18263
|
{ name: "clause$subexpression$1", symbols: ["select_clause"] },
|
|
18178
18264
|
{ name: "clause$subexpression$1", symbols: ["other_clause"] },
|
|
18179
18265
|
{ name: "clause$subexpression$1", symbols: ["set_operation"] },
|
|
18180
|
-
{ name: "clause", symbols: ["clause$subexpression$1"], postprocess:
|
|
18266
|
+
{ name: "clause", symbols: ["clause$subexpression$1"], postprocess: V },
|
|
18181
18267
|
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
|
|
18182
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]]) },
|
|
18183
18269
|
{ name: "limit_clause$ebnf$1$subexpression$1", symbols: [G.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
|
|
@@ -18191,14 +18277,14 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18191
18277
|
const [S, e] = A;
|
|
18192
18278
|
return {
|
|
18193
18279
|
type: M.limit_clause,
|
|
18194
|
-
limitKw: F(
|
|
18280
|
+
limitKw: Y(F(T), { trailing: E }),
|
|
18195
18281
|
offset: R,
|
|
18196
18282
|
count: e
|
|
18197
18283
|
};
|
|
18198
18284
|
} else
|
|
18199
18285
|
return {
|
|
18200
18286
|
type: M.limit_clause,
|
|
18201
|
-
limitKw: F(
|
|
18287
|
+
limitKw: Y(F(T), { trailing: E }),
|
|
18202
18288
|
count: R
|
|
18203
18289
|
};
|
|
18204
18290
|
}
|
|
@@ -18214,7 +18300,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18214
18300
|
symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
|
|
18215
18301
|
postprocess: ([T, [E, R]]) => ({
|
|
18216
18302
|
type: M.clause,
|
|
18217
|
-
nameKw:
|
|
18303
|
+
nameKw: F(T),
|
|
18218
18304
|
children: [E, ...R]
|
|
18219
18305
|
})
|
|
18220
18306
|
},
|
|
@@ -18223,7 +18309,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18223
18309
|
symbols: [G.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
|
|
18224
18310
|
postprocess: ([T]) => ({
|
|
18225
18311
|
type: M.clause,
|
|
18226
|
-
nameKw:
|
|
18312
|
+
nameKw: F(T),
|
|
18227
18313
|
children: []
|
|
18228
18314
|
})
|
|
18229
18315
|
},
|
|
@@ -18239,7 +18325,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18239
18325
|
symbols: [G.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
|
|
18240
18326
|
postprocess: ([T, E]) => ({
|
|
18241
18327
|
type: M.clause,
|
|
18242
|
-
nameKw:
|
|
18328
|
+
nameKw: F(T),
|
|
18243
18329
|
children: E
|
|
18244
18330
|
})
|
|
18245
18331
|
},
|
|
@@ -18250,7 +18336,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18250
18336
|
symbols: [G.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
|
|
18251
18337
|
postprocess: ([T, E]) => ({
|
|
18252
18338
|
type: M.set_operation,
|
|
18253
|
-
nameKw:
|
|
18339
|
+
nameKw: F(T),
|
|
18254
18340
|
children: E
|
|
18255
18341
|
})
|
|
18256
18342
|
},
|
|
@@ -18274,37 +18360,37 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18274
18360
|
{
|
|
18275
18361
|
name: "expression_with_comments_",
|
|
18276
18362
|
symbols: ["expression", "_"],
|
|
18277
|
-
postprocess: ([T, E]) =>
|
|
18363
|
+
postprocess: ([T, E]) => Y(T, { trailing: E })
|
|
18278
18364
|
},
|
|
18279
18365
|
{
|
|
18280
18366
|
name: "_expression_with_comments",
|
|
18281
18367
|
symbols: ["_", "expression"],
|
|
18282
|
-
postprocess: ([T, E]) =>
|
|
18368
|
+
postprocess: ([T, E]) => Y(E, { leading: T })
|
|
18283
18369
|
},
|
|
18284
18370
|
{
|
|
18285
18371
|
name: "_andless_expression_with_comments",
|
|
18286
18372
|
symbols: ["_", "andless_expression"],
|
|
18287
|
-
postprocess: ([T, E]) =>
|
|
18373
|
+
postprocess: ([T, E]) => Y(E, { leading: T })
|
|
18288
18374
|
},
|
|
18289
18375
|
{ name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
|
|
18290
18376
|
{ name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
|
|
18291
|
-
{ name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess:
|
|
18377
|
+
{ name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess: V },
|
|
18292
18378
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
18293
18379
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["logic_operator"] },
|
|
18294
18380
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comma"] },
|
|
18295
18381
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comment"] },
|
|
18296
18382
|
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["other_keyword"] },
|
|
18297
|
-
{ 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 },
|
|
18298
18384
|
{ name: "expression$subexpression$1", symbols: ["andless_expression"] },
|
|
18299
18385
|
{ name: "expression$subexpression$1", symbols: ["logic_operator"] },
|
|
18300
|
-
{ name: "expression", symbols: ["expression$subexpression$1"], postprocess:
|
|
18386
|
+
{ name: "expression", symbols: ["expression$subexpression$1"], postprocess: V },
|
|
18301
18387
|
{ name: "andless_expression$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
18302
18388
|
{ name: "andless_expression$subexpression$1", symbols: ["asterisk"] },
|
|
18303
|
-
{ name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess:
|
|
18389
|
+
{ name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess: V },
|
|
18304
18390
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["atomic_expression"] },
|
|
18305
18391
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["between_predicate"] },
|
|
18306
18392
|
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["case_expression"] },
|
|
18307
|
-
{ name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess:
|
|
18393
|
+
{ name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess: V },
|
|
18308
18394
|
{ name: "atomic_expression$subexpression$1", symbols: ["array_subscript"] },
|
|
18309
18395
|
{ name: "atomic_expression$subexpression$1", symbols: ["function_call"] },
|
|
18310
18396
|
{ name: "atomic_expression$subexpression$1", symbols: ["property_access"] },
|
|
@@ -18317,13 +18403,13 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18317
18403
|
{ name: "atomic_expression$subexpression$1", symbols: ["literal"] },
|
|
18318
18404
|
{ name: "atomic_expression$subexpression$1", symbols: ["data_type"] },
|
|
18319
18405
|
{ name: "atomic_expression$subexpression$1", symbols: ["keyword"] },
|
|
18320
|
-
{ name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess:
|
|
18406
|
+
{ name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess: V },
|
|
18321
18407
|
{
|
|
18322
18408
|
name: "array_subscript",
|
|
18323
18409
|
symbols: [G.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
|
|
18324
18410
|
postprocess: ([T, E, R]) => ({
|
|
18325
18411
|
type: M.array_subscript,
|
|
18326
|
-
array:
|
|
18412
|
+
array: Y({ type: M.identifier, quoted: !1, text: T.text }, { trailing: E }),
|
|
18327
18413
|
parenthesis: R
|
|
18328
18414
|
})
|
|
18329
18415
|
},
|
|
@@ -18332,7 +18418,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18332
18418
|
symbols: [G.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
|
|
18333
18419
|
postprocess: ([T, E, R]) => ({
|
|
18334
18420
|
type: M.array_subscript,
|
|
18335
|
-
array: F(
|
|
18421
|
+
array: Y(F(T), { trailing: E }),
|
|
18336
18422
|
parenthesis: R
|
|
18337
18423
|
})
|
|
18338
18424
|
},
|
|
@@ -18341,7 +18427,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18341
18427
|
symbols: [G.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
|
|
18342
18428
|
postprocess: ([T, E, R]) => ({
|
|
18343
18429
|
type: M.function_call,
|
|
18344
|
-
nameKw: F(
|
|
18430
|
+
nameKw: Y(F(T), { trailing: E }),
|
|
18345
18431
|
parenthesis: R
|
|
18346
18432
|
})
|
|
18347
18433
|
},
|
|
@@ -18393,9 +18479,9 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18393
18479
|
// %ARRAY_IDENTIFIER on the left side of <array_subscript>.
|
|
18394
18480
|
([T, E, R, A, [S]]) => ({
|
|
18395
18481
|
type: M.property_access,
|
|
18396
|
-
object:
|
|
18482
|
+
object: Y(T, { trailing: E }),
|
|
18397
18483
|
operator: R.text,
|
|
18398
|
-
property:
|
|
18484
|
+
property: Y(S, { leading: A })
|
|
18399
18485
|
})
|
|
18400
18486
|
)
|
|
18401
18487
|
},
|
|
@@ -18404,10 +18490,10 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18404
18490
|
symbols: [G.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", G.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
|
|
18405
18491
|
postprocess: ([T, E, R, A, S, e, O]) => ({
|
|
18406
18492
|
type: M.between_predicate,
|
|
18407
|
-
betweenKw:
|
|
18408
|
-
expr1:
|
|
18409
|
-
andKw:
|
|
18410
|
-
expr2: [
|
|
18493
|
+
betweenKw: F(T),
|
|
18494
|
+
expr1: HI(R, { leading: E, trailing: A }),
|
|
18495
|
+
andKw: F(S),
|
|
18496
|
+
expr2: [Y(O, { leading: e })]
|
|
18411
18497
|
})
|
|
18412
18498
|
},
|
|
18413
18499
|
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: BE },
|
|
@@ -18419,8 +18505,8 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18419
18505
|
symbols: [G.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", G.has("END") ? { type: "END" } : END],
|
|
18420
18506
|
postprocess: ([T, E, R, A, S]) => ({
|
|
18421
18507
|
type: M.case_expression,
|
|
18422
|
-
caseKw: F(
|
|
18423
|
-
endKw:
|
|
18508
|
+
caseKw: Y(F(T), { trailing: E }),
|
|
18509
|
+
endKw: F(S),
|
|
18424
18510
|
expr: R || [],
|
|
18425
18511
|
clauses: A
|
|
18426
18512
|
})
|
|
@@ -18430,8 +18516,8 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18430
18516
|
symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", G.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
|
|
18431
18517
|
postprocess: ([T, E, R, A, S, e]) => ({
|
|
18432
18518
|
type: M.case_when,
|
|
18433
|
-
whenKw: F(
|
|
18434
|
-
thenKw: F(
|
|
18519
|
+
whenKw: Y(F(T), { trailing: E }),
|
|
18520
|
+
thenKw: Y(F(A), { trailing: S }),
|
|
18435
18521
|
condition: R,
|
|
18436
18522
|
result: e
|
|
18437
18523
|
})
|
|
@@ -18441,7 +18527,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18441
18527
|
symbols: [G.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
|
|
18442
18528
|
postprocess: ([T, E, R]) => ({
|
|
18443
18529
|
type: M.case_else,
|
|
18444
|
-
elseKw: F(
|
|
18530
|
+
elseKw: Y(F(T), { trailing: E }),
|
|
18445
18531
|
result: R
|
|
18446
18532
|
})
|
|
18447
18533
|
},
|
|
@@ -18470,21 +18556,21 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18470
18556
|
{
|
|
18471
18557
|
name: "keyword",
|
|
18472
18558
|
symbols: ["keyword$subexpression$1"],
|
|
18473
|
-
postprocess: ([[T]]) =>
|
|
18559
|
+
postprocess: ([[T]]) => F(T)
|
|
18474
18560
|
},
|
|
18475
18561
|
{ name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
|
|
18476
18562
|
{ name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE_PHRASE") ? { type: "RESERVED_DATA_TYPE_PHRASE" } : RESERVED_DATA_TYPE_PHRASE] },
|
|
18477
18563
|
{
|
|
18478
18564
|
name: "data_type",
|
|
18479
18565
|
symbols: ["data_type$subexpression$1"],
|
|
18480
|
-
postprocess: ([[T]]) =>
|
|
18566
|
+
postprocess: ([[T]]) => aT(T)
|
|
18481
18567
|
},
|
|
18482
18568
|
{
|
|
18483
18569
|
name: "data_type",
|
|
18484
18570
|
symbols: [G.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
18485
18571
|
postprocess: ([T, E, R]) => ({
|
|
18486
18572
|
type: M.parameterized_data_type,
|
|
18487
|
-
dataType:
|
|
18573
|
+
dataType: Y(aT(T), { trailing: E }),
|
|
18488
18574
|
parenthesis: R
|
|
18489
18575
|
})
|
|
18490
18576
|
},
|
|
@@ -18494,7 +18580,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18494
18580
|
{
|
|
18495
18581
|
name: "logic_operator",
|
|
18496
18582
|
symbols: ["logic_operator$subexpression$1"],
|
|
18497
|
-
postprocess: ([[T]]) =>
|
|
18583
|
+
postprocess: ([[T]]) => F(T)
|
|
18498
18584
|
},
|
|
18499
18585
|
{ name: "other_keyword$subexpression$1", symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN] },
|
|
18500
18586
|
{ name: "other_keyword$subexpression$1", symbols: [G.has("THEN") ? { type: "THEN" } : THEN] },
|
|
@@ -18503,7 +18589,7 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18503
18589
|
{
|
|
18504
18590
|
name: "other_keyword",
|
|
18505
18591
|
symbols: ["other_keyword$subexpression$1"],
|
|
18506
|
-
postprocess: ([[T]]) =>
|
|
18592
|
+
postprocess: ([[T]]) => F(T)
|
|
18507
18593
|
},
|
|
18508
18594
|
{ name: "_$ebnf$1", symbols: [] },
|
|
18509
18595
|
{ name: "_$ebnf$1", symbols: ["_$ebnf$1", "comment"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
@@ -18537,13 +18623,13 @@ const G = new hT((T) => []), h = ([[T]]) => T, B = (T) => ({
|
|
|
18537
18623
|
}
|
|
18538
18624
|
],
|
|
18539
18625
|
ParserStart: "main"
|
|
18540
|
-
}, { Parser:
|
|
18541
|
-
function
|
|
18626
|
+
}, { Parser: BI, Grammar: FI } = iI;
|
|
18627
|
+
function YI(T) {
|
|
18542
18628
|
let E = {};
|
|
18543
|
-
const R = new
|
|
18544
|
-
...
|
|
18545
|
-
|
|
18546
|
-
]), 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 });
|
|
18547
18633
|
return {
|
|
18548
18634
|
parse: (S, e) => {
|
|
18549
18635
|
E = e;
|
|
@@ -18595,16 +18681,16 @@ class WT {
|
|
|
18595
18681
|
}
|
|
18596
18682
|
}
|
|
18597
18683
|
trimHorizontalWhitespace() {
|
|
18598
|
-
for (;
|
|
18684
|
+
for (; mI(Q(this.items)); )
|
|
18599
18685
|
this.items.pop();
|
|
18600
18686
|
}
|
|
18601
18687
|
trimWhitespace() {
|
|
18602
|
-
for (;
|
|
18688
|
+
for (; pI(Q(this.items)); )
|
|
18603
18689
|
this.items.pop();
|
|
18604
18690
|
}
|
|
18605
18691
|
addNewline(E) {
|
|
18606
18692
|
if (this.items.length > 0)
|
|
18607
|
-
switch (
|
|
18693
|
+
switch (Q(this.items)) {
|
|
18608
18694
|
case n.NEWLINE:
|
|
18609
18695
|
this.items.pop(), this.items.push(E);
|
|
18610
18696
|
break;
|
|
@@ -18646,7 +18732,7 @@ class WT {
|
|
|
18646
18732
|
}
|
|
18647
18733
|
}
|
|
18648
18734
|
}
|
|
18649
|
-
const
|
|
18735
|
+
const mI = (T) => T === n.SPACE || T === n.SINGLE_INDENT, pI = (T) => T === n.SPACE || T === n.SINGLE_INDENT || T === n.NEWLINE;
|
|
18650
18736
|
function MT(T, E) {
|
|
18651
18737
|
if (E === "standard")
|
|
18652
18738
|
return T;
|
|
@@ -18654,10 +18740,10 @@ function MT(T, E) {
|
|
|
18654
18740
|
return T.length >= 10 && T.includes(" ") && ([T, ...R] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...R].join(" ");
|
|
18655
18741
|
}
|
|
18656
18742
|
function UT(T) {
|
|
18657
|
-
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;
|
|
18658
18744
|
}
|
|
18659
|
-
const FE = "top-level",
|
|
18660
|
-
class
|
|
18745
|
+
const FE = "top-level", dI = "block-level";
|
|
18746
|
+
class XT {
|
|
18661
18747
|
/**
|
|
18662
18748
|
* @param {string} indent A string to indent with
|
|
18663
18749
|
*/
|
|
@@ -18686,14 +18772,14 @@ class fT {
|
|
|
18686
18772
|
* Increases indentation by one block-level indent.
|
|
18687
18773
|
*/
|
|
18688
18774
|
increaseBlockLevel() {
|
|
18689
|
-
this.indentTypes.push(
|
|
18775
|
+
this.indentTypes.push(dI);
|
|
18690
18776
|
}
|
|
18691
18777
|
/**
|
|
18692
18778
|
* Decreases indentation by one top-level indent.
|
|
18693
18779
|
* Does nothing when the previous indent is not top-level.
|
|
18694
18780
|
*/
|
|
18695
18781
|
decreaseTopLevel() {
|
|
18696
|
-
this.indentTypes.length > 0 &&
|
|
18782
|
+
this.indentTypes.length > 0 && Q(this.indentTypes) === FE && this.indentTypes.pop();
|
|
18697
18783
|
}
|
|
18698
18784
|
/**
|
|
18699
18785
|
* Decreases indentation by one block-level indent.
|
|
@@ -18705,9 +18791,9 @@ class fT {
|
|
|
18705
18791
|
;
|
|
18706
18792
|
}
|
|
18707
18793
|
}
|
|
18708
|
-
class
|
|
18794
|
+
class hI extends WT {
|
|
18709
18795
|
constructor(E) {
|
|
18710
|
-
super(new
|
|
18796
|
+
super(new XT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
18711
18797
|
}
|
|
18712
18798
|
add(...E) {
|
|
18713
18799
|
if (E.forEach((R) => this.addToLength(R)), this.length > this.expressionWidth)
|
|
@@ -18900,7 +18986,7 @@ class z {
|
|
|
18900
18986
|
// first line starts with /* or /**
|
|
18901
18987
|
/^\/\*\*?$/.test(R[0]) && // intermediate lines start with *
|
|
18902
18988
|
R.slice(1, R.length - 1).every((A) => /^\s*\*/.test(A)) && // last line ends with */
|
|
18903
|
-
/^\s*\*\/$/.test(
|
|
18989
|
+
/^\s*\*\/$/.test(Q(R))
|
|
18904
18990
|
);
|
|
18905
18991
|
}
|
|
18906
18992
|
// Breaks up block comment to multiple lines.
|
|
@@ -18949,7 +19035,7 @@ class z {
|
|
|
18949
19035
|
cfg: this.cfg,
|
|
18950
19036
|
dialectCfg: this.dialectCfg,
|
|
18951
19037
|
params: this.params,
|
|
18952
|
-
layout: new
|
|
19038
|
+
layout: new hI(this.cfg.expressionWidth),
|
|
18953
19039
|
inline: !0
|
|
18954
19040
|
}).format(E);
|
|
18955
19041
|
} catch (A) {
|
|
@@ -18991,7 +19077,7 @@ class z {
|
|
|
18991
19077
|
showNonTabularKw(E) {
|
|
18992
19078
|
switch (this.cfg.keywordCase) {
|
|
18993
19079
|
case "preserve":
|
|
18994
|
-
return
|
|
19080
|
+
return q(E.raw);
|
|
18995
19081
|
case "upper":
|
|
18996
19082
|
return E.text;
|
|
18997
19083
|
case "lower":
|
|
@@ -19005,7 +19091,7 @@ class z {
|
|
|
19005
19091
|
showNonTabularFunctionKw(E) {
|
|
19006
19092
|
switch (this.cfg.functionCase) {
|
|
19007
19093
|
case "preserve":
|
|
19008
|
-
return
|
|
19094
|
+
return q(E.raw);
|
|
19009
19095
|
case "upper":
|
|
19010
19096
|
return E.text;
|
|
19011
19097
|
case "lower":
|
|
@@ -19027,7 +19113,7 @@ class z {
|
|
|
19027
19113
|
showDataType(E) {
|
|
19028
19114
|
switch (this.cfg.dataTypeCase) {
|
|
19029
19115
|
case "preserve":
|
|
19030
|
-
return
|
|
19116
|
+
return q(E.raw);
|
|
19031
19117
|
case "upper":
|
|
19032
19118
|
return E.text;
|
|
19033
19119
|
case "lower":
|
|
@@ -19037,7 +19123,7 @@ class z {
|
|
|
19037
19123
|
}
|
|
19038
19124
|
class VI {
|
|
19039
19125
|
constructor(E, R) {
|
|
19040
|
-
this.dialect = E, this.cfg = R, this.params = new
|
|
19126
|
+
this.dialect = E, this.cfg = R, this.params = new LI(this.cfg.params);
|
|
19041
19127
|
}
|
|
19042
19128
|
/**
|
|
19043
19129
|
* Formats an SQL query.
|
|
@@ -19049,7 +19135,7 @@ class VI {
|
|
|
19049
19135
|
return this.formatAst(R).trimEnd();
|
|
19050
19136
|
}
|
|
19051
19137
|
parse(E) {
|
|
19052
|
-
return
|
|
19138
|
+
return YI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
|
|
19053
19139
|
}
|
|
19054
19140
|
formatAst(E) {
|
|
19055
19141
|
return E.map((R) => this.formatStatement(R)).join(`
|
|
@@ -19060,14 +19146,14 @@ class VI {
|
|
|
19060
19146
|
cfg: this.cfg,
|
|
19061
19147
|
dialectCfg: this.dialect.formatOptions,
|
|
19062
19148
|
params: this.params,
|
|
19063
|
-
layout: new WT(new
|
|
19149
|
+
layout: new WT(new XT(CI(this.cfg)))
|
|
19064
19150
|
}).format(E.children);
|
|
19065
19151
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(n.NEWLINE, ";") : R.add(n.NO_NEWLINE, ";")), R.toString();
|
|
19066
19152
|
}
|
|
19067
19153
|
}
|
|
19068
19154
|
class k extends Error {
|
|
19069
19155
|
}
|
|
19070
|
-
function
|
|
19156
|
+
function fI(T) {
|
|
19071
19157
|
const E = [
|
|
19072
19158
|
"multilineLists",
|
|
19073
19159
|
"newlineBeforeOpenParen",
|
|
@@ -19081,17 +19167,17 @@ function hI(T) {
|
|
|
19081
19167
|
throw new k(`${R} config is no more supported.`);
|
|
19082
19168
|
if (T.expressionWidth <= 0)
|
|
19083
19169
|
throw new k(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
19084
|
-
if (T.params && !WI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !
|
|
19170
|
+
if (T.params && !WI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !XI(T.paramTypes))
|
|
19085
19171
|
throw new k("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
19086
19172
|
return T;
|
|
19087
19173
|
}
|
|
19088
19174
|
function WI(T) {
|
|
19089
19175
|
return (T instanceof Array ? T : Object.values(T)).every((R) => typeof R == "string");
|
|
19090
19176
|
}
|
|
19091
|
-
function
|
|
19177
|
+
function XI(T) {
|
|
19092
19178
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
19093
19179
|
}
|
|
19094
|
-
var
|
|
19180
|
+
var bI = function(T, E) {
|
|
19095
19181
|
var R = {};
|
|
19096
19182
|
for (var A in T) Object.prototype.hasOwnProperty.call(T, A) && E.indexOf(A) < 0 && (R[A] = T[A]);
|
|
19097
19183
|
if (T != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -19099,7 +19185,7 @@ var XI = function(T, E) {
|
|
|
19099
19185
|
E.indexOf(A[S]) < 0 && Object.prototype.propertyIsEnumerable.call(T, A[S]) && (R[A[S]] = T[A[S]]);
|
|
19100
19186
|
return R;
|
|
19101
19187
|
};
|
|
19102
|
-
const
|
|
19188
|
+
const bT = {
|
|
19103
19189
|
bigquery: "bigquery",
|
|
19104
19190
|
db2: "db2",
|
|
19105
19191
|
db2i: "db2i",
|
|
@@ -19120,7 +19206,7 @@ const XT = {
|
|
|
19120
19206
|
tsql: "transactsql",
|
|
19121
19207
|
singlestoredb: "singlestoredb",
|
|
19122
19208
|
snowflake: "snowflake"
|
|
19123
|
-
},
|
|
19209
|
+
}, yI = Object.keys(bT), KI = {
|
|
19124
19210
|
tabWidth: 2,
|
|
19125
19211
|
useTabs: !1,
|
|
19126
19212
|
keywordCase: "preserve",
|
|
@@ -19133,21 +19219,21 @@ const XT = {
|
|
|
19133
19219
|
linesBetweenQueries: 1,
|
|
19134
19220
|
denseOperators: !1,
|
|
19135
19221
|
newlineBeforeSemicolon: !1
|
|
19136
|
-
},
|
|
19137
|
-
if (typeof E.language == "string" && !
|
|
19222
|
+
}, $I = (T, E = {}) => {
|
|
19223
|
+
if (typeof E.language == "string" && !yI.includes(E.language))
|
|
19138
19224
|
throw new k(`Unsupported SQL dialect: ${E.language}`);
|
|
19139
|
-
const R =
|
|
19140
|
-
return
|
|
19141
|
-
},
|
|
19142
|
-
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"]);
|
|
19143
19229
|
if (typeof T != "string")
|
|
19144
19230
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
|
|
19145
|
-
const S =
|
|
19146
|
-
return new VI(
|
|
19231
|
+
const S = fI(Object.assign(Object.assign({}, KI), A));
|
|
19232
|
+
return new VI(NI(R), S).format(T);
|
|
19147
19233
|
};
|
|
19148
19234
|
function GT(T, E) {
|
|
19149
19235
|
try {
|
|
19150
|
-
return
|
|
19236
|
+
return $I(T, {
|
|
19151
19237
|
language: {
|
|
19152
19238
|
postgres: "postgresql",
|
|
19153
19239
|
mysql: "mysql",
|
|
@@ -19163,7 +19249,7 @@ function GT(T, E) {
|
|
|
19163
19249
|
return console.warn("SQL formatting failed:", R), T;
|
|
19164
19250
|
}
|
|
19165
19251
|
}
|
|
19166
|
-
class
|
|
19252
|
+
class fE {
|
|
19167
19253
|
cubes = /* @__PURE__ */ new Map();
|
|
19168
19254
|
dbExecutor;
|
|
19169
19255
|
metadataCache;
|
|
@@ -19280,9 +19366,9 @@ class WE {
|
|
|
19280
19366
|
*/
|
|
19281
19367
|
generateCubeMetadata(E) {
|
|
19282
19368
|
const R = Object.keys(E.measures), A = Object.keys(E.dimensions), S = new Array(R.length), e = new Array(A.length);
|
|
19283
|
-
for (let
|
|
19284
|
-
const D = R[
|
|
19285
|
-
S[
|
|
19369
|
+
for (let t = 0; t < R.length; t++) {
|
|
19370
|
+
const D = R[t], I = E.measures[D];
|
|
19371
|
+
S[t] = {
|
|
19286
19372
|
name: `${E.name}.${D}`,
|
|
19287
19373
|
title: I.title || D,
|
|
19288
19374
|
shortTitle: I.title || D,
|
|
@@ -19292,9 +19378,9 @@ class WE {
|
|
|
19292
19378
|
description: I.description
|
|
19293
19379
|
};
|
|
19294
19380
|
}
|
|
19295
|
-
for (let
|
|
19296
|
-
const D = A[
|
|
19297
|
-
e[
|
|
19381
|
+
for (let t = 0; t < A.length; t++) {
|
|
19382
|
+
const D = A[t], I = E.dimensions[D];
|
|
19383
|
+
e[t] = {
|
|
19298
19384
|
name: `${E.name}.${D}`,
|
|
19299
19385
|
title: I.title || D,
|
|
19300
19386
|
shortTitle: I.title || D,
|
|
@@ -19306,12 +19392,12 @@ class WE {
|
|
|
19306
19392
|
}
|
|
19307
19393
|
const O = [];
|
|
19308
19394
|
if (E.joins)
|
|
19309
|
-
for (const [,
|
|
19310
|
-
const D = typeof
|
|
19395
|
+
for (const [, t] of Object.entries(E.joins)) {
|
|
19396
|
+
const D = typeof t.targetCube == "function" ? t.targetCube() : t.targetCube;
|
|
19311
19397
|
O.push({
|
|
19312
19398
|
targetCube: D.name,
|
|
19313
|
-
relationship:
|
|
19314
|
-
joinFields:
|
|
19399
|
+
relationship: t.relationship,
|
|
19400
|
+
joinFields: t.on.map((I) => ({
|
|
19315
19401
|
sourceField: this.getColumnName(I.source),
|
|
19316
19402
|
targetField: this.getColumnName(I.target)
|
|
19317
19403
|
}))
|
|
@@ -19337,9 +19423,9 @@ class WE {
|
|
|
19337
19423
|
throw new Error(`Cube '${E}' not found`);
|
|
19338
19424
|
if (!this.dbExecutor)
|
|
19339
19425
|
throw new Error("Database executor not configured");
|
|
19340
|
-
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();
|
|
19341
19427
|
return {
|
|
19342
|
-
sql: GT(O.sql,
|
|
19428
|
+
sql: GT(O.sql, t),
|
|
19343
19429
|
params: O.params
|
|
19344
19430
|
};
|
|
19345
19431
|
}
|
|
@@ -19392,10 +19478,10 @@ class WE {
|
|
|
19392
19478
|
* Ensures all referenced cubes and fields exist
|
|
19393
19479
|
*/
|
|
19394
19480
|
validateQuery(E) {
|
|
19395
|
-
return
|
|
19481
|
+
return yT(this.cubes, E);
|
|
19396
19482
|
}
|
|
19397
19483
|
}
|
|
19398
|
-
function
|
|
19484
|
+
function yT(T, E) {
|
|
19399
19485
|
const R = [], A = /* @__PURE__ */ new Set();
|
|
19400
19486
|
if (E.measures)
|
|
19401
19487
|
for (const S of E.measures) {
|
|
@@ -19405,12 +19491,12 @@ function bT(T, E) {
|
|
|
19405
19491
|
continue;
|
|
19406
19492
|
}
|
|
19407
19493
|
A.add(e);
|
|
19408
|
-
const
|
|
19409
|
-
if (!
|
|
19494
|
+
const t = T.get(e);
|
|
19495
|
+
if (!t) {
|
|
19410
19496
|
R.push(`Cube '${e}' not found (referenced in measure '${S}')`);
|
|
19411
19497
|
continue;
|
|
19412
19498
|
}
|
|
19413
|
-
|
|
19499
|
+
t.measures[O] || R.push(`Measure '${O}' not found on cube '${e}'`);
|
|
19414
19500
|
}
|
|
19415
19501
|
if (E.dimensions)
|
|
19416
19502
|
for (const S of E.dimensions) {
|
|
@@ -19420,12 +19506,12 @@ function bT(T, E) {
|
|
|
19420
19506
|
continue;
|
|
19421
19507
|
}
|
|
19422
19508
|
A.add(e);
|
|
19423
|
-
const
|
|
19424
|
-
if (!
|
|
19509
|
+
const t = T.get(e);
|
|
19510
|
+
if (!t) {
|
|
19425
19511
|
R.push(`Cube '${e}' not found (referenced in dimension '${S}')`);
|
|
19426
19512
|
continue;
|
|
19427
19513
|
}
|
|
19428
|
-
|
|
19514
|
+
t.dimensions[O] || R.push(`Dimension '${O}' not found on cube '${e}'`);
|
|
19429
19515
|
}
|
|
19430
19516
|
if (E.timeDimensions)
|
|
19431
19517
|
for (const S of E.timeDimensions) {
|
|
@@ -19435,12 +19521,12 @@ function bT(T, E) {
|
|
|
19435
19521
|
continue;
|
|
19436
19522
|
}
|
|
19437
19523
|
A.add(e);
|
|
19438
|
-
const
|
|
19439
|
-
if (!
|
|
19524
|
+
const t = T.get(e);
|
|
19525
|
+
if (!t) {
|
|
19440
19526
|
R.push(`Cube '${e}' not found (referenced in timeDimension '${S.dimension}')`);
|
|
19441
19527
|
continue;
|
|
19442
19528
|
}
|
|
19443
|
-
|
|
19529
|
+
t.dimensions[O] || R.push(`TimeDimension '${O}' not found on cube '${e}' (must be a dimension with time type)`);
|
|
19444
19530
|
}
|
|
19445
19531
|
if (E.filters)
|
|
19446
19532
|
for (const S of E.filters)
|
|
@@ -19452,8 +19538,8 @@ function bT(T, E) {
|
|
|
19452
19538
|
}
|
|
19453
19539
|
function KT(T, E, R, A) {
|
|
19454
19540
|
if ("and" in T || "or" in T) {
|
|
19455
|
-
const
|
|
19456
|
-
for (const D of
|
|
19541
|
+
const t = T.and || T.or || [];
|
|
19542
|
+
for (const D of t)
|
|
19457
19543
|
KT(D, E, R, A);
|
|
19458
19544
|
return;
|
|
19459
19545
|
}
|
|
@@ -19474,17 +19560,17 @@ function KT(T, E, R, A) {
|
|
|
19474
19560
|
}
|
|
19475
19561
|
!O.dimensions[e] && !O.measures[e] && R.push(`Filter field '${e}' not found on cube '${S}' (must be a dimension or measure)`);
|
|
19476
19562
|
}
|
|
19477
|
-
function
|
|
19478
|
-
return new
|
|
19563
|
+
function QI(T) {
|
|
19564
|
+
return new fE(T);
|
|
19479
19565
|
}
|
|
19480
|
-
const
|
|
19481
|
-
function
|
|
19482
|
-
return new
|
|
19566
|
+
const JI = new fE(), ZI = JI;
|
|
19567
|
+
function qI(T) {
|
|
19568
|
+
return new fE({
|
|
19483
19569
|
drizzle: T.drizzle,
|
|
19484
19570
|
schema: T.schema
|
|
19485
19571
|
});
|
|
19486
19572
|
}
|
|
19487
|
-
const
|
|
19573
|
+
const jI = {
|
|
19488
19574
|
/**
|
|
19489
19575
|
* Create a simple query builder
|
|
19490
19576
|
*/
|
|
@@ -19591,26 +19677,26 @@ const qI = {
|
|
|
19591
19677
|
}
|
|
19592
19678
|
};
|
|
19593
19679
|
export {
|
|
19594
|
-
|
|
19680
|
+
hE as BaseDatabaseExecutor,
|
|
19595
19681
|
lT as MySQLExecutor,
|
|
19596
|
-
|
|
19597
|
-
|
|
19682
|
+
qT as PostgresExecutor,
|
|
19683
|
+
RR as QueryBuilder,
|
|
19598
19684
|
OE as QueryExecutor,
|
|
19599
|
-
|
|
19685
|
+
AR as QueryPlanner,
|
|
19600
19686
|
kT as SQLiteExecutor,
|
|
19601
|
-
|
|
19602
|
-
|
|
19687
|
+
fE as SemanticLayerCompiler,
|
|
19688
|
+
jI as SemanticLayerUtils,
|
|
19603
19689
|
JE as createDatabaseExecutor,
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19690
|
+
qI as createDrizzleSemanticLayer,
|
|
19691
|
+
xI as createMultiCubeContext,
|
|
19692
|
+
jT as createMySQLExecutor,
|
|
19607
19693
|
$E as createPostgresExecutor,
|
|
19608
19694
|
gE as createSQLiteExecutor,
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19695
|
+
QI as createSemanticLayer,
|
|
19696
|
+
ZI as defaultSemanticLayer,
|
|
19697
|
+
vI as defineCube,
|
|
19698
|
+
HT as getJoinType,
|
|
19613
19699
|
wE as resolveCubeReference,
|
|
19614
|
-
|
|
19615
|
-
|
|
19700
|
+
f as resolveSqlExpression,
|
|
19701
|
+
JI as semanticLayer
|
|
19616
19702
|
};
|