drizzle-cube 0.1.26 → 0.1.29
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-CSr2Ti96.js → compiler-BibS3bXd.js} +980 -920
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/utils.d.ts +1 -1
- package/dist/client/charts.js +1 -1
- package/dist/client/chunks/{charts-JUvTF2xT.js → charts-BM1k01Jw.js} +1067 -911
- package/dist/client/chunks/charts-BM1k01Jw.js.map +1 -0
- package/dist/client/chunks/{icons-ChgBIaCg.js → icons-B_0yoGjv.js} +398 -352
- package/dist/client/chunks/icons-B_0yoGjv.js.map +1 -0
- package/dist/client/chunks/providers-B7MVnAAt.js.map +1 -1
- package/dist/client/components/CubeRelationshipDiagram/CubeNode.d.ts +13 -0
- package/dist/client/components/CubeRelationshipDiagram/ERDControls.d.ts +7 -0
- package/dist/client/components/CubeRelationshipDiagram/RelationshipEdge.d.ts +11 -0
- package/dist/client/components/CubeRelationshipDiagram/index.d.ts +10 -0
- package/dist/client/components/CubeRelationshipDiagram/useERDLayout.d.ts +21 -0
- package/dist/client/components/DataHistogram.d.ts +3 -1
- package/dist/client/components/QueryBuilder/types.d.ts +4 -0
- package/dist/client/components.js +14910 -4905
- package/dist/client/components.js.map +1 -1
- package/dist/client/hooks/useCubeMeta.d.ts +9 -0
- package/dist/client/index.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +3 -1
- package/dist/client/utils/targetUtils.d.ts +36 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.d.ts +27 -9
- package/dist/server/index.js +1002 -942
- package/package.json +5 -2
- package/dist/client/chunks/charts-JUvTF2xT.js.map +0 -1
- package/dist/client/chunks/icons-ChgBIaCg.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var W = (T, E, R) =>
|
|
4
|
-
import { sql as _, count as IE, sum as y, max as dE, min as VE, and as d, countDistinct as
|
|
1
|
+
var wT = Object.defineProperty;
|
|
2
|
+
var xT = (T, E, R) => E in T ? wT(T, E, { enumerable: !0, configurable: !0, writable: !0, value: R }) : T[E] = R;
|
|
3
|
+
var W = (T, E, R) => xT(T, typeof E != "symbol" ? E + "" : E, R);
|
|
4
|
+
import { sql as _, count as IE, sum as y, max as dE, min as VE, and as d, countDistinct as vT, SQL as QT, or as OE, isNotNull as KE, ne as yE, isNull as $E, eq as EE, notInArray as gE, inArray as eE, lt as NE, gt as tE, gte as J, lte as w, desc as ZT, asc as JE } from "drizzle-orm";
|
|
5
5
|
class WE {
|
|
6
6
|
/**
|
|
7
7
|
* Helper method to build pattern for string matching
|
|
@@ -21,7 +21,7 @@ class WE {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
class
|
|
24
|
+
class kT extends WE {
|
|
25
25
|
getEngineType() {
|
|
26
26
|
return "postgres";
|
|
27
27
|
}
|
|
@@ -145,7 +145,7 @@ class QT extends WE {
|
|
|
145
145
|
return E;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
class
|
|
148
|
+
class HT extends WE {
|
|
149
149
|
getEngineType() {
|
|
150
150
|
return "mysql";
|
|
151
151
|
}
|
|
@@ -270,7 +270,7 @@ class ZT extends WE {
|
|
|
270
270
|
return E;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
class
|
|
273
|
+
class qT extends WE {
|
|
274
274
|
getEngineType() {
|
|
275
275
|
return "sqlite";
|
|
276
276
|
}
|
|
@@ -301,8 +301,8 @@ class kT extends WE {
|
|
|
301
301
|
const I = _`datetime(${R}, 'unixepoch')`;
|
|
302
302
|
return _`datetime(strftime('%Y-%m-%d %H:%M:00', ${I}))`;
|
|
303
303
|
case "second":
|
|
304
|
-
const
|
|
305
|
-
return _`datetime(strftime('%Y-%m-%d %H:%M:%S', ${
|
|
304
|
+
const e = _`datetime(${R}, 'unixepoch')`;
|
|
305
|
+
return _`datetime(strftime('%Y-%m-%d %H:%M:%S', ${e}))`;
|
|
306
306
|
default:
|
|
307
307
|
return _`datetime(${R}, 'unixepoch')`;
|
|
308
308
|
}
|
|
@@ -406,14 +406,29 @@ class kT extends WE {
|
|
|
406
406
|
return E;
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
|
|
409
|
+
class jT extends HT {
|
|
410
|
+
getEngineType() {
|
|
411
|
+
return "singlestore";
|
|
412
|
+
}
|
|
413
|
+
// SingleStore inherits most MySQL functionality
|
|
414
|
+
// Override methods here only if SingleStore-specific behavior is needed
|
|
415
|
+
// Note: SingleStore has some known limitations:
|
|
416
|
+
// - ORDER BY and LIMIT cannot be chained together in some contexts
|
|
417
|
+
// - Nested selects with aggregation functions are not supported
|
|
418
|
+
// - Serial column type only assures uniqueness (tests may need ORDER BY)
|
|
419
|
+
// These limitations are typically handled at the query building level
|
|
420
|
+
// rather than in the adapter, but can be addressed here if needed
|
|
421
|
+
}
|
|
422
|
+
function zT(T) {
|
|
410
423
|
switch (T) {
|
|
411
424
|
case "postgres":
|
|
412
|
-
return new
|
|
425
|
+
return new kT();
|
|
413
426
|
case "mysql":
|
|
414
|
-
return new
|
|
427
|
+
return new HT();
|
|
415
428
|
case "sqlite":
|
|
416
|
-
return new
|
|
429
|
+
return new qT();
|
|
430
|
+
case "singlestore":
|
|
431
|
+
return new jT();
|
|
417
432
|
default:
|
|
418
433
|
throw new Error(`Unsupported database engine: ${T}`);
|
|
419
434
|
}
|
|
@@ -423,10 +438,10 @@ class fE {
|
|
|
423
438
|
W(this, "databaseAdapter");
|
|
424
439
|
this.db = E, this.schema = R;
|
|
425
440
|
const S = A || this.getEngineType();
|
|
426
|
-
this.databaseAdapter =
|
|
441
|
+
this.databaseAdapter = zT(S);
|
|
427
442
|
}
|
|
428
443
|
}
|
|
429
|
-
class
|
|
444
|
+
class ER extends fE {
|
|
430
445
|
async execute(E, R) {
|
|
431
446
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
432
447
|
const S = await E.execute();
|
|
@@ -479,9 +494,9 @@ class jT extends fE {
|
|
|
479
494
|
}
|
|
480
495
|
}
|
|
481
496
|
function wE(T, E) {
|
|
482
|
-
return new
|
|
497
|
+
return new ER(T, E, "postgres");
|
|
483
498
|
}
|
|
484
|
-
class
|
|
499
|
+
class BT extends fE {
|
|
485
500
|
async execute(E, R) {
|
|
486
501
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
487
502
|
const S = await E.execute();
|
|
@@ -519,10 +534,10 @@ class zT extends fE {
|
|
|
519
534
|
return "mysql";
|
|
520
535
|
}
|
|
521
536
|
}
|
|
522
|
-
function
|
|
523
|
-
return new
|
|
537
|
+
function TR(T, E) {
|
|
538
|
+
return new BT(T, E, "mysql");
|
|
524
539
|
}
|
|
525
|
-
class
|
|
540
|
+
class RR extends fE {
|
|
526
541
|
async execute(E, R) {
|
|
527
542
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
528
543
|
const A = await E.execute();
|
|
@@ -569,7 +584,18 @@ class TR extends fE {
|
|
|
569
584
|
}
|
|
570
585
|
}
|
|
571
586
|
function xE(T, E) {
|
|
572
|
-
return new
|
|
587
|
+
return new RR(T, E, "sqlite");
|
|
588
|
+
}
|
|
589
|
+
class AR extends BT {
|
|
590
|
+
getEngineType() {
|
|
591
|
+
return "singlestore";
|
|
592
|
+
}
|
|
593
|
+
// SingleStore-specific optimizations can be added here if needed
|
|
594
|
+
// For now, we inherit all behavior from MySQLExecutor since
|
|
595
|
+
// SingleStore is largely MySQL-compatible
|
|
596
|
+
}
|
|
597
|
+
function SR(T, E) {
|
|
598
|
+
return new AR(T, E);
|
|
573
599
|
}
|
|
574
600
|
function vE(T, E, R) {
|
|
575
601
|
if (R)
|
|
@@ -577,9 +603,11 @@ function vE(T, E, R) {
|
|
|
577
603
|
case "postgres":
|
|
578
604
|
return wE(T, E);
|
|
579
605
|
case "mysql":
|
|
580
|
-
return
|
|
606
|
+
return TR(T, E);
|
|
581
607
|
case "sqlite":
|
|
582
608
|
return xE(T, E);
|
|
609
|
+
case "singlestore":
|
|
610
|
+
return SR(T, E);
|
|
583
611
|
}
|
|
584
612
|
if (T.all && T.run)
|
|
585
613
|
return xE(T, E);
|
|
@@ -590,7 +618,7 @@ function vE(T, E, R) {
|
|
|
590
618
|
function QE(T) {
|
|
591
619
|
return typeof T == "function" ? T() : T;
|
|
592
620
|
}
|
|
593
|
-
function
|
|
621
|
+
function IR(T, E) {
|
|
594
622
|
if (E) return E;
|
|
595
623
|
switch (T) {
|
|
596
624
|
case "belongsTo":
|
|
@@ -606,20 +634,20 @@ function RR(T, E) {
|
|
|
606
634
|
function K(T, E) {
|
|
607
635
|
return typeof T == "function" ? T(E) : T;
|
|
608
636
|
}
|
|
609
|
-
function
|
|
637
|
+
function mO(T, E, R) {
|
|
610
638
|
return {
|
|
611
639
|
...T,
|
|
612
640
|
cubes: E,
|
|
613
641
|
currentCube: R
|
|
614
642
|
};
|
|
615
643
|
}
|
|
616
|
-
function
|
|
644
|
+
function pO(T, E) {
|
|
617
645
|
return {
|
|
618
646
|
name: T,
|
|
619
647
|
...E
|
|
620
648
|
};
|
|
621
649
|
}
|
|
622
|
-
class
|
|
650
|
+
class eR {
|
|
623
651
|
constructor(E) {
|
|
624
652
|
this.databaseAdapter = E;
|
|
625
653
|
}
|
|
@@ -630,31 +658,31 @@ class AR {
|
|
|
630
658
|
buildSelections(E, R, A) {
|
|
631
659
|
const S = {}, I = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
632
660
|
if (R.dimensions)
|
|
633
|
-
for (const
|
|
634
|
-
const [
|
|
661
|
+
for (const e of R.dimensions) {
|
|
662
|
+
const [N, n] = e.split("."), O = I.get(N);
|
|
635
663
|
if (O && O.dimensions && O.dimensions[n]) {
|
|
636
|
-
const
|
|
637
|
-
S[
|
|
664
|
+
const s = O.dimensions[n], t = K(s.sql, A);
|
|
665
|
+
S[e] = _`${t}`.as(e);
|
|
638
666
|
}
|
|
639
667
|
}
|
|
640
668
|
if (R.measures)
|
|
641
|
-
for (const
|
|
642
|
-
const [
|
|
669
|
+
for (const e of R.measures) {
|
|
670
|
+
const [N, n] = e.split("."), O = I.get(N);
|
|
643
671
|
if (O && O.measures && O.measures[n]) {
|
|
644
|
-
const
|
|
645
|
-
S[
|
|
672
|
+
const s = O.measures[n], t = this.buildMeasureExpression(s, A);
|
|
673
|
+
S[e] = _`${t}`.as(e);
|
|
646
674
|
}
|
|
647
675
|
}
|
|
648
676
|
if (R.timeDimensions)
|
|
649
|
-
for (const
|
|
650
|
-
const [
|
|
677
|
+
for (const e of R.timeDimensions) {
|
|
678
|
+
const [N, n] = e.dimension.split("."), O = I.get(N);
|
|
651
679
|
if (O && O.dimensions && O.dimensions[n]) {
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
680
|
+
const s = O.dimensions[n], t = this.buildTimeDimensionExpression(
|
|
681
|
+
s.sql,
|
|
682
|
+
e.granularity,
|
|
655
683
|
A
|
|
656
684
|
);
|
|
657
|
-
S[
|
|
685
|
+
S[e.dimension] = _`${t}`.as(e.dimension);
|
|
658
686
|
}
|
|
659
687
|
}
|
|
660
688
|
return Object.keys(S).length === 0 && (S.count = IE()), S;
|
|
@@ -664,24 +692,24 @@ class AR {
|
|
|
664
692
|
*/
|
|
665
693
|
buildHavingMeasureExpression(E, R, A, S, I) {
|
|
666
694
|
if (I && I.preAggregationCTEs) {
|
|
667
|
-
const
|
|
668
|
-
if (
|
|
669
|
-
const
|
|
695
|
+
const e = I.preAggregationCTEs.find((N) => N.cube.name === E);
|
|
696
|
+
if (e && e.measures.includes(`${E}.${R}`)) {
|
|
697
|
+
const N = _`${_.identifier(e.cteAlias)}.${_.identifier(R)}`;
|
|
670
698
|
switch (A.type) {
|
|
671
699
|
case "count":
|
|
672
700
|
case "countDistinct":
|
|
673
701
|
case "sum":
|
|
674
|
-
return y(
|
|
702
|
+
return y(N);
|
|
675
703
|
case "avg":
|
|
676
|
-
return this.databaseAdapter.buildAvg(
|
|
704
|
+
return this.databaseAdapter.buildAvg(N);
|
|
677
705
|
case "min":
|
|
678
|
-
return VE(
|
|
706
|
+
return VE(N);
|
|
679
707
|
case "max":
|
|
680
|
-
return dE(
|
|
708
|
+
return dE(N);
|
|
681
709
|
case "number":
|
|
682
|
-
return y(
|
|
710
|
+
return y(N);
|
|
683
711
|
default:
|
|
684
|
-
return y(
|
|
712
|
+
return y(N);
|
|
685
713
|
}
|
|
686
714
|
}
|
|
687
715
|
}
|
|
@@ -705,7 +733,7 @@ class AR {
|
|
|
705
733
|
case "count":
|
|
706
734
|
return IE(A);
|
|
707
735
|
case "countDistinct":
|
|
708
|
-
return
|
|
736
|
+
return vT(A);
|
|
709
737
|
case "sum":
|
|
710
738
|
return y(A);
|
|
711
739
|
case "avg":
|
|
@@ -725,26 +753,26 @@ class AR {
|
|
|
725
753
|
*/
|
|
726
754
|
buildTimeDimensionExpression(E, R, A) {
|
|
727
755
|
const S = K(E, A);
|
|
728
|
-
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof
|
|
756
|
+
return R ? this.databaseAdapter.buildTimeDimension(R, S) : S instanceof QT ? S : _`${S}`;
|
|
729
757
|
}
|
|
730
758
|
/**
|
|
731
759
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
732
760
|
* Works for both single and multi-cube queries
|
|
733
761
|
*/
|
|
734
762
|
buildWhereConditions(E, R, A, S) {
|
|
735
|
-
const I = [],
|
|
763
|
+
const I = [], e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
736
764
|
if (R.filters && R.filters.length > 0)
|
|
737
|
-
for (const
|
|
738
|
-
const n = this.processFilter(
|
|
765
|
+
for (const N of R.filters) {
|
|
766
|
+
const n = this.processFilter(N, e, A, "where", S);
|
|
739
767
|
n && I.push(n);
|
|
740
768
|
}
|
|
741
769
|
if (R.timeDimensions)
|
|
742
|
-
for (const
|
|
743
|
-
const [n, O] =
|
|
744
|
-
if (
|
|
770
|
+
for (const N of R.timeDimensions) {
|
|
771
|
+
const [n, O] = N.dimension.split("."), s = e.get(n);
|
|
772
|
+
if (s && s.dimensions[O] && N.dateRange) {
|
|
745
773
|
if (S != null && S.preAggregationCTEs && S.preAggregationCTEs.some((U) => U.cube.name === n))
|
|
746
774
|
continue;
|
|
747
|
-
const
|
|
775
|
+
const t = s.dimensions[O], C = K(t.sql, A), i = this.buildDateRangeCondition(C, N.dateRange);
|
|
748
776
|
i && I.push(i);
|
|
749
777
|
}
|
|
750
778
|
}
|
|
@@ -755,10 +783,10 @@ class AR {
|
|
|
755
783
|
* Works for both single and multi-cube queries
|
|
756
784
|
*/
|
|
757
785
|
buildHavingConditions(E, R, A, S) {
|
|
758
|
-
const I = [],
|
|
786
|
+
const I = [], e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
759
787
|
if (R.filters && R.filters.length > 0)
|
|
760
|
-
for (const
|
|
761
|
-
const n = this.processFilter(
|
|
788
|
+
for (const N of R.filters) {
|
|
789
|
+
const n = this.processFilter(N, e, A, "having", S);
|
|
762
790
|
n && I.push(n);
|
|
763
791
|
}
|
|
764
792
|
return I;
|
|
@@ -779,21 +807,21 @@ class AR {
|
|
|
779
807
|
return a.length > 0 ? OE(...a) : null;
|
|
780
808
|
}
|
|
781
809
|
}
|
|
782
|
-
const
|
|
810
|
+
const e = E, [N, n] = e.member.split("."), O = R.get(N);
|
|
783
811
|
if (!O) return null;
|
|
784
|
-
const
|
|
785
|
-
if (!
|
|
786
|
-
if (S === "where" &&
|
|
787
|
-
if (I != null && I.preAggregationCTEs && I.preAggregationCTEs.some((U) => U.cube.name ===
|
|
812
|
+
const s = O.dimensions[n], t = O.measures[n], C = s || t;
|
|
813
|
+
if (!C) return null;
|
|
814
|
+
if (S === "where" && s) {
|
|
815
|
+
if (I != null && I.preAggregationCTEs && I.preAggregationCTEs.some((U) => U.cube.name === N))
|
|
788
816
|
return null;
|
|
789
|
-
const i = K(
|
|
790
|
-
return this.buildFilterCondition(i,
|
|
817
|
+
const i = K(s.sql, A);
|
|
818
|
+
return this.buildFilterCondition(i, e.operator, e.values, C);
|
|
791
819
|
} else {
|
|
792
|
-
if (S === "where" &&
|
|
820
|
+
if (S === "where" && t)
|
|
793
821
|
return null;
|
|
794
|
-
if (S === "having" &&
|
|
795
|
-
const i = this.buildHavingMeasureExpression(
|
|
796
|
-
return this.buildFilterCondition(i,
|
|
822
|
+
if (S === "having" && t) {
|
|
823
|
+
const i = this.buildHavingMeasureExpression(N, n, t, A, I);
|
|
824
|
+
return this.buildFilterCondition(i, e.operator, e.values, C);
|
|
797
825
|
}
|
|
798
826
|
}
|
|
799
827
|
return null;
|
|
@@ -804,62 +832,62 @@ class AR {
|
|
|
804
832
|
buildFilterCondition(E, R, A, S) {
|
|
805
833
|
if (!A || A.length === 0)
|
|
806
834
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
807
|
-
const I = A.filter((
|
|
835
|
+
const I = A.filter((N) => !(N == null || N === "" || typeof N == "string" && N.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
|
|
808
836
|
if (I.length === 0 && !["set", "notSet"].includes(R))
|
|
809
837
|
return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
810
|
-
const
|
|
838
|
+
const e = I[0];
|
|
811
839
|
switch (R) {
|
|
812
840
|
case "equals":
|
|
813
841
|
if (I.length > 1) {
|
|
814
842
|
if ((S == null ? void 0 : S.type) === "time") {
|
|
815
|
-
const
|
|
816
|
-
return
|
|
843
|
+
const N = I.map((n) => this.normalizeDate(n) || n);
|
|
844
|
+
return eE(E, N);
|
|
817
845
|
}
|
|
818
|
-
return
|
|
846
|
+
return eE(E, I);
|
|
819
847
|
} else if (I.length === 1) {
|
|
820
|
-
const
|
|
821
|
-
return EE(E,
|
|
848
|
+
const N = (S == null ? void 0 : S.type) === "time" && this.normalizeDate(e) || e;
|
|
849
|
+
return EE(E, N);
|
|
822
850
|
}
|
|
823
851
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
824
852
|
case "notEquals":
|
|
825
|
-
return I.length > 1 ? gE(E, I) : I.length === 1 ? yE(E,
|
|
853
|
+
return I.length > 1 ? gE(E, I) : I.length === 1 ? yE(E, e) : null;
|
|
826
854
|
case "contains":
|
|
827
|
-
return this.databaseAdapter.buildStringCondition(E, "contains",
|
|
855
|
+
return this.databaseAdapter.buildStringCondition(E, "contains", e);
|
|
828
856
|
case "notContains":
|
|
829
|
-
return this.databaseAdapter.buildStringCondition(E, "notContains",
|
|
857
|
+
return this.databaseAdapter.buildStringCondition(E, "notContains", e);
|
|
830
858
|
case "startsWith":
|
|
831
|
-
return this.databaseAdapter.buildStringCondition(E, "startsWith",
|
|
859
|
+
return this.databaseAdapter.buildStringCondition(E, "startsWith", e);
|
|
832
860
|
case "endsWith":
|
|
833
|
-
return this.databaseAdapter.buildStringCondition(E, "endsWith",
|
|
861
|
+
return this.databaseAdapter.buildStringCondition(E, "endsWith", e);
|
|
834
862
|
case "gt":
|
|
835
|
-
return
|
|
863
|
+
return tE(E, e);
|
|
836
864
|
case "gte":
|
|
837
|
-
return J(E,
|
|
865
|
+
return J(E, e);
|
|
838
866
|
case "lt":
|
|
839
|
-
return
|
|
867
|
+
return NE(E, e);
|
|
840
868
|
case "lte":
|
|
841
|
-
return w(E,
|
|
869
|
+
return w(E, e);
|
|
842
870
|
case "set":
|
|
843
871
|
return KE(E);
|
|
844
872
|
case "notSet":
|
|
845
873
|
return $E(E);
|
|
846
874
|
case "inDateRange":
|
|
847
875
|
if (I.length >= 2) {
|
|
848
|
-
const
|
|
849
|
-
if (
|
|
876
|
+
const N = this.normalizeDate(I[0]), n = this.normalizeDate(I[1]);
|
|
877
|
+
if (N && n)
|
|
850
878
|
return d(
|
|
851
|
-
J(E,
|
|
879
|
+
J(E, N),
|
|
852
880
|
w(E, n)
|
|
853
881
|
);
|
|
854
882
|
}
|
|
855
883
|
return null;
|
|
856
884
|
case "beforeDate": {
|
|
857
|
-
const
|
|
858
|
-
return
|
|
885
|
+
const N = this.normalizeDate(e);
|
|
886
|
+
return N ? NE(E, N) : null;
|
|
859
887
|
}
|
|
860
888
|
case "afterDate": {
|
|
861
|
-
const
|
|
862
|
-
return
|
|
889
|
+
const N = this.normalizeDate(e);
|
|
890
|
+
return N ? tE(E, N) : null;
|
|
863
891
|
}
|
|
864
892
|
case "between":
|
|
865
893
|
return I.length >= 2 ? d(
|
|
@@ -868,23 +896,23 @@ class AR {
|
|
|
868
896
|
) : null;
|
|
869
897
|
case "notBetween":
|
|
870
898
|
return I.length >= 2 ? OE(
|
|
871
|
-
|
|
872
|
-
|
|
899
|
+
NE(E, I[0]),
|
|
900
|
+
tE(E, I[1])
|
|
873
901
|
) : null;
|
|
874
902
|
case "in":
|
|
875
|
-
return I.length > 0 ?
|
|
903
|
+
return I.length > 0 ? eE(E, I) : null;
|
|
876
904
|
case "notIn":
|
|
877
905
|
return I.length > 0 ? gE(E, I) : null;
|
|
878
906
|
case "like":
|
|
879
|
-
return this.databaseAdapter.buildStringCondition(E, "like",
|
|
907
|
+
return this.databaseAdapter.buildStringCondition(E, "like", e);
|
|
880
908
|
case "notLike":
|
|
881
|
-
return this.databaseAdapter.buildStringCondition(E, "notLike",
|
|
909
|
+
return this.databaseAdapter.buildStringCondition(E, "notLike", e);
|
|
882
910
|
case "ilike":
|
|
883
|
-
return this.databaseAdapter.buildStringCondition(E, "ilike",
|
|
911
|
+
return this.databaseAdapter.buildStringCondition(E, "ilike", e);
|
|
884
912
|
case "regex":
|
|
885
|
-
return this.databaseAdapter.buildStringCondition(E, "regex",
|
|
913
|
+
return this.databaseAdapter.buildStringCondition(E, "regex", e);
|
|
886
914
|
case "notRegex":
|
|
887
|
-
return this.databaseAdapter.buildStringCondition(E, "notRegex",
|
|
915
|
+
return this.databaseAdapter.buildStringCondition(E, "notRegex", e);
|
|
888
916
|
case "isEmpty":
|
|
889
917
|
return OE(
|
|
890
918
|
$E(E),
|
|
@@ -922,10 +950,10 @@ class AR {
|
|
|
922
950
|
if (!S) return null;
|
|
923
951
|
const I = new Date(S);
|
|
924
952
|
I.setUTCHours(0, 0, 0, 0);
|
|
925
|
-
const
|
|
926
|
-
return
|
|
953
|
+
const e = new Date(S);
|
|
954
|
+
return e.setUTCHours(23, 59, 59, 999), d(
|
|
927
955
|
J(E, I),
|
|
928
|
-
w(E,
|
|
956
|
+
w(E, e)
|
|
929
957
|
);
|
|
930
958
|
}
|
|
931
959
|
return null;
|
|
@@ -935,75 +963,75 @@ class AR {
|
|
|
935
963
|
* Handles all 14 DATE_RANGE_OPTIONS from the client
|
|
936
964
|
*/
|
|
937
965
|
parseRelativeDateRange(E) {
|
|
938
|
-
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), I = R.getUTCMonth(),
|
|
966
|
+
const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), S = R.getUTCFullYear(), I = R.getUTCMonth(), e = R.getUTCDate(), N = R.getUTCDay();
|
|
939
967
|
if (A === "today") {
|
|
968
|
+
const t = new Date(R);
|
|
969
|
+
t.setUTCHours(0, 0, 0, 0);
|
|
940
970
|
const C = new Date(R);
|
|
941
|
-
C.setUTCHours(
|
|
942
|
-
const s = new Date(R);
|
|
943
|
-
return s.setUTCHours(23, 59, 59, 999), { start: C, end: s };
|
|
971
|
+
return C.setUTCHours(23, 59, 59, 999), { start: t, end: C };
|
|
944
972
|
}
|
|
945
973
|
if (A === "yesterday") {
|
|
974
|
+
const t = new Date(R);
|
|
975
|
+
t.setUTCDate(e - 1), t.setUTCHours(0, 0, 0, 0);
|
|
946
976
|
const C = new Date(R);
|
|
947
|
-
C.setUTCDate(
|
|
948
|
-
const s = new Date(R);
|
|
949
|
-
return s.setUTCDate(N - 1), s.setUTCHours(23, 59, 59, 999), { start: C, end: s };
|
|
977
|
+
return C.setUTCDate(e - 1), C.setUTCHours(23, 59, 59, 999), { start: t, end: C };
|
|
950
978
|
}
|
|
951
979
|
if (A === "this week") {
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
const i = new Date(
|
|
955
|
-
return i.setUTCDate(
|
|
980
|
+
const t = N === 0 ? -6 : 1 - N, C = new Date(R);
|
|
981
|
+
C.setUTCDate(e + t), C.setUTCHours(0, 0, 0, 0);
|
|
982
|
+
const i = new Date(C);
|
|
983
|
+
return i.setUTCDate(C.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
956
984
|
}
|
|
957
985
|
if (A === "this month") {
|
|
958
|
-
const
|
|
959
|
-
return { start:
|
|
986
|
+
const t = new Date(Date.UTC(S, I, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(S, I + 1, 0, 23, 59, 59, 999));
|
|
987
|
+
return { start: t, end: C };
|
|
960
988
|
}
|
|
961
989
|
if (A === "this quarter") {
|
|
962
|
-
const
|
|
963
|
-
return { start:
|
|
990
|
+
const t = Math.floor(I / 3), C = new Date(Date.UTC(S, t * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(S, t * 3 + 3, 0, 23, 59, 59, 999));
|
|
991
|
+
return { start: C, end: i };
|
|
964
992
|
}
|
|
965
993
|
if (A === "this year") {
|
|
966
|
-
const
|
|
967
|
-
return { start:
|
|
994
|
+
const t = new Date(Date.UTC(S, 0, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(S, 11, 31, 23, 59, 59, 999));
|
|
995
|
+
return { start: t, end: C };
|
|
968
996
|
}
|
|
969
997
|
const n = A.match(/^last\s+(\d+)\s+days?$/);
|
|
970
998
|
if (n) {
|
|
971
|
-
const
|
|
972
|
-
|
|
999
|
+
const t = parseInt(n[1], 10), C = new Date(R);
|
|
1000
|
+
C.setUTCDate(e - t + 1), C.setUTCHours(0, 0, 0, 0);
|
|
973
1001
|
const i = new Date(R);
|
|
974
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1002
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
975
1003
|
}
|
|
976
1004
|
if (A === "last week") {
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
const i = new Date(
|
|
980
|
-
return i.setUTCDate(
|
|
1005
|
+
const t = N === 0 ? -13 : -6 - N, C = new Date(R);
|
|
1006
|
+
C.setUTCDate(e + t), C.setUTCHours(0, 0, 0, 0);
|
|
1007
|
+
const i = new Date(C);
|
|
1008
|
+
return i.setUTCDate(C.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
981
1009
|
}
|
|
982
1010
|
if (A === "last month") {
|
|
983
|
-
const
|
|
984
|
-
return { start:
|
|
1011
|
+
const t = new Date(Date.UTC(S, I - 1, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(S, I, 0, 23, 59, 59, 999));
|
|
1012
|
+
return { start: t, end: C };
|
|
985
1013
|
}
|
|
986
1014
|
if (A === "last quarter") {
|
|
987
|
-
const
|
|
1015
|
+
const t = Math.floor(I / 3), C = t === 0 ? 3 : t - 1, i = t === 0 ? S - 1 : S, a = new Date(Date.UTC(i, C * 3, 1, 0, 0, 0, 0)), U = new Date(Date.UTC(i, C * 3 + 3, 0, 23, 59, 59, 999));
|
|
988
1016
|
return { start: a, end: U };
|
|
989
1017
|
}
|
|
990
1018
|
if (A === "last year") {
|
|
991
|
-
const
|
|
992
|
-
return { start:
|
|
1019
|
+
const t = new Date(Date.UTC(S - 1, 0, 1, 0, 0, 0, 0)), C = new Date(Date.UTC(S - 1, 11, 31, 23, 59, 59, 999));
|
|
1020
|
+
return { start: t, end: C };
|
|
993
1021
|
}
|
|
994
1022
|
if (A === "last 12 months") {
|
|
995
|
-
const
|
|
996
|
-
return
|
|
1023
|
+
const t = new Date(Date.UTC(S, I - 11, 1, 0, 0, 0, 0)), C = new Date(R);
|
|
1024
|
+
return C.setUTCHours(23, 59, 59, 999), { start: t, end: C };
|
|
997
1025
|
}
|
|
998
1026
|
const O = A.match(/^last\s+(\d+)\s+months?$/);
|
|
999
1027
|
if (O) {
|
|
1000
|
-
const
|
|
1001
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1028
|
+
const t = parseInt(O[1], 10), C = new Date(Date.UTC(S, I - t + 1, 1, 0, 0, 0, 0)), i = new Date(R);
|
|
1029
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
1002
1030
|
}
|
|
1003
|
-
const
|
|
1004
|
-
if (
|
|
1005
|
-
const
|
|
1006
|
-
return i.setUTCHours(23, 59, 59, 999), { start:
|
|
1031
|
+
const s = A.match(/^last\s+(\d+)\s+years?$/);
|
|
1032
|
+
if (s) {
|
|
1033
|
+
const t = parseInt(s[1], 10), C = new Date(Date.UTC(S - t, 0, 1, 0, 0, 0, 0)), i = new Date(R);
|
|
1034
|
+
return i.setUTCHours(23, 59, 59, 999), { start: C, end: i };
|
|
1007
1035
|
}
|
|
1008
1036
|
return null;
|
|
1009
1037
|
}
|
|
@@ -1036,45 +1064,45 @@ class AR {
|
|
|
1036
1064
|
const I = [];
|
|
1037
1065
|
if (!(R.measures && R.measures.length > 0))
|
|
1038
1066
|
return [];
|
|
1039
|
-
const
|
|
1067
|
+
const N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1040
1068
|
if (R.dimensions)
|
|
1041
|
-
for (const
|
|
1042
|
-
const [
|
|
1043
|
-
if (i && i.dimensions && i.dimensions[
|
|
1044
|
-
if ((n = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : n.some((U) => U.cube.name ===
|
|
1045
|
-
const U = S.preAggregationCTEs.find((G) => G.cube.name ===
|
|
1069
|
+
for (const s of R.dimensions) {
|
|
1070
|
+
const [t, C] = s.split("."), i = N.get(t);
|
|
1071
|
+
if (i && i.dimensions && i.dimensions[C])
|
|
1072
|
+
if ((n = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : n.some((U) => U.cube.name === t)) {
|
|
1073
|
+
const U = S.preAggregationCTEs.find((G) => G.cube.name === t), o = U.joinKeys.find((G) => G.targetColumn === C);
|
|
1046
1074
|
if (o && o.sourceColumnObj)
|
|
1047
1075
|
I.push(o.sourceColumnObj);
|
|
1048
1076
|
else {
|
|
1049
|
-
const G = _`${_.identifier(U.cteAlias)}.${_.identifier(
|
|
1077
|
+
const G = _`${_.identifier(U.cteAlias)}.${_.identifier(C)}`;
|
|
1050
1078
|
I.push(G);
|
|
1051
1079
|
}
|
|
1052
1080
|
} else {
|
|
1053
|
-
const U = i.dimensions[
|
|
1081
|
+
const U = i.dimensions[C], o = K(U.sql, A);
|
|
1054
1082
|
I.push(o);
|
|
1055
1083
|
}
|
|
1056
1084
|
}
|
|
1057
1085
|
if (R.timeDimensions)
|
|
1058
|
-
for (const
|
|
1059
|
-
const [
|
|
1060
|
-
if (i && i.dimensions && i.dimensions[
|
|
1061
|
-
if ((O = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : O.some((U) => U.cube.name ===
|
|
1062
|
-
const U = S.preAggregationCTEs.find((G) => G.cube.name ===
|
|
1086
|
+
for (const s of R.timeDimensions) {
|
|
1087
|
+
const [t, C] = s.dimension.split("."), i = N.get(t);
|
|
1088
|
+
if (i && i.dimensions && i.dimensions[C])
|
|
1089
|
+
if ((O = S == null ? void 0 : S.preAggregationCTEs) == null ? void 0 : O.some((U) => U.cube.name === t)) {
|
|
1090
|
+
const U = S.preAggregationCTEs.find((G) => G.cube.name === t), o = U.joinKeys.find((G) => G.targetColumn === C);
|
|
1063
1091
|
if (o && o.sourceColumnObj) {
|
|
1064
1092
|
const G = this.buildTimeDimensionExpression(
|
|
1065
1093
|
o.sourceColumnObj,
|
|
1066
|
-
|
|
1094
|
+
s.granularity,
|
|
1067
1095
|
A
|
|
1068
1096
|
);
|
|
1069
1097
|
I.push(G);
|
|
1070
1098
|
} else {
|
|
1071
|
-
const G = _`${_.identifier(U.cteAlias)}.${_.identifier(
|
|
1099
|
+
const G = _`${_.identifier(U.cteAlias)}.${_.identifier(C)}`;
|
|
1072
1100
|
I.push(G);
|
|
1073
1101
|
}
|
|
1074
1102
|
} else {
|
|
1075
|
-
const U = i.dimensions[
|
|
1103
|
+
const U = i.dimensions[C], o = this.buildTimeDimensionExpression(
|
|
1076
1104
|
U.sql,
|
|
1077
|
-
|
|
1105
|
+
s.granularity,
|
|
1078
1106
|
A
|
|
1079
1107
|
);
|
|
1080
1108
|
I.push(o);
|
|
@@ -1090,21 +1118,21 @@ class AR {
|
|
|
1090
1118
|
const A = [], S = R || [
|
|
1091
1119
|
...E.measures || [],
|
|
1092
1120
|
...E.dimensions || [],
|
|
1093
|
-
...((I = E.timeDimensions) == null ? void 0 : I.map((
|
|
1121
|
+
...((I = E.timeDimensions) == null ? void 0 : I.map((e) => e.dimension)) || []
|
|
1094
1122
|
];
|
|
1095
1123
|
if (E.order && Object.keys(E.order).length > 0)
|
|
1096
|
-
for (const [
|
|
1097
|
-
if (!S.includes(
|
|
1098
|
-
throw new Error(`Cannot order by '${
|
|
1099
|
-
const n =
|
|
1124
|
+
for (const [e, N] of Object.entries(E.order)) {
|
|
1125
|
+
if (!S.includes(e))
|
|
1126
|
+
throw new Error(`Cannot order by '${e}': field is not selected in the query`);
|
|
1127
|
+
const n = N === "desc" ? ZT(_.identifier(e)) : JE(_.identifier(e));
|
|
1100
1128
|
A.push(n);
|
|
1101
1129
|
}
|
|
1102
1130
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
1103
|
-
const
|
|
1131
|
+
const e = new Set(Object.keys(E.order || {})), N = [...E.timeDimensions].sort(
|
|
1104
1132
|
(n, O) => n.dimension.localeCompare(O.dimension)
|
|
1105
1133
|
);
|
|
1106
|
-
for (const n of
|
|
1107
|
-
|
|
1134
|
+
for (const n of N)
|
|
1135
|
+
e.has(n.dimension) || A.push(JE(_.identifier(n.dimension)));
|
|
1108
1136
|
}
|
|
1109
1137
|
return A;
|
|
1110
1138
|
}
|
|
@@ -1116,9 +1144,9 @@ class AR {
|
|
|
1116
1144
|
const A = [], S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1117
1145
|
if (R.measures && A.push(...R.measures), R.dimensions)
|
|
1118
1146
|
for (const I of R.dimensions) {
|
|
1119
|
-
const [
|
|
1147
|
+
const [e, N] = I.split("."), n = S.get(e);
|
|
1120
1148
|
if (n) {
|
|
1121
|
-
const O = n.dimensions[
|
|
1149
|
+
const O = n.dimensions[N];
|
|
1122
1150
|
O && O.type === "number" && A.push(I);
|
|
1123
1151
|
}
|
|
1124
1152
|
}
|
|
@@ -1145,7 +1173,7 @@ class AR {
|
|
|
1145
1173
|
return S;
|
|
1146
1174
|
}
|
|
1147
1175
|
}
|
|
1148
|
-
class
|
|
1176
|
+
class NR {
|
|
1149
1177
|
/**
|
|
1150
1178
|
* Analyze a semantic query to determine which cubes are involved
|
|
1151
1179
|
*/
|
|
@@ -1219,12 +1247,12 @@ class SR {
|
|
|
1219
1247
|
const S = this.analyzeCubeUsage(R), I = Array.from(S);
|
|
1220
1248
|
if (I.length === 0)
|
|
1221
1249
|
throw new Error("No cubes found in query");
|
|
1222
|
-
const
|
|
1223
|
-
if (!
|
|
1224
|
-
throw new Error(`Primary cube '${
|
|
1250
|
+
const e = this.choosePrimaryCube(I, R, E), N = E.get(e);
|
|
1251
|
+
if (!N)
|
|
1252
|
+
throw new Error(`Primary cube '${e}' not found`);
|
|
1225
1253
|
if (I.length === 1)
|
|
1226
1254
|
return {
|
|
1227
|
-
primaryCube:
|
|
1255
|
+
primaryCube: N,
|
|
1228
1256
|
joinCubes: [],
|
|
1229
1257
|
// Empty for single cube
|
|
1230
1258
|
selections: {},
|
|
@@ -1234,9 +1262,9 @@ class SR {
|
|
|
1234
1262
|
groupByFields: []
|
|
1235
1263
|
// Will be built by QueryBuilder
|
|
1236
1264
|
};
|
|
1237
|
-
const n = this.buildJoinPlan(E,
|
|
1265
|
+
const n = this.buildJoinPlan(E, N, I), O = this.planPreAggregationCTEs(E, N, n, R);
|
|
1238
1266
|
return {
|
|
1239
|
-
primaryCube:
|
|
1267
|
+
primaryCube: N,
|
|
1240
1268
|
joinCubes: n,
|
|
1241
1269
|
selections: {},
|
|
1242
1270
|
// Will be built by QueryBuilder
|
|
@@ -1253,12 +1281,12 @@ class SR {
|
|
|
1253
1281
|
*/
|
|
1254
1282
|
choosePrimaryCube(E, R, A) {
|
|
1255
1283
|
if (R.dimensions && R.dimensions.length > 0 && A) {
|
|
1256
|
-
const S = R.dimensions.map((
|
|
1257
|
-
for (const
|
|
1258
|
-
I.set(
|
|
1284
|
+
const S = R.dimensions.map((e) => e.split(".")[0]), I = /* @__PURE__ */ new Map();
|
|
1285
|
+
for (const e of S)
|
|
1286
|
+
I.set(e, (I.get(e) || 0) + 1);
|
|
1259
1287
|
if (I.size > 0) {
|
|
1260
|
-
const
|
|
1261
|
-
for (const n of
|
|
1288
|
+
const e = Math.max(...I.values()), N = [...I.entries()].filter(([, n]) => n === e).map(([n]) => n).sort();
|
|
1289
|
+
for (const n of N)
|
|
1262
1290
|
if (this.canReachAllCubes(n, E, A))
|
|
1263
1291
|
return n;
|
|
1264
1292
|
}
|
|
@@ -1267,12 +1295,12 @@ class SR {
|
|
|
1267
1295
|
const S = /* @__PURE__ */ new Map();
|
|
1268
1296
|
for (const I of E)
|
|
1269
1297
|
if (this.canReachAllCubes(I, E, A)) {
|
|
1270
|
-
const
|
|
1271
|
-
S.set(I,
|
|
1298
|
+
const e = A.get(I), N = e != null && e.joins ? Object.keys(e.joins).length : 0;
|
|
1299
|
+
S.set(I, N);
|
|
1272
1300
|
}
|
|
1273
1301
|
if (S.size > 0) {
|
|
1274
1302
|
const I = Math.max(...S.values());
|
|
1275
|
-
return [...S.entries()].filter(([,
|
|
1303
|
+
return [...S.entries()].filter(([, N]) => N === I).map(([N]) => N).sort()[0];
|
|
1276
1304
|
}
|
|
1277
1305
|
}
|
|
1278
1306
|
return [...E].sort()[0];
|
|
@@ -1283,8 +1311,8 @@ class SR {
|
|
|
1283
1311
|
canReachAllCubes(E, R, A) {
|
|
1284
1312
|
const S = R.filter((I) => I !== E);
|
|
1285
1313
|
for (const I of S) {
|
|
1286
|
-
const
|
|
1287
|
-
if (!
|
|
1314
|
+
const e = this.findJoinPath(A, E, I, /* @__PURE__ */ new Set());
|
|
1315
|
+
if (!e || e.length === 0)
|
|
1288
1316
|
return !1;
|
|
1289
1317
|
}
|
|
1290
1318
|
return !0;
|
|
@@ -1294,31 +1322,31 @@ class SR {
|
|
|
1294
1322
|
* Supports both direct joins and transitive joins through intermediate cubes
|
|
1295
1323
|
*/
|
|
1296
1324
|
buildJoinPlan(E, R, A) {
|
|
1297
|
-
const S = [], I = /* @__PURE__ */ new Set([R.name]),
|
|
1298
|
-
for (const
|
|
1299
|
-
if (I.has(
|
|
1325
|
+
const S = [], I = /* @__PURE__ */ new Set([R.name]), e = A.filter((N) => N !== R.name);
|
|
1326
|
+
for (const N of e) {
|
|
1327
|
+
if (I.has(N))
|
|
1300
1328
|
continue;
|
|
1301
|
-
const n = this.findJoinPath(E, R.name,
|
|
1329
|
+
const n = this.findJoinPath(E, R.name, N, I);
|
|
1302
1330
|
if (!n || n.length === 0)
|
|
1303
|
-
throw new Error(`No join path found from '${R.name}' to '${
|
|
1304
|
-
for (const { toCube: O, joinDef:
|
|
1331
|
+
throw new Error(`No join path found from '${R.name}' to '${N}'`);
|
|
1332
|
+
for (const { toCube: O, joinDef: s } of n) {
|
|
1305
1333
|
if (I.has(O))
|
|
1306
1334
|
continue;
|
|
1307
|
-
const
|
|
1308
|
-
if (!
|
|
1335
|
+
const t = E.get(O);
|
|
1336
|
+
if (!t)
|
|
1309
1337
|
throw new Error(`Cube '${O}' not found`);
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1338
|
+
const C = this.buildJoinCondition(
|
|
1339
|
+
s,
|
|
1312
1340
|
null,
|
|
1313
1341
|
// No source alias needed - use the actual column
|
|
1314
1342
|
null
|
|
1315
1343
|
// No target alias needed - use the actual column
|
|
1316
|
-
), i =
|
|
1344
|
+
), i = IR(s.relationship, s.sqlJoinType);
|
|
1317
1345
|
S.push({
|
|
1318
|
-
cube:
|
|
1346
|
+
cube: t,
|
|
1319
1347
|
alias: `${O.toLowerCase()}_cube`,
|
|
1320
1348
|
joinType: i,
|
|
1321
|
-
joinCondition:
|
|
1349
|
+
joinCondition: C
|
|
1322
1350
|
}), I.add(O);
|
|
1323
1351
|
}
|
|
1324
1352
|
}
|
|
@@ -1330,8 +1358,8 @@ class SR {
|
|
|
1330
1358
|
buildJoinCondition(E, R, A) {
|
|
1331
1359
|
const S = [];
|
|
1332
1360
|
for (const I of E.on) {
|
|
1333
|
-
const
|
|
1334
|
-
S.push(n(
|
|
1361
|
+
const e = R ? _`${_.identifier(R)}.${_.identifier(I.source.name)}` : I.source, N = A ? _`${_.identifier(A)}.${_.identifier(I.target.name)}` : I.target, n = I.as || EE;
|
|
1362
|
+
S.push(n(e, N));
|
|
1335
1363
|
}
|
|
1336
1364
|
return d(...S);
|
|
1337
1365
|
}
|
|
@@ -1344,22 +1372,22 @@ class SR {
|
|
|
1344
1372
|
return [];
|
|
1345
1373
|
const I = [
|
|
1346
1374
|
{ cube: R, path: [] }
|
|
1347
|
-
],
|
|
1375
|
+
], e = /* @__PURE__ */ new Set([R, ...S]);
|
|
1348
1376
|
for (; I.length > 0; ) {
|
|
1349
|
-
const { cube:
|
|
1377
|
+
const { cube: N, path: n } = I.shift(), O = E.get(N);
|
|
1350
1378
|
if (O != null && O.joins)
|
|
1351
|
-
for (const [,
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1379
|
+
for (const [, s] of Object.entries(O.joins)) {
|
|
1380
|
+
const C = QE(s.targetCube).name;
|
|
1381
|
+
if (e.has(C))
|
|
1354
1382
|
continue;
|
|
1355
1383
|
const i = [...n, {
|
|
1356
|
-
fromCube:
|
|
1357
|
-
toCube:
|
|
1358
|
-
joinDef:
|
|
1384
|
+
fromCube: N,
|
|
1385
|
+
toCube: C,
|
|
1386
|
+
joinDef: s
|
|
1359
1387
|
}];
|
|
1360
|
-
if (
|
|
1388
|
+
if (C === A)
|
|
1361
1389
|
return i;
|
|
1362
|
-
|
|
1390
|
+
e.add(C), I.push({ cube: C, path: i });
|
|
1363
1391
|
}
|
|
1364
1392
|
}
|
|
1365
1393
|
return null;
|
|
@@ -1371,27 +1399,27 @@ class SR {
|
|
|
1371
1399
|
const I = [];
|
|
1372
1400
|
if (!S.measures || S.measures.length === 0)
|
|
1373
1401
|
return I;
|
|
1374
|
-
for (const
|
|
1375
|
-
const
|
|
1376
|
-
if (!
|
|
1402
|
+
for (const e of A) {
|
|
1403
|
+
const N = this.findHasManyJoinDef(R, e.cube.name);
|
|
1404
|
+
if (!N)
|
|
1377
1405
|
continue;
|
|
1378
1406
|
const n = S.measures ? S.measures.filter(
|
|
1379
|
-
(
|
|
1380
|
-
) : [], O = this.extractMeasuresFromFilters(S,
|
|
1381
|
-
if (
|
|
1407
|
+
(C) => C.startsWith(e.cube.name + ".")
|
|
1408
|
+
) : [], O = this.extractMeasuresFromFilters(S, e.cube.name), s = [.../* @__PURE__ */ new Set([...n, ...O])];
|
|
1409
|
+
if (s.length === 0)
|
|
1382
1410
|
continue;
|
|
1383
|
-
const
|
|
1384
|
-
sourceColumn:
|
|
1385
|
-
targetColumn:
|
|
1386
|
-
sourceColumnObj:
|
|
1387
|
-
targetColumnObj:
|
|
1411
|
+
const t = N.on.map((C) => ({
|
|
1412
|
+
sourceColumn: C.source.name,
|
|
1413
|
+
targetColumn: C.target.name,
|
|
1414
|
+
sourceColumnObj: C.source,
|
|
1415
|
+
targetColumnObj: C.target
|
|
1388
1416
|
}));
|
|
1389
1417
|
I.push({
|
|
1390
|
-
cube:
|
|
1391
|
-
alias:
|
|
1392
|
-
cteAlias: `${
|
|
1393
|
-
joinKeys:
|
|
1394
|
-
measures:
|
|
1418
|
+
cube: e.cube,
|
|
1419
|
+
alias: e.alias,
|
|
1420
|
+
cteAlias: `${e.cube.name.toLowerCase()}_agg`,
|
|
1421
|
+
joinKeys: t,
|
|
1422
|
+
measures: s
|
|
1395
1423
|
});
|
|
1396
1424
|
}
|
|
1397
1425
|
return I;
|
|
@@ -1408,29 +1436,29 @@ class SR {
|
|
|
1408
1436
|
return null;
|
|
1409
1437
|
}
|
|
1410
1438
|
}
|
|
1411
|
-
class
|
|
1439
|
+
class sE {
|
|
1412
1440
|
constructor(E) {
|
|
1413
1441
|
W(this, "queryBuilder");
|
|
1414
1442
|
W(this, "queryPlanner");
|
|
1415
1443
|
W(this, "databaseAdapter");
|
|
1416
1444
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
1417
1445
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
1418
|
-
this.queryBuilder = new
|
|
1446
|
+
this.queryBuilder = new eR(this.databaseAdapter), this.queryPlanner = new NR();
|
|
1419
1447
|
}
|
|
1420
1448
|
/**
|
|
1421
1449
|
* Unified query execution method that handles both single and multi-cube queries
|
|
1422
1450
|
*/
|
|
1423
1451
|
async execute(E, R, A) {
|
|
1424
1452
|
try {
|
|
1425
|
-
const S =
|
|
1453
|
+
const S = $T(E, R);
|
|
1426
1454
|
if (!S.isValid)
|
|
1427
1455
|
throw new Error(`Query validation failed: ${S.errors.join(", ")}`);
|
|
1428
1456
|
const I = {
|
|
1429
1457
|
db: this.dbExecutor.db,
|
|
1430
1458
|
schema: this.dbExecutor.schema,
|
|
1431
1459
|
securityContext: A
|
|
1432
|
-
},
|
|
1433
|
-
const i = { ...
|
|
1460
|
+
}, e = this.queryPlanner.createQueryPlan(E, R, I), N = this.buildUnifiedQuery(e, R, I), n = this.queryBuilder.collectNumericFields(E, R), O = await this.dbExecutor.execute(N, n), s = Array.isArray(O) ? O.map((C) => {
|
|
1461
|
+
const i = { ...C };
|
|
1434
1462
|
if (R.timeDimensions) {
|
|
1435
1463
|
for (const a of R.timeDimensions)
|
|
1436
1464
|
if (a.dimension in i) {
|
|
@@ -1443,10 +1471,10 @@ class tE {
|
|
|
1443
1471
|
}
|
|
1444
1472
|
}
|
|
1445
1473
|
return i;
|
|
1446
|
-
}) : [O],
|
|
1474
|
+
}) : [O], t = this.generateAnnotations(e, R);
|
|
1447
1475
|
return {
|
|
1448
|
-
data:
|
|
1449
|
-
annotation:
|
|
1476
|
+
data: s,
|
|
1477
|
+
annotation: t
|
|
1450
1478
|
};
|
|
1451
1479
|
} catch (S) {
|
|
1452
1480
|
throw new Error(`Query execution failed: ${S instanceof Error ? S.message : "Unknown error"}`);
|
|
@@ -1464,18 +1492,18 @@ class tE {
|
|
|
1464
1492
|
*/
|
|
1465
1493
|
buildPreAggregationCTE(E, R, A, S) {
|
|
1466
1494
|
var U;
|
|
1467
|
-
const I = E.cube,
|
|
1495
|
+
const I = E.cube, e = I.sql(A), N = {};
|
|
1468
1496
|
for (const o of E.joinKeys)
|
|
1469
1497
|
if (o.targetColumnObj) {
|
|
1470
|
-
|
|
1498
|
+
N[o.targetColumn] = o.targetColumnObj;
|
|
1471
1499
|
for (const [G, P] of Object.entries(I.dimensions || {}))
|
|
1472
|
-
P.sql === o.targetColumnObj && G !== o.targetColumn && (
|
|
1500
|
+
P.sql === o.targetColumnObj && G !== o.targetColumn && (N[G] = _`${o.targetColumnObj}`.as(G));
|
|
1473
1501
|
}
|
|
1474
1502
|
for (const o of E.measures) {
|
|
1475
1503
|
const [, G] = o.split(".");
|
|
1476
1504
|
if (I.measures && I.measures[G]) {
|
|
1477
1505
|
const P = I.measures[G], H = this.queryBuilder.buildMeasureExpression(P, A);
|
|
1478
|
-
|
|
1506
|
+
N[G] = _`${H}`.as(G);
|
|
1479
1507
|
}
|
|
1480
1508
|
}
|
|
1481
1509
|
const n = I.name;
|
|
@@ -1484,7 +1512,7 @@ class tE {
|
|
|
1484
1512
|
const [G, P] = o.split(".");
|
|
1485
1513
|
if (G === n && I.dimensions && I.dimensions[P]) {
|
|
1486
1514
|
const H = I.dimensions[P], l = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A);
|
|
1487
|
-
|
|
1515
|
+
N[P] = _`${l}`.as(P);
|
|
1488
1516
|
}
|
|
1489
1517
|
}
|
|
1490
1518
|
if (R.timeDimensions)
|
|
@@ -1492,22 +1520,22 @@ class tE {
|
|
|
1492
1520
|
const [G, P] = o.dimension.split(".");
|
|
1493
1521
|
if (G === n && I.dimensions && I.dimensions[P]) {
|
|
1494
1522
|
const H = I.dimensions[P], l = this.queryBuilder.buildTimeDimensionExpression(H.sql, o.granularity, A);
|
|
1495
|
-
|
|
1523
|
+
N[P] = _`${l}`.as(P);
|
|
1496
1524
|
}
|
|
1497
1525
|
}
|
|
1498
|
-
if (Object.keys(
|
|
1526
|
+
if (Object.keys(N).length === 0)
|
|
1499
1527
|
return null;
|
|
1500
|
-
let O = A.db.select(
|
|
1501
|
-
const
|
|
1528
|
+
let O = A.db.select(N).from(e.from);
|
|
1529
|
+
const s = S ? {
|
|
1502
1530
|
...S,
|
|
1503
1531
|
preAggregationCTEs: (U = S.preAggregationCTEs) == null ? void 0 : U.filter((o) => o.cube.name !== I.name)
|
|
1504
|
-
} : void 0,
|
|
1532
|
+
} : void 0, t = this.queryBuilder.buildWhereConditions(I, R, A, s), C = [];
|
|
1505
1533
|
if (R.timeDimensions)
|
|
1506
1534
|
for (const o of R.timeDimensions) {
|
|
1507
1535
|
const [G, P] = o.dimension.split(".");
|
|
1508
1536
|
if (G === n && I.dimensions && I.dimensions[P] && o.dateRange) {
|
|
1509
1537
|
const H = I.dimensions[P], l = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(l, o.dateRange);
|
|
1510
|
-
B &&
|
|
1538
|
+
B && C.push(B);
|
|
1511
1539
|
}
|
|
1512
1540
|
}
|
|
1513
1541
|
if (R.filters) {
|
|
@@ -1518,13 +1546,13 @@ class tE {
|
|
|
1518
1546
|
const l = I.dimensions[H];
|
|
1519
1547
|
if (G.operator === "inDateRange") {
|
|
1520
1548
|
const B = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), u = this.queryBuilder.buildDateRangeCondition(B, G.values);
|
|
1521
|
-
u &&
|
|
1549
|
+
u && C.push(u);
|
|
1522
1550
|
}
|
|
1523
1551
|
}
|
|
1524
1552
|
}
|
|
1525
1553
|
}
|
|
1526
1554
|
const i = [];
|
|
1527
|
-
if (
|
|
1555
|
+
if (e.where && i.push(e.where), i.push(...t, ...C), i.length > 0) {
|
|
1528
1556
|
const o = i.length === 1 ? i[0] : d(...i);
|
|
1529
1557
|
O = O.where(o);
|
|
1530
1558
|
}
|
|
@@ -1554,13 +1582,13 @@ class tE {
|
|
|
1554
1582
|
* Build join condition for CTE
|
|
1555
1583
|
*/
|
|
1556
1584
|
buildCTEJoinCondition(E, R, A) {
|
|
1557
|
-
var
|
|
1558
|
-
const S = (
|
|
1585
|
+
var e;
|
|
1586
|
+
const S = (e = A.preAggregationCTEs) == null ? void 0 : e.find((N) => N.cube.name === E.cube.name);
|
|
1559
1587
|
if (!S)
|
|
1560
1588
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
1561
1589
|
const I = [];
|
|
1562
|
-
for (const
|
|
1563
|
-
const n =
|
|
1590
|
+
for (const N of S.joinKeys) {
|
|
1591
|
+
const n = N.sourceColumnObj || _.identifier(N.sourceColumn), O = _`${_.identifier(R)}.${_.identifier(N.targetColumn)}`;
|
|
1564
1592
|
I.push(EE(n, O));
|
|
1565
1593
|
}
|
|
1566
1594
|
return I.length === 1 ? I[0] : d(...I);
|
|
@@ -1576,7 +1604,7 @@ class tE {
|
|
|
1576
1604
|
const H = this.buildPreAggregationCTE(P, R, A, E);
|
|
1577
1605
|
H && (S.push(H), I.set(P.cube.name, P.cteAlias));
|
|
1578
1606
|
}
|
|
1579
|
-
const
|
|
1607
|
+
const e = E.primaryCube.sql(A), n = { ...this.queryBuilder.buildSelections(
|
|
1580
1608
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1581
1609
|
// Single cube
|
|
1582
1610
|
R,
|
|
@@ -1623,16 +1651,16 @@ class tE {
|
|
|
1623
1651
|
let AE = P.joinKeys.find((SE) => SE.targetColumn === u);
|
|
1624
1652
|
if (!AE && ((o = p == null ? void 0 : p.dimensions) != null && o[u])) {
|
|
1625
1653
|
const SE = p.dimensions[u].sql;
|
|
1626
|
-
AE = P.joinKeys.find((
|
|
1654
|
+
AE = P.joinKeys.find((JT) => JT.targetColumnObj === SE);
|
|
1627
1655
|
}
|
|
1628
1656
|
AE ? n[l] = _`${_.identifier(P.cteAlias)}.${_.identifier(u)}`.as(l) : h && ((G = p == null ? void 0 : p.dimensions) != null && G[u]) && (n[l] = _`${_.identifier(P.cteAlias)}.${_.identifier(u)}`.as(l));
|
|
1629
1657
|
}
|
|
1630
1658
|
}
|
|
1631
1659
|
}
|
|
1632
1660
|
}
|
|
1633
|
-
let O = A.db.select(n).from(
|
|
1634
|
-
if (S.length > 0 && (O = A.db.with(...S).select(n).from(
|
|
1635
|
-
for (const P of
|
|
1661
|
+
let O = A.db.select(n).from(e.from);
|
|
1662
|
+
if (S.length > 0 && (O = A.db.with(...S).select(n).from(e.from)), e.joins)
|
|
1663
|
+
for (const P of e.joins)
|
|
1636
1664
|
switch (P.type || "left") {
|
|
1637
1665
|
case "left":
|
|
1638
1666
|
O = O.leftJoin(P.table, P.on);
|
|
@@ -1670,15 +1698,15 @@ class tE {
|
|
|
1670
1698
|
} catch {
|
|
1671
1699
|
}
|
|
1672
1700
|
}
|
|
1673
|
-
const
|
|
1674
|
-
if (
|
|
1701
|
+
const s = [];
|
|
1702
|
+
if (e.where && s.push(e.where), E.joinCubes && E.joinCubes.length > 0)
|
|
1675
1703
|
for (const P of E.joinCubes) {
|
|
1676
1704
|
if (I.get(P.cube.name))
|
|
1677
1705
|
continue;
|
|
1678
1706
|
const l = P.cube.sql(A);
|
|
1679
|
-
l.where &&
|
|
1707
|
+
l.where && s.push(l.where);
|
|
1680
1708
|
}
|
|
1681
|
-
const
|
|
1709
|
+
const t = this.queryBuilder.buildWhereConditions(
|
|
1682
1710
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1683
1711
|
// Single cube
|
|
1684
1712
|
R,
|
|
@@ -1686,11 +1714,11 @@ class tE {
|
|
|
1686
1714
|
E
|
|
1687
1715
|
// Pass the queryPlan to handle CTE scenarios
|
|
1688
1716
|
);
|
|
1689
|
-
if (
|
|
1690
|
-
const P =
|
|
1717
|
+
if (t.length > 0 && s.push(...t), s.length > 0) {
|
|
1718
|
+
const P = s.length === 1 ? s[0] : d(...s);
|
|
1691
1719
|
O = O.where(P);
|
|
1692
1720
|
}
|
|
1693
|
-
const
|
|
1721
|
+
const C = this.queryBuilder.buildGroupByFields(
|
|
1694
1722
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1695
1723
|
// Single cube
|
|
1696
1724
|
R,
|
|
@@ -1698,7 +1726,7 @@ class tE {
|
|
|
1698
1726
|
E
|
|
1699
1727
|
// Pass the queryPlan to handle CTE scenarios
|
|
1700
1728
|
);
|
|
1701
|
-
|
|
1729
|
+
C.length > 0 && (O = O.groupBy(...C));
|
|
1702
1730
|
const i = this.queryBuilder.buildHavingConditions(
|
|
1703
1731
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
1704
1732
|
// Single cube
|
|
@@ -1745,51 +1773,51 @@ class tE {
|
|
|
1745
1773
|
db: this.dbExecutor.db,
|
|
1746
1774
|
schema: this.dbExecutor.schema,
|
|
1747
1775
|
securityContext: A
|
|
1748
|
-
}, I = this.queryPlanner.createQueryPlan(E, R, S),
|
|
1776
|
+
}, I = this.queryPlanner.createQueryPlan(E, R, S), N = this.buildUnifiedQuery(I, R, S).toSQL();
|
|
1749
1777
|
return {
|
|
1750
|
-
sql:
|
|
1751
|
-
params:
|
|
1778
|
+
sql: N.sql,
|
|
1779
|
+
params: N.params
|
|
1752
1780
|
};
|
|
1753
1781
|
}
|
|
1754
1782
|
/**
|
|
1755
1783
|
* Generate annotations for UI metadata - unified approach
|
|
1756
1784
|
*/
|
|
1757
1785
|
generateAnnotations(E, R) {
|
|
1758
|
-
const A = {}, S = {}, I = {},
|
|
1759
|
-
if (E.joinCubes && E.joinCubes.length > 0 &&
|
|
1760
|
-
for (const
|
|
1761
|
-
const [n, O] =
|
|
1762
|
-
if (
|
|
1763
|
-
const
|
|
1764
|
-
A[
|
|
1765
|
-
title:
|
|
1766
|
-
shortTitle:
|
|
1767
|
-
type:
|
|
1786
|
+
const A = {}, S = {}, I = {}, e = [E.primaryCube];
|
|
1787
|
+
if (E.joinCubes && E.joinCubes.length > 0 && e.push(...E.joinCubes.map((N) => N.cube)), R.measures)
|
|
1788
|
+
for (const N of R.measures) {
|
|
1789
|
+
const [n, O] = N.split("."), s = e.find((t) => t.name === n);
|
|
1790
|
+
if (s && s.measures[O]) {
|
|
1791
|
+
const t = s.measures[O];
|
|
1792
|
+
A[N] = {
|
|
1793
|
+
title: t.title || O,
|
|
1794
|
+
shortTitle: t.title || O,
|
|
1795
|
+
type: t.type
|
|
1768
1796
|
};
|
|
1769
1797
|
}
|
|
1770
1798
|
}
|
|
1771
1799
|
if (R.dimensions)
|
|
1772
|
-
for (const
|
|
1773
|
-
const [n, O] =
|
|
1774
|
-
if (
|
|
1775
|
-
const
|
|
1776
|
-
S[
|
|
1777
|
-
title:
|
|
1778
|
-
shortTitle:
|
|
1779
|
-
type:
|
|
1800
|
+
for (const N of R.dimensions) {
|
|
1801
|
+
const [n, O] = N.split("."), s = e.find((t) => t.name === n);
|
|
1802
|
+
if (s && s.dimensions[O]) {
|
|
1803
|
+
const t = s.dimensions[O];
|
|
1804
|
+
S[N] = {
|
|
1805
|
+
title: t.title || O,
|
|
1806
|
+
shortTitle: t.title || O,
|
|
1807
|
+
type: t.type
|
|
1780
1808
|
};
|
|
1781
1809
|
}
|
|
1782
1810
|
}
|
|
1783
1811
|
if (R.timeDimensions)
|
|
1784
|
-
for (const
|
|
1785
|
-
const [n, O] =
|
|
1786
|
-
if (
|
|
1787
|
-
const
|
|
1788
|
-
I[
|
|
1789
|
-
title:
|
|
1790
|
-
shortTitle:
|
|
1791
|
-
type:
|
|
1792
|
-
granularity:
|
|
1812
|
+
for (const N of R.timeDimensions) {
|
|
1813
|
+
const [n, O] = N.dimension.split("."), s = e.find((t) => t.name === n);
|
|
1814
|
+
if (s && s.dimensions && s.dimensions[O]) {
|
|
1815
|
+
const t = s.dimensions[O];
|
|
1816
|
+
I[N.dimension] = {
|
|
1817
|
+
title: t.title || O,
|
|
1818
|
+
shortTitle: t.title || O,
|
|
1819
|
+
type: t.type,
|
|
1820
|
+
granularity: N.granularity
|
|
1793
1821
|
};
|
|
1794
1822
|
}
|
|
1795
1823
|
}
|
|
@@ -1801,13 +1829,13 @@ class tE {
|
|
|
1801
1829
|
};
|
|
1802
1830
|
}
|
|
1803
1831
|
}
|
|
1804
|
-
const L = (T) => T.flatMap(
|
|
1832
|
+
const L = (T) => T.flatMap(tR), tR = (T) => q(CR(T)).map(sR), sR = (T) => T.replace(/ +/g, " ").trim(), CR = (T) => ({
|
|
1805
1833
|
type: "mandatory_block",
|
|
1806
1834
|
items: XE(T, 0)[0]
|
|
1807
1835
|
}), XE = (T, E, R) => {
|
|
1808
1836
|
const A = [];
|
|
1809
1837
|
for (; T[E]; ) {
|
|
1810
|
-
const [S, I] =
|
|
1838
|
+
const [S, I] = LR(T, E);
|
|
1811
1839
|
if (A.push(S), E = I, T[E] === "|")
|
|
1812
1840
|
E++;
|
|
1813
1841
|
else if (T[E] === "}" || T[E] === "]") {
|
|
@@ -1822,44 +1850,44 @@ const L = (T) => T.flatMap(IR), IR = (T) => q(eR(T)).map(NR), NR = (T) => T.repl
|
|
|
1822
1850
|
throw new Error(`Unexpected "${T[E]}"`);
|
|
1823
1851
|
}
|
|
1824
1852
|
return [A, E];
|
|
1825
|
-
},
|
|
1853
|
+
}, LR = (T, E) => {
|
|
1826
1854
|
const R = [];
|
|
1827
1855
|
for (; ; ) {
|
|
1828
|
-
const [A, S] =
|
|
1856
|
+
const [A, S] = _R(T, E);
|
|
1829
1857
|
if (A)
|
|
1830
1858
|
R.push(A), E = S;
|
|
1831
1859
|
else
|
|
1832
1860
|
break;
|
|
1833
1861
|
}
|
|
1834
1862
|
return R.length === 1 ? [R[0], E] : [{ type: "concatenation", items: R }, E];
|
|
1835
|
-
},
|
|
1863
|
+
}, _R = (T, E) => {
|
|
1836
1864
|
if (T[E] === "{")
|
|
1837
|
-
return
|
|
1865
|
+
return rR(T, E + 1);
|
|
1838
1866
|
if (T[E] === "[")
|
|
1839
|
-
return
|
|
1867
|
+
return nR(T, E + 1);
|
|
1840
1868
|
{
|
|
1841
1869
|
let R = "";
|
|
1842
1870
|
for (; T[E] && /[A-Za-z0-9_ ]/.test(T[E]); )
|
|
1843
1871
|
R += T[E], E++;
|
|
1844
1872
|
return [R, E];
|
|
1845
1873
|
}
|
|
1846
|
-
},
|
|
1874
|
+
}, rR = (T, E) => {
|
|
1847
1875
|
const [R, A] = XE(T, E, "}");
|
|
1848
1876
|
return [{ type: "mandatory_block", items: R }, A];
|
|
1849
|
-
},
|
|
1877
|
+
}, nR = (T, E) => {
|
|
1850
1878
|
const [R, A] = XE(T, E, "]");
|
|
1851
1879
|
return [{ type: "optional_block", items: R }, A];
|
|
1852
1880
|
}, q = (T) => {
|
|
1853
1881
|
if (typeof T == "string")
|
|
1854
1882
|
return [T];
|
|
1855
1883
|
if (T.type === "concatenation")
|
|
1856
|
-
return T.items.map(q).reduce(
|
|
1884
|
+
return T.items.map(q).reduce(DR, [""]);
|
|
1857
1885
|
if (T.type === "mandatory_block")
|
|
1858
1886
|
return T.items.flatMap(q);
|
|
1859
1887
|
if (T.type === "optional_block")
|
|
1860
1888
|
return ["", ...T.items.flatMap(q)];
|
|
1861
1889
|
throw new Error(`Unknown node type: ${T}`);
|
|
1862
|
-
},
|
|
1890
|
+
}, DR = (T, E) => {
|
|
1863
1891
|
const R = [];
|
|
1864
1892
|
for (const A of T)
|
|
1865
1893
|
for (const S of E)
|
|
@@ -1870,19 +1898,19 @@ var D;
|
|
|
1870
1898
|
(function(T) {
|
|
1871
1899
|
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_PHRASE = "RESERVED_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";
|
|
1872
1900
|
})(D = D || (D = {}));
|
|
1873
|
-
const
|
|
1901
|
+
const uT = (T) => ({
|
|
1874
1902
|
type: D.EOF,
|
|
1875
1903
|
raw: "«EOF»",
|
|
1876
1904
|
text: "«EOF»",
|
|
1877
1905
|
start: T
|
|
1878
|
-
}), Q =
|
|
1906
|
+
}), Q = uT(1 / 0), x = (T) => (E) => E.type === T.type && E.text === T.text, $ = {
|
|
1879
1907
|
ARRAY: x({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
|
|
1880
1908
|
BY: x({ text: "BY", type: D.RESERVED_KEYWORD }),
|
|
1881
1909
|
SET: x({ text: "SET", type: D.RESERVED_CLAUSE }),
|
|
1882
1910
|
STRUCT: x({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
|
|
1883
1911
|
WINDOW: x({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
|
|
1884
1912
|
VALUES: x({ text: "VALUES", type: D.RESERVED_CLAUSE })
|
|
1885
|
-
},
|
|
1913
|
+
}, FT = (T) => T === D.RESERVED_DATA_TYPE || T === D.RESERVED_KEYWORD || T === D.RESERVED_FUNCTION_NAME || T === D.RESERVED_PHRASE || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.ARRAY_KEYWORD || T === D.CASE || T === D.END || T === D.WHEN || T === D.ELSE || T === D.THEN || T === D.LIMIT || T === D.BETWEEN || T === D.AND || T === D.OR || T === D.XOR, iR = (T) => T === D.AND || T === D.OR || T === D.XOR, PR = [
|
|
1886
1914
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
1887
1915
|
"KEYS.NEW_KEYSET",
|
|
1888
1916
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -2426,7 +2454,7 @@ const HT = (T) => ({
|
|
|
2426
2454
|
// pivot
|
|
2427
2455
|
"PIVOT",
|
|
2428
2456
|
"UNPIVOT"
|
|
2429
|
-
],
|
|
2457
|
+
], oR = [
|
|
2430
2458
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
|
|
2431
2459
|
"ALL",
|
|
2432
2460
|
"AND",
|
|
@@ -2534,7 +2562,7 @@ const HT = (T) => ({
|
|
|
2534
2562
|
"CASCADE",
|
|
2535
2563
|
"RESTRICT",
|
|
2536
2564
|
"DETERMINISTIC"
|
|
2537
|
-
],
|
|
2565
|
+
], aR = [
|
|
2538
2566
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
|
|
2539
2567
|
"ARRAY",
|
|
2540
2568
|
"BOOL",
|
|
@@ -2559,7 +2587,7 @@ const HT = (T) => ({
|
|
|
2559
2587
|
"STRUCT",
|
|
2560
2588
|
"TIME",
|
|
2561
2589
|
"TIMEZONE"
|
|
2562
|
-
],
|
|
2590
|
+
], MR = L(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), UR = L([
|
|
2563
2591
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
2564
2592
|
"WITH [RECURSIVE]",
|
|
2565
2593
|
"FROM",
|
|
@@ -2590,7 +2618,7 @@ const HT = (T) => ({
|
|
|
2590
2618
|
"REMOTE WITH CONNECTION"
|
|
2591
2619
|
]), ZE = L([
|
|
2592
2620
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
2593
|
-
]),
|
|
2621
|
+
]), CE = L([
|
|
2594
2622
|
// - create:
|
|
2595
2623
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
2596
2624
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -2678,15 +2706,15 @@ const HT = (T) => ({
|
|
|
2678
2706
|
"ASSERT",
|
|
2679
2707
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
2680
2708
|
"EXPORT DATA"
|
|
2681
|
-
]),
|
|
2709
|
+
]), GR = L([
|
|
2682
2710
|
"UNION {ALL | DISTINCT}",
|
|
2683
2711
|
"EXCEPT DISTINCT",
|
|
2684
2712
|
"INTERSECT DISTINCT"
|
|
2685
|
-
]),
|
|
2713
|
+
]), cR = L([
|
|
2686
2714
|
"JOIN",
|
|
2687
2715
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
2688
2716
|
"{INNER | CROSS} JOIN"
|
|
2689
|
-
]),
|
|
2717
|
+
]), lR = L([
|
|
2690
2718
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
2691
2719
|
"TABLESAMPLE SYSTEM",
|
|
2692
2720
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -2697,17 +2725,17 @@ const HT = (T) => ({
|
|
|
2697
2725
|
"{ROWS | RANGE} BETWEEN",
|
|
2698
2726
|
// comparison operator
|
|
2699
2727
|
"IS [NOT] DISTINCT FROM"
|
|
2700
|
-
]),
|
|
2728
|
+
]), HR = {
|
|
2701
2729
|
name: "bigquery",
|
|
2702
2730
|
tokenizerOptions: {
|
|
2703
|
-
reservedSelect:
|
|
2704
|
-
reservedClauses: [...
|
|
2705
|
-
reservedSetOperations:
|
|
2706
|
-
reservedJoins:
|
|
2707
|
-
reservedPhrases:
|
|
2708
|
-
reservedKeywords:
|
|
2709
|
-
reservedDataTypes:
|
|
2710
|
-
reservedFunctionNames:
|
|
2731
|
+
reservedSelect: MR,
|
|
2732
|
+
reservedClauses: [...UR, ...CE, ...ZE],
|
|
2733
|
+
reservedSetOperations: GR,
|
|
2734
|
+
reservedJoins: cR,
|
|
2735
|
+
reservedPhrases: lR,
|
|
2736
|
+
reservedKeywords: oR,
|
|
2737
|
+
reservedDataTypes: aR,
|
|
2738
|
+
reservedFunctionNames: PR,
|
|
2711
2739
|
extraParens: ["[]"],
|
|
2712
2740
|
stringTypes: [
|
|
2713
2741
|
// The triple-quoted strings are listed first, so they get matched first.
|
|
@@ -2725,31 +2753,31 @@ const HT = (T) => ({
|
|
|
2725
2753
|
variableTypes: [{ regex: String.raw`@@\w+` }],
|
|
2726
2754
|
lineCommentTypes: ["--", "#"],
|
|
2727
2755
|
operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
|
|
2728
|
-
postProcess:
|
|
2756
|
+
postProcess: BR
|
|
2729
2757
|
},
|
|
2730
2758
|
formatOptions: {
|
|
2731
|
-
onelineClauses: [...ZE, ...
|
|
2732
|
-
tabularOnelineClauses:
|
|
2759
|
+
onelineClauses: [...ZE, ...CE],
|
|
2760
|
+
tabularOnelineClauses: CE
|
|
2733
2761
|
}
|
|
2734
2762
|
};
|
|
2735
|
-
function
|
|
2736
|
-
return
|
|
2763
|
+
function BR(T) {
|
|
2764
|
+
return uR(FR(T));
|
|
2737
2765
|
}
|
|
2738
|
-
function
|
|
2766
|
+
function uR(T) {
|
|
2739
2767
|
let E = Q;
|
|
2740
2768
|
return T.map((R) => R.text === "OFFSET" && E.text === "[" ? (E = R, Object.assign(Object.assign({}, R), { type: D.RESERVED_FUNCTION_NAME })) : (E = R, R));
|
|
2741
2769
|
}
|
|
2742
|
-
function
|
|
2770
|
+
function FR(T) {
|
|
2743
2771
|
var E;
|
|
2744
2772
|
const R = [];
|
|
2745
2773
|
for (let A = 0; A < T.length; A++) {
|
|
2746
2774
|
const S = T[A];
|
|
2747
2775
|
if (($.ARRAY(S) || $.STRUCT(S)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
2748
|
-
const I =
|
|
2776
|
+
const I = YR(T, A + 1), e = T.slice(A, I + 1);
|
|
2749
2777
|
R.push({
|
|
2750
2778
|
type: D.IDENTIFIER,
|
|
2751
|
-
raw:
|
|
2752
|
-
text:
|
|
2779
|
+
raw: e.map(kE("raw")).join(""),
|
|
2780
|
+
text: e.map(kE("text")).join(""),
|
|
2753
2781
|
start: S.start
|
|
2754
2782
|
}), A = I;
|
|
2755
2783
|
} else
|
|
@@ -2758,7 +2786,7 @@ function HR(T) {
|
|
|
2758
2786
|
return R;
|
|
2759
2787
|
}
|
|
2760
2788
|
const kE = (T) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[T] + " " : E[T];
|
|
2761
|
-
function
|
|
2789
|
+
function YR(T, E) {
|
|
2762
2790
|
let R = 0;
|
|
2763
2791
|
for (let A = E; A < T.length; A++) {
|
|
2764
2792
|
const S = T[A];
|
|
@@ -2767,7 +2795,7 @@ function BR(T, E) {
|
|
|
2767
2795
|
}
|
|
2768
2796
|
return T.length - 1;
|
|
2769
2797
|
}
|
|
2770
|
-
const
|
|
2798
|
+
const mR = [
|
|
2771
2799
|
// https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
|
|
2772
2800
|
"ARRAY_AGG",
|
|
2773
2801
|
"AVG",
|
|
@@ -3087,7 +3115,7 @@ const uR = [
|
|
|
3087
3115
|
"RATIO_TO_REPORT",
|
|
3088
3116
|
// Type casting
|
|
3089
3117
|
"CAST"
|
|
3090
|
-
],
|
|
3118
|
+
], pR = [
|
|
3091
3119
|
// https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
|
|
3092
3120
|
"ACTIVATE",
|
|
3093
3121
|
"ADD",
|
|
@@ -3488,7 +3516,7 @@ const uR = [
|
|
|
3488
3516
|
"XMLNAMESPACES",
|
|
3489
3517
|
"YEAR",
|
|
3490
3518
|
"YEARS"
|
|
3491
|
-
],
|
|
3519
|
+
], dR = [
|
|
3492
3520
|
// https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
|
|
3493
3521
|
"ARRAY",
|
|
3494
3522
|
"BIGINT",
|
|
@@ -3530,7 +3558,7 @@ const uR = [
|
|
|
3530
3558
|
"VARBINARY",
|
|
3531
3559
|
"VARCHAR",
|
|
3532
3560
|
"VARGRAPHIC"
|
|
3533
|
-
],
|
|
3561
|
+
], VR = L(["SELECT [ALL | DISTINCT]"]), hR = L([
|
|
3534
3562
|
// queries
|
|
3535
3563
|
"WITH",
|
|
3536
3564
|
"FROM",
|
|
@@ -3764,26 +3792,26 @@ const uR = [
|
|
|
3764
3792
|
"TRANSFER OWNERSHIP OF",
|
|
3765
3793
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
3766
3794
|
"WHILE"
|
|
3767
|
-
]),
|
|
3795
|
+
]), WR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), fR = L([
|
|
3768
3796
|
"JOIN",
|
|
3769
3797
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3770
3798
|
"{INNER | CROSS} JOIN"
|
|
3771
|
-
]),
|
|
3799
|
+
]), XR = L([
|
|
3772
3800
|
"ON DELETE",
|
|
3773
3801
|
"ON UPDATE",
|
|
3774
3802
|
"SET NULL",
|
|
3775
3803
|
"{ROWS | RANGE} BETWEEN"
|
|
3776
|
-
]),
|
|
3804
|
+
]), bR = {
|
|
3777
3805
|
name: "db2",
|
|
3778
3806
|
tokenizerOptions: {
|
|
3779
|
-
reservedSelect:
|
|
3780
|
-
reservedClauses: [...
|
|
3781
|
-
reservedSetOperations:
|
|
3782
|
-
reservedJoins:
|
|
3783
|
-
reservedPhrases:
|
|
3784
|
-
reservedKeywords:
|
|
3785
|
-
reservedDataTypes:
|
|
3786
|
-
reservedFunctionNames:
|
|
3807
|
+
reservedSelect: VR,
|
|
3808
|
+
reservedClauses: [...hR, ...qE, ...LE],
|
|
3809
|
+
reservedSetOperations: WR,
|
|
3810
|
+
reservedJoins: fR,
|
|
3811
|
+
reservedPhrases: XR,
|
|
3812
|
+
reservedKeywords: pR,
|
|
3813
|
+
reservedDataTypes: dR,
|
|
3814
|
+
reservedFunctionNames: mR,
|
|
3787
3815
|
extraParens: ["[]"],
|
|
3788
3816
|
stringTypes: [
|
|
3789
3817
|
{ quote: "''-qq", prefixes: ["G", "N", "U&"] },
|
|
@@ -3817,7 +3845,7 @@ const uR = [
|
|
|
3817
3845
|
onelineClauses: [...qE, ...LE],
|
|
3818
3846
|
tabularOnelineClauses: LE
|
|
3819
3847
|
}
|
|
3820
|
-
},
|
|
3848
|
+
}, KR = [
|
|
3821
3849
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
3822
3850
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
3823
3851
|
"ARRAY_AGG",
|
|
@@ -4151,7 +4179,7 @@ const uR = [
|
|
|
4151
4179
|
"ROW_NUMBER",
|
|
4152
4180
|
// Type casting
|
|
4153
4181
|
"CAST"
|
|
4154
|
-
],
|
|
4182
|
+
], yR = [
|
|
4155
4183
|
// https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
|
|
4156
4184
|
// TODO: This list likely contains all keywords, not only the reserved ones,
|
|
4157
4185
|
// try to filter it down to just the reserved keywords.
|
|
@@ -4647,7 +4675,7 @@ const uR = [
|
|
|
4647
4675
|
"YEARS",
|
|
4648
4676
|
"YES",
|
|
4649
4677
|
"ZONE"
|
|
4650
|
-
],
|
|
4678
|
+
], $R = [
|
|
4651
4679
|
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
|
|
4652
4680
|
"ARRAY",
|
|
4653
4681
|
"BIGINT",
|
|
@@ -4683,7 +4711,7 @@ const uR = [
|
|
|
4683
4711
|
"VARCHAR",
|
|
4684
4712
|
"VARGRAPHIC",
|
|
4685
4713
|
"XML"
|
|
4686
|
-
],
|
|
4714
|
+
], gR = L(["SELECT [ALL | DISTINCT]"]), JR = L([
|
|
4687
4715
|
// queries
|
|
4688
4716
|
"WITH [RECURSIVE]",
|
|
4689
4717
|
"INTO",
|
|
@@ -4809,27 +4837,27 @@ const uR = [
|
|
|
4809
4837
|
"TAG",
|
|
4810
4838
|
"TRANSFER OWNERSHIP OF",
|
|
4811
4839
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
4812
|
-
]),
|
|
4840
|
+
]), wR = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), xR = L([
|
|
4813
4841
|
"JOIN",
|
|
4814
4842
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4815
4843
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
4816
4844
|
"{INNER | CROSS} JOIN"
|
|
4817
|
-
]),
|
|
4845
|
+
]), vR = L([
|
|
4818
4846
|
"ON DELETE",
|
|
4819
4847
|
"ON UPDATE",
|
|
4820
4848
|
"SET NULL",
|
|
4821
4849
|
"{ROWS | RANGE} BETWEEN"
|
|
4822
|
-
]),
|
|
4850
|
+
]), QR = {
|
|
4823
4851
|
name: "db2i",
|
|
4824
4852
|
tokenizerOptions: {
|
|
4825
|
-
reservedSelect:
|
|
4826
|
-
reservedClauses: [...
|
|
4827
|
-
reservedSetOperations:
|
|
4828
|
-
reservedJoins:
|
|
4829
|
-
reservedPhrases:
|
|
4830
|
-
reservedKeywords:
|
|
4831
|
-
reservedDataTypes:
|
|
4832
|
-
reservedFunctionNames:
|
|
4853
|
+
reservedSelect: gR,
|
|
4854
|
+
reservedClauses: [...JR, ...jE, ..._E],
|
|
4855
|
+
reservedSetOperations: wR,
|
|
4856
|
+
reservedJoins: xR,
|
|
4857
|
+
reservedPhrases: vR,
|
|
4858
|
+
reservedKeywords: yR,
|
|
4859
|
+
reservedDataTypes: $R,
|
|
4860
|
+
reservedFunctionNames: KR,
|
|
4833
4861
|
nestedBlockComments: !0,
|
|
4834
4862
|
extraParens: ["[]"],
|
|
4835
4863
|
stringTypes: [
|
|
@@ -4846,7 +4874,7 @@ const uR = [
|
|
|
4846
4874
|
onelineClauses: [...jE, ..._E],
|
|
4847
4875
|
tabularOnelineClauses: _E
|
|
4848
4876
|
}
|
|
4849
|
-
},
|
|
4877
|
+
}, ZR = [
|
|
4850
4878
|
// Functions from DuckDB (excluding those that start with an underscore):
|
|
4851
4879
|
// SELECT DISTINCT upper(function_name) AS function_name
|
|
4852
4880
|
// FROM duckdb_functions()
|
|
@@ -5509,7 +5537,7 @@ const uR = [
|
|
|
5509
5537
|
// 'NULL', we really prefer treating it as keyword
|
|
5510
5538
|
"RANK",
|
|
5511
5539
|
"ROW_NUMBER"
|
|
5512
|
-
],
|
|
5540
|
+
], kR = [
|
|
5513
5541
|
// Keywords from DuckDB:
|
|
5514
5542
|
// SELECT upper(keyword_name)
|
|
5515
5543
|
// FROM duckdb_keywords()
|
|
@@ -5591,7 +5619,7 @@ const uR = [
|
|
|
5591
5619
|
"WHERE",
|
|
5592
5620
|
"WINDOW",
|
|
5593
5621
|
"WITH"
|
|
5594
|
-
],
|
|
5622
|
+
], qR = [
|
|
5595
5623
|
// Types from DuckDB:
|
|
5596
5624
|
// SELECT DISTINCT upper(type_name)
|
|
5597
5625
|
// FROM duckdb_types()
|
|
@@ -5671,7 +5699,7 @@ const uR = [
|
|
|
5671
5699
|
"UUID",
|
|
5672
5700
|
"VARBINARY",
|
|
5673
5701
|
"VARCHAR"
|
|
5674
|
-
],
|
|
5702
|
+
], jR = L(["SELECT [ALL | DISTINCT]"]), zR = L([
|
|
5675
5703
|
// queries
|
|
5676
5704
|
"WITH [RECURSIVE]",
|
|
5677
5705
|
"FROM",
|
|
@@ -5775,11 +5803,11 @@ const uR = [
|
|
|
5775
5803
|
"PREPARE",
|
|
5776
5804
|
"EXECUTE",
|
|
5777
5805
|
"DEALLOCATE [PREPARE]"
|
|
5778
|
-
]),
|
|
5806
|
+
]), EA = L([
|
|
5779
5807
|
"UNION [ALL | BY NAME]",
|
|
5780
5808
|
"EXCEPT [ALL]",
|
|
5781
5809
|
"INTERSECT [ALL]"
|
|
5782
|
-
]),
|
|
5810
|
+
]), TA = L([
|
|
5783
5811
|
"JOIN",
|
|
5784
5812
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5785
5813
|
"{INNER | CROSS} JOIN",
|
|
@@ -5788,23 +5816,23 @@ const uR = [
|
|
|
5788
5816
|
"POSITIONAL JOIN",
|
|
5789
5817
|
"ANTI JOIN",
|
|
5790
5818
|
"SEMI JOIN"
|
|
5791
|
-
]),
|
|
5819
|
+
]), RA = L([
|
|
5792
5820
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
5793
5821
|
"SIMILAR TO",
|
|
5794
5822
|
"IS [NOT] DISTINCT FROM",
|
|
5795
5823
|
"TIMESTAMP WITH TIME ZONE"
|
|
5796
|
-
]),
|
|
5824
|
+
]), AA = {
|
|
5797
5825
|
name: "duckdb",
|
|
5798
5826
|
tokenizerOptions: {
|
|
5799
|
-
reservedSelect:
|
|
5800
|
-
reservedClauses: [...
|
|
5801
|
-
reservedSetOperations:
|
|
5802
|
-
reservedJoins:
|
|
5803
|
-
reservedPhrases:
|
|
5827
|
+
reservedSelect: jR,
|
|
5828
|
+
reservedClauses: [...zR, ...zE, ...rE],
|
|
5829
|
+
reservedSetOperations: EA,
|
|
5830
|
+
reservedJoins: TA,
|
|
5831
|
+
reservedPhrases: RA,
|
|
5804
5832
|
supportsXor: !0,
|
|
5805
|
-
reservedKeywords:
|
|
5806
|
-
reservedDataTypes:
|
|
5807
|
-
reservedFunctionNames:
|
|
5833
|
+
reservedKeywords: kR,
|
|
5834
|
+
reservedDataTypes: qR,
|
|
5835
|
+
reservedFunctionNames: ZR,
|
|
5808
5836
|
nestedBlockComments: !0,
|
|
5809
5837
|
extraParens: ["[]", "{}"],
|
|
5810
5838
|
stringTypes: [
|
|
@@ -5867,7 +5895,7 @@ const uR = [
|
|
|
5867
5895
|
onelineClauses: [...zE, ...rE],
|
|
5868
5896
|
tabularOnelineClauses: rE
|
|
5869
5897
|
}
|
|
5870
|
-
},
|
|
5898
|
+
}, SA = [
|
|
5871
5899
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
|
|
5872
5900
|
// math
|
|
5873
5901
|
"ABS",
|
|
@@ -6075,7 +6103,7 @@ const uR = [
|
|
|
6075
6103
|
"CUME_DIST",
|
|
6076
6104
|
"PERCENT_RANK",
|
|
6077
6105
|
"NTILE"
|
|
6078
|
-
],
|
|
6106
|
+
], IA = [
|
|
6079
6107
|
// https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
|
|
6080
6108
|
// Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
|
|
6081
6109
|
"ADD",
|
|
@@ -6390,7 +6418,7 @@ const uR = [
|
|
|
6390
6418
|
"JSONFILE",
|
|
6391
6419
|
"INPUTFORMAT",
|
|
6392
6420
|
"OUTPUTFORMAT"
|
|
6393
|
-
],
|
|
6421
|
+
], OA = [
|
|
6394
6422
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
|
|
6395
6423
|
"ARRAY",
|
|
6396
6424
|
"BIGINT",
|
|
@@ -6411,7 +6439,7 @@ const uR = [
|
|
|
6411
6439
|
"STRUCT",
|
|
6412
6440
|
"TIMESTAMP",
|
|
6413
6441
|
"VARCHAR"
|
|
6414
|
-
],
|
|
6442
|
+
], eA = L(["SELECT [ALL | DISTINCT]"]), NA = L([
|
|
6415
6443
|
// queries
|
|
6416
6444
|
"WITH",
|
|
6417
6445
|
"FROM",
|
|
@@ -6472,23 +6500,23 @@ const uR = [
|
|
|
6472
6500
|
"STORED AS",
|
|
6473
6501
|
"STORED BY",
|
|
6474
6502
|
"ROW FORMAT"
|
|
6475
|
-
]),
|
|
6503
|
+
]), tA = L(["UNION [ALL | DISTINCT]"]), sA = L([
|
|
6476
6504
|
"JOIN",
|
|
6477
6505
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6478
6506
|
"{INNER | CROSS} JOIN",
|
|
6479
6507
|
// non-standard joins
|
|
6480
6508
|
"LEFT SEMI JOIN"
|
|
6481
|
-
]),
|
|
6509
|
+
]), CA = L(["{ROWS | RANGE} BETWEEN"]), LA = {
|
|
6482
6510
|
name: "hive",
|
|
6483
6511
|
tokenizerOptions: {
|
|
6484
|
-
reservedSelect:
|
|
6485
|
-
reservedClauses: [...
|
|
6486
|
-
reservedSetOperations:
|
|
6487
|
-
reservedJoins:
|
|
6488
|
-
reservedPhrases:
|
|
6489
|
-
reservedKeywords:
|
|
6490
|
-
reservedDataTypes:
|
|
6491
|
-
reservedFunctionNames:
|
|
6512
|
+
reservedSelect: eA,
|
|
6513
|
+
reservedClauses: [...NA, ...ET, ...nE],
|
|
6514
|
+
reservedSetOperations: tA,
|
|
6515
|
+
reservedJoins: sA,
|
|
6516
|
+
reservedPhrases: CA,
|
|
6517
|
+
reservedKeywords: IA,
|
|
6518
|
+
reservedDataTypes: OA,
|
|
6519
|
+
reservedFunctionNames: SA,
|
|
6492
6520
|
extraParens: ["[]"],
|
|
6493
6521
|
stringTypes: ['""-bs', "''-bs"],
|
|
6494
6522
|
identTypes: ["``"],
|
|
@@ -6509,7 +6537,7 @@ function RE(T) {
|
|
|
6509
6537
|
return $.VALUES(E) && S.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
|
|
6510
6538
|
});
|
|
6511
6539
|
}
|
|
6512
|
-
const
|
|
6540
|
+
const _A = [
|
|
6513
6541
|
// https://mariadb.com/kb/en/reserved-words/
|
|
6514
6542
|
"ACCESSIBLE",
|
|
6515
6543
|
"ADD",
|
|
@@ -6726,7 +6754,7 @@ const tA = [
|
|
|
6726
6754
|
"XOR",
|
|
6727
6755
|
"YEAR_MONTH",
|
|
6728
6756
|
"ZEROFILL"
|
|
6729
|
-
],
|
|
6757
|
+
], rA = [
|
|
6730
6758
|
// https://mariadb.com/kb/en/data-types/
|
|
6731
6759
|
"BIGINT",
|
|
6732
6760
|
"BINARY",
|
|
@@ -6777,7 +6805,7 @@ const tA = [
|
|
|
6777
6805
|
"YEAR"
|
|
6778
6806
|
// 'NUMBER', // ?? In oracle mode only
|
|
6779
6807
|
// 'SET' // handled as special-case in postProcess
|
|
6780
|
-
],
|
|
6808
|
+
], nA = [
|
|
6781
6809
|
// https://mariadb.com/kb/en/information-schema-sql_functions-table/
|
|
6782
6810
|
"ADDDATE",
|
|
6783
6811
|
"ADD_MONTHS",
|
|
@@ -7015,7 +7043,7 @@ const tA = [
|
|
|
7015
7043
|
// CASE expression shorthands
|
|
7016
7044
|
"COALESCE",
|
|
7017
7045
|
"NULLIF"
|
|
7018
|
-
],
|
|
7046
|
+
], DA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), iA = L([
|
|
7019
7047
|
// queries
|
|
7020
7048
|
"WITH [RECURSIVE]",
|
|
7021
7049
|
"FROM",
|
|
@@ -7246,12 +7274,12 @@ const tA = [
|
|
|
7246
7274
|
"XA RECOVER",
|
|
7247
7275
|
"XA ROLLBACK",
|
|
7248
7276
|
"XA START"
|
|
7249
|
-
]),
|
|
7277
|
+
]), PA = L([
|
|
7250
7278
|
"UNION [ALL | DISTINCT]",
|
|
7251
7279
|
"EXCEPT [ALL | DISTINCT]",
|
|
7252
7280
|
"INTERSECT [ALL | DISTINCT]",
|
|
7253
7281
|
"MINUS [ALL | DISTINCT]"
|
|
7254
|
-
]),
|
|
7282
|
+
]), oA = L([
|
|
7255
7283
|
"JOIN",
|
|
7256
7284
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
7257
7285
|
"{INNER | CROSS} JOIN",
|
|
@@ -7259,23 +7287,23 @@ const tA = [
|
|
|
7259
7287
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7260
7288
|
// non-standard joins
|
|
7261
7289
|
"STRAIGHT_JOIN"
|
|
7262
|
-
]),
|
|
7290
|
+
]), aA = L([
|
|
7263
7291
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7264
7292
|
"CHARACTER SET",
|
|
7265
7293
|
"{ROWS | RANGE} BETWEEN",
|
|
7266
7294
|
"IDENTIFIED BY"
|
|
7267
|
-
]),
|
|
7295
|
+
]), MA = {
|
|
7268
7296
|
name: "mariadb",
|
|
7269
7297
|
tokenizerOptions: {
|
|
7270
|
-
reservedSelect:
|
|
7271
|
-
reservedClauses: [...
|
|
7272
|
-
reservedSetOperations:
|
|
7273
|
-
reservedJoins:
|
|
7274
|
-
reservedPhrases:
|
|
7298
|
+
reservedSelect: DA,
|
|
7299
|
+
reservedClauses: [...iA, ...TT, ...DE],
|
|
7300
|
+
reservedSetOperations: PA,
|
|
7301
|
+
reservedJoins: oA,
|
|
7302
|
+
reservedPhrases: aA,
|
|
7275
7303
|
supportsXor: !0,
|
|
7276
|
-
reservedKeywords:
|
|
7277
|
-
reservedDataTypes:
|
|
7278
|
-
reservedFunctionNames:
|
|
7304
|
+
reservedKeywords: _A,
|
|
7305
|
+
reservedDataTypes: rA,
|
|
7306
|
+
reservedFunctionNames: nA,
|
|
7279
7307
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
7280
7308
|
stringTypes: [
|
|
7281
7309
|
'""-qq-bs',
|
|
@@ -7314,7 +7342,7 @@ const tA = [
|
|
|
7314
7342
|
onelineClauses: [...TT, ...DE],
|
|
7315
7343
|
tabularOnelineClauses: DE
|
|
7316
7344
|
}
|
|
7317
|
-
},
|
|
7345
|
+
}, UA = [
|
|
7318
7346
|
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
|
|
7319
7347
|
"ACCESSIBLE",
|
|
7320
7348
|
"ADD",
|
|
@@ -7545,7 +7573,7 @@ const tA = [
|
|
|
7545
7573
|
"YEAR_MONTH",
|
|
7546
7574
|
"ZEROFILL"
|
|
7547
7575
|
// (R)
|
|
7548
|
-
],
|
|
7576
|
+
], GA = [
|
|
7549
7577
|
// https://dev.mysql.com/doc/refman/8.0/en/data-types.html
|
|
7550
7578
|
"BIGINT",
|
|
7551
7579
|
"BINARY",
|
|
@@ -7597,7 +7625,7 @@ const tA = [
|
|
|
7597
7625
|
"VARYING",
|
|
7598
7626
|
"YEAR"
|
|
7599
7627
|
// 'SET' // handled as special-case in postProcess
|
|
7600
|
-
],
|
|
7628
|
+
], cA = [
|
|
7601
7629
|
// https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
|
|
7602
7630
|
"ABS",
|
|
7603
7631
|
"ACOS",
|
|
@@ -8020,7 +8048,7 @@ const tA = [
|
|
|
8020
8048
|
// 'XOR',
|
|
8021
8049
|
"YEAR",
|
|
8022
8050
|
"YEARWEEK"
|
|
8023
|
-
],
|
|
8051
|
+
], lA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), HA = L([
|
|
8024
8052
|
// queries
|
|
8025
8053
|
"WITH [RECURSIVE]",
|
|
8026
8054
|
"FROM",
|
|
@@ -8221,7 +8249,7 @@ const tA = [
|
|
|
8221
8249
|
"REPEAT",
|
|
8222
8250
|
"RETURN",
|
|
8223
8251
|
"WHILE"
|
|
8224
|
-
]),
|
|
8252
|
+
]), BA = L(["UNION [ALL | DISTINCT]"]), uA = L([
|
|
8225
8253
|
"JOIN",
|
|
8226
8254
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8227
8255
|
"{INNER | CROSS} JOIN",
|
|
@@ -8229,23 +8257,23 @@ const tA = [
|
|
|
8229
8257
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8230
8258
|
// non-standard joins
|
|
8231
8259
|
"STRAIGHT_JOIN"
|
|
8232
|
-
]),
|
|
8260
|
+
]), FA = L([
|
|
8233
8261
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8234
8262
|
"CHARACTER SET",
|
|
8235
8263
|
"{ROWS | RANGE} BETWEEN",
|
|
8236
8264
|
"IDENTIFIED BY"
|
|
8237
|
-
]),
|
|
8265
|
+
]), YA = {
|
|
8238
8266
|
name: "mysql",
|
|
8239
8267
|
tokenizerOptions: {
|
|
8240
|
-
reservedSelect:
|
|
8241
|
-
reservedClauses: [...
|
|
8242
|
-
reservedSetOperations:
|
|
8243
|
-
reservedJoins:
|
|
8244
|
-
reservedPhrases:
|
|
8268
|
+
reservedSelect: lA,
|
|
8269
|
+
reservedClauses: [...HA, ...RT, ...iE],
|
|
8270
|
+
reservedSetOperations: BA,
|
|
8271
|
+
reservedJoins: uA,
|
|
8272
|
+
reservedPhrases: FA,
|
|
8245
8273
|
supportsXor: !0,
|
|
8246
|
-
reservedKeywords:
|
|
8247
|
-
reservedDataTypes:
|
|
8248
|
-
reservedFunctionNames:
|
|
8274
|
+
reservedKeywords: UA,
|
|
8275
|
+
reservedDataTypes: GA,
|
|
8276
|
+
reservedFunctionNames: cA,
|
|
8249
8277
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
8250
8278
|
stringTypes: [
|
|
8251
8279
|
'""-qq-bs',
|
|
@@ -8286,7 +8314,7 @@ const tA = [
|
|
|
8286
8314
|
onelineClauses: [...RT, ...iE],
|
|
8287
8315
|
tabularOnelineClauses: iE
|
|
8288
8316
|
}
|
|
8289
|
-
},
|
|
8317
|
+
}, mA = [
|
|
8290
8318
|
// https://docs.pingcap.com/tidb/stable/keywords
|
|
8291
8319
|
"ADD",
|
|
8292
8320
|
"ALL",
|
|
@@ -8478,7 +8506,7 @@ const tA = [
|
|
|
8478
8506
|
"YEAR_MONTH",
|
|
8479
8507
|
"ZEROFILL"
|
|
8480
8508
|
// (R)
|
|
8481
|
-
],
|
|
8509
|
+
], pA = [
|
|
8482
8510
|
// https://docs.pingcap.com/tidb/stable/data-type-overview
|
|
8483
8511
|
"BIGINT",
|
|
8484
8512
|
"BINARY",
|
|
@@ -8525,7 +8553,7 @@ const tA = [
|
|
|
8525
8553
|
"VARYING",
|
|
8526
8554
|
"YEAR"
|
|
8527
8555
|
// 'SET' // handled as special-case in postProcess
|
|
8528
|
-
],
|
|
8556
|
+
], dA = [
|
|
8529
8557
|
// https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
|
|
8530
8558
|
// https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
|
|
8531
8559
|
// + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
|
|
@@ -8851,7 +8879,7 @@ const tA = [
|
|
|
8851
8879
|
// 'XOR',
|
|
8852
8880
|
"YEAR",
|
|
8853
8881
|
"YEARWEEK"
|
|
8854
|
-
],
|
|
8882
|
+
], VA = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), hA = L([
|
|
8855
8883
|
// queries
|
|
8856
8884
|
"WITH [RECURSIVE]",
|
|
8857
8885
|
"FROM",
|
|
@@ -8986,7 +9014,7 @@ const tA = [
|
|
|
8986
9014
|
"UNLOCK TABLES",
|
|
8987
9015
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
8988
9016
|
"USE"
|
|
8989
|
-
]),
|
|
9017
|
+
]), WA = L(["UNION [ALL | DISTINCT]"]), fA = L([
|
|
8990
9018
|
"JOIN",
|
|
8991
9019
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8992
9020
|
"{INNER | CROSS} JOIN",
|
|
@@ -8994,23 +9022,23 @@ const tA = [
|
|
|
8994
9022
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8995
9023
|
// non-standard joins
|
|
8996
9024
|
"STRAIGHT_JOIN"
|
|
8997
|
-
]),
|
|
9025
|
+
]), XA = L([
|
|
8998
9026
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8999
9027
|
"CHARACTER SET",
|
|
9000
9028
|
"{ROWS | RANGE} BETWEEN",
|
|
9001
9029
|
"IDENTIFIED BY"
|
|
9002
|
-
]),
|
|
9030
|
+
]), bA = {
|
|
9003
9031
|
name: "tidb",
|
|
9004
9032
|
tokenizerOptions: {
|
|
9005
|
-
reservedSelect:
|
|
9006
|
-
reservedClauses: [...
|
|
9007
|
-
reservedSetOperations:
|
|
9008
|
-
reservedJoins:
|
|
9009
|
-
reservedPhrases:
|
|
9033
|
+
reservedSelect: VA,
|
|
9034
|
+
reservedClauses: [...hA, ...AT, ...PE],
|
|
9035
|
+
reservedSetOperations: WA,
|
|
9036
|
+
reservedJoins: fA,
|
|
9037
|
+
reservedPhrases: XA,
|
|
9010
9038
|
supportsXor: !0,
|
|
9011
|
-
reservedKeywords:
|
|
9012
|
-
reservedDataTypes:
|
|
9013
|
-
reservedFunctionNames:
|
|
9039
|
+
reservedKeywords: mA,
|
|
9040
|
+
reservedDataTypes: pA,
|
|
9041
|
+
reservedFunctionNames: dA,
|
|
9014
9042
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
9015
9043
|
stringTypes: [
|
|
9016
9044
|
'""-qq-bs',
|
|
@@ -9051,7 +9079,7 @@ const tA = [
|
|
|
9051
9079
|
onelineClauses: [...AT, ...PE],
|
|
9052
9080
|
tabularOnelineClauses: PE
|
|
9053
9081
|
}
|
|
9054
|
-
},
|
|
9082
|
+
}, KA = [
|
|
9055
9083
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
9056
9084
|
"ABORT",
|
|
9057
9085
|
"ABS",
|
|
@@ -9281,7 +9309,7 @@ const tA = [
|
|
|
9281
9309
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
9282
9310
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
9283
9311
|
"CAST"
|
|
9284
|
-
],
|
|
9312
|
+
], yA = [
|
|
9285
9313
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
9286
9314
|
"ADVISE",
|
|
9287
9315
|
"ALL",
|
|
@@ -9487,7 +9515,7 @@ const tA = [
|
|
|
9487
9515
|
"WITHIN",
|
|
9488
9516
|
"WORK",
|
|
9489
9517
|
"XOR"
|
|
9490
|
-
],
|
|
9518
|
+
], $A = [
|
|
9491
9519
|
// N1QL does not support any way of declaring types for columns.
|
|
9492
9520
|
// It does not support the CREATE TABLE statement nor the CAST() expression.
|
|
9493
9521
|
//
|
|
@@ -9496,7 +9524,7 @@ const tA = [
|
|
|
9496
9524
|
// which it actually doesn't use.
|
|
9497
9525
|
//
|
|
9498
9526
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
9499
|
-
],
|
|
9527
|
+
], gA = L(["SELECT [ALL | DISTINCT]"]), JA = L([
|
|
9500
9528
|
// queries
|
|
9501
9529
|
"WITH",
|
|
9502
9530
|
"FROM",
|
|
@@ -9563,18 +9591,18 @@ const tA = [
|
|
|
9563
9591
|
"SET CURRENT SCHEMA",
|
|
9564
9592
|
"SHOW",
|
|
9565
9593
|
"USE [PRIMARY] KEYS"
|
|
9566
|
-
]),
|
|
9594
|
+
]), wA = L(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), xA = L(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), vA = L(["{ROWS | RANGE | GROUPS} BETWEEN"]), QA = {
|
|
9567
9595
|
name: "n1ql",
|
|
9568
9596
|
tokenizerOptions: {
|
|
9569
|
-
reservedSelect:
|
|
9570
|
-
reservedClauses: [...
|
|
9571
|
-
reservedSetOperations:
|
|
9572
|
-
reservedJoins:
|
|
9573
|
-
reservedPhrases:
|
|
9597
|
+
reservedSelect: gA,
|
|
9598
|
+
reservedClauses: [...JA, ...ST],
|
|
9599
|
+
reservedSetOperations: wA,
|
|
9600
|
+
reservedJoins: xA,
|
|
9601
|
+
reservedPhrases: vA,
|
|
9574
9602
|
supportsXor: !0,
|
|
9575
|
-
reservedKeywords:
|
|
9576
|
-
reservedDataTypes:
|
|
9577
|
-
reservedFunctionNames:
|
|
9603
|
+
reservedKeywords: yA,
|
|
9604
|
+
reservedDataTypes: $A,
|
|
9605
|
+
reservedFunctionNames: KA,
|
|
9578
9606
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
9579
9607
|
// but we support them anyway as all other SQL dialects do,
|
|
9580
9608
|
// which simplifies writing tests that are shared between all dialects.
|
|
@@ -9588,7 +9616,7 @@ const tA = [
|
|
|
9588
9616
|
formatOptions: {
|
|
9589
9617
|
onelineClauses: ST
|
|
9590
9618
|
}
|
|
9591
|
-
},
|
|
9619
|
+
}, ZA = [
|
|
9592
9620
|
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
|
|
9593
9621
|
// 'A',
|
|
9594
9622
|
"ADD",
|
|
@@ -9893,7 +9921,7 @@ const tA = [
|
|
|
9893
9921
|
"WRITE",
|
|
9894
9922
|
"YEAR",
|
|
9895
9923
|
"ZONE"
|
|
9896
|
-
],
|
|
9924
|
+
], kA = [
|
|
9897
9925
|
// https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
|
|
9898
9926
|
"ARRAY",
|
|
9899
9927
|
"BFILE_BASE",
|
|
@@ -9931,7 +9959,7 @@ const tA = [
|
|
|
9931
9959
|
"UROWID",
|
|
9932
9960
|
"VARCHAR",
|
|
9933
9961
|
"VARCHAR2"
|
|
9934
|
-
],
|
|
9962
|
+
], qA = [
|
|
9935
9963
|
// https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
|
|
9936
9964
|
// numeric
|
|
9937
9965
|
"ABS",
|
|
@@ -10196,7 +10224,7 @@ const tA = [
|
|
|
10196
10224
|
"PRESENTNNV",
|
|
10197
10225
|
"PRESENTV",
|
|
10198
10226
|
"PREVIOUS"
|
|
10199
|
-
],
|
|
10227
|
+
], jA = L(["SELECT [ALL | DISTINCT | UNIQUE]"]), zA = L([
|
|
10200
10228
|
// queries
|
|
10201
10229
|
"WITH",
|
|
10202
10230
|
"FROM",
|
|
@@ -10250,7 +10278,7 @@ const tA = [
|
|
|
10250
10278
|
"EXCEPTION",
|
|
10251
10279
|
"LOOP",
|
|
10252
10280
|
"START WITH"
|
|
10253
|
-
]),
|
|
10281
|
+
]), ES = L(["UNION [ALL]", "MINUS", "INTERSECT"]), TS = L([
|
|
10254
10282
|
"JOIN",
|
|
10255
10283
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10256
10284
|
"{INNER | CROSS} JOIN",
|
|
@@ -10258,22 +10286,22 @@ const tA = [
|
|
|
10258
10286
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10259
10287
|
// non-standard joins
|
|
10260
10288
|
"{CROSS | OUTER} APPLY"
|
|
10261
|
-
]),
|
|
10289
|
+
]), RS = L([
|
|
10262
10290
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10263
10291
|
"ON COMMIT",
|
|
10264
10292
|
"{ROWS | RANGE} BETWEEN"
|
|
10265
|
-
]),
|
|
10293
|
+
]), AS = {
|
|
10266
10294
|
name: "plsql",
|
|
10267
10295
|
tokenizerOptions: {
|
|
10268
|
-
reservedSelect:
|
|
10269
|
-
reservedClauses: [...
|
|
10270
|
-
reservedSetOperations:
|
|
10271
|
-
reservedJoins:
|
|
10272
|
-
reservedPhrases:
|
|
10296
|
+
reservedSelect: jA,
|
|
10297
|
+
reservedClauses: [...zA, ...IT, ...oE],
|
|
10298
|
+
reservedSetOperations: ES,
|
|
10299
|
+
reservedJoins: TS,
|
|
10300
|
+
reservedPhrases: RS,
|
|
10273
10301
|
supportsXor: !0,
|
|
10274
|
-
reservedKeywords:
|
|
10275
|
-
reservedDataTypes:
|
|
10276
|
-
reservedFunctionNames:
|
|
10302
|
+
reservedKeywords: ZA,
|
|
10303
|
+
reservedDataTypes: kA,
|
|
10304
|
+
reservedFunctionNames: qA,
|
|
10277
10305
|
stringTypes: [
|
|
10278
10306
|
{ quote: "''-qq", prefixes: ["N"] },
|
|
10279
10307
|
{ quote: "q''", prefixes: ["N"] }
|
|
@@ -10298,7 +10326,7 @@ const tA = [
|
|
|
10298
10326
|
"@",
|
|
10299
10327
|
"||"
|
|
10300
10328
|
],
|
|
10301
|
-
postProcess:
|
|
10329
|
+
postProcess: SS
|
|
10302
10330
|
},
|
|
10303
10331
|
formatOptions: {
|
|
10304
10332
|
alwaysDenseOperators: ["@"],
|
|
@@ -10306,11 +10334,11 @@ const tA = [
|
|
|
10306
10334
|
tabularOnelineClauses: oE
|
|
10307
10335
|
}
|
|
10308
10336
|
};
|
|
10309
|
-
function
|
|
10337
|
+
function SS(T) {
|
|
10310
10338
|
let E = Q;
|
|
10311
|
-
return T.map((R) => $.SET(R) && $.BY(E) ? Object.assign(Object.assign({}, R), { type: D.RESERVED_KEYWORD }) : (
|
|
10339
|
+
return T.map((R) => $.SET(R) && $.BY(E) ? Object.assign(Object.assign({}, R), { type: D.RESERVED_KEYWORD }) : (FT(R.type) && (E = R), R));
|
|
10312
10340
|
}
|
|
10313
|
-
const
|
|
10341
|
+
const IS = [
|
|
10314
10342
|
// https://www.postgresql.org/docs/14/functions.html
|
|
10315
10343
|
//
|
|
10316
10344
|
// https://www.postgresql.org/docs/14/functions-math.html
|
|
@@ -10994,7 +11022,7 @@ const RS = [
|
|
|
10994
11022
|
"PG_MCV_LIST_ITEMS",
|
|
10995
11023
|
// cast
|
|
10996
11024
|
"CAST"
|
|
10997
|
-
],
|
|
11025
|
+
], OS = [
|
|
10998
11026
|
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
|
|
10999
11027
|
"ALL",
|
|
11000
11028
|
"ANALYSE",
|
|
@@ -11113,7 +11141,7 @@ const RS = [
|
|
|
11113
11141
|
"WITHOUT",
|
|
11114
11142
|
"YEAR"
|
|
11115
11143
|
// requires AS
|
|
11116
|
-
],
|
|
11144
|
+
], eS = [
|
|
11117
11145
|
// https://www.postgresql.org/docs/current/datatype.html
|
|
11118
11146
|
"ARRAY",
|
|
11119
11147
|
"BIGINT",
|
|
@@ -11147,7 +11175,7 @@ const RS = [
|
|
|
11147
11175
|
"VARCHAR",
|
|
11148
11176
|
"XML",
|
|
11149
11177
|
"ZONE"
|
|
11150
|
-
],
|
|
11178
|
+
], NS = L(["SELECT [ALL | DISTINCT]"]), tS = L([
|
|
11151
11179
|
// queries
|
|
11152
11180
|
"WITH [RECURSIVE]",
|
|
11153
11181
|
"FROM",
|
|
@@ -11370,17 +11398,17 @@ const RS = [
|
|
|
11370
11398
|
"START TRANSACTION",
|
|
11371
11399
|
"UNLISTEN",
|
|
11372
11400
|
"VACUUM"
|
|
11373
|
-
]),
|
|
11401
|
+
]), sS = L([
|
|
11374
11402
|
"UNION [ALL | DISTINCT]",
|
|
11375
11403
|
"EXCEPT [ALL | DISTINCT]",
|
|
11376
11404
|
"INTERSECT [ALL | DISTINCT]"
|
|
11377
|
-
]),
|
|
11405
|
+
]), CS = L([
|
|
11378
11406
|
"JOIN",
|
|
11379
11407
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11380
11408
|
"{INNER | CROSS} JOIN",
|
|
11381
11409
|
"NATURAL [INNER] JOIN",
|
|
11382
11410
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
11383
|
-
]),
|
|
11411
|
+
]), LS = L([
|
|
11384
11412
|
"PRIMARY KEY",
|
|
11385
11413
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
11386
11414
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -11393,17 +11421,17 @@ const RS = [
|
|
|
11393
11421
|
"IS [NOT] DISTINCT FROM",
|
|
11394
11422
|
"NULLS {FIRST | LAST}",
|
|
11395
11423
|
"WITH ORDINALITY"
|
|
11396
|
-
]),
|
|
11424
|
+
]), _S = {
|
|
11397
11425
|
name: "postgresql",
|
|
11398
11426
|
tokenizerOptions: {
|
|
11399
|
-
reservedSelect:
|
|
11400
|
-
reservedClauses: [...
|
|
11401
|
-
reservedSetOperations:
|
|
11402
|
-
reservedJoins:
|
|
11403
|
-
reservedPhrases:
|
|
11404
|
-
reservedKeywords:
|
|
11405
|
-
reservedDataTypes:
|
|
11406
|
-
reservedFunctionNames:
|
|
11427
|
+
reservedSelect: NS,
|
|
11428
|
+
reservedClauses: [...tS, ...OT, ...aE],
|
|
11429
|
+
reservedSetOperations: sS,
|
|
11430
|
+
reservedJoins: CS,
|
|
11431
|
+
reservedPhrases: LS,
|
|
11432
|
+
reservedKeywords: OS,
|
|
11433
|
+
reservedDataTypes: eS,
|
|
11434
|
+
reservedFunctionNames: IS,
|
|
11407
11435
|
nestedBlockComments: !0,
|
|
11408
11436
|
extraParens: ["[]"],
|
|
11409
11437
|
stringTypes: [
|
|
@@ -11517,7 +11545,7 @@ const RS = [
|
|
|
11517
11545
|
onelineClauses: [...OT, ...aE],
|
|
11518
11546
|
tabularOnelineClauses: aE
|
|
11519
11547
|
}
|
|
11520
|
-
},
|
|
11548
|
+
}, rS = [
|
|
11521
11549
|
// https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
|
|
11522
11550
|
"ANY_VALUE",
|
|
11523
11551
|
"APPROXIMATE PERCENTILE_DISC",
|
|
@@ -11863,7 +11891,7 @@ const RS = [
|
|
|
11863
11891
|
"SLICE_NUM",
|
|
11864
11892
|
"USER",
|
|
11865
11893
|
"VERSION"
|
|
11866
|
-
],
|
|
11894
|
+
], nS = [
|
|
11867
11895
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
|
|
11868
11896
|
"AES128",
|
|
11869
11897
|
"AES256",
|
|
@@ -12052,7 +12080,7 @@ const RS = [
|
|
|
12052
12080
|
* SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
|
|
12053
12081
|
* SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
|
|
12054
12082
|
*/
|
|
12055
|
-
],
|
|
12083
|
+
], DS = [
|
|
12056
12084
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
|
|
12057
12085
|
"ARRAY",
|
|
12058
12086
|
"BIGINT",
|
|
@@ -12073,7 +12101,7 @@ const RS = [
|
|
|
12073
12101
|
"TEXT",
|
|
12074
12102
|
"VARBYTE",
|
|
12075
12103
|
"VARCHAR"
|
|
12076
|
-
],
|
|
12104
|
+
], iS = L(["SELECT [ALL | DISTINCT]"]), PS = L([
|
|
12077
12105
|
// queries
|
|
12078
12106
|
"WITH [RECURSIVE]",
|
|
12079
12107
|
"FROM",
|
|
@@ -12091,7 +12119,7 @@ const RS = [
|
|
|
12091
12119
|
"VALUES",
|
|
12092
12120
|
// - update:
|
|
12093
12121
|
"SET"
|
|
12094
|
-
]),
|
|
12122
|
+
]), eT = L([
|
|
12095
12123
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
12096
12124
|
]), ME = L([
|
|
12097
12125
|
// - create:
|
|
@@ -12184,13 +12212,13 @@ const RS = [
|
|
|
12184
12212
|
"START TRANSACTION",
|
|
12185
12213
|
"UNLOAD",
|
|
12186
12214
|
"VACUUM"
|
|
12187
|
-
]),
|
|
12215
|
+
]), oS = L(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), aS = L([
|
|
12188
12216
|
"JOIN",
|
|
12189
12217
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12190
12218
|
"{INNER | CROSS} JOIN",
|
|
12191
12219
|
"NATURAL [INNER] JOIN",
|
|
12192
12220
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12193
|
-
]),
|
|
12221
|
+
]), MS = L([
|
|
12194
12222
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12195
12223
|
"NULL AS",
|
|
12196
12224
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12198,17 +12226,17 @@ const RS = [
|
|
|
12198
12226
|
"HIVE METASTORE",
|
|
12199
12227
|
// in window specifications
|
|
12200
12228
|
"{ROWS | RANGE} BETWEEN"
|
|
12201
|
-
]),
|
|
12229
|
+
]), US = {
|
|
12202
12230
|
name: "redshift",
|
|
12203
12231
|
tokenizerOptions: {
|
|
12204
|
-
reservedSelect:
|
|
12205
|
-
reservedClauses: [...
|
|
12206
|
-
reservedSetOperations:
|
|
12207
|
-
reservedJoins:
|
|
12208
|
-
reservedPhrases:
|
|
12209
|
-
reservedKeywords:
|
|
12210
|
-
reservedDataTypes:
|
|
12211
|
-
reservedFunctionNames:
|
|
12232
|
+
reservedSelect: iS,
|
|
12233
|
+
reservedClauses: [...PS, ...eT, ...ME],
|
|
12234
|
+
reservedSetOperations: oS,
|
|
12235
|
+
reservedJoins: aS,
|
|
12236
|
+
reservedPhrases: MS,
|
|
12237
|
+
reservedKeywords: nS,
|
|
12238
|
+
reservedDataTypes: DS,
|
|
12239
|
+
reservedFunctionNames: rS,
|
|
12212
12240
|
stringTypes: ["''-qq"],
|
|
12213
12241
|
identTypes: ['""-qq'],
|
|
12214
12242
|
identChars: { first: "#" },
|
|
@@ -12231,10 +12259,10 @@ const RS = [
|
|
|
12231
12259
|
},
|
|
12232
12260
|
formatOptions: {
|
|
12233
12261
|
alwaysDenseOperators: ["::"],
|
|
12234
|
-
onelineClauses: [...
|
|
12262
|
+
onelineClauses: [...eT, ...ME],
|
|
12235
12263
|
tabularOnelineClauses: ME
|
|
12236
12264
|
}
|
|
12237
|
-
},
|
|
12265
|
+
}, GS = [
|
|
12238
12266
|
// https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
|
|
12239
12267
|
"ADD",
|
|
12240
12268
|
"AFTER",
|
|
@@ -12501,7 +12529,7 @@ const RS = [
|
|
|
12501
12529
|
"UNSIGNED",
|
|
12502
12530
|
"VARIABLES",
|
|
12503
12531
|
"YEAR_MONTH"
|
|
12504
|
-
],
|
|
12532
|
+
], cS = [
|
|
12505
12533
|
// https://spark.apache.org/docs/latest/sql-ref-datatypes.html
|
|
12506
12534
|
"ARRAY",
|
|
12507
12535
|
"BIGINT",
|
|
@@ -12531,7 +12559,7 @@ const RS = [
|
|
|
12531
12559
|
"TINYINT",
|
|
12532
12560
|
"VARCHAR"
|
|
12533
12561
|
// No varchar type in Spark, only STRING. Added for the sake of tests
|
|
12534
|
-
],
|
|
12562
|
+
], lS = [
|
|
12535
12563
|
// http://spark.apache.org/docs/latest/sql-ref-functions.html
|
|
12536
12564
|
//
|
|
12537
12565
|
// http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
|
|
@@ -12852,7 +12880,7 @@ const RS = [
|
|
|
12852
12880
|
// Shorthand functions to use in place of CASE expression
|
|
12853
12881
|
"COALESCE",
|
|
12854
12882
|
"NULLIF"
|
|
12855
|
-
],
|
|
12883
|
+
], HS = L(["SELECT [ALL | DISTINCT]"]), BS = L([
|
|
12856
12884
|
// queries
|
|
12857
12885
|
"WITH",
|
|
12858
12886
|
"FROM",
|
|
@@ -12877,7 +12905,7 @@ const RS = [
|
|
|
12877
12905
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
12878
12906
|
"LOAD DATA [LOCAL] INPATH",
|
|
12879
12907
|
"[OVERWRITE] INTO TABLE"
|
|
12880
|
-
]),
|
|
12908
|
+
]), NT = L(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), UE = L([
|
|
12881
12909
|
// - create:
|
|
12882
12910
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
12883
12911
|
// - drop table:
|
|
@@ -12933,11 +12961,11 @@ const RS = [
|
|
|
12933
12961
|
"SHOW TBLPROPERTIES",
|
|
12934
12962
|
"SHOW VIEWS",
|
|
12935
12963
|
"UNCACHE TABLE"
|
|
12936
|
-
]),
|
|
12964
|
+
]), uS = L([
|
|
12937
12965
|
"UNION [ALL | DISTINCT]",
|
|
12938
12966
|
"EXCEPT [ALL | DISTINCT]",
|
|
12939
12967
|
"INTERSECT [ALL | DISTINCT]"
|
|
12940
|
-
]),
|
|
12968
|
+
]), FS = L([
|
|
12941
12969
|
"JOIN",
|
|
12942
12970
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12943
12971
|
"{INNER | CROSS} JOIN",
|
|
@@ -12946,23 +12974,23 @@ const RS = [
|
|
|
12946
12974
|
// non-standard-joins
|
|
12947
12975
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
12948
12976
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
12949
|
-
]),
|
|
12977
|
+
]), YS = L([
|
|
12950
12978
|
"ON DELETE",
|
|
12951
12979
|
"ON UPDATE",
|
|
12952
12980
|
"CURRENT ROW",
|
|
12953
12981
|
"{ROWS | RANGE} BETWEEN"
|
|
12954
|
-
]),
|
|
12982
|
+
]), mS = {
|
|
12955
12983
|
name: "spark",
|
|
12956
12984
|
tokenizerOptions: {
|
|
12957
|
-
reservedSelect:
|
|
12958
|
-
reservedClauses: [...
|
|
12959
|
-
reservedSetOperations:
|
|
12960
|
-
reservedJoins:
|
|
12961
|
-
reservedPhrases:
|
|
12985
|
+
reservedSelect: HS,
|
|
12986
|
+
reservedClauses: [...BS, ...NT, ...UE],
|
|
12987
|
+
reservedSetOperations: uS,
|
|
12988
|
+
reservedJoins: FS,
|
|
12989
|
+
reservedPhrases: YS,
|
|
12962
12990
|
supportsXor: !0,
|
|
12963
|
-
reservedKeywords:
|
|
12964
|
-
reservedDataTypes:
|
|
12965
|
-
reservedFunctionNames:
|
|
12991
|
+
reservedKeywords: GS,
|
|
12992
|
+
reservedDataTypes: cS,
|
|
12993
|
+
reservedFunctionNames: lS,
|
|
12966
12994
|
extraParens: ["[]"],
|
|
12967
12995
|
stringTypes: [
|
|
12968
12996
|
"''-bs",
|
|
@@ -12974,20 +13002,20 @@ const RS = [
|
|
|
12974
13002
|
identChars: { allowFirstCharNumber: !0 },
|
|
12975
13003
|
variableTypes: [{ quote: "{}", prefixes: ["$"], requirePrefix: !0 }],
|
|
12976
13004
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||", "->"],
|
|
12977
|
-
postProcess:
|
|
13005
|
+
postProcess: pS
|
|
12978
13006
|
},
|
|
12979
13007
|
formatOptions: {
|
|
12980
|
-
onelineClauses: [...
|
|
13008
|
+
onelineClauses: [...NT, ...UE],
|
|
12981
13009
|
tabularOnelineClauses: UE
|
|
12982
13010
|
}
|
|
12983
13011
|
};
|
|
12984
|
-
function
|
|
13012
|
+
function pS(T) {
|
|
12985
13013
|
return T.map((E, R) => {
|
|
12986
13014
|
const A = T[R - 1] || Q, S = T[R + 1] || Q;
|
|
12987
13015
|
return $.WINDOW(E) && S.type === D.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === D.RESERVED_KEYWORD && !(A.text === "COLLECTION" && S.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
|
|
12988
13016
|
});
|
|
12989
13017
|
}
|
|
12990
|
-
const
|
|
13018
|
+
const dS = [
|
|
12991
13019
|
// https://www.sqlite.org/lang_corefunc.html
|
|
12992
13020
|
"ABS",
|
|
12993
13021
|
"CHANGES",
|
|
@@ -13111,7 +13139,7 @@ const YS = [
|
|
|
13111
13139
|
"JSON_TREE",
|
|
13112
13140
|
// cast
|
|
13113
13141
|
"CAST"
|
|
13114
|
-
],
|
|
13142
|
+
], VS = [
|
|
13115
13143
|
// https://www.sqlite.org/lang_keywords.html
|
|
13116
13144
|
// Note: The keywords listed on that URL are not all reserved keywords.
|
|
13117
13145
|
// We'll need to clean up this list to only include reserved keywords.
|
|
@@ -13264,7 +13292,7 @@ const YS = [
|
|
|
13264
13292
|
"WINDOW",
|
|
13265
13293
|
"WITH",
|
|
13266
13294
|
"WITHOUT"
|
|
13267
|
-
],
|
|
13295
|
+
], hS = [
|
|
13268
13296
|
// SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
|
|
13269
13297
|
// Here we just list some common ones as SQL Formatter
|
|
13270
13298
|
// is only able to detect a predefined list of data types.
|
|
@@ -13285,7 +13313,7 @@ const YS = [
|
|
|
13285
13313
|
"TEXT",
|
|
13286
13314
|
"VARCHAR",
|
|
13287
13315
|
"VARYING CHARACTER"
|
|
13288
|
-
],
|
|
13316
|
+
], WS = L(["SELECT [ALL | DISTINCT]"]), fS = L([
|
|
13289
13317
|
// queries
|
|
13290
13318
|
"WITH [RECURSIVE]",
|
|
13291
13319
|
"FROM",
|
|
@@ -13304,7 +13332,7 @@ const YS = [
|
|
|
13304
13332
|
"VALUES",
|
|
13305
13333
|
// - update:
|
|
13306
13334
|
"SET"
|
|
13307
|
-
]),
|
|
13335
|
+
]), tT = L(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = L([
|
|
13308
13336
|
// - create:
|
|
13309
13337
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
13310
13338
|
// - update:
|
|
@@ -13323,27 +13351,27 @@ const YS = [
|
|
|
13323
13351
|
"RENAME TO",
|
|
13324
13352
|
// - set schema
|
|
13325
13353
|
"SET SCHEMA"
|
|
13326
|
-
]),
|
|
13354
|
+
]), XS = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), bS = L([
|
|
13327
13355
|
"JOIN",
|
|
13328
13356
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13329
13357
|
"{INNER | CROSS} JOIN",
|
|
13330
13358
|
"NATURAL [INNER] JOIN",
|
|
13331
13359
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13332
|
-
]),
|
|
13360
|
+
]), KS = L([
|
|
13333
13361
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13334
13362
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
13335
13363
|
"DO UPDATE"
|
|
13336
|
-
]),
|
|
13364
|
+
]), yS = {
|
|
13337
13365
|
name: "sqlite",
|
|
13338
13366
|
tokenizerOptions: {
|
|
13339
|
-
reservedSelect:
|
|
13340
|
-
reservedClauses: [...
|
|
13341
|
-
reservedSetOperations:
|
|
13342
|
-
reservedJoins:
|
|
13343
|
-
reservedPhrases:
|
|
13344
|
-
reservedKeywords:
|
|
13345
|
-
reservedDataTypes:
|
|
13346
|
-
reservedFunctionNames:
|
|
13367
|
+
reservedSelect: WS,
|
|
13368
|
+
reservedClauses: [...fS, ...tT, ...GE],
|
|
13369
|
+
reservedSetOperations: XS,
|
|
13370
|
+
reservedJoins: bS,
|
|
13371
|
+
reservedPhrases: KS,
|
|
13372
|
+
reservedKeywords: VS,
|
|
13373
|
+
reservedDataTypes: hS,
|
|
13374
|
+
reservedFunctionNames: dS,
|
|
13347
13375
|
stringTypes: [
|
|
13348
13376
|
"''-qq",
|
|
13349
13377
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -13356,10 +13384,10 @@ const YS = [
|
|
|
13356
13384
|
operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
|
|
13357
13385
|
},
|
|
13358
13386
|
formatOptions: {
|
|
13359
|
-
onelineClauses: [...
|
|
13387
|
+
onelineClauses: [...tT, ...GE],
|
|
13360
13388
|
tabularOnelineClauses: GE
|
|
13361
13389
|
}
|
|
13362
|
-
},
|
|
13390
|
+
}, $S = [
|
|
13363
13391
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
|
|
13364
13392
|
"GROUPING",
|
|
13365
13393
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_10_window_function
|
|
@@ -13456,7 +13484,7 @@ const YS = [
|
|
|
13456
13484
|
"ASIN",
|
|
13457
13485
|
"ACOS",
|
|
13458
13486
|
"ATAN"
|
|
13459
|
-
],
|
|
13487
|
+
], gS = [
|
|
13460
13488
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
|
|
13461
13489
|
"ALL",
|
|
13462
13490
|
"ALLOCATE",
|
|
@@ -13654,7 +13682,7 @@ const YS = [
|
|
|
13654
13682
|
"WITHIN",
|
|
13655
13683
|
"WITHOUT",
|
|
13656
13684
|
"YEAR"
|
|
13657
|
-
],
|
|
13685
|
+
], JS = [
|
|
13658
13686
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
|
|
13659
13687
|
"ARRAY",
|
|
13660
13688
|
"BIGINT",
|
|
@@ -13694,7 +13722,7 @@ const YS = [
|
|
|
13694
13722
|
"TIMESTAMP",
|
|
13695
13723
|
"VARBINARY",
|
|
13696
13724
|
"VARCHAR"
|
|
13697
|
-
],
|
|
13725
|
+
], wS = L(["SELECT [ALL | DISTINCT]"]), xS = L([
|
|
13698
13726
|
// queries
|
|
13699
13727
|
"WITH [RECURSIVE]",
|
|
13700
13728
|
"FROM",
|
|
@@ -13713,7 +13741,7 @@ const YS = [
|
|
|
13713
13741
|
"VALUES",
|
|
13714
13742
|
// - update:
|
|
13715
13743
|
"SET"
|
|
13716
|
-
]),
|
|
13744
|
+
]), sT = L(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), cE = L([
|
|
13717
13745
|
// - create:
|
|
13718
13746
|
"CREATE [RECURSIVE] VIEW",
|
|
13719
13747
|
// - update:
|
|
@@ -13738,30 +13766,30 @@ const YS = [
|
|
|
13738
13766
|
"TRUNCATE TABLE",
|
|
13739
13767
|
// other
|
|
13740
13768
|
"SET SCHEMA"
|
|
13741
|
-
]),
|
|
13769
|
+
]), vS = L([
|
|
13742
13770
|
"UNION [ALL | DISTINCT]",
|
|
13743
13771
|
"EXCEPT [ALL | DISTINCT]",
|
|
13744
13772
|
"INTERSECT [ALL | DISTINCT]"
|
|
13745
|
-
]),
|
|
13773
|
+
]), QS = L([
|
|
13746
13774
|
"JOIN",
|
|
13747
13775
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13748
13776
|
"{INNER | CROSS} JOIN",
|
|
13749
13777
|
"NATURAL [INNER] JOIN",
|
|
13750
13778
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13751
|
-
]),
|
|
13779
|
+
]), ZS = L([
|
|
13752
13780
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
13753
13781
|
"{ROWS | RANGE} BETWEEN"
|
|
13754
|
-
]),
|
|
13782
|
+
]), kS = {
|
|
13755
13783
|
name: "sql",
|
|
13756
13784
|
tokenizerOptions: {
|
|
13757
|
-
reservedSelect:
|
|
13758
|
-
reservedClauses: [...
|
|
13759
|
-
reservedSetOperations:
|
|
13760
|
-
reservedJoins:
|
|
13761
|
-
reservedPhrases:
|
|
13762
|
-
reservedKeywords:
|
|
13763
|
-
reservedDataTypes:
|
|
13764
|
-
reservedFunctionNames:
|
|
13785
|
+
reservedSelect: wS,
|
|
13786
|
+
reservedClauses: [...xS, ...sT, ...cE],
|
|
13787
|
+
reservedSetOperations: vS,
|
|
13788
|
+
reservedJoins: QS,
|
|
13789
|
+
reservedPhrases: ZS,
|
|
13790
|
+
reservedKeywords: gS,
|
|
13791
|
+
reservedDataTypes: JS,
|
|
13792
|
+
reservedFunctionNames: $S,
|
|
13765
13793
|
stringTypes: [
|
|
13766
13794
|
{ quote: "''-qq-bs", prefixes: ["N", "U&"] },
|
|
13767
13795
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -13771,10 +13799,10 @@ const YS = [
|
|
|
13771
13799
|
operators: ["||"]
|
|
13772
13800
|
},
|
|
13773
13801
|
formatOptions: {
|
|
13774
|
-
onelineClauses: [...
|
|
13802
|
+
onelineClauses: [...sT, ...cE],
|
|
13775
13803
|
tabularOnelineClauses: cE
|
|
13776
13804
|
}
|
|
13777
|
-
},
|
|
13805
|
+
}, qS = [
|
|
13778
13806
|
// https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
|
|
13779
13807
|
// rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
|
|
13780
13808
|
// rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
|
|
@@ -14208,7 +14236,7 @@ const YS = [
|
|
|
14208
14236
|
"NEXT",
|
|
14209
14237
|
"PERMUTE",
|
|
14210
14238
|
"PREV"
|
|
14211
|
-
],
|
|
14239
|
+
], jS = [
|
|
14212
14240
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
|
|
14213
14241
|
"ABSENT",
|
|
14214
14242
|
"ADD",
|
|
@@ -14445,7 +14473,7 @@ const YS = [
|
|
|
14445
14473
|
"WRAPPER",
|
|
14446
14474
|
"WRITE",
|
|
14447
14475
|
"ZONE"
|
|
14448
|
-
],
|
|
14476
|
+
], zS = [
|
|
14449
14477
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
|
|
14450
14478
|
// or https://trino.io/docs/current/language/types.html
|
|
14451
14479
|
"BIGINT",
|
|
@@ -14484,7 +14512,7 @@ const YS = [
|
|
|
14484
14512
|
"CODEPOINTS",
|
|
14485
14513
|
"FUNCTION",
|
|
14486
14514
|
"JSONPATH"
|
|
14487
|
-
],
|
|
14515
|
+
], EI = L(["SELECT [ALL | DISTINCT]"]), TI = L([
|
|
14488
14516
|
// queries
|
|
14489
14517
|
"WITH [RECURSIVE]",
|
|
14490
14518
|
"FROM",
|
|
@@ -14512,7 +14540,7 @@ const YS = [
|
|
|
14512
14540
|
"PATTERN",
|
|
14513
14541
|
"SUBSET",
|
|
14514
14542
|
"DEFINE"
|
|
14515
|
-
]),
|
|
14543
|
+
]), CT = L(["CREATE TABLE [IF NOT EXISTS]"]), lE = L([
|
|
14516
14544
|
// - create:
|
|
14517
14545
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
14518
14546
|
// - update:
|
|
@@ -14570,31 +14598,31 @@ const YS = [
|
|
|
14570
14598
|
"SHOW ROLE GRANTS",
|
|
14571
14599
|
"SHOW FUNCTIONS",
|
|
14572
14600
|
"SHOW SESSION"
|
|
14573
|
-
]),
|
|
14601
|
+
]), RI = L([
|
|
14574
14602
|
"UNION [ALL | DISTINCT]",
|
|
14575
14603
|
"EXCEPT [ALL | DISTINCT]",
|
|
14576
14604
|
"INTERSECT [ALL | DISTINCT]"
|
|
14577
|
-
]),
|
|
14605
|
+
]), AI = L([
|
|
14578
14606
|
"JOIN",
|
|
14579
14607
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14580
14608
|
"{INNER | CROSS} JOIN",
|
|
14581
14609
|
"NATURAL [INNER] JOIN",
|
|
14582
14610
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14583
|
-
]),
|
|
14611
|
+
]), SI = L([
|
|
14584
14612
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14585
14613
|
// comparison operator
|
|
14586
14614
|
"IS [NOT] DISTINCT FROM"
|
|
14587
|
-
]),
|
|
14615
|
+
]), II = {
|
|
14588
14616
|
name: "trino",
|
|
14589
14617
|
tokenizerOptions: {
|
|
14590
|
-
reservedSelect:
|
|
14591
|
-
reservedClauses: [...
|
|
14592
|
-
reservedSetOperations:
|
|
14593
|
-
reservedJoins:
|
|
14594
|
-
reservedPhrases:
|
|
14595
|
-
reservedKeywords:
|
|
14596
|
-
reservedDataTypes:
|
|
14597
|
-
reservedFunctionNames:
|
|
14618
|
+
reservedSelect: EI,
|
|
14619
|
+
reservedClauses: [...TI, ...CT, ...lE],
|
|
14620
|
+
reservedSetOperations: RI,
|
|
14621
|
+
reservedJoins: AI,
|
|
14622
|
+
reservedPhrases: SI,
|
|
14623
|
+
reservedKeywords: jS,
|
|
14624
|
+
reservedDataTypes: zS,
|
|
14625
|
+
reservedFunctionNames: qS,
|
|
14598
14626
|
// Trino also supports {- ... -} parenthesis.
|
|
14599
14627
|
// The formatting of these currently works out as a result of { and -
|
|
14600
14628
|
// not getting a space added in-between.
|
|
@@ -14623,10 +14651,10 @@ const YS = [
|
|
|
14623
14651
|
]
|
|
14624
14652
|
},
|
|
14625
14653
|
formatOptions: {
|
|
14626
|
-
onelineClauses: [...
|
|
14654
|
+
onelineClauses: [...CT, ...lE],
|
|
14627
14655
|
tabularOnelineClauses: lE
|
|
14628
14656
|
}
|
|
14629
|
-
},
|
|
14657
|
+
}, OI = [
|
|
14630
14658
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
14631
14659
|
// aggregate
|
|
14632
14660
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -14931,7 +14959,7 @@ const YS = [
|
|
|
14931
14959
|
// Shorthand functions to use in place of CASE expression
|
|
14932
14960
|
"COALESCE",
|
|
14933
14961
|
"NULLIF"
|
|
14934
|
-
],
|
|
14962
|
+
], eI = [
|
|
14935
14963
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
14936
14964
|
// standard
|
|
14937
14965
|
"ADD",
|
|
@@ -15112,7 +15140,7 @@ const YS = [
|
|
|
15112
15140
|
"WRITETEXT",
|
|
15113
15141
|
// https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver16#action
|
|
15114
15142
|
"$ACTION"
|
|
15115
|
-
],
|
|
15143
|
+
], NI = [
|
|
15116
15144
|
// https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15
|
|
15117
15145
|
"BINARY",
|
|
15118
15146
|
"BIT",
|
|
@@ -15139,7 +15167,7 @@ const YS = [
|
|
|
15139
15167
|
"TIMESTAMP",
|
|
15140
15168
|
"VARBINARY",
|
|
15141
15169
|
"VARCHAR"
|
|
15142
|
-
],
|
|
15170
|
+
], tI = L(["SELECT [ALL | DISTINCT]"]), sI = L([
|
|
15143
15171
|
// queries
|
|
15144
15172
|
"WITH",
|
|
15145
15173
|
"INTO",
|
|
@@ -15346,26 +15374,26 @@ const YS = [
|
|
|
15346
15374
|
"XACT_ABORT",
|
|
15347
15375
|
"XML INDEX",
|
|
15348
15376
|
"XML SCHEMA COLLECTION"
|
|
15349
|
-
]),
|
|
15377
|
+
]), CI = L(["UNION [ALL]", "EXCEPT", "INTERSECT"]), LI = L([
|
|
15350
15378
|
"JOIN",
|
|
15351
15379
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15352
15380
|
"{INNER | CROSS} JOIN",
|
|
15353
15381
|
// non-standard joins
|
|
15354
15382
|
"{CROSS | OUTER} APPLY"
|
|
15355
|
-
]),
|
|
15383
|
+
]), _I = L([
|
|
15356
15384
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
15357
15385
|
"{ROWS | RANGE} BETWEEN"
|
|
15358
|
-
]),
|
|
15386
|
+
]), rI = {
|
|
15359
15387
|
name: "transactsql",
|
|
15360
15388
|
tokenizerOptions: {
|
|
15361
|
-
reservedSelect:
|
|
15362
|
-
reservedClauses: [...
|
|
15363
|
-
reservedSetOperations:
|
|
15364
|
-
reservedJoins:
|
|
15365
|
-
reservedPhrases:
|
|
15366
|
-
reservedKeywords:
|
|
15367
|
-
reservedDataTypes:
|
|
15368
|
-
reservedFunctionNames:
|
|
15389
|
+
reservedSelect: tI,
|
|
15390
|
+
reservedClauses: [...sI, ...LT, ...HE],
|
|
15391
|
+
reservedSetOperations: CI,
|
|
15392
|
+
reservedJoins: LI,
|
|
15393
|
+
reservedPhrases: _I,
|
|
15394
|
+
reservedKeywords: eI,
|
|
15395
|
+
reservedDataTypes: NI,
|
|
15396
|
+
reservedFunctionNames: OI,
|
|
15369
15397
|
nestedBlockComments: !0,
|
|
15370
15398
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
15371
15399
|
identTypes: ['""-qq', "[]"],
|
|
@@ -15398,7 +15426,7 @@ const YS = [
|
|
|
15398
15426
|
onelineClauses: [...LT, ...HE],
|
|
15399
15427
|
tabularOnelineClauses: HE
|
|
15400
15428
|
}
|
|
15401
|
-
},
|
|
15429
|
+
}, nI = [
|
|
15402
15430
|
// List of all keywords taken from:
|
|
15403
15431
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
|
|
15404
15432
|
// Then filtered down to reserved keywords by running
|
|
@@ -15611,7 +15639,7 @@ const YS = [
|
|
|
15611
15639
|
"XOR",
|
|
15612
15640
|
"YEAR_MONTH",
|
|
15613
15641
|
"ZEROFILL"
|
|
15614
|
-
],
|
|
15642
|
+
], DI = [
|
|
15615
15643
|
// https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
|
|
15616
15644
|
"BIGINT",
|
|
15617
15645
|
"BINARY",
|
|
@@ -15660,7 +15688,7 @@ const YS = [
|
|
|
15660
15688
|
"VARCHAR",
|
|
15661
15689
|
"VARCHARACTER",
|
|
15662
15690
|
"YEAR"
|
|
15663
|
-
],
|
|
15691
|
+
], iI = [
|
|
15664
15692
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
|
|
15665
15693
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
|
|
15666
15694
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
|
|
@@ -15940,7 +15968,7 @@ const YS = [
|
|
|
15940
15968
|
"WEEKDAY",
|
|
15941
15969
|
"WEEKOFYEAR",
|
|
15942
15970
|
"YEAR"
|
|
15943
|
-
],
|
|
15971
|
+
], PI = L(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), oI = L([
|
|
15944
15972
|
// queries
|
|
15945
15973
|
"WITH",
|
|
15946
15974
|
"FROM",
|
|
@@ -16141,35 +16169,35 @@ const YS = [
|
|
|
16141
16169
|
"REPEAT",
|
|
16142
16170
|
"RETURN",
|
|
16143
16171
|
"WHILE"
|
|
16144
|
-
]),
|
|
16172
|
+
]), aI = L([
|
|
16145
16173
|
"UNION [ALL | DISTINCT]",
|
|
16146
16174
|
"EXCEPT",
|
|
16147
16175
|
"INTERSECT",
|
|
16148
16176
|
"MINUS"
|
|
16149
|
-
]),
|
|
16177
|
+
]), MI = L([
|
|
16150
16178
|
"JOIN",
|
|
16151
16179
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16152
16180
|
"{INNER | CROSS} JOIN",
|
|
16153
16181
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
16154
16182
|
// non-standard joins
|
|
16155
16183
|
"STRAIGHT_JOIN"
|
|
16156
|
-
]),
|
|
16184
|
+
]), UI = L([
|
|
16157
16185
|
"ON DELETE",
|
|
16158
16186
|
"ON UPDATE",
|
|
16159
16187
|
"CHARACTER SET",
|
|
16160
16188
|
"{ROWS | RANGE} BETWEEN",
|
|
16161
16189
|
"IDENTIFIED BY"
|
|
16162
|
-
]),
|
|
16190
|
+
]), GI = {
|
|
16163
16191
|
name: "singlestoredb",
|
|
16164
16192
|
tokenizerOptions: {
|
|
16165
|
-
reservedSelect:
|
|
16166
|
-
reservedClauses: [...
|
|
16167
|
-
reservedSetOperations:
|
|
16168
|
-
reservedJoins:
|
|
16169
|
-
reservedPhrases:
|
|
16170
|
-
reservedKeywords:
|
|
16171
|
-
reservedDataTypes:
|
|
16172
|
-
reservedFunctionNames:
|
|
16193
|
+
reservedSelect: PI,
|
|
16194
|
+
reservedClauses: [...oI, ..._T, ...BE],
|
|
16195
|
+
reservedSetOperations: aI,
|
|
16196
|
+
reservedJoins: MI,
|
|
16197
|
+
reservedPhrases: UI,
|
|
16198
|
+
reservedKeywords: nI,
|
|
16199
|
+
reservedDataTypes: DI,
|
|
16200
|
+
reservedFunctionNames: iI,
|
|
16173
16201
|
// TODO: support _binary"some string" prefix
|
|
16174
16202
|
stringTypes: [
|
|
16175
16203
|
'""-qq-bs',
|
|
@@ -16209,7 +16237,7 @@ const YS = [
|
|
|
16209
16237
|
onelineClauses: [..._T, ...BE],
|
|
16210
16238
|
tabularOnelineClauses: BE
|
|
16211
16239
|
}
|
|
16212
|
-
},
|
|
16240
|
+
}, cI = [
|
|
16213
16241
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
16214
16242
|
//
|
|
16215
16243
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -16816,7 +16844,7 @@ const YS = [
|
|
|
16816
16844
|
"QUARTER",
|
|
16817
16845
|
"ZEROIFNULL",
|
|
16818
16846
|
"ZIPF"
|
|
16819
|
-
],
|
|
16847
|
+
], lI = [
|
|
16820
16848
|
// https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
|
|
16821
16849
|
//
|
|
16822
16850
|
// run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
|
|
@@ -16913,7 +16941,7 @@ const YS = [
|
|
|
16913
16941
|
"WITH",
|
|
16914
16942
|
// These are definitely keywords, but haven't found a definite list in the docs
|
|
16915
16943
|
"COMMENT"
|
|
16916
|
-
],
|
|
16944
|
+
], HI = [
|
|
16917
16945
|
"NUMBER",
|
|
16918
16946
|
"DECIMAL",
|
|
16919
16947
|
"NUMERIC",
|
|
@@ -16950,7 +16978,7 @@ const YS = [
|
|
|
16950
16978
|
"ARRAY",
|
|
16951
16979
|
"GEOGRAPHY",
|
|
16952
16980
|
"GEOMETRY"
|
|
16953
|
-
],
|
|
16981
|
+
], BI = L(["SELECT [ALL | DISTINCT]"]), uI = L([
|
|
16954
16982
|
// queries
|
|
16955
16983
|
"WITH [RECURSIVE]",
|
|
16956
16984
|
"FROM",
|
|
@@ -17222,24 +17250,24 @@ const YS = [
|
|
|
17222
17250
|
"USE SCHEMA",
|
|
17223
17251
|
"USE SECONDARY ROLES",
|
|
17224
17252
|
"USE WAREHOUSE"
|
|
17225
|
-
]),
|
|
17253
|
+
]), FI = L(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), YI = L([
|
|
17226
17254
|
"[INNER] JOIN",
|
|
17227
17255
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17228
17256
|
"{CROSS | NATURAL} JOIN"
|
|
17229
|
-
]),
|
|
17257
|
+
]), mI = L([
|
|
17230
17258
|
"{ROWS | RANGE} BETWEEN",
|
|
17231
17259
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17232
|
-
]),
|
|
17260
|
+
]), pI = {
|
|
17233
17261
|
name: "snowflake",
|
|
17234
17262
|
tokenizerOptions: {
|
|
17235
|
-
reservedSelect:
|
|
17236
|
-
reservedClauses: [...
|
|
17237
|
-
reservedSetOperations:
|
|
17238
|
-
reservedJoins:
|
|
17239
|
-
reservedPhrases:
|
|
17240
|
-
reservedKeywords:
|
|
17241
|
-
reservedDataTypes:
|
|
17242
|
-
reservedFunctionNames:
|
|
17263
|
+
reservedSelect: BI,
|
|
17264
|
+
reservedClauses: [...uI, ...rT, ...uE],
|
|
17265
|
+
reservedSetOperations: FI,
|
|
17266
|
+
reservedJoins: YI,
|
|
17267
|
+
reservedPhrases: mI,
|
|
17268
|
+
reservedKeywords: lI,
|
|
17269
|
+
reservedDataTypes: HI,
|
|
17270
|
+
reservedFunctionNames: cI,
|
|
17243
17271
|
stringTypes: ["$$", "''-qq-bs"],
|
|
17244
17272
|
identTypes: ['""-qq'],
|
|
17245
17273
|
variableTypes: [
|
|
@@ -17272,49 +17300,49 @@ const YS = [
|
|
|
17272
17300
|
onelineClauses: [...rT, ...uE],
|
|
17273
17301
|
tabularOnelineClauses: uE
|
|
17274
17302
|
}
|
|
17275
|
-
},
|
|
17303
|
+
}, dI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
17276
17304
|
__proto__: null,
|
|
17277
|
-
bigquery:
|
|
17278
|
-
db2:
|
|
17279
|
-
db2i:
|
|
17280
|
-
duckdb:
|
|
17281
|
-
hive:
|
|
17282
|
-
mariadb:
|
|
17283
|
-
mysql:
|
|
17284
|
-
n1ql:
|
|
17285
|
-
plsql:
|
|
17286
|
-
postgresql:
|
|
17287
|
-
redshift:
|
|
17288
|
-
singlestoredb:
|
|
17289
|
-
snowflake:
|
|
17290
|
-
spark:
|
|
17291
|
-
sql:
|
|
17292
|
-
sqlite:
|
|
17293
|
-
tidb:
|
|
17294
|
-
transactsql:
|
|
17295
|
-
trino:
|
|
17296
|
-
}, Symbol.toStringTag, { value: "Module" })), k = (T) => T[T.length - 1],
|
|
17305
|
+
bigquery: HR,
|
|
17306
|
+
db2: bR,
|
|
17307
|
+
db2i: QR,
|
|
17308
|
+
duckdb: AA,
|
|
17309
|
+
hive: LA,
|
|
17310
|
+
mariadb: MA,
|
|
17311
|
+
mysql: YA,
|
|
17312
|
+
n1ql: QA,
|
|
17313
|
+
plsql: AS,
|
|
17314
|
+
postgresql: _S,
|
|
17315
|
+
redshift: US,
|
|
17316
|
+
singlestoredb: GI,
|
|
17317
|
+
snowflake: pI,
|
|
17318
|
+
spark: mS,
|
|
17319
|
+
sql: kS,
|
|
17320
|
+
sqlite: yS,
|
|
17321
|
+
tidb: bA,
|
|
17322
|
+
transactsql: rI,
|
|
17323
|
+
trino: II
|
|
17324
|
+
}, Symbol.toStringTag, { value: "Module" })), k = (T) => T[T.length - 1], YT = (T) => T.sort((E, R) => R.length - E.length || E.localeCompare(R)), j = (T) => T.replace(/\s+/gu, " "), FE = (T) => /\n/.test(T), V = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), nT = /\s+/uy, g = (T) => new RegExp(`(?:${T})`, "uy"), VI = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), hI = (T) => T + "(?:-" + T + ")*", WI = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(VI).join("|")}${E ? "" : "|"})`, fI = (T) => new RegExp(`(?:${T.map(V).join("|")}).*?(?=\r
|
|
17297
17325
|
|\r|
|
|
17298
17326
|
|$)`, "uy"), DT = (T, E = []) => {
|
|
17299
17327
|
const R = T === "open" ? 0 : 1, A = ["()", ...E].map((S) => S[R]);
|
|
17300
17328
|
return g(A.map(V).join("|"));
|
|
17301
|
-
}, iT = (T) => g(`${
|
|
17329
|
+
}, iT = (T) => g(`${YT(T).map(V).join("|")}`), XI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", X = (T, E = {}) => {
|
|
17302
17330
|
if (T.length === 0)
|
|
17303
17331
|
return /^\b$/u;
|
|
17304
|
-
const R =
|
|
17332
|
+
const R = XI(E), A = YT(T).map(V).join("|").replace(/ /gu, "\\s+");
|
|
17305
17333
|
return new RegExp(`(?:${A})${R}\\b`, "iuy");
|
|
17306
17334
|
}, YE = (T, E) => {
|
|
17307
17335
|
if (!T.length)
|
|
17308
17336
|
return;
|
|
17309
17337
|
const R = T.map(V).join("|");
|
|
17310
17338
|
return g(`(?:${R})(?:${E})`);
|
|
17311
|
-
},
|
|
17339
|
+
}, bI = () => {
|
|
17312
17340
|
const T = {
|
|
17313
17341
|
"<": ">",
|
|
17314
17342
|
"[": "]",
|
|
17315
17343
|
"(": ")",
|
|
17316
17344
|
"{": "}"
|
|
17317
|
-
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([
|
|
17345
|
+
}, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([e, N]) => E.replace(/{left}/g, V(e)).replace(/{right}/g, V(N))), A = V(Object.keys(T).join(""));
|
|
17318
17346
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
|
|
17319
17347
|
}, PT = {
|
|
17320
17348
|
// - backtick quoted (using `` to escape)
|
|
@@ -17340,16 +17368,16 @@ const YS = [
|
|
|
17340
17368
|
// Hive and Spark variables: ${name}
|
|
17341
17369
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
17342
17370
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
17343
|
-
"q''":
|
|
17344
|
-
},
|
|
17345
|
-
const S = "\\p{Alphabetic}\\p{Mark}_", I = "\\p{Decimal_Number}",
|
|
17346
|
-
return R ?
|
|
17371
|
+
"q''": bI()
|
|
17372
|
+
}, mT = (T) => typeof T == "string" ? PT[T] : "regex" in T ? T.regex : WI(T) + PT[T.quote], KI = (T) => g(T.map((E) => "regex" in E ? E.regex : mT(E)).join("|")), pT = (T) => T.map(mT).join("|"), oT = (T) => g(pT(T)), yI = (T = {}) => g(dT(T)), dT = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
|
|
17373
|
+
const S = "\\p{Alphabetic}\\p{Mark}_", I = "\\p{Decimal_Number}", e = V(T ?? ""), N = V(E ?? ""), n = A ? `[${S}${I}${e}][${S}${I}${N}]*` : `[${S}${e}][${S}${I}${N}]*`;
|
|
17374
|
+
return R ? hI(n) : n;
|
|
17347
17375
|
};
|
|
17348
|
-
function
|
|
17376
|
+
function VT(T, E) {
|
|
17349
17377
|
const R = T.slice(0, E).split(/\n/);
|
|
17350
17378
|
return { line: R.length, col: R[R.length - 1].length + 1 };
|
|
17351
17379
|
}
|
|
17352
|
-
class
|
|
17380
|
+
class $I {
|
|
17353
17381
|
constructor(E, R) {
|
|
17354
17382
|
this.rules = E, this.dialectName = R, this.input = "", this.index = 0;
|
|
17355
17383
|
}
|
|
@@ -17375,7 +17403,7 @@ class bI {
|
|
|
17375
17403
|
return R;
|
|
17376
17404
|
}
|
|
17377
17405
|
createParseError() {
|
|
17378
|
-
const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } =
|
|
17406
|
+
const E = this.input.slice(this.index, this.index + 10), { line: R, col: A } = VT(this.input, this.index);
|
|
17379
17407
|
return new Error(`Parse error: Unexpected "${E}" at line ${R} column ${A}.
|
|
17380
17408
|
${this.dialectInfo()}`);
|
|
17381
17409
|
}
|
|
@@ -17411,8 +17439,8 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
|
|
|
17411
17439
|
}
|
|
17412
17440
|
}
|
|
17413
17441
|
}
|
|
17414
|
-
const aT = /\/\*/uy,
|
|
17415
|
-
class
|
|
17442
|
+
const aT = /\/\*/uy, gI = /[\s\S]/uy, JI = /\*\//uy;
|
|
17443
|
+
class wI {
|
|
17416
17444
|
constructor() {
|
|
17417
17445
|
this.lastIndex = 0;
|
|
17418
17446
|
}
|
|
@@ -17425,9 +17453,9 @@ class $I {
|
|
|
17425
17453
|
for (; S > 0; )
|
|
17426
17454
|
if (A = this.matchSection(aT, E))
|
|
17427
17455
|
R += A, S++;
|
|
17428
|
-
else if (A = this.matchSection(
|
|
17456
|
+
else if (A = this.matchSection(JI, E))
|
|
17429
17457
|
R += A, S--;
|
|
17430
|
-
else if (A = this.matchSection(
|
|
17458
|
+
else if (A = this.matchSection(gI, E))
|
|
17431
17459
|
R += A;
|
|
17432
17460
|
else
|
|
17433
17461
|
return null;
|
|
@@ -17439,7 +17467,7 @@ class $I {
|
|
|
17439
17467
|
return A && (this.lastIndex += A[0].length), A ? A[0] : null;
|
|
17440
17468
|
}
|
|
17441
17469
|
}
|
|
17442
|
-
class
|
|
17470
|
+
class xI {
|
|
17443
17471
|
constructor(E, R) {
|
|
17444
17472
|
this.cfg = E, this.dialectName = R, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
|
|
17445
17473
|
}
|
|
@@ -17448,7 +17476,7 @@ class gI {
|
|
|
17448
17476
|
...this.rulesBeforeParams,
|
|
17449
17477
|
...this.buildParamRules(this.cfg, R),
|
|
17450
17478
|
...this.rulesAfterParams
|
|
17451
|
-
], S = new
|
|
17479
|
+
], S = new $I(A, this.dialectName).tokenize(E);
|
|
17452
17480
|
return this.cfg.postProcess ? this.cfg.postProcess(S) : S;
|
|
17453
17481
|
}
|
|
17454
17482
|
// These rules can be cached as they only depend on
|
|
@@ -17462,11 +17490,11 @@ class gI {
|
|
|
17462
17490
|
},
|
|
17463
17491
|
{
|
|
17464
17492
|
type: D.BLOCK_COMMENT,
|
|
17465
|
-
regex: E.nestedBlockComments ? new
|
|
17493
|
+
regex: E.nestedBlockComments ? new wI() : /(\/\*[^]*?\*\/)/uy
|
|
17466
17494
|
},
|
|
17467
17495
|
{
|
|
17468
17496
|
type: D.LINE_COMMENT,
|
|
17469
|
-
regex:
|
|
17497
|
+
regex: fI((R = E.lineCommentTypes) !== null && R !== void 0 ? R : ["--"])
|
|
17470
17498
|
},
|
|
17471
17499
|
{
|
|
17472
17500
|
type: D.QUOTED_IDENTIFIER,
|
|
@@ -17583,12 +17611,12 @@ class gI {
|
|
|
17583
17611
|
return this.validRules([
|
|
17584
17612
|
{
|
|
17585
17613
|
type: D.VARIABLE,
|
|
17586
|
-
regex: E.variableTypes ?
|
|
17614
|
+
regex: E.variableTypes ? KI(E.variableTypes) : void 0
|
|
17587
17615
|
},
|
|
17588
17616
|
{ type: D.STRING, regex: oT(E.stringTypes) },
|
|
17589
17617
|
{
|
|
17590
17618
|
type: D.IDENTIFIER,
|
|
17591
|
-
regex:
|
|
17619
|
+
regex: yI(E.identChars)
|
|
17592
17620
|
},
|
|
17593
17621
|
{ type: D.DELIMITER, regex: /[;]/uy },
|
|
17594
17622
|
{ type: D.COMMA, regex: /[,]/y },
|
|
@@ -17627,24 +17655,24 @@ class gI {
|
|
|
17627
17655
|
// These rules can't be blindly cached as the paramTypesOverrides object
|
|
17628
17656
|
// can differ on each invocation of the format() function.
|
|
17629
17657
|
buildParamRules(E, R) {
|
|
17630
|
-
var A, S, I,
|
|
17658
|
+
var A, S, I, e, N;
|
|
17631
17659
|
const n = {
|
|
17632
17660
|
named: (R == null ? void 0 : R.named) || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
|
|
17633
17661
|
quoted: (R == null ? void 0 : R.quoted) || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.quoted) || [],
|
|
17634
17662
|
numbered: (R == null ? void 0 : R.numbered) || ((I = E.paramTypes) === null || I === void 0 ? void 0 : I.numbered) || [],
|
|
17635
|
-
positional: typeof (R == null ? void 0 : R.positional) == "boolean" ? R.positional : (
|
|
17636
|
-
custom: (R == null ? void 0 : R.custom) || ((
|
|
17663
|
+
positional: typeof (R == null ? void 0 : R.positional) == "boolean" ? R.positional : (e = E.paramTypes) === null || e === void 0 ? void 0 : e.positional,
|
|
17664
|
+
custom: (R == null ? void 0 : R.custom) || ((N = E.paramTypes) === null || N === void 0 ? void 0 : N.custom) || []
|
|
17637
17665
|
};
|
|
17638
17666
|
return this.validRules([
|
|
17639
17667
|
{
|
|
17640
17668
|
type: D.NAMED_PARAMETER,
|
|
17641
|
-
regex: YE(n.named,
|
|
17669
|
+
regex: YE(n.named, dT(E.paramChars || E.identChars)),
|
|
17642
17670
|
key: (O) => O.slice(1)
|
|
17643
17671
|
},
|
|
17644
17672
|
{
|
|
17645
17673
|
type: D.QUOTED_PARAMETER,
|
|
17646
|
-
regex: YE(n.quoted,
|
|
17647
|
-
key: (O) => (({ tokenKey:
|
|
17674
|
+
regex: YE(n.quoted, pT(E.identTypes)),
|
|
17675
|
+
key: (O) => (({ tokenKey: s, quoteChar: t }) => s.replace(new RegExp(V("\\" + t), "gu"), t))({
|
|
17648
17676
|
tokenKey: O.slice(2, -1),
|
|
17649
17677
|
quoteChar: O.slice(-1)
|
|
17650
17678
|
})
|
|
@@ -17659,11 +17687,11 @@ class gI {
|
|
|
17659
17687
|
regex: n.positional ? /[?]/y : void 0
|
|
17660
17688
|
},
|
|
17661
17689
|
...n.custom.map((O) => {
|
|
17662
|
-
var
|
|
17690
|
+
var s;
|
|
17663
17691
|
return {
|
|
17664
17692
|
type: D.CUSTOM_PARAMETER,
|
|
17665
17693
|
regex: g(O.regex),
|
|
17666
|
-
key: (
|
|
17694
|
+
key: (s = O.key) !== null && s !== void 0 ? s : (t) => t
|
|
17667
17695
|
};
|
|
17668
17696
|
})
|
|
17669
17697
|
]);
|
|
@@ -17673,13 +17701,13 @@ class gI {
|
|
|
17673
17701
|
return E.filter((R) => !!R.regex);
|
|
17674
17702
|
}
|
|
17675
17703
|
}
|
|
17676
|
-
const F = (T) => j(T.toUpperCase()), MT = /* @__PURE__ */ new Map(),
|
|
17704
|
+
const F = (T) => j(T.toUpperCase()), MT = /* @__PURE__ */ new Map(), vI = (T) => {
|
|
17677
17705
|
let E = MT.get(T);
|
|
17678
|
-
return E || (E =
|
|
17679
|
-
},
|
|
17680
|
-
tokenizer: new
|
|
17681
|
-
formatOptions:
|
|
17682
|
-
}),
|
|
17706
|
+
return E || (E = QI(T), MT.set(T, E)), E;
|
|
17707
|
+
}, QI = (T) => ({
|
|
17708
|
+
tokenizer: new xI(T.tokenizerOptions, T.name),
|
|
17709
|
+
formatOptions: ZI(T.formatOptions)
|
|
17710
|
+
}), ZI = (T) => {
|
|
17683
17711
|
var E;
|
|
17684
17712
|
return {
|
|
17685
17713
|
alwaysDenseOperators: T.alwaysDenseOperators || [],
|
|
@@ -17687,13 +17715,13 @@ const F = (T) => j(T.toUpperCase()), MT = /* @__PURE__ */ new Map(), JI = (T) =>
|
|
|
17687
17715
|
tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((R) => [R, !0]))
|
|
17688
17716
|
};
|
|
17689
17717
|
};
|
|
17690
|
-
function
|
|
17718
|
+
function kI(T) {
|
|
17691
17719
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
|
|
17692
17720
|
}
|
|
17693
17721
|
function v(T) {
|
|
17694
17722
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
|
|
17695
17723
|
}
|
|
17696
|
-
class
|
|
17724
|
+
class qI {
|
|
17697
17725
|
constructor(E) {
|
|
17698
17726
|
this.params = E, this.index = 0;
|
|
17699
17727
|
}
|
|
@@ -17716,47 +17744,47 @@ class QI {
|
|
|
17716
17744
|
this.index = E;
|
|
17717
17745
|
}
|
|
17718
17746
|
}
|
|
17719
|
-
var
|
|
17720
|
-
function
|
|
17747
|
+
var jI = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
17748
|
+
function zI(T) {
|
|
17721
17749
|
return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
|
|
17722
17750
|
}
|
|
17723
|
-
var
|
|
17751
|
+
var hT = { exports: {} };
|
|
17724
17752
|
(function(T) {
|
|
17725
17753
|
(function(E, R) {
|
|
17726
17754
|
T.exports ? T.exports = R() : E.nearley = R();
|
|
17727
|
-
})(
|
|
17728
|
-
function E(O,
|
|
17729
|
-
return this.id = ++E.highestId, this.name = O, this.symbols =
|
|
17755
|
+
})(jI, function() {
|
|
17756
|
+
function E(O, s, t) {
|
|
17757
|
+
return this.id = ++E.highestId, this.name = O, this.symbols = s, this.postprocess = t, this;
|
|
17730
17758
|
}
|
|
17731
17759
|
E.highestId = 0, E.prototype.toString = function(O) {
|
|
17732
|
-
var
|
|
17733
|
-
return this.name + " → " +
|
|
17760
|
+
var s = typeof O > "u" ? this.symbols.map(n).join(" ") : this.symbols.slice(0, O).map(n).join(" ") + " ● " + this.symbols.slice(O).map(n).join(" ");
|
|
17761
|
+
return this.name + " → " + s;
|
|
17734
17762
|
};
|
|
17735
|
-
function R(O, t, C
|
|
17736
|
-
this.rule = O, this.dot =
|
|
17763
|
+
function R(O, s, t, C) {
|
|
17764
|
+
this.rule = O, this.dot = s, this.reference = t, this.data = [], this.wantedBy = C, this.isComplete = this.dot === O.symbols.length;
|
|
17737
17765
|
}
|
|
17738
17766
|
R.prototype.toString = function() {
|
|
17739
17767
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
17740
17768
|
}, R.prototype.nextState = function(O) {
|
|
17741
|
-
var
|
|
17742
|
-
return
|
|
17769
|
+
var s = new R(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
17770
|
+
return s.left = this, s.right = O, s.isComplete && (s.data = s.build(), s.right = void 0), s;
|
|
17743
17771
|
}, R.prototype.build = function() {
|
|
17744
|
-
var O = [],
|
|
17772
|
+
var O = [], s = this;
|
|
17745
17773
|
do
|
|
17746
|
-
O.push(
|
|
17747
|
-
while (
|
|
17774
|
+
O.push(s.right.data), s = s.left;
|
|
17775
|
+
while (s.left);
|
|
17748
17776
|
return O.reverse(), O;
|
|
17749
17777
|
}, R.prototype.finish = function() {
|
|
17750
|
-
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference,
|
|
17778
|
+
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, e.fail));
|
|
17751
17779
|
};
|
|
17752
|
-
function A(O,
|
|
17753
|
-
this.grammar = O, this.index =
|
|
17780
|
+
function A(O, s) {
|
|
17781
|
+
this.grammar = O, this.index = s, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
17754
17782
|
}
|
|
17755
17783
|
A.prototype.process = function(O) {
|
|
17756
|
-
for (var
|
|
17757
|
-
var a =
|
|
17784
|
+
for (var s = this.states, t = this.wants, C = this.completed, i = 0; i < s.length; i++) {
|
|
17785
|
+
var a = s[i];
|
|
17758
17786
|
if (a.isComplete) {
|
|
17759
|
-
if (a.finish(), a.data !==
|
|
17787
|
+
if (a.finish(), a.data !== e.fail) {
|
|
17760
17788
|
for (var U = a.wantedBy, o = U.length; o--; ) {
|
|
17761
17789
|
var G = U[o];
|
|
17762
17790
|
this.complete(G, a);
|
|
@@ -17772,45 +17800,45 @@ var dT = { exports: {} };
|
|
|
17772
17800
|
this.scannable.push(a);
|
|
17773
17801
|
continue;
|
|
17774
17802
|
}
|
|
17775
|
-
if (
|
|
17776
|
-
if (
|
|
17777
|
-
for (var H =
|
|
17803
|
+
if (t[P]) {
|
|
17804
|
+
if (t[P].push(a), C.hasOwnProperty(P))
|
|
17805
|
+
for (var H = C[P], o = 0; o < H.length; o++) {
|
|
17778
17806
|
var l = H[o];
|
|
17779
17807
|
this.complete(a, l);
|
|
17780
17808
|
}
|
|
17781
17809
|
} else
|
|
17782
|
-
|
|
17810
|
+
t[P] = [a], this.predict(P);
|
|
17783
17811
|
}
|
|
17784
17812
|
}
|
|
17785
17813
|
}, A.prototype.predict = function(O) {
|
|
17786
|
-
for (var
|
|
17787
|
-
var
|
|
17814
|
+
for (var s = this.grammar.byName[O] || [], t = 0; t < s.length; t++) {
|
|
17815
|
+
var C = s[t], i = this.wants[O], a = new R(C, 0, this.index, i);
|
|
17788
17816
|
this.states.push(a);
|
|
17789
17817
|
}
|
|
17790
|
-
}, A.prototype.complete = function(O,
|
|
17791
|
-
var
|
|
17792
|
-
this.states.push(
|
|
17818
|
+
}, A.prototype.complete = function(O, s) {
|
|
17819
|
+
var t = O.nextState(s);
|
|
17820
|
+
this.states.push(t);
|
|
17793
17821
|
};
|
|
17794
|
-
function S(O,
|
|
17795
|
-
this.rules = O, this.start =
|
|
17796
|
-
var
|
|
17797
|
-
this.rules.forEach(function(
|
|
17798
|
-
|
|
17822
|
+
function S(O, s) {
|
|
17823
|
+
this.rules = O, this.start = s || this.rules[0].name;
|
|
17824
|
+
var t = this.byName = {};
|
|
17825
|
+
this.rules.forEach(function(C) {
|
|
17826
|
+
t.hasOwnProperty(C.name) || (t[C.name] = []), t[C.name].push(C);
|
|
17799
17827
|
});
|
|
17800
17828
|
}
|
|
17801
|
-
S.fromCompiled = function(
|
|
17802
|
-
var
|
|
17803
|
-
|
|
17804
|
-
var
|
|
17829
|
+
S.fromCompiled = function(C, s) {
|
|
17830
|
+
var t = C.Lexer;
|
|
17831
|
+
C.ParserStart && (s = C.ParserStart, C = C.ParserRules);
|
|
17832
|
+
var C = C.map(function(a) {
|
|
17805
17833
|
return new E(a.name, a.symbols, a.postprocess);
|
|
17806
|
-
}), i = new S(
|
|
17807
|
-
return i.lexer =
|
|
17834
|
+
}), i = new S(C, s);
|
|
17835
|
+
return i.lexer = t, i;
|
|
17808
17836
|
};
|
|
17809
17837
|
function I() {
|
|
17810
17838
|
this.reset("");
|
|
17811
17839
|
}
|
|
17812
|
-
I.prototype.reset = function(O,
|
|
17813
|
-
this.buffer = O, this.index = 0, this.line =
|
|
17840
|
+
I.prototype.reset = function(O, s) {
|
|
17841
|
+
this.buffer = O, this.index = 0, this.line = s ? s.line : 1, this.lastLineBreak = s ? -s.col : 0;
|
|
17814
17842
|
}, I.prototype.next = function() {
|
|
17815
17843
|
if (this.index < this.buffer.length) {
|
|
17816
17844
|
var O = this.buffer[this.index++];
|
|
@@ -17822,144 +17850,144 @@ var dT = { exports: {} };
|
|
|
17822
17850
|
line: this.line,
|
|
17823
17851
|
col: this.index - this.lastLineBreak
|
|
17824
17852
|
};
|
|
17825
|
-
}, I.prototype.formatError = function(O,
|
|
17826
|
-
var
|
|
17827
|
-
if (typeof
|
|
17828
|
-
var
|
|
17853
|
+
}, I.prototype.formatError = function(O, s) {
|
|
17854
|
+
var t = this.buffer;
|
|
17855
|
+
if (typeof t == "string") {
|
|
17856
|
+
var C = t.split(`
|
|
17829
17857
|
`).slice(
|
|
17830
17858
|
Math.max(0, this.line - 5),
|
|
17831
17859
|
this.line
|
|
17832
|
-
), i =
|
|
17860
|
+
), i = t.indexOf(`
|
|
17833
17861
|
`, this.index);
|
|
17834
|
-
i === -1 && (i =
|
|
17862
|
+
i === -1 && (i = t.length);
|
|
17835
17863
|
var a = this.index - this.lastLineBreak, U = String(this.line).length;
|
|
17836
|
-
return
|
|
17864
|
+
return s += " at line " + this.line + " col " + a + `:
|
|
17837
17865
|
|
|
17838
|
-
`,
|
|
17839
|
-
return o(this.line -
|
|
17866
|
+
`, s += C.map(function(G, P) {
|
|
17867
|
+
return o(this.line - C.length + P + 1, U) + " " + G;
|
|
17840
17868
|
}, this).join(`
|
|
17841
|
-
`),
|
|
17869
|
+
`), s += `
|
|
17842
17870
|
` + o("", U + a) + `^
|
|
17843
|
-
`,
|
|
17871
|
+
`, s;
|
|
17844
17872
|
} else
|
|
17845
|
-
return
|
|
17873
|
+
return s + " at index " + (this.index - 1);
|
|
17846
17874
|
function o(G, P) {
|
|
17847
17875
|
var H = String(G);
|
|
17848
17876
|
return Array(P - H.length + 1).join(" ") + H;
|
|
17849
17877
|
}
|
|
17850
17878
|
};
|
|
17851
|
-
function
|
|
17879
|
+
function e(O, s, t) {
|
|
17852
17880
|
if (O instanceof S)
|
|
17853
|
-
var
|
|
17881
|
+
var C = O, t = s;
|
|
17854
17882
|
else
|
|
17855
|
-
var
|
|
17856
|
-
this.grammar =
|
|
17883
|
+
var C = S.fromCompiled(O, s);
|
|
17884
|
+
this.grammar = C, this.options = {
|
|
17857
17885
|
keepHistory: !1,
|
|
17858
|
-
lexer:
|
|
17886
|
+
lexer: C.lexer || new I()
|
|
17859
17887
|
};
|
|
17860
|
-
for (var i in
|
|
17861
|
-
this.options[i] =
|
|
17888
|
+
for (var i in t || {})
|
|
17889
|
+
this.options[i] = t[i];
|
|
17862
17890
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
17863
|
-
var a = new A(
|
|
17864
|
-
this.table = [a], a.wants[
|
|
17891
|
+
var a = new A(C, 0);
|
|
17892
|
+
this.table = [a], a.wants[C.start] = [], a.predict(C.start), a.process(), this.current = 0;
|
|
17865
17893
|
}
|
|
17866
|
-
|
|
17867
|
-
var
|
|
17868
|
-
|
|
17869
|
-
for (var
|
|
17894
|
+
e.fail = {}, e.prototype.feed = function(O) {
|
|
17895
|
+
var s = this.lexer;
|
|
17896
|
+
s.reset(O, this.lexerState);
|
|
17897
|
+
for (var t; ; ) {
|
|
17870
17898
|
try {
|
|
17871
|
-
if (
|
|
17899
|
+
if (t = s.next(), !t)
|
|
17872
17900
|
break;
|
|
17873
17901
|
} catch (p) {
|
|
17874
17902
|
var U = new A(this.grammar, this.current + 1);
|
|
17875
17903
|
this.table.push(U);
|
|
17876
|
-
var
|
|
17877
|
-
throw
|
|
17904
|
+
var C = new Error(this.reportLexerError(p));
|
|
17905
|
+
throw C.offset = this.current, C.token = p.token, C;
|
|
17878
17906
|
}
|
|
17879
17907
|
var i = this.table[this.current];
|
|
17880
17908
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
17881
17909
|
var a = this.current + 1, U = new A(this.grammar, a);
|
|
17882
17910
|
this.table.push(U);
|
|
17883
|
-
for (var o =
|
|
17911
|
+
for (var o = t.text !== void 0 ? t.text : t.value, G = s.constructor === I ? t.value : t, P = i.scannable, H = P.length; H--; ) {
|
|
17884
17912
|
var l = P[H], B = l.rule.symbols[l.dot];
|
|
17885
|
-
if (B.test ? B.test(G) : B.type ? B.type ===
|
|
17886
|
-
var u = l.nextState({ data: G, token:
|
|
17913
|
+
if (B.test ? B.test(G) : B.type ? B.type === t.type : B.literal === o) {
|
|
17914
|
+
var u = l.nextState({ data: G, token: t, isToken: !0, reference: a - 1 });
|
|
17887
17915
|
U.states.push(u);
|
|
17888
17916
|
}
|
|
17889
17917
|
}
|
|
17890
17918
|
if (U.process(), U.states.length === 0) {
|
|
17891
|
-
var
|
|
17892
|
-
throw
|
|
17919
|
+
var C = new Error(this.reportError(t));
|
|
17920
|
+
throw C.offset = this.current, C.token = t, C;
|
|
17893
17921
|
}
|
|
17894
|
-
this.options.keepHistory && (i.lexerState =
|
|
17922
|
+
this.options.keepHistory && (i.lexerState = s.save()), this.current++;
|
|
17895
17923
|
}
|
|
17896
|
-
return i && (this.lexerState =
|
|
17897
|
-
},
|
|
17898
|
-
var t, C
|
|
17899
|
-
return
|
|
17900
|
-
},
|
|
17901
|
-
var
|
|
17902
|
-
return this.reportErrorCommon(
|
|
17903
|
-
},
|
|
17904
|
-
var
|
|
17905
|
-
|
|
17906
|
-
var
|
|
17924
|
+
return i && (this.lexerState = s.save()), this.results = this.finish(), this;
|
|
17925
|
+
}, e.prototype.reportLexerError = function(O) {
|
|
17926
|
+
var s, t, C = O.token;
|
|
17927
|
+
return C ? (s = "input " + JSON.stringify(C.text[0]) + " (lexer error)", t = this.lexer.formatError(C, "Syntax error")) : (s = "input (lexer error)", t = O.message), this.reportErrorCommon(t, s);
|
|
17928
|
+
}, e.prototype.reportError = function(O) {
|
|
17929
|
+
var s = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), t = this.lexer.formatError(O, "Syntax error");
|
|
17930
|
+
return this.reportErrorCommon(t, s);
|
|
17931
|
+
}, e.prototype.reportErrorCommon = function(O, s) {
|
|
17932
|
+
var t = [];
|
|
17933
|
+
t.push(O);
|
|
17934
|
+
var C = this.table.length - 2, i = this.table[C], a = i.states.filter(function(o) {
|
|
17907
17935
|
var G = o.rule.symbols[o.dot];
|
|
17908
17936
|
return G && typeof G != "string";
|
|
17909
17937
|
});
|
|
17910
17938
|
if (a.length === 0)
|
|
17911
|
-
|
|
17912
|
-
`), this.displayStateStack(i.states,
|
|
17939
|
+
t.push("Unexpected " + s + `. I did not expect any more input. Here is the state of my parse table:
|
|
17940
|
+
`), this.displayStateStack(i.states, t);
|
|
17913
17941
|
else {
|
|
17914
|
-
|
|
17942
|
+
t.push("Unexpected " + s + `. Instead, I was expecting to see one of the following:
|
|
17915
17943
|
`);
|
|
17916
17944
|
var U = a.map(function(o) {
|
|
17917
17945
|
return this.buildFirstStateStack(o, []) || [o];
|
|
17918
17946
|
}, this);
|
|
17919
17947
|
U.forEach(function(o) {
|
|
17920
17948
|
var G = o[0], P = G.rule.symbols[G.dot], H = this.getSymbolDisplay(P);
|
|
17921
|
-
|
|
17949
|
+
t.push("A " + H + " based on:"), this.displayStateStack(o, t);
|
|
17922
17950
|
}, this);
|
|
17923
17951
|
}
|
|
17924
|
-
return
|
|
17952
|
+
return t.push(""), t.join(`
|
|
17925
17953
|
`);
|
|
17926
|
-
},
|
|
17927
|
-
for (var
|
|
17954
|
+
}, e.prototype.displayStateStack = function(O, s) {
|
|
17955
|
+
for (var t, C = 0, i = 0; i < O.length; i++) {
|
|
17928
17956
|
var a = O[i], U = a.rule.toString(a.dot);
|
|
17929
|
-
U ===
|
|
17957
|
+
U === t ? C++ : (C > 0 && s.push(" ^ " + C + " more lines identical to this"), C = 0, s.push(" " + U)), t = U;
|
|
17930
17958
|
}
|
|
17931
|
-
},
|
|
17932
|
-
return
|
|
17933
|
-
},
|
|
17934
|
-
if (
|
|
17959
|
+
}, e.prototype.getSymbolDisplay = function(O) {
|
|
17960
|
+
return N(O);
|
|
17961
|
+
}, e.prototype.buildFirstStateStack = function(O, s) {
|
|
17962
|
+
if (s.indexOf(O) !== -1)
|
|
17935
17963
|
return null;
|
|
17936
17964
|
if (O.wantedBy.length === 0)
|
|
17937
17965
|
return [O];
|
|
17938
|
-
var
|
|
17966
|
+
var t = O.wantedBy[0], C = [O].concat(s), i = this.buildFirstStateStack(t, C);
|
|
17939
17967
|
return i === null ? null : [O].concat(i);
|
|
17940
|
-
},
|
|
17968
|
+
}, e.prototype.save = function() {
|
|
17941
17969
|
var O = this.table[this.current];
|
|
17942
17970
|
return O.lexerState = this.lexerState, O;
|
|
17943
|
-
},
|
|
17944
|
-
var
|
|
17945
|
-
this.current =
|
|
17946
|
-
},
|
|
17971
|
+
}, e.prototype.restore = function(O) {
|
|
17972
|
+
var s = O.index;
|
|
17973
|
+
this.current = s, this.table[s] = O, this.table.splice(s + 1), this.lexerState = O.lexerState, this.results = this.finish();
|
|
17974
|
+
}, e.prototype.rewind = function(O) {
|
|
17947
17975
|
if (!this.options.keepHistory)
|
|
17948
17976
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
17949
17977
|
this.restore(this.table[O]);
|
|
17950
|
-
},
|
|
17951
|
-
var O = [],
|
|
17952
|
-
return
|
|
17953
|
-
|
|
17954
|
-
}), O.map(function(
|
|
17955
|
-
return
|
|
17978
|
+
}, e.prototype.finish = function() {
|
|
17979
|
+
var O = [], s = this.grammar.start, t = this.table[this.table.length - 1];
|
|
17980
|
+
return t.states.forEach(function(C) {
|
|
17981
|
+
C.rule.name === s && C.dot === C.rule.symbols.length && C.reference === 0 && C.data !== e.fail && O.push(C);
|
|
17982
|
+
}), O.map(function(C) {
|
|
17983
|
+
return C.data;
|
|
17956
17984
|
});
|
|
17957
17985
|
};
|
|
17958
|
-
function
|
|
17959
|
-
var
|
|
17960
|
-
if (
|
|
17986
|
+
function N(O) {
|
|
17987
|
+
var s = typeof O;
|
|
17988
|
+
if (s === "string")
|
|
17961
17989
|
return O;
|
|
17962
|
-
if (
|
|
17990
|
+
if (s === "object") {
|
|
17963
17991
|
if (O.literal)
|
|
17964
17992
|
return JSON.stringify(O.literal);
|
|
17965
17993
|
if (O instanceof RegExp)
|
|
@@ -17972,10 +18000,10 @@ var dT = { exports: {} };
|
|
|
17972
18000
|
}
|
|
17973
18001
|
}
|
|
17974
18002
|
function n(O) {
|
|
17975
|
-
var
|
|
17976
|
-
if (
|
|
18003
|
+
var s = typeof O;
|
|
18004
|
+
if (s === "string")
|
|
17977
18005
|
return O;
|
|
17978
|
-
if (
|
|
18006
|
+
if (s === "object") {
|
|
17979
18007
|
if (O.literal)
|
|
17980
18008
|
return JSON.stringify(O.literal);
|
|
17981
18009
|
if (O instanceof RegExp)
|
|
@@ -17988,20 +18016,20 @@ var dT = { exports: {} };
|
|
|
17988
18016
|
}
|
|
17989
18017
|
}
|
|
17990
18018
|
return {
|
|
17991
|
-
Parser:
|
|
18019
|
+
Parser: e,
|
|
17992
18020
|
Grammar: S,
|
|
17993
18021
|
Rule: E
|
|
17994
18022
|
};
|
|
17995
18023
|
});
|
|
17996
|
-
})(
|
|
17997
|
-
var
|
|
17998
|
-
const
|
|
17999
|
-
function
|
|
18000
|
-
return T.map(
|
|
18024
|
+
})(hT);
|
|
18025
|
+
var EO = hT.exports;
|
|
18026
|
+
const TO = /* @__PURE__ */ zI(EO);
|
|
18027
|
+
function RO(T) {
|
|
18028
|
+
return T.map(AO).map(SO).map(IO).map(OO).map(eO);
|
|
18001
18029
|
}
|
|
18002
|
-
const
|
|
18003
|
-
if (
|
|
18004
|
-
const A =
|
|
18030
|
+
const AO = (T, E, R) => {
|
|
18031
|
+
if (FT(T.type)) {
|
|
18032
|
+
const A = NO(R, E);
|
|
18005
18033
|
if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
|
|
18006
18034
|
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
18007
18035
|
const S = Z(R, E);
|
|
@@ -18009,41 +18037,41 @@ const EO = (T, E, R) => {
|
|
|
18009
18037
|
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
18010
18038
|
}
|
|
18011
18039
|
return T;
|
|
18012
|
-
},
|
|
18040
|
+
}, SO = (T, E, R) => {
|
|
18013
18041
|
if (T.type === D.RESERVED_FUNCTION_NAME) {
|
|
18014
18042
|
const A = Z(R, E);
|
|
18015
|
-
if (!A || !
|
|
18043
|
+
if (!A || !WT(A))
|
|
18016
18044
|
return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
|
|
18017
18045
|
}
|
|
18018
18046
|
return T;
|
|
18019
|
-
},
|
|
18047
|
+
}, IO = (T, E, R) => {
|
|
18020
18048
|
if (T.type === D.RESERVED_DATA_TYPE) {
|
|
18021
18049
|
const A = Z(R, E);
|
|
18022
|
-
if (A &&
|
|
18050
|
+
if (A && WT(A))
|
|
18023
18051
|
return Object.assign(Object.assign({}, T), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
18024
18052
|
}
|
|
18025
18053
|
return T;
|
|
18026
|
-
},
|
|
18054
|
+
}, OO = (T, E, R) => {
|
|
18027
18055
|
if (T.type === D.IDENTIFIER) {
|
|
18028
18056
|
const A = Z(R, E);
|
|
18029
|
-
if (A &&
|
|
18057
|
+
if (A && fT(A))
|
|
18030
18058
|
return Object.assign(Object.assign({}, T), { type: D.ARRAY_IDENTIFIER });
|
|
18031
18059
|
}
|
|
18032
18060
|
return T;
|
|
18033
|
-
},
|
|
18061
|
+
}, eO = (T, E, R) => {
|
|
18034
18062
|
if (T.type === D.RESERVED_DATA_TYPE) {
|
|
18035
18063
|
const A = Z(R, E);
|
|
18036
|
-
if (A &&
|
|
18064
|
+
if (A && fT(A))
|
|
18037
18065
|
return Object.assign(Object.assign({}, T), { type: D.ARRAY_KEYWORD });
|
|
18038
18066
|
}
|
|
18039
18067
|
return T;
|
|
18040
|
-
},
|
|
18068
|
+
}, NO = (T, E) => Z(T, E, -1), Z = (T, E, R = 1) => {
|
|
18041
18069
|
let A = 1;
|
|
18042
|
-
for (; T[E + A * R] &&
|
|
18070
|
+
for (; T[E + A * R] && tO(T[E + A * R]); )
|
|
18043
18071
|
A++;
|
|
18044
18072
|
return T[E + A * R];
|
|
18045
|
-
},
|
|
18046
|
-
class
|
|
18073
|
+
}, WT = (T) => T.type === D.OPEN_PAREN && T.text === "(", fT = (T) => T.type === D.OPEN_PAREN && T.text === "[", tO = (T) => T.type === D.BLOCK_COMMENT || T.type === D.LINE_COMMENT;
|
|
18074
|
+
class XT {
|
|
18047
18075
|
constructor(E) {
|
|
18048
18076
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
18049
18077
|
}
|
|
@@ -18056,7 +18084,7 @@ class WT {
|
|
|
18056
18084
|
save() {
|
|
18057
18085
|
}
|
|
18058
18086
|
formatError(E) {
|
|
18059
|
-
const { line: R, col: A } =
|
|
18087
|
+
const { line: R, col: A } = VT(this.input, E.start);
|
|
18060
18088
|
return `Parse error at token: ${E.text} at line ${R} column ${A}`;
|
|
18061
18089
|
}
|
|
18062
18090
|
has(E) {
|
|
@@ -18070,7 +18098,7 @@ var M;
|
|
|
18070
18098
|
function mE(T) {
|
|
18071
18099
|
return T[0];
|
|
18072
18100
|
}
|
|
18073
|
-
const c = new
|
|
18101
|
+
const c = new XT((T) => []), b = ([[T]]) => T, Y = (T) => ({
|
|
18074
18102
|
type: M.keyword,
|
|
18075
18103
|
tokenType: T.type,
|
|
18076
18104
|
text: T.text,
|
|
@@ -18079,7 +18107,7 @@ const c = new WT((T) => []), b = ([[T]]) => T, Y = (T) => ({
|
|
|
18079
18107
|
type: M.data_type,
|
|
18080
18108
|
text: T.text,
|
|
18081
18109
|
raw: T.raw
|
|
18082
|
-
}), m = (T, { leading: E, trailing: R }) => (E != null && E.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R != null && R.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T),
|
|
18110
|
+
}), m = (T, { leading: E, trailing: R }) => (E != null && E.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R != null && R.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), sO = (T, { leading: E, trailing: R }) => {
|
|
18083
18111
|
if (E != null && E.length) {
|
|
18084
18112
|
const [A, ...S] = T;
|
|
18085
18113
|
T = [m(A, { leading: E }), ...S];
|
|
@@ -18089,7 +18117,7 @@ const c = new WT((T) => []), b = ([[T]]) => T, Y = (T) => ({
|
|
|
18089
18117
|
T = [...A, m(S, { trailing: R })];
|
|
18090
18118
|
}
|
|
18091
18119
|
return T;
|
|
18092
|
-
},
|
|
18120
|
+
}, CO = {
|
|
18093
18121
|
Lexer: c,
|
|
18094
18122
|
ParserRules: [
|
|
18095
18123
|
{ name: "main$ebnf$1", symbols: [] },
|
|
@@ -18351,12 +18379,12 @@ const c = new WT((T) => []), b = ([[T]]) => T, Y = (T) => ({
|
|
|
18351
18379
|
{
|
|
18352
18380
|
name: "between_predicate",
|
|
18353
18381
|
symbols: [c.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", c.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
|
|
18354
|
-
postprocess: ([T, E, R, A, S, I,
|
|
18382
|
+
postprocess: ([T, E, R, A, S, I, e]) => ({
|
|
18355
18383
|
type: M.between_predicate,
|
|
18356
18384
|
betweenKw: Y(T),
|
|
18357
|
-
expr1:
|
|
18385
|
+
expr1: sO(R, { leading: E, trailing: A }),
|
|
18358
18386
|
andKw: Y(S),
|
|
18359
|
-
expr2: [m(
|
|
18387
|
+
expr2: [m(e, { leading: I })]
|
|
18360
18388
|
})
|
|
18361
18389
|
},
|
|
18362
18390
|
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: mE },
|
|
@@ -18485,21 +18513,21 @@ const c = new WT((T) => []), b = ([[T]]) => T, Y = (T) => ({
|
|
|
18485
18513
|
}
|
|
18486
18514
|
],
|
|
18487
18515
|
ParserStart: "main"
|
|
18488
|
-
}, { Parser:
|
|
18489
|
-
function
|
|
18516
|
+
}, { Parser: LO, Grammar: _O } = TO;
|
|
18517
|
+
function rO(T) {
|
|
18490
18518
|
let E = {};
|
|
18491
|
-
const R = new
|
|
18492
|
-
...
|
|
18493
|
-
|
|
18494
|
-
]), A = new
|
|
18519
|
+
const R = new XT((S) => [
|
|
18520
|
+
...RO(T.tokenize(S, E)),
|
|
18521
|
+
uT(S.length)
|
|
18522
|
+
]), A = new LO(_O.fromCompiled(CO), { lexer: R });
|
|
18495
18523
|
return {
|
|
18496
18524
|
parse: (S, I) => {
|
|
18497
18525
|
E = I;
|
|
18498
|
-
const { results:
|
|
18499
|
-
if (
|
|
18500
|
-
return
|
|
18501
|
-
throw
|
|
18502
|
-
${JSON.stringify(
|
|
18526
|
+
const { results: e } = A.feed(S);
|
|
18527
|
+
if (e.length === 1)
|
|
18528
|
+
return e[0];
|
|
18529
|
+
throw e.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
|
|
18530
|
+
${JSON.stringify(e, void 0, 2)}`);
|
|
18503
18531
|
}
|
|
18504
18532
|
};
|
|
18505
18533
|
}
|
|
@@ -18507,7 +18535,7 @@ var r;
|
|
|
18507
18535
|
(function(T) {
|
|
18508
18536
|
T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
18509
18537
|
})(r = r || (r = {}));
|
|
18510
|
-
class
|
|
18538
|
+
class bT {
|
|
18511
18539
|
constructor(E) {
|
|
18512
18540
|
this.indentation = E, this.items = [];
|
|
18513
18541
|
}
|
|
@@ -18543,11 +18571,11 @@ class fT {
|
|
|
18543
18571
|
}
|
|
18544
18572
|
}
|
|
18545
18573
|
trimHorizontalWhitespace() {
|
|
18546
|
-
for (;
|
|
18574
|
+
for (; nO(k(this.items)); )
|
|
18547
18575
|
this.items.pop();
|
|
18548
18576
|
}
|
|
18549
18577
|
trimWhitespace() {
|
|
18550
|
-
for (;
|
|
18578
|
+
for (; DO(k(this.items)); )
|
|
18551
18579
|
this.items.pop();
|
|
18552
18580
|
}
|
|
18553
18581
|
addNewline(E) {
|
|
@@ -18594,7 +18622,7 @@ class fT {
|
|
|
18594
18622
|
}
|
|
18595
18623
|
}
|
|
18596
18624
|
}
|
|
18597
|
-
const
|
|
18625
|
+
const nO = (T) => T === r.SPACE || T === r.SINGLE_INDENT, DO = (T) => T === r.SPACE || T === r.SINGLE_INDENT || T === r.NEWLINE;
|
|
18598
18626
|
function GT(T, E) {
|
|
18599
18627
|
if (E === "standard")
|
|
18600
18628
|
return T;
|
|
@@ -18602,10 +18630,10 @@ function GT(T, E) {
|
|
|
18602
18630
|
return T.length >= 10 && T.includes(" ") && ([T, ...R] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...R].join(" ");
|
|
18603
18631
|
}
|
|
18604
18632
|
function cT(T) {
|
|
18605
|
-
return
|
|
18633
|
+
return iR(T) || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.LIMIT;
|
|
18606
18634
|
}
|
|
18607
|
-
const pE = "top-level",
|
|
18608
|
-
class
|
|
18635
|
+
const pE = "top-level", iO = "block-level";
|
|
18636
|
+
class KT {
|
|
18609
18637
|
/**
|
|
18610
18638
|
* @param {string} indent A string to indent with
|
|
18611
18639
|
*/
|
|
@@ -18634,7 +18662,7 @@ class XT {
|
|
|
18634
18662
|
* Increases indentation by one block-level indent.
|
|
18635
18663
|
*/
|
|
18636
18664
|
increaseBlockLevel() {
|
|
18637
|
-
this.indentTypes.push(
|
|
18665
|
+
this.indentTypes.push(iO);
|
|
18638
18666
|
}
|
|
18639
18667
|
/**
|
|
18640
18668
|
* Decreases indentation by one top-level indent.
|
|
@@ -18653,9 +18681,9 @@ class XT {
|
|
|
18653
18681
|
;
|
|
18654
18682
|
}
|
|
18655
18683
|
}
|
|
18656
|
-
class
|
|
18684
|
+
class PO extends bT {
|
|
18657
18685
|
constructor(E) {
|
|
18658
|
-
super(new
|
|
18686
|
+
super(new KT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
18659
18687
|
}
|
|
18660
18688
|
add(...E) {
|
|
18661
18689
|
if (E.forEach((R) => this.addToLength(R)), this.length > this.expressionWidth)
|
|
@@ -18897,7 +18925,7 @@ class TE {
|
|
|
18897
18925
|
cfg: this.cfg,
|
|
18898
18926
|
dialectCfg: this.dialectCfg,
|
|
18899
18927
|
params: this.params,
|
|
18900
|
-
layout: new
|
|
18928
|
+
layout: new PO(this.cfg.expressionWidth),
|
|
18901
18929
|
inline: !0
|
|
18902
18930
|
}).format(E);
|
|
18903
18931
|
} catch (A) {
|
|
@@ -18983,9 +19011,9 @@ class TE {
|
|
|
18983
19011
|
}
|
|
18984
19012
|
}
|
|
18985
19013
|
}
|
|
18986
|
-
class
|
|
19014
|
+
class oO {
|
|
18987
19015
|
constructor(E, R) {
|
|
18988
|
-
this.dialect = E, this.cfg = R, this.params = new
|
|
19016
|
+
this.dialect = E, this.cfg = R, this.params = new qI(this.cfg.params);
|
|
18989
19017
|
}
|
|
18990
19018
|
/**
|
|
18991
19019
|
* Formats an SQL query.
|
|
@@ -18997,7 +19025,7 @@ class DO {
|
|
|
18997
19025
|
return this.formatAst(R).trimEnd();
|
|
18998
19026
|
}
|
|
18999
19027
|
parse(E) {
|
|
19000
|
-
return
|
|
19028
|
+
return rO(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
|
|
19001
19029
|
}
|
|
19002
19030
|
formatAst(E) {
|
|
19003
19031
|
return E.map((R) => this.formatStatement(R)).join(`
|
|
@@ -19008,14 +19036,14 @@ class DO {
|
|
|
19008
19036
|
cfg: this.cfg,
|
|
19009
19037
|
dialectCfg: this.dialect.formatOptions,
|
|
19010
19038
|
params: this.params,
|
|
19011
|
-
layout: new
|
|
19039
|
+
layout: new bT(new KT(kI(this.cfg)))
|
|
19012
19040
|
}).format(E.children);
|
|
19013
19041
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(r.NEWLINE, ";") : R.add(r.NO_NEWLINE, ";")), R.toString();
|
|
19014
19042
|
}
|
|
19015
19043
|
}
|
|
19016
19044
|
class z extends Error {
|
|
19017
19045
|
}
|
|
19018
|
-
function
|
|
19046
|
+
function aO(T) {
|
|
19019
19047
|
const E = [
|
|
19020
19048
|
"multilineLists",
|
|
19021
19049
|
"newlineBeforeOpenParen",
|
|
@@ -19029,17 +19057,17 @@ function iO(T) {
|
|
|
19029
19057
|
throw new z(`${R} config is no more supported.`);
|
|
19030
19058
|
if (T.expressionWidth <= 0)
|
|
19031
19059
|
throw new z(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
19032
|
-
if (T.params && !
|
|
19060
|
+
if (T.params && !MO(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !UO(T.paramTypes))
|
|
19033
19061
|
throw new z("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
19034
19062
|
return T;
|
|
19035
19063
|
}
|
|
19036
|
-
function
|
|
19064
|
+
function MO(T) {
|
|
19037
19065
|
return (T instanceof Array ? T : Object.values(T)).every((R) => typeof R == "string");
|
|
19038
19066
|
}
|
|
19039
|
-
function
|
|
19067
|
+
function UO(T) {
|
|
19040
19068
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
19041
19069
|
}
|
|
19042
|
-
var
|
|
19070
|
+
var GO = function(T, E) {
|
|
19043
19071
|
var R = {};
|
|
19044
19072
|
for (var A in T) Object.prototype.hasOwnProperty.call(T, A) && E.indexOf(A) < 0 && (R[A] = T[A]);
|
|
19045
19073
|
if (T != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -19047,7 +19075,7 @@ var aO = function(T, E) {
|
|
|
19047
19075
|
E.indexOf(A[S]) < 0 && Object.prototype.propertyIsEnumerable.call(T, A[S]) && (R[A[S]] = T[A[S]]);
|
|
19048
19076
|
return R;
|
|
19049
19077
|
};
|
|
19050
|
-
const
|
|
19078
|
+
const yT = {
|
|
19051
19079
|
bigquery: "bigquery",
|
|
19052
19080
|
db2: "db2",
|
|
19053
19081
|
db2i: "db2i",
|
|
@@ -19068,7 +19096,7 @@ const bT = {
|
|
|
19068
19096
|
tsql: "transactsql",
|
|
19069
19097
|
singlestoredb: "singlestoredb",
|
|
19070
19098
|
snowflake: "snowflake"
|
|
19071
|
-
},
|
|
19099
|
+
}, cO = Object.keys(yT), lO = {
|
|
19072
19100
|
tabWidth: 2,
|
|
19073
19101
|
useTabs: !1,
|
|
19074
19102
|
keywordCase: "preserve",
|
|
@@ -19081,25 +19109,27 @@ const bT = {
|
|
|
19081
19109
|
linesBetweenQueries: 1,
|
|
19082
19110
|
denseOperators: !1,
|
|
19083
19111
|
newlineBeforeSemicolon: !1
|
|
19084
|
-
},
|
|
19085
|
-
if (typeof E.language == "string" && !
|
|
19112
|
+
}, HO = (T, E = {}) => {
|
|
19113
|
+
if (typeof E.language == "string" && !cO.includes(E.language))
|
|
19086
19114
|
throw new z(`Unsupported SQL dialect: ${E.language}`);
|
|
19087
|
-
const R =
|
|
19088
|
-
return
|
|
19089
|
-
},
|
|
19090
|
-
var { dialect: R } = E, A =
|
|
19115
|
+
const R = yT[E.language || "sql"];
|
|
19116
|
+
return BO(T, Object.assign(Object.assign({}, E), { dialect: dI[R] }));
|
|
19117
|
+
}, BO = (T, E) => {
|
|
19118
|
+
var { dialect: R } = E, A = GO(E, ["dialect"]);
|
|
19091
19119
|
if (typeof T != "string")
|
|
19092
19120
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
|
|
19093
|
-
const S =
|
|
19094
|
-
return new
|
|
19121
|
+
const S = aO(Object.assign(Object.assign({}, lO), A));
|
|
19122
|
+
return new oO(vI(R), S).format(T);
|
|
19095
19123
|
};
|
|
19096
19124
|
function lT(T, E) {
|
|
19097
19125
|
try {
|
|
19098
|
-
return
|
|
19126
|
+
return HO(T, {
|
|
19099
19127
|
language: {
|
|
19100
19128
|
postgres: "postgresql",
|
|
19101
19129
|
mysql: "mysql",
|
|
19102
|
-
sqlite: "sqlite"
|
|
19130
|
+
sqlite: "sqlite",
|
|
19131
|
+
singlestore: "mysql"
|
|
19132
|
+
// SingleStore uses MySQL dialect for formatting
|
|
19103
19133
|
}[E],
|
|
19104
19134
|
tabWidth: 2,
|
|
19105
19135
|
keywordCase: "upper",
|
|
@@ -19178,7 +19208,7 @@ class bE {
|
|
|
19178
19208
|
async execute(E, R) {
|
|
19179
19209
|
if (!this.dbExecutor)
|
|
19180
19210
|
throw new Error("Database executor not configured");
|
|
19181
|
-
return new
|
|
19211
|
+
return new sE(this.dbExecutor).execute(this.cubes, E, R);
|
|
19182
19212
|
}
|
|
19183
19213
|
/**
|
|
19184
19214
|
* Execute a multi-cube query
|
|
@@ -19205,6 +19235,22 @@ class bE {
|
|
|
19205
19235
|
const R = Array.from(this.cubes.values()).map((A) => this.generateCubeMetadata(A));
|
|
19206
19236
|
return this.metadataCache = R, this.metadataCacheTimestamp = E, R;
|
|
19207
19237
|
}
|
|
19238
|
+
/**
|
|
19239
|
+
* Extract column name from Drizzle column reference
|
|
19240
|
+
* Handles different column types and extracts the actual column name
|
|
19241
|
+
*/
|
|
19242
|
+
getColumnName(E) {
|
|
19243
|
+
if (E && E.name || E && E.columnType && E.name)
|
|
19244
|
+
return E.name;
|
|
19245
|
+
if (typeof E == "string")
|
|
19246
|
+
return E;
|
|
19247
|
+
if (E && typeof E == "object") {
|
|
19248
|
+
if (E._.name) return E._.name;
|
|
19249
|
+
if (E.name) return E.name;
|
|
19250
|
+
if (E.columnName) return E.columnName;
|
|
19251
|
+
}
|
|
19252
|
+
return "unknown_column";
|
|
19253
|
+
}
|
|
19208
19254
|
/**
|
|
19209
19255
|
* Generate cube metadata for API responses from cubes
|
|
19210
19256
|
* Optimized version that minimizes object iterations
|
|
@@ -19212,37 +19258,51 @@ class bE {
|
|
|
19212
19258
|
generateCubeMetadata(E) {
|
|
19213
19259
|
const R = Object.keys(E.measures), A = Object.keys(E.dimensions), S = new Array(R.length), I = new Array(A.length);
|
|
19214
19260
|
for (let N = 0; N < R.length; N++) {
|
|
19215
|
-
const
|
|
19261
|
+
const n = R[N], O = E.measures[n];
|
|
19216
19262
|
S[N] = {
|
|
19217
|
-
name: `${E.name}.${
|
|
19218
|
-
title:
|
|
19219
|
-
shortTitle:
|
|
19220
|
-
type:
|
|
19263
|
+
name: `${E.name}.${n}`,
|
|
19264
|
+
title: O.title || n,
|
|
19265
|
+
shortTitle: O.title || n,
|
|
19266
|
+
type: O.type,
|
|
19221
19267
|
format: void 0,
|
|
19222
19268
|
// Measure doesn't have format field
|
|
19223
|
-
description:
|
|
19269
|
+
description: O.description
|
|
19224
19270
|
};
|
|
19225
19271
|
}
|
|
19226
19272
|
for (let N = 0; N < A.length; N++) {
|
|
19227
|
-
const
|
|
19273
|
+
const n = A[N], O = E.dimensions[n];
|
|
19228
19274
|
I[N] = {
|
|
19229
|
-
name: `${E.name}.${
|
|
19230
|
-
title:
|
|
19231
|
-
shortTitle:
|
|
19232
|
-
type:
|
|
19275
|
+
name: `${E.name}.${n}`,
|
|
19276
|
+
title: O.title || n,
|
|
19277
|
+
shortTitle: O.title || n,
|
|
19278
|
+
type: O.type,
|
|
19233
19279
|
format: void 0,
|
|
19234
19280
|
// Dimension doesn't have format field
|
|
19235
|
-
description:
|
|
19281
|
+
description: O.description
|
|
19236
19282
|
};
|
|
19237
19283
|
}
|
|
19284
|
+
const e = [];
|
|
19285
|
+
if (E.joins)
|
|
19286
|
+
for (const [, N] of Object.entries(E.joins)) {
|
|
19287
|
+
const n = typeof N.targetCube == "function" ? N.targetCube() : N.targetCube;
|
|
19288
|
+
e.push({
|
|
19289
|
+
targetCube: n.name,
|
|
19290
|
+
relationship: N.relationship,
|
|
19291
|
+
joinFields: N.on.map((O) => ({
|
|
19292
|
+
sourceField: this.getColumnName(O.source),
|
|
19293
|
+
targetField: this.getColumnName(O.target)
|
|
19294
|
+
}))
|
|
19295
|
+
});
|
|
19296
|
+
}
|
|
19238
19297
|
return {
|
|
19239
19298
|
name: E.name,
|
|
19240
19299
|
title: E.title || E.name,
|
|
19241
19300
|
description: E.description,
|
|
19242
19301
|
measures: S,
|
|
19243
19302
|
dimensions: I,
|
|
19244
|
-
segments: []
|
|
19303
|
+
segments: [],
|
|
19245
19304
|
// Add segments support later if needed
|
|
19305
|
+
relationships: e.length > 0 ? e : void 0
|
|
19246
19306
|
};
|
|
19247
19307
|
}
|
|
19248
19308
|
/**
|
|
@@ -19254,10 +19314,10 @@ class bE {
|
|
|
19254
19314
|
throw new Error(`Cube '${E}' not found`);
|
|
19255
19315
|
if (!this.dbExecutor)
|
|
19256
19316
|
throw new Error("Database executor not configured");
|
|
19257
|
-
const
|
|
19317
|
+
const e = await new sE(this.dbExecutor).generateSQL(S, R, A), N = this.dbExecutor.getEngineType();
|
|
19258
19318
|
return {
|
|
19259
|
-
sql: lT(
|
|
19260
|
-
params:
|
|
19319
|
+
sql: lT(e.sql, N),
|
|
19320
|
+
params: e.params
|
|
19261
19321
|
};
|
|
19262
19322
|
}
|
|
19263
19323
|
/**
|
|
@@ -19266,7 +19326,7 @@ class bE {
|
|
|
19266
19326
|
async generateMultiCubeSQL(E, R) {
|
|
19267
19327
|
if (!this.dbExecutor)
|
|
19268
19328
|
throw new Error("Database executor not configured");
|
|
19269
|
-
const S = await new
|
|
19329
|
+
const S = await new sE(this.dbExecutor).generateMultiCubeSQL(this.cubes, E, R), I = this.dbExecutor.getEngineType();
|
|
19270
19330
|
return {
|
|
19271
19331
|
sql: lT(S.sql, I),
|
|
19272
19332
|
params: S.params
|
|
@@ -19309,69 +19369,69 @@ class bE {
|
|
|
19309
19369
|
* Ensures all referenced cubes and fields exist
|
|
19310
19370
|
*/
|
|
19311
19371
|
validateQuery(E) {
|
|
19312
|
-
return
|
|
19372
|
+
return $T(this.cubes, E);
|
|
19313
19373
|
}
|
|
19314
19374
|
}
|
|
19315
|
-
function
|
|
19375
|
+
function $T(T, E) {
|
|
19316
19376
|
const R = [], A = /* @__PURE__ */ new Set();
|
|
19317
19377
|
if (E.measures)
|
|
19318
19378
|
for (const S of E.measures) {
|
|
19319
|
-
const [I,
|
|
19320
|
-
if (!I || !
|
|
19379
|
+
const [I, e] = S.split(".");
|
|
19380
|
+
if (!I || !e) {
|
|
19321
19381
|
R.push(`Invalid measure format: ${S}. Expected format: 'CubeName.fieldName'`);
|
|
19322
19382
|
continue;
|
|
19323
19383
|
}
|
|
19324
19384
|
A.add(I);
|
|
19325
|
-
const
|
|
19326
|
-
if (!
|
|
19385
|
+
const N = T.get(I);
|
|
19386
|
+
if (!N) {
|
|
19327
19387
|
R.push(`Cube '${I}' not found (referenced in measure '${S}')`);
|
|
19328
19388
|
continue;
|
|
19329
19389
|
}
|
|
19330
|
-
|
|
19390
|
+
N.measures[e] || R.push(`Measure '${e}' not found on cube '${I}'`);
|
|
19331
19391
|
}
|
|
19332
19392
|
if (E.dimensions)
|
|
19333
19393
|
for (const S of E.dimensions) {
|
|
19334
|
-
const [I,
|
|
19335
|
-
if (!I || !
|
|
19394
|
+
const [I, e] = S.split(".");
|
|
19395
|
+
if (!I || !e) {
|
|
19336
19396
|
R.push(`Invalid dimension format: ${S}. Expected format: 'CubeName.fieldName'`);
|
|
19337
19397
|
continue;
|
|
19338
19398
|
}
|
|
19339
19399
|
A.add(I);
|
|
19340
|
-
const
|
|
19341
|
-
if (!
|
|
19400
|
+
const N = T.get(I);
|
|
19401
|
+
if (!N) {
|
|
19342
19402
|
R.push(`Cube '${I}' not found (referenced in dimension '${S}')`);
|
|
19343
19403
|
continue;
|
|
19344
19404
|
}
|
|
19345
|
-
|
|
19405
|
+
N.dimensions[e] || R.push(`Dimension '${e}' not found on cube '${I}'`);
|
|
19346
19406
|
}
|
|
19347
19407
|
if (E.timeDimensions)
|
|
19348
19408
|
for (const S of E.timeDimensions) {
|
|
19349
|
-
const [I,
|
|
19350
|
-
if (!I || !
|
|
19409
|
+
const [I, e] = S.dimension.split(".");
|
|
19410
|
+
if (!I || !e) {
|
|
19351
19411
|
R.push(`Invalid timeDimension format: ${S.dimension}. Expected format: 'CubeName.fieldName'`);
|
|
19352
19412
|
continue;
|
|
19353
19413
|
}
|
|
19354
19414
|
A.add(I);
|
|
19355
|
-
const
|
|
19356
|
-
if (!
|
|
19415
|
+
const N = T.get(I);
|
|
19416
|
+
if (!N) {
|
|
19357
19417
|
R.push(`Cube '${I}' not found (referenced in timeDimension '${S.dimension}')`);
|
|
19358
19418
|
continue;
|
|
19359
19419
|
}
|
|
19360
|
-
|
|
19420
|
+
N.dimensions[e] || R.push(`TimeDimension '${e}' not found on cube '${I}' (must be a dimension with time type)`);
|
|
19361
19421
|
}
|
|
19362
19422
|
if (E.filters)
|
|
19363
19423
|
for (const S of E.filters)
|
|
19364
|
-
|
|
19424
|
+
gT(S, T, R, A);
|
|
19365
19425
|
return A.size === 0 && R.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
19366
19426
|
isValid: R.length === 0,
|
|
19367
19427
|
errors: R
|
|
19368
19428
|
};
|
|
19369
19429
|
}
|
|
19370
|
-
function
|
|
19430
|
+
function gT(T, E, R, A) {
|
|
19371
19431
|
if ("and" in T || "or" in T) {
|
|
19372
|
-
const
|
|
19373
|
-
for (const n of
|
|
19374
|
-
|
|
19432
|
+
const N = T.and || T.or || [];
|
|
19433
|
+
for (const n of N)
|
|
19434
|
+
gT(n, E, R, A);
|
|
19375
19435
|
return;
|
|
19376
19436
|
}
|
|
19377
19437
|
if (!("member" in T)) {
|
|
@@ -19384,35 +19444,35 @@ function yT(T, E, R, A) {
|
|
|
19384
19444
|
return;
|
|
19385
19445
|
}
|
|
19386
19446
|
A.add(S);
|
|
19387
|
-
const
|
|
19388
|
-
if (!
|
|
19447
|
+
const e = E.get(S);
|
|
19448
|
+
if (!e) {
|
|
19389
19449
|
R.push(`Cube '${S}' not found (referenced in filter '${T.member}')`);
|
|
19390
19450
|
return;
|
|
19391
19451
|
}
|
|
19392
|
-
!
|
|
19452
|
+
!e.dimensions[I] && !e.measures[I] && R.push(`Filter field '${I}' not found on cube '${S}' (must be a dimension or measure)`);
|
|
19393
19453
|
}
|
|
19394
|
-
function
|
|
19454
|
+
function dO(T) {
|
|
19395
19455
|
return new bE(T);
|
|
19396
19456
|
}
|
|
19397
|
-
const
|
|
19398
|
-
function
|
|
19457
|
+
const uO = new bE(), VO = uO;
|
|
19458
|
+
function hO(T) {
|
|
19399
19459
|
return new bE({
|
|
19400
19460
|
drizzle: T.drizzle,
|
|
19401
19461
|
schema: T.schema
|
|
19402
19462
|
});
|
|
19403
19463
|
}
|
|
19404
|
-
const
|
|
19464
|
+
const WO = {
|
|
19405
19465
|
/**
|
|
19406
19466
|
* Create a simple query builder
|
|
19407
19467
|
*/
|
|
19408
19468
|
query: () => {
|
|
19409
|
-
const T = (E, R = [], A = [], S = [], I,
|
|
19469
|
+
const T = (E, R = [], A = [], S = [], I, e) => ({
|
|
19410
19470
|
measures: E,
|
|
19411
19471
|
dimensions: R,
|
|
19412
19472
|
filters: A,
|
|
19413
19473
|
timeDimensions: S,
|
|
19414
19474
|
limit: I,
|
|
19415
|
-
order:
|
|
19475
|
+
order: e
|
|
19416
19476
|
});
|
|
19417
19477
|
return {
|
|
19418
19478
|
measures: (E) => ({
|
|
@@ -19420,7 +19480,7 @@ const dO = {
|
|
|
19420
19480
|
filters: (A = []) => ({
|
|
19421
19481
|
timeDimensions: (S = []) => ({
|
|
19422
19482
|
limit: (I) => ({
|
|
19423
|
-
order: (
|
|
19483
|
+
order: (e) => T(E, R, A, S, I, e)
|
|
19424
19484
|
}),
|
|
19425
19485
|
order: (I) => T(E, R, A, S, void 0, I)
|
|
19426
19486
|
}),
|
|
@@ -19432,7 +19492,7 @@ const dO = {
|
|
|
19432
19492
|
timeDimensions: (A = []) => ({
|
|
19433
19493
|
filters: (S = []) => ({
|
|
19434
19494
|
limit: (I) => ({
|
|
19435
|
-
order: (
|
|
19495
|
+
order: (e) => T(E, R, S, A, I, e)
|
|
19436
19496
|
}),
|
|
19437
19497
|
order: (I) => T(E, R, S, A, void 0, I)
|
|
19438
19498
|
}),
|
|
@@ -19450,7 +19510,7 @@ const dO = {
|
|
|
19450
19510
|
dimensions: (A = []) => ({
|
|
19451
19511
|
timeDimensions: (S = []) => ({
|
|
19452
19512
|
limit: (I) => ({
|
|
19453
|
-
order: (
|
|
19513
|
+
order: (e) => T(E, A, R, S, I, e)
|
|
19454
19514
|
}),
|
|
19455
19515
|
order: (I) => T(E, A, R, S, void 0, I)
|
|
19456
19516
|
}),
|
|
@@ -19462,7 +19522,7 @@ const dO = {
|
|
|
19462
19522
|
timeDimensions: (A = []) => ({
|
|
19463
19523
|
dimensions: (S = []) => ({
|
|
19464
19524
|
limit: (I) => ({
|
|
19465
|
-
order: (
|
|
19525
|
+
order: (e) => T(E, S, R, A, I, e)
|
|
19466
19526
|
}),
|
|
19467
19527
|
order: (I) => T(E, S, R, A, void 0, I)
|
|
19468
19528
|
}),
|
|
@@ -19509,25 +19569,25 @@ const dO = {
|
|
|
19509
19569
|
};
|
|
19510
19570
|
export {
|
|
19511
19571
|
fE as BaseDatabaseExecutor,
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19572
|
+
BT as MySQLExecutor,
|
|
19573
|
+
ER as PostgresExecutor,
|
|
19574
|
+
eR as QueryBuilder,
|
|
19575
|
+
sE as QueryExecutor,
|
|
19576
|
+
NR as QueryPlanner,
|
|
19577
|
+
RR as SQLiteExecutor,
|
|
19518
19578
|
bE as SemanticLayerCompiler,
|
|
19519
|
-
|
|
19579
|
+
WO as SemanticLayerUtils,
|
|
19520
19580
|
vE as createDatabaseExecutor,
|
|
19521
|
-
|
|
19522
|
-
|
|
19523
|
-
|
|
19581
|
+
hO as createDrizzleSemanticLayer,
|
|
19582
|
+
mO as createMultiCubeContext,
|
|
19583
|
+
TR as createMySQLExecutor,
|
|
19524
19584
|
wE as createPostgresExecutor,
|
|
19525
19585
|
xE as createSQLiteExecutor,
|
|
19526
|
-
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19586
|
+
dO as createSemanticLayer,
|
|
19587
|
+
VO as defaultSemanticLayer,
|
|
19588
|
+
pO as defineCube,
|
|
19589
|
+
IR as getJoinType,
|
|
19530
19590
|
QE as resolveCubeReference,
|
|
19531
19591
|
K as resolveSqlExpression,
|
|
19532
|
-
|
|
19592
|
+
uO as semanticLayer
|
|
19533
19593
|
};
|