drizzle-cube 0.1.59 → 0.1.62

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.
@@ -1,4 +1,4 @@
1
- import { sql as n, eq as x, and as p, StringChunk as xT, count as SE, sum as f, max as q, min as j, countDistinct as vT, SQL as QT, or as IE, isNotNull as yE, ne as KE, isNull as $E, notInArray as gE, inArray as OE, lt as NE, gt as tE, gte as $, lte as g, desc as ZT, asc as wE } from "drizzle-orm";
1
+ import { sql as n, eq as x, and as m, StringChunk as xT, count as SE, sum as f, max as q, min as j, countDistinct as vT, SQL as QT, or as IE, arrayContained as ZT, arrayOverlaps as qT, arrayContains as jT, isNotNull as yE, ne as KE, isNull as gE, notInArray as $E, inArray as OE, lt as NE, gt as tE, gte as g, lte as $, desc as kT, asc as wE } from "drizzle-orm";
2
2
  class fE {
3
3
  /**
4
4
  * Default implementation returns template unchanged
@@ -25,7 +25,7 @@ class fE {
25
25
  }
26
26
  }
27
27
  }
28
- class qT extends fE {
28
+ class zT extends fE {
29
29
  getEngineType() {
30
30
  return "postgres";
31
31
  }
@@ -274,7 +274,7 @@ class HT extends fE {
274
274
  return E;
275
275
  }
276
276
  }
277
- class jT extends fE {
277
+ class ER extends fE {
278
278
  getEngineType() {
279
279
  return "sqlite";
280
280
  }
@@ -426,7 +426,7 @@ class jT extends fE {
426
426
  return E;
427
427
  }
428
428
  }
429
- class kT extends HT {
429
+ class TR extends HT {
430
430
  getEngineType() {
431
431
  return "singlestore";
432
432
  }
@@ -439,16 +439,16 @@ class kT extends HT {
439
439
  // These limitations are typically handled at the query building level
440
440
  // rather than in the adapter, but can be addressed here if needed
441
441
  }
442
- function zT(R) {
442
+ function RR(R) {
443
443
  switch (R) {
444
444
  case "postgres":
445
- return new qT();
445
+ return new zT();
446
446
  case "mysql":
447
447
  return new HT();
448
448
  case "sqlite":
449
- return new jT();
449
+ return new ER();
450
450
  case "singlestore":
451
- return new kT();
451
+ return new TR();
452
452
  default:
453
453
  throw new Error(`Unsupported database engine: ${R}`);
454
454
  }
@@ -457,11 +457,11 @@ class VE {
457
457
  constructor(E, T, A) {
458
458
  this.db = E, this.schema = T;
459
459
  const e = A || this.getEngineType();
460
- this.databaseAdapter = zT(e);
460
+ this.databaseAdapter = RR(e);
461
461
  }
462
462
  databaseAdapter;
463
463
  }
464
- class ER extends VE {
464
+ class AR extends VE {
465
465
  async execute(E, T) {
466
466
  if (E && typeof E == "object" && typeof E.execute == "function") {
467
467
  const e = await E.execute();
@@ -513,7 +513,7 @@ class ER extends VE {
513
513
  }
514
514
  }
515
515
  function JE(R, E) {
516
- return new ER(R, E, "postgres");
516
+ return new AR(R, E, "postgres");
517
517
  }
518
518
  class BT extends VE {
519
519
  async execute(E, T) {
@@ -553,10 +553,10 @@ class BT extends VE {
553
553
  return "mysql";
554
554
  }
555
555
  }
556
- function TR(R, E) {
556
+ function eR(R, E) {
557
557
  return new BT(R, E, "mysql");
558
558
  }
559
- class RR extends VE {
559
+ class SR extends VE {
560
560
  async execute(E, T) {
561
561
  if (E && typeof E == "object" && typeof E.execute == "function") {
562
562
  const A = await E.execute();
@@ -603,9 +603,9 @@ class RR extends VE {
603
603
  }
604
604
  }
605
605
  function xE(R, E) {
606
- return new RR(R, E, "sqlite");
606
+ return new SR(R, E, "sqlite");
607
607
  }
608
- class AR extends BT {
608
+ class IR extends BT {
609
609
  getEngineType() {
610
610
  return "singlestore";
611
611
  }
@@ -613,8 +613,8 @@ class AR extends BT {
613
613
  // For now, we inherit all behavior from MySQLExecutor since
614
614
  // SingleStore is largely MySQL-compatible
615
615
  }
616
- function eR(R, E) {
617
- return new AR(R, E);
616
+ function NR(R, E) {
617
+ return new IR(R, E);
618
618
  }
619
619
  function vE(R, E, T) {
620
620
  if (T)
@@ -622,11 +622,11 @@ function vE(R, E, T) {
622
622
  case "postgres":
623
623
  return JE(R, E);
624
624
  case "mysql":
625
- return TR(R, E);
625
+ return eR(R, E);
626
626
  case "sqlite":
627
627
  return xE(R, E);
628
628
  case "singlestore":
629
- return eR(R, E);
629
+ return NR(R, E);
630
630
  }
631
631
  if (R.all && R.run)
632
632
  return xE(R, E);
@@ -656,27 +656,27 @@ function dT(R, E) {
656
656
  return "left";
657
657
  }
658
658
  }
659
- function SR(R) {
659
+ function tR(R) {
660
660
  return R && typeof R == "object" ? n`${n`${R}`}` : R;
661
661
  }
662
662
  function X(R, E) {
663
663
  const T = typeof R == "function" ? R(E) : R;
664
- return SR(T);
664
+ return tR(T);
665
665
  }
666
- function zI(R, E, T) {
666
+ function RO(R, E, T) {
667
667
  return {
668
668
  ...R,
669
669
  cubes: E,
670
670
  currentCube: T
671
671
  };
672
672
  }
673
- function EO(R, E) {
673
+ function AO(R, E) {
674
674
  return {
675
675
  name: R,
676
676
  ...E
677
677
  };
678
678
  }
679
- function IR(R, E) {
679
+ function sR(R, E) {
680
680
  if (R.relationship !== "belongsToMany" || !R.through)
681
681
  throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
682
682
  const { table: T, sourceKey: A, targetKey: e, securitySql: S } = R.through, I = [];
@@ -700,13 +700,13 @@ function IR(R, E) {
700
700
  {
701
701
  joinType: O,
702
702
  table: T,
703
- condition: p(...I)
703
+ condition: m(...I)
704
704
  },
705
705
  {
706
706
  joinType: O,
707
707
  table: T,
708
708
  // This will be replaced with target cube table in query planner
709
- condition: p(...t)
709
+ condition: m(...t)
710
710
  }
711
711
  ],
712
712
  junctionSecurityConditions: C
@@ -932,15 +932,15 @@ class b {
932
932
  return E.type === "calculated" && !!E.calculatedSql;
933
933
  }
934
934
  }
935
- function NR(R, E) {
935
+ function CR(R, E) {
936
936
  const { cube: T, allCubes: A, resolvedMeasures: e } = E, S = WE(R), I = /* @__PURE__ */ new Map();
937
937
  for (const s of S) {
938
- const { originalRef: r, cubeName: L, fieldName: i } = s, o = L || T.name;
939
- if (!A.get(o))
938
+ const { originalRef: r, cubeName: L, fieldName: i } = s, D = L || T.name;
939
+ if (!A.get(D))
940
940
  throw new Error(
941
- `Cannot substitute {${r}}: cube '${o}' not found`
941
+ `Cannot substitute {${r}}: cube '${D}' not found`
942
942
  );
943
- const P = `${o}.${i}`, c = e.get(P);
943
+ const P = `${D}.${i}`, c = e.get(P);
944
944
  if (!c)
945
945
  throw new Error(
946
946
  `Cannot substitute {${r}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
@@ -985,7 +985,7 @@ function WE(R) {
985
985
  }
986
986
  return A;
987
987
  }
988
- function tR(R) {
988
+ function LR(R) {
989
989
  const E = [];
990
990
  let T = 0;
991
991
  for (let I = 0; I < R.length; I++)
@@ -1018,7 +1018,7 @@ function sE(R, E) {
1018
1018
  }
1019
1019
  return Array.from(A);
1020
1020
  }
1021
- class sR {
1021
+ class _R {
1022
1022
  constructor(E) {
1023
1023
  this.databaseAdapter = E;
1024
1024
  }
@@ -1060,17 +1060,17 @@ class sR {
1060
1060
  for (const N of I) {
1061
1061
  const [s, r] = N.split("."), L = T.get(s), i = L.measures[r];
1062
1062
  if (e) {
1063
- const o = e(N, i, L);
1064
- S.set(N, () => o);
1063
+ const D = e(N, i, L);
1064
+ S.set(N, () => D);
1065
1065
  } else
1066
1066
  S.set(N, () => this.buildMeasureExpression(i, A));
1067
1067
  }
1068
1068
  if (t.length > 0) {
1069
1069
  const N = O.topologicalSort(t);
1070
1070
  for (const s of N) {
1071
- const [r, L] = s.split("."), i = T.get(r), o = i.measures[L];
1071
+ const [r, L] = s.split("."), i = T.get(r), D = i.measures[L];
1072
1072
  S.set(s, () => this.buildCalculatedMeasure(
1073
- o,
1073
+ D,
1074
1074
  i,
1075
1075
  T,
1076
1076
  S,
@@ -1133,7 +1133,7 @@ class sR {
1133
1133
  `Calculated measure '${T.name}.${E.name}' missing calculatedSql property`
1134
1134
  );
1135
1135
  const I = this.databaseAdapter.preprocessCalculatedTemplate(E.calculatedSql);
1136
- return NR(I, {
1136
+ return CR(I, {
1137
1137
  cube: T,
1138
1138
  allCubes: A,
1139
1139
  resolvedMeasures: e
@@ -1263,7 +1263,7 @@ class sR {
1263
1263
  return I ? n`(${I})` : void 0;
1264
1264
  }).filter(Boolean);
1265
1265
  if (e.length > 0) {
1266
- const S = e.length === 1 ? e[0] : p(...e);
1266
+ const S = e.length === 1 ? e[0] : m(...e);
1267
1267
  A = this.databaseAdapter.buildCaseWhen([
1268
1268
  { when: S, then: A }
1269
1269
  ]);
@@ -1310,7 +1310,7 @@ class sR {
1310
1310
  for (const t of T.timeDimensions) {
1311
1311
  const [C, O] = t.dimension.split("."), N = I.get(C);
1312
1312
  if (N && N.dimensions[O] && t.dateRange) {
1313
- if (e?.preAggregationCTEs && e.preAggregationCTEs.some((o) => o.cube.name === C))
1313
+ if (e?.preAggregationCTEs && e.preAggregationCTEs.some((D) => D.cube.name === C))
1314
1314
  continue;
1315
1315
  const s = N.dimensions[O], r = X(s.sql, A), L = this.buildDateRangeCondition(r, t.dateRange);
1316
1316
  L && S.push(L);
@@ -1339,11 +1339,11 @@ class sR {
1339
1339
  if ("and" in E || "or" in E) {
1340
1340
  const L = E;
1341
1341
  if (L.and) {
1342
- const i = L.and.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1343
- return i.length > 0 ? p(...i) : null;
1342
+ const i = L.and.map((D) => this.processFilter(D, T, A, e, S)).filter((D) => D !== null);
1343
+ return i.length > 0 ? m(...i) : null;
1344
1344
  }
1345
1345
  if (L.or) {
1346
- const i = L.or.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
1346
+ const i = L.or.map((D) => this.processFilter(D, T, A, e, S)).filter((D) => D !== null);
1347
1347
  return i.length > 0 ? IE(...i) : null;
1348
1348
  }
1349
1349
  }
@@ -1352,11 +1352,11 @@ class sR {
1352
1352
  const N = O.dimensions[C], s = O.measures[C], r = N || s;
1353
1353
  if (!r) return null;
1354
1354
  if (e === "where" && N) {
1355
- if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
1355
+ if (S?.preAggregationCTEs && S.preAggregationCTEs.some((l) => l.cube.name === t))
1356
1356
  return null;
1357
- const L = X(N.sql, A);
1357
+ const i = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(I.operator) ? typeof N.sql == "function" ? N.sql(A) : N.sql : X(N.sql, A);
1358
1358
  return this.buildFilterCondition(
1359
- L,
1359
+ i,
1360
1360
  I.operator,
1361
1361
  I.values,
1362
1362
  r,
@@ -1413,7 +1413,7 @@ class sR {
1413
1413
  }
1414
1414
  return this.databaseAdapter.buildBooleanLiteral(!1);
1415
1415
  case "notEquals":
1416
- return I.length > 1 ? gE(E, I) : I.length === 1 ? KE(E, t) : null;
1416
+ return I.length > 1 ? $E(E, I) : I.length === 1 ? KE(E, t) : null;
1417
1417
  case "contains":
1418
1418
  return this.databaseAdapter.buildStringCondition(E, "contains", t);
1419
1419
  case "notContains":
@@ -1425,15 +1425,15 @@ class sR {
1425
1425
  case "gt":
1426
1426
  return tE(E, t);
1427
1427
  case "gte":
1428
- return $(E, t);
1428
+ return g(E, t);
1429
1429
  case "lt":
1430
1430
  return NE(E, t);
1431
1431
  case "lte":
1432
- return g(E, t);
1432
+ return $(E, t);
1433
1433
  case "set":
1434
1434
  return yE(E);
1435
1435
  case "notSet":
1436
- return $E(E);
1436
+ return gE(E);
1437
1437
  case "inDateRange":
1438
1438
  if (I.length >= 2) {
1439
1439
  const C = this.normalizeDate(I[0]);
@@ -1444,9 +1444,9 @@ class sR {
1444
1444
  const s = typeof O == "number" ? new Date(O * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(O), r = new Date(s);
1445
1445
  r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? O = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : O = r.toISOString();
1446
1446
  }
1447
- return p(
1448
- $(E, C),
1449
- g(E, O)
1447
+ return m(
1448
+ g(E, C),
1449
+ $(E, O)
1450
1450
  );
1451
1451
  }
1452
1452
  }
@@ -1460,9 +1460,9 @@ class sR {
1460
1460
  return C ? tE(E, C) : null;
1461
1461
  }
1462
1462
  case "between":
1463
- return I.length >= 2 ? p(
1464
- $(E, I[0]),
1465
- g(E, I[1])
1463
+ return I.length >= 2 ? m(
1464
+ g(E, I[0]),
1465
+ $(E, I[1])
1466
1466
  ) : null;
1467
1467
  case "notBetween":
1468
1468
  return I.length >= 2 ? IE(
@@ -1472,7 +1472,7 @@ class sR {
1472
1472
  case "in":
1473
1473
  return I.length > 0 ? OE(E, I) : null;
1474
1474
  case "notIn":
1475
- return I.length > 0 ? gE(E, I) : null;
1475
+ return I.length > 0 ? $E(E, I) : null;
1476
1476
  case "like":
1477
1477
  return this.databaseAdapter.buildStringCondition(E, "like", t);
1478
1478
  case "notLike":
@@ -1485,14 +1485,22 @@ class sR {
1485
1485
  return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
1486
1486
  case "isEmpty":
1487
1487
  return IE(
1488
- $E(E),
1488
+ gE(E),
1489
1489
  x(E, "")
1490
1490
  );
1491
1491
  case "isNotEmpty":
1492
- return p(
1492
+ return m(
1493
1493
  yE(E),
1494
1494
  KE(E, "")
1495
1495
  );
1496
+ // PostgreSQL array operators - silent no-op for other databases
1497
+ // These use Drizzle's built-in array operator functions
1498
+ case "arrayContains":
1499
+ return this.databaseAdapter.getEngineType() === "postgres" ? jT(E, I) : null;
1500
+ case "arrayOverlaps":
1501
+ return this.databaseAdapter.getEngineType() === "postgres" ? qT(E, I) : null;
1502
+ case "arrayContained":
1503
+ return this.databaseAdapter.getEngineType() === "postgres" ? ZT(E, I) : null;
1496
1504
  default:
1497
1505
  return null;
1498
1506
  }
@@ -1510,18 +1518,18 @@ class sR {
1510
1518
  const S = typeof e == "number" ? new Date(e * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(e), I = new Date(S);
1511
1519
  I.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? e = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(I.getTime() / 1e3) : I.getTime() : e = I.toISOString();
1512
1520
  }
1513
- return p(
1514
- $(E, A),
1515
- g(E, e)
1521
+ return m(
1522
+ g(E, A),
1523
+ $(E, e)
1516
1524
  );
1517
1525
  }
1518
1526
  if (typeof T == "string") {
1519
1527
  const A = this.parseRelativeDateRange(T);
1520
1528
  if (A) {
1521
1529
  let N, s;
1522
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (N = Math.floor(A.start.getTime() / 1e3), s = Math.floor(A.end.getTime() / 1e3)) : (N = A.start.getTime(), s = A.end.getTime()) : (N = A.start.toISOString(), s = A.end.toISOString()), p(
1523
- $(E, N),
1524
- g(E, s)
1530
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (N = Math.floor(A.start.getTime() / 1e3), s = Math.floor(A.end.getTime() / 1e3)) : (N = A.start.getTime(), s = A.end.getTime()) : (N = A.start.toISOString(), s = A.end.toISOString()), m(
1531
+ g(E, N),
1532
+ $(E, s)
1525
1533
  );
1526
1534
  }
1527
1535
  const e = this.normalizeDate(T);
@@ -1531,9 +1539,9 @@ class sR {
1531
1539
  const t = new Date(S);
1532
1540
  t.setUTCHours(23, 59, 59, 999);
1533
1541
  let C, O;
1534
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (C = I.getTime(), O = t.getTime()) : (C = I.toISOString(), O = t.toISOString()), p(
1535
- $(E, C),
1536
- g(E, O)
1542
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (C = I.getTime(), O = t.getTime()) : (C = I.toISOString(), O = t.toISOString()), m(
1543
+ g(E, C),
1544
+ $(E, O)
1537
1545
  );
1538
1546
  }
1539
1547
  return null;
@@ -1585,8 +1593,8 @@ class sR {
1585
1593
  if (O) {
1586
1594
  const L = parseInt(O[1], 10) * 7, i = new Date(T);
1587
1595
  i.setUTCDate(I - L + 1), i.setUTCHours(0, 0, 0, 0);
1588
- const o = new Date(T);
1589
- return o.setUTCHours(23, 59, 59, 999), { start: i, end: o };
1596
+ const D = new Date(T);
1597
+ return D.setUTCHours(23, 59, 59, 999), { start: i, end: D };
1590
1598
  }
1591
1599
  if (A === "last week") {
1592
1600
  const r = t === 0 ? -13 : -6 - t, L = new Date(T);
@@ -1599,8 +1607,8 @@ class sR {
1599
1607
  return { start: r, end: L };
1600
1608
  }
1601
1609
  if (A === "last quarter") {
1602
- const r = Math.floor(S / 3), L = r === 0 ? 3 : r - 1, i = r === 0 ? e - 1 : e, o = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, L * 3 + 3, 0, 23, 59, 59, 999));
1603
- return { start: o, end: l };
1610
+ const r = Math.floor(S / 3), L = r === 0 ? 3 : r - 1, i = r === 0 ? e - 1 : e, D = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, L * 3 + 3, 0, 23, 59, 59, 999));
1611
+ return { start: D, end: l };
1604
1612
  }
1605
1613
  if (A === "last year") {
1606
1614
  const r = new Date(Date.UTC(e - 1, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e - 1, 11, 31, 23, 59, 59, 999));
@@ -1660,12 +1668,12 @@ class sR {
1660
1668
  const [O, N] = C.split("."), s = t.get(O);
1661
1669
  if (s && s.dimensions && s.dimensions[N])
1662
1670
  if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
1663
- const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
1671
+ const L = e.preAggregationCTEs.find((D) => D.cube.name === O), i = L.joinKeys.find((D) => D.targetColumn === N);
1664
1672
  if (i && i.sourceColumnObj)
1665
1673
  S.push(i.sourceColumnObj);
1666
1674
  else {
1667
- const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1668
- S.push(o);
1675
+ const D = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1676
+ S.push(D);
1669
1677
  }
1670
1678
  } else {
1671
1679
  const L = s.dimensions[N], i = X(L.sql, A);
@@ -1677,17 +1685,17 @@ class sR {
1677
1685
  const [O, N] = C.dimension.split("."), s = t.get(O);
1678
1686
  if (s && s.dimensions && s.dimensions[N])
1679
1687
  if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
1680
- const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
1688
+ const L = e.preAggregationCTEs.find((D) => D.cube.name === O), i = L.joinKeys.find((D) => D.targetColumn === N);
1681
1689
  if (i && i.sourceColumnObj) {
1682
- const o = this.buildTimeDimensionExpression(
1690
+ const D = this.buildTimeDimensionExpression(
1683
1691
  i.sourceColumnObj,
1684
1692
  C.granularity,
1685
1693
  A
1686
1694
  );
1687
- S.push(o);
1695
+ S.push(D);
1688
1696
  } else {
1689
- const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1690
- S.push(o);
1697
+ const D = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
1698
+ S.push(D);
1691
1699
  }
1692
1700
  } else {
1693
1701
  const L = s.dimensions[N], i = this.buildTimeDimensionExpression(
@@ -1713,7 +1721,7 @@ class sR {
1713
1721
  for (const [S, I] of Object.entries(E.order)) {
1714
1722
  if (!e.includes(S))
1715
1723
  throw new Error(`Cannot order by '${S}': field is not selected in the query`);
1716
- const t = I === "desc" ? ZT(n.identifier(S)) : wE(n.identifier(S));
1724
+ const t = I === "desc" ? kT(n.identifier(S)) : wE(n.identifier(S));
1717
1725
  A.push(t);
1718
1726
  }
1719
1727
  if (E.timeDimensions && E.timeDimensions.length > 0) {
@@ -1762,7 +1770,7 @@ class sR {
1762
1770
  return e;
1763
1771
  }
1764
1772
  }
1765
- class CR {
1773
+ class rR {
1766
1774
  /**
1767
1775
  * Analyze a semantic query to determine which cubes are involved
1768
1776
  */
@@ -1925,7 +1933,7 @@ class CR {
1925
1933
  if (!r)
1926
1934
  throw new Error(`Cube '${N}' not found`);
1927
1935
  if (s.relationship === "belongsToMany" && s.through) {
1928
- const L = IR(s, e.securityContext);
1936
+ const L = sR(s, e.securityContext);
1929
1937
  S.push({
1930
1938
  cube: r,
1931
1939
  alias: `${N.toLowerCase()}_cube`,
@@ -1970,7 +1978,7 @@ class CR {
1970
1978
  const I = T ? n`${n.identifier(T)}.${n.identifier(S.source.name)}` : S.source, t = A ? n`${n.identifier(A)}.${n.identifier(S.target.name)}` : S.target, C = S.as || x;
1971
1979
  e.push(C(I, t));
1972
1980
  }
1973
- return p(...e);
1981
+ return m(...e);
1974
1982
  }
1975
1983
  /**
1976
1984
  * Find join path from source cube to target cube
@@ -2087,7 +2095,7 @@ class CE {
2087
2095
  constructor(E) {
2088
2096
  if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
2089
2097
  throw new Error("DatabaseExecutor must have a databaseAdapter property");
2090
- this.queryBuilder = new sR(this.databaseAdapter), this.queryPlanner = new CR();
2098
+ this.queryBuilder = new _R(this.databaseAdapter), this.queryPlanner = new rR();
2091
2099
  }
2092
2100
  queryBuilder;
2093
2101
  queryPlanner;
@@ -2097,7 +2105,7 @@ class CE {
2097
2105
  */
2098
2106
  async execute(E, T, A) {
2099
2107
  try {
2100
- const e = gT(E, T);
2108
+ const e = $T(E, T);
2101
2109
  if (!e.isValid)
2102
2110
  throw new Error(`Query validation failed: ${e.errors.join(", ")}`);
2103
2111
  const S = {
@@ -2109,12 +2117,12 @@ class CE {
2109
2117
  if (T.timeDimensions) {
2110
2118
  for (const i of T.timeDimensions)
2111
2119
  if (i.dimension in L) {
2112
- let o = L[i.dimension];
2113
- if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
2114
- const l = o.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
2115
- o = new Date(P);
2120
+ let D = L[i.dimension];
2121
+ if (typeof D == "string" && D.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
2122
+ const l = D.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
2123
+ D = new Date(P);
2116
2124
  }
2117
- o = this.databaseAdapter.convertTimeDimensionResult(o), L[i.dimension] = o;
2125
+ D = this.databaseAdapter.convertTimeDimensionResult(D), L[i.dimension] = D;
2118
2126
  }
2119
2127
  }
2120
2128
  return L;
@@ -2201,9 +2209,9 @@ class CE {
2201
2209
  }
2202
2210
  }
2203
2211
  }
2204
- const o = [];
2205
- if (I.where && o.push(I.where), o.push(...L, ...i), o.length > 0) {
2206
- const P = o.length === 1 ? o[0] : p(...o);
2212
+ const D = [];
2213
+ if (I.where && D.push(I.where), D.push(...L, ...i), D.length > 0) {
2214
+ const P = D.length === 1 ? D[0] : m(...D);
2207
2215
  s = s.where(P);
2208
2216
  }
2209
2217
  const l = [];
@@ -2240,7 +2248,7 @@ class CE {
2240
2248
  const t = I.sourceColumnObj || n.identifier(I.sourceColumn), C = n`${n.identifier(T)}.${n.identifier(I.targetColumn)}`;
2241
2249
  S.push(x(t, C));
2242
2250
  }
2243
- return S.length === 1 ? S[0] : p(...S);
2251
+ return S.length === 1 ? S[0] : m(...S);
2244
2252
  }
2245
2253
  /**
2246
2254
  * Build unified query that works for both single and multi-cube queries
@@ -2248,9 +2256,9 @@ class CE {
2248
2256
  buildUnifiedQuery(E, T, A) {
2249
2257
  const e = [], S = /* @__PURE__ */ new Map();
2250
2258
  if (E.preAggregationCTEs && E.preAggregationCTEs.length > 0)
2251
- for (const o of E.preAggregationCTEs) {
2252
- const l = this.buildPreAggregationCTE(o, T, A, E);
2253
- l && (e.push(l), S.set(o.cube.name, o.cteAlias));
2259
+ for (const D of E.preAggregationCTEs) {
2260
+ const l = this.buildPreAggregationCTE(D, T, A, E);
2261
+ l && (e.push(l), S.set(D.cube.name, D.cteAlias));
2254
2262
  }
2255
2263
  const I = E.primaryCube.sql(A), C = { ...this.queryBuilder.buildSelections(
2256
2264
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
@@ -2259,9 +2267,9 @@ class CE {
2259
2267
  A
2260
2268
  ) };
2261
2269
  if (E.preAggregationCTEs)
2262
- for (const o of E.preAggregationCTEs) {
2263
- const l = o.cube.name;
2264
- for (const P of o.measures)
2270
+ for (const D of E.preAggregationCTEs) {
2271
+ const l = D.cube.name;
2272
+ for (const P of D.measures)
2265
2273
  if (C[P]) {
2266
2274
  const [, c] = P.split("."), M = this.getCubesFromPlan(E).get(l);
2267
2275
  if (M && M.measures && M.measures[c]) {
@@ -2272,12 +2280,12 @@ class CE {
2272
2280
  H = this.queryBuilder.buildCTECalculatedMeasure(
2273
2281
  u,
2274
2282
  M,
2275
- o,
2283
+ D,
2276
2284
  B,
2277
2285
  A
2278
2286
  );
2279
2287
  } else {
2280
- const B = n`${n.identifier(o.cteAlias)}.${n.identifier(c)}`;
2288
+ const B = n`${n.identifier(D.cteAlias)}.${n.identifier(c)}`;
2281
2289
  switch (u.type) {
2282
2290
  case "count":
2283
2291
  case "countDistinct":
@@ -2308,12 +2316,12 @@ class CE {
2308
2316
  if (c === l) {
2309
2317
  const u = this.getCubesFromPlan(E).get(l), H = u && u.dimensions?.[M], B = P.startsWith(l + ".");
2310
2318
  if (H || B) {
2311
- let Y = o.joinKeys.find((eE) => eE.targetColumn === M);
2319
+ let Y = D.joinKeys.find((eE) => eE.targetColumn === M);
2312
2320
  if (!Y && u?.dimensions?.[M]) {
2313
2321
  const eE = u.dimensions[M].sql;
2314
- Y = o.joinKeys.find((JT) => JT.targetColumnObj === eE);
2322
+ Y = D.joinKeys.find((JT) => JT.targetColumnObj === eE);
2315
2323
  }
2316
- Y ? C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P) : B && u?.dimensions?.[M] && (C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P));
2324
+ Y ? C[P] = n`${n.identifier(D.cteAlias)}.${n.identifier(M)}`.as(P) : B && u?.dimensions?.[M] && (C[P] = n`${n.identifier(D.cteAlias)}.${n.identifier(M)}`.as(P));
2317
2325
  }
2318
2326
  }
2319
2327
  }
@@ -2321,26 +2329,26 @@ class CE {
2321
2329
  const O = [];
2322
2330
  let N = A.db.select(C).from(I.from);
2323
2331
  if (e.length > 0 && (N = A.db.with(...e).select(C).from(I.from)), I.joins)
2324
- for (const o of I.joins)
2325
- switch (o.type || "left") {
2332
+ for (const D of I.joins)
2333
+ switch (D.type || "left") {
2326
2334
  case "left":
2327
- N = N.leftJoin(o.table, o.on);
2335
+ N = N.leftJoin(D.table, D.on);
2328
2336
  break;
2329
2337
  case "inner":
2330
- N = N.innerJoin(o.table, o.on);
2338
+ N = N.innerJoin(D.table, D.on);
2331
2339
  break;
2332
2340
  case "right":
2333
- N = N.rightJoin(o.table, o.on);
2341
+ N = N.rightJoin(D.table, D.on);
2334
2342
  break;
2335
2343
  case "full":
2336
- N = N.fullJoin(o.table, o.on);
2344
+ N = N.fullJoin(D.table, D.on);
2337
2345
  break;
2338
2346
  }
2339
2347
  if (E.joinCubes && E.joinCubes.length > 0)
2340
- for (const o of E.joinCubes) {
2341
- const l = S.get(o.cube.name);
2342
- if (o.junctionTable) {
2343
- const M = o.junctionTable, u = [];
2348
+ for (const D of E.joinCubes) {
2349
+ const l = S.get(D.cube.name);
2350
+ if (D.junctionTable) {
2351
+ const M = D.junctionTable, u = [];
2344
2352
  if (M.securitySql) {
2345
2353
  const H = M.securitySql(A.securityContext);
2346
2354
  Array.isArray(H) ? u.push(...H) : u.push(H);
@@ -2365,9 +2373,9 @@ class CE {
2365
2373
  }
2366
2374
  }
2367
2375
  let P, c;
2368
- l ? (P = n`${n.identifier(l)}`, c = this.buildCTEJoinCondition(o, l, E)) : (P = o.cube.sql(A).from, c = o.joinCondition);
2376
+ l ? (P = n`${n.identifier(l)}`, c = this.buildCTEJoinCondition(D, l, E)) : (P = D.cube.sql(A).from, c = D.joinCondition);
2369
2377
  try {
2370
- switch (o.joinType || "left") {
2378
+ switch (D.joinType || "left") {
2371
2379
  case "left":
2372
2380
  N = N.leftJoin(P, c);
2373
2381
  break;
@@ -2385,10 +2393,10 @@ class CE {
2385
2393
  }
2386
2394
  }
2387
2395
  if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
2388
- for (const o of E.joinCubes) {
2389
- if (S.get(o.cube.name))
2396
+ for (const D of E.joinCubes) {
2397
+ if (S.get(D.cube.name))
2390
2398
  continue;
2391
- const P = o.cube.sql(A);
2399
+ const P = D.cube.sql(A);
2392
2400
  P.where && O.push(P.where);
2393
2401
  }
2394
2402
  const s = this.queryBuilder.buildWhereConditions(
@@ -2400,8 +2408,8 @@ class CE {
2400
2408
  // Pass the queryPlan to handle CTE scenarios
2401
2409
  );
2402
2410
  if (s.length > 0 && O.push(...s), O.length > 0) {
2403
- const o = O.length === 1 ? O[0] : p(...O);
2404
- N = N.where(o);
2411
+ const D = O.length === 1 ? O[0] : m(...O);
2412
+ N = N.where(D);
2405
2413
  }
2406
2414
  const r = this.queryBuilder.buildGroupByFields(
2407
2415
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
@@ -2421,8 +2429,8 @@ class CE {
2421
2429
  // Pass the queryPlan to handle CTE scenarios
2422
2430
  );
2423
2431
  if (L.length > 0) {
2424
- const o = L.length === 1 ? L[0] : p(...L);
2425
- N = N.having(o);
2432
+ const D = L.length === 1 ? L[0] : m(...L);
2433
+ N = N.having(D);
2426
2434
  }
2427
2435
  const i = this.queryBuilder.buildOrderBy(T);
2428
2436
  return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, T), N;
@@ -2514,13 +2522,13 @@ class CE {
2514
2522
  };
2515
2523
  }
2516
2524
  }
2517
- const _ = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.replace(/ +/g, " ").trim(), rR = (R) => ({
2525
+ const _ = (R) => R.flatMap(nR), nR = (R) => k(aR(R)).map(iR), iR = (R) => R.replace(/ +/g, " ").trim(), aR = (R) => ({
2518
2526
  type: "mandatory_block",
2519
2527
  items: XE(R, 0)[0]
2520
2528
  }), XE = (R, E, T) => {
2521
2529
  const A = [];
2522
2530
  for (; R[E]; ) {
2523
- const [e, S] = nR(R, E);
2531
+ const [e, S] = oR(R, E);
2524
2532
  if (A.push(e), E = S, R[E] === "|")
2525
2533
  E++;
2526
2534
  else if (R[E] === "}" || R[E] === "]") {
@@ -2535,67 +2543,67 @@ const _ = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.repl
2535
2543
  throw new Error(`Unexpected "${R[E]}"`);
2536
2544
  }
2537
2545
  return [A, E];
2538
- }, nR = (R, E) => {
2546
+ }, oR = (R, E) => {
2539
2547
  const T = [];
2540
2548
  for (; ; ) {
2541
- const [A, e] = iR(R, E);
2549
+ const [A, e] = DR(R, E);
2542
2550
  if (A)
2543
2551
  T.push(A), E = e;
2544
2552
  else
2545
2553
  break;
2546
2554
  }
2547
2555
  return T.length === 1 ? [T[0], E] : [{ type: "concatenation", items: T }, E];
2548
- }, iR = (R, E) => {
2556
+ }, DR = (R, E) => {
2549
2557
  if (R[E] === "{")
2550
- return aR(R, E + 1);
2558
+ return PR(R, E + 1);
2551
2559
  if (R[E] === "[")
2552
- return oR(R, E + 1);
2560
+ return MR(R, E + 1);
2553
2561
  {
2554
2562
  let T = "";
2555
2563
  for (; R[E] && /[A-Za-z0-9_ ]/.test(R[E]); )
2556
2564
  T += R[E], E++;
2557
2565
  return [T, E];
2558
2566
  }
2559
- }, aR = (R, E) => {
2567
+ }, PR = (R, E) => {
2560
2568
  const [T, A] = XE(R, E, "}");
2561
2569
  return [{ type: "mandatory_block", items: T }, A];
2562
- }, oR = (R, E) => {
2570
+ }, MR = (R, E) => {
2563
2571
  const [T, A] = XE(R, E, "]");
2564
2572
  return [{ type: "optional_block", items: T }, A];
2565
2573
  }, k = (R) => {
2566
2574
  if (typeof R == "string")
2567
2575
  return [R];
2568
2576
  if (R.type === "concatenation")
2569
- return R.items.map(k).reduce(DR, [""]);
2577
+ return R.items.map(k).reduce(UR, [""]);
2570
2578
  if (R.type === "mandatory_block")
2571
2579
  return R.items.flatMap(k);
2572
2580
  if (R.type === "optional_block")
2573
2581
  return ["", ...R.items.flatMap(k)];
2574
2582
  throw new Error(`Unknown node type: ${R}`);
2575
- }, DR = (R, E) => {
2583
+ }, UR = (R, E) => {
2576
2584
  const T = [];
2577
2585
  for (const A of R)
2578
2586
  for (const e of E)
2579
2587
  T.push(A + e);
2580
2588
  return T;
2581
2589
  };
2582
- var D;
2590
+ var o;
2583
2591
  (function(R) {
2584
2592
  R.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", R.IDENTIFIER = "IDENTIFIER", R.STRING = "STRING", R.VARIABLE = "VARIABLE", R.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", R.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", R.RESERVED_KEYWORD = "RESERVED_KEYWORD", R.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", R.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", R.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", R.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", R.RESERVED_CLAUSE = "RESERVED_CLAUSE", R.RESERVED_SELECT = "RESERVED_SELECT", R.RESERVED_JOIN = "RESERVED_JOIN", R.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", R.ARRAY_KEYWORD = "ARRAY_KEYWORD", R.CASE = "CASE", R.END = "END", R.WHEN = "WHEN", R.ELSE = "ELSE", R.THEN = "THEN", R.LIMIT = "LIMIT", R.BETWEEN = "BETWEEN", R.AND = "AND", R.OR = "OR", R.XOR = "XOR", R.OPERATOR = "OPERATOR", R.COMMA = "COMMA", R.ASTERISK = "ASTERISK", R.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", R.OPEN_PAREN = "OPEN_PAREN", R.CLOSE_PAREN = "CLOSE_PAREN", R.LINE_COMMENT = "LINE_COMMENT", R.BLOCK_COMMENT = "BLOCK_COMMENT", R.DISABLE_COMMENT = "DISABLE_COMMENT", R.NUMBER = "NUMBER", R.NAMED_PARAMETER = "NAMED_PARAMETER", R.QUOTED_PARAMETER = "QUOTED_PARAMETER", R.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", R.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", R.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", R.DELIMITER = "DELIMITER", R.EOF = "EOF";
2585
- })(D = D || (D = {}));
2593
+ })(o = o || (o = {}));
2586
2594
  const FT = (R) => ({
2587
- type: D.EOF,
2595
+ type: o.EOF,
2588
2596
  raw: "«EOF»",
2589
2597
  text: "«EOF»",
2590
2598
  start: R
2591
2599
  }), v = FT(1 / 0), w = (R) => (E) => E.type === R.type && E.text === R.text, y = {
2592
- ARRAY: w({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
2593
- BY: w({ text: "BY", type: D.RESERVED_KEYWORD }),
2594
- SET: w({ text: "SET", type: D.RESERVED_CLAUSE }),
2595
- STRUCT: w({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
2596
- WINDOW: w({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
2597
- VALUES: w({ text: "VALUES", type: D.RESERVED_CLAUSE })
2598
- }, mT = (R) => R === D.RESERVED_DATA_TYPE || R === D.RESERVED_KEYWORD || R === D.RESERVED_FUNCTION_NAME || R === D.RESERVED_KEYWORD_PHRASE || R === D.RESERVED_DATA_TYPE_PHRASE || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.ARRAY_KEYWORD || R === D.CASE || R === D.END || R === D.WHEN || R === D.ELSE || R === D.THEN || R === D.LIMIT || R === D.BETWEEN || R === D.AND || R === D.OR || R === D.XOR, PR = (R) => R === D.AND || R === D.OR || R === D.XOR, MR = [
2600
+ ARRAY: w({ text: "ARRAY", type: o.RESERVED_DATA_TYPE }),
2601
+ BY: w({ text: "BY", type: o.RESERVED_KEYWORD }),
2602
+ SET: w({ text: "SET", type: o.RESERVED_CLAUSE }),
2603
+ STRUCT: w({ text: "STRUCT", type: o.RESERVED_DATA_TYPE }),
2604
+ WINDOW: w({ text: "WINDOW", type: o.RESERVED_CLAUSE }),
2605
+ VALUES: w({ text: "VALUES", type: o.RESERVED_CLAUSE })
2606
+ }, pT = (R) => R === o.RESERVED_DATA_TYPE || R === o.RESERVED_KEYWORD || R === o.RESERVED_FUNCTION_NAME || R === o.RESERVED_KEYWORD_PHRASE || R === o.RESERVED_DATA_TYPE_PHRASE || R === o.RESERVED_CLAUSE || R === o.RESERVED_SELECT || R === o.RESERVED_SET_OPERATION || R === o.RESERVED_JOIN || R === o.ARRAY_KEYWORD || R === o.CASE || R === o.END || R === o.WHEN || R === o.ELSE || R === o.THEN || R === o.LIMIT || R === o.BETWEEN || R === o.AND || R === o.OR || R === o.XOR, cR = (R) => R === o.AND || R === o.OR || R === o.XOR, lR = [
2599
2607
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
2600
2608
  "KEYS.NEW_KEYSET",
2601
2609
  "KEYS.ADD_KEY_FROM_RAW_BYTES",
@@ -3139,7 +3147,7 @@ const FT = (R) => ({
3139
3147
  // pivot
3140
3148
  "PIVOT",
3141
3149
  "UNPIVOT"
3142
- ], UR = [
3150
+ ], GR = [
3143
3151
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
3144
3152
  "ALL",
3145
3153
  "AND",
@@ -3247,7 +3255,7 @@ const FT = (R) => ({
3247
3255
  "CASCADE",
3248
3256
  "RESTRICT",
3249
3257
  "DETERMINISTIC"
3250
- ], cR = [
3258
+ ], uR = [
3251
3259
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
3252
3260
  "ARRAY",
3253
3261
  "BOOL",
@@ -3272,7 +3280,7 @@ const FT = (R) => ({
3272
3280
  "STRUCT",
3273
3281
  "TIME",
3274
3282
  "TIMEZONE"
3275
- ], GR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = _([
3283
+ ], HR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), BR = _([
3276
3284
  // Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
3277
3285
  "WITH [RECURSIVE]",
3278
3286
  "FROM",
@@ -3391,15 +3399,15 @@ const FT = (R) => ({
3391
3399
  "ASSERT",
3392
3400
  // Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
3393
3401
  "EXPORT DATA"
3394
- ]), uR = _([
3402
+ ]), dR = _([
3395
3403
  "UNION {ALL | DISTINCT}",
3396
3404
  "EXCEPT DISTINCT",
3397
3405
  "INTERSECT DISTINCT"
3398
- ]), HR = _([
3406
+ ]), FR = _([
3399
3407
  "JOIN",
3400
3408
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
3401
3409
  "{INNER | CROSS} JOIN"
3402
- ]), BR = _([
3410
+ ]), pR = _([
3403
3411
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
3404
3412
  "TABLESAMPLE SYSTEM",
3405
3413
  // From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
@@ -3410,18 +3418,18 @@ const FT = (R) => ({
3410
3418
  "{ROWS | RANGE} BETWEEN",
3411
3419
  // comparison operator
3412
3420
  "IS [NOT] DISTINCT FROM"
3413
- ]), dR = _([]), FR = {
3421
+ ]), mR = _([]), YR = {
3414
3422
  name: "bigquery",
3415
3423
  tokenizerOptions: {
3416
- reservedSelect: GR,
3417
- reservedClauses: [...lR, ...LE, ...ZE],
3418
- reservedSetOperations: uR,
3419
- reservedJoins: HR,
3420
- reservedKeywordPhrases: BR,
3421
- reservedDataTypePhrases: dR,
3422
- reservedKeywords: UR,
3423
- reservedDataTypes: cR,
3424
- reservedFunctionNames: MR,
3424
+ reservedSelect: HR,
3425
+ reservedClauses: [...BR, ...LE, ...ZE],
3426
+ reservedSetOperations: dR,
3427
+ reservedJoins: FR,
3428
+ reservedKeywordPhrases: pR,
3429
+ reservedDataTypePhrases: mR,
3430
+ reservedKeywords: GR,
3431
+ reservedDataTypes: uR,
3432
+ reservedFunctionNames: lR,
3425
3433
  extraParens: ["[]"],
3426
3434
  stringTypes: [
3427
3435
  // The triple-quoted strings are listed first, so they get matched first.
@@ -3439,29 +3447,29 @@ const FT = (R) => ({
3439
3447
  variableTypes: [{ regex: String.raw`@@\w+` }],
3440
3448
  lineCommentTypes: ["--", "#"],
3441
3449
  operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
3442
- postProcess: mR
3450
+ postProcess: hR
3443
3451
  },
3444
3452
  formatOptions: {
3445
3453
  onelineClauses: [...ZE, ...LE],
3446
3454
  tabularOnelineClauses: LE
3447
3455
  }
3448
3456
  };
3449
- function mR(R) {
3450
- return pR(YR(R));
3457
+ function hR(R) {
3458
+ return fR(VR(R));
3451
3459
  }
3452
- function pR(R) {
3460
+ function fR(R) {
3453
3461
  let E = v;
3454
- return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type: D.RESERVED_FUNCTION_NAME })) : (E = T, T));
3462
+ return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type: o.RESERVED_FUNCTION_NAME })) : (E = T, T));
3455
3463
  }
3456
- function YR(R) {
3464
+ function VR(R) {
3457
3465
  var E;
3458
3466
  const T = [];
3459
3467
  for (let A = 0; A < R.length; A++) {
3460
3468
  const e = R[A];
3461
3469
  if ((y.ARRAY(e) || y.STRUCT(e)) && ((E = R[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3462
- const S = hR(R, A + 1), I = R.slice(A, S + 1);
3470
+ const S = WR(R, A + 1), I = R.slice(A, S + 1);
3463
3471
  T.push({
3464
- type: D.IDENTIFIER,
3472
+ type: o.IDENTIFIER,
3465
3473
  raw: I.map(qE("raw")).join(""),
3466
3474
  text: I.map(qE("text")).join(""),
3467
3475
  start: e.start
@@ -3471,8 +3479,8 @@ function YR(R) {
3471
3479
  }
3472
3480
  return T;
3473
3481
  }
3474
- const qE = (R) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[R] + " " : E[R];
3475
- function hR(R, E) {
3482
+ const qE = (R) => (E) => E.type === o.IDENTIFIER || E.type === o.COMMA ? E[R] + " " : E[R];
3483
+ function WR(R, E) {
3476
3484
  let T = 0;
3477
3485
  for (let A = E; A < R.length; A++) {
3478
3486
  const e = R[A];
@@ -3481,7 +3489,7 @@ function hR(R, E) {
3481
3489
  }
3482
3490
  return R.length - 1;
3483
3491
  }
3484
- const fR = [
3492
+ const XR = [
3485
3493
  // https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
3486
3494
  "ARRAY_AGG",
3487
3495
  "AVG",
@@ -3801,7 +3809,7 @@ const fR = [
3801
3809
  "RATIO_TO_REPORT",
3802
3810
  // Type casting
3803
3811
  "CAST"
3804
- ], VR = [
3812
+ ], bR = [
3805
3813
  // https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
3806
3814
  "ACTIVATE",
3807
3815
  "ADD",
@@ -4202,7 +4210,7 @@ const fR = [
4202
4210
  "XMLNAMESPACES",
4203
4211
  "YEAR",
4204
4212
  "YEARS"
4205
- ], WR = [
4213
+ ], yR = [
4206
4214
  // https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
4207
4215
  "ARRAY",
4208
4216
  "BIGINT",
@@ -4244,7 +4252,7 @@ const fR = [
4244
4252
  "VARBINARY",
4245
4253
  "VARCHAR",
4246
4254
  "VARGRAPHIC"
4247
- ], XR = _(["SELECT [ALL | DISTINCT]"]), bR = _([
4255
+ ], KR = _(["SELECT [ALL | DISTINCT]"]), gR = _([
4248
4256
  // queries
4249
4257
  "WITH",
4250
4258
  "FROM",
@@ -4478,27 +4486,27 @@ const fR = [
4478
4486
  "TRANSFER OWNERSHIP OF",
4479
4487
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
4480
4488
  "WHILE"
4481
- ]), yR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = _([
4489
+ ]), $R = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), wR = _([
4482
4490
  "JOIN",
4483
4491
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
4484
4492
  "{INNER | CROSS} JOIN"
4485
- ]), $R = _([
4493
+ ]), JR = _([
4486
4494
  "ON DELETE",
4487
4495
  "ON UPDATE",
4488
4496
  "SET NULL",
4489
4497
  "{ROWS | RANGE} BETWEEN"
4490
- ]), gR = _([]), wR = {
4498
+ ]), xR = _([]), vR = {
4491
4499
  name: "db2",
4492
4500
  tokenizerOptions: {
4493
- reservedSelect: XR,
4494
- reservedClauses: [...bR, ...jE, ..._E],
4495
- reservedSetOperations: yR,
4496
- reservedJoins: KR,
4497
- reservedKeywordPhrases: $R,
4498
- reservedDataTypePhrases: gR,
4499
- reservedKeywords: VR,
4500
- reservedDataTypes: WR,
4501
- reservedFunctionNames: fR,
4501
+ reservedSelect: KR,
4502
+ reservedClauses: [...gR, ...jE, ..._E],
4503
+ reservedSetOperations: $R,
4504
+ reservedJoins: wR,
4505
+ reservedKeywordPhrases: JR,
4506
+ reservedDataTypePhrases: xR,
4507
+ reservedKeywords: bR,
4508
+ reservedDataTypes: yR,
4509
+ reservedFunctionNames: XR,
4502
4510
  extraParens: ["[]"],
4503
4511
  stringTypes: [
4504
4512
  { quote: "''-qq", prefixes: ["G", "N", "U&"] },
@@ -4532,7 +4540,7 @@ const fR = [
4532
4540
  onelineClauses: [...jE, ..._E],
4533
4541
  tabularOnelineClauses: _E
4534
4542
  }
4535
- }, JR = [
4543
+ }, QR = [
4536
4544
  // https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
4537
4545
  // TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
4538
4546
  "ARRAY_AGG",
@@ -4866,7 +4874,7 @@ const fR = [
4866
4874
  "ROW_NUMBER",
4867
4875
  // Type casting
4868
4876
  "CAST"
4869
- ], xR = [
4877
+ ], ZR = [
4870
4878
  // https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
4871
4879
  // TODO: This list likely contains all keywords, not only the reserved ones,
4872
4880
  // try to filter it down to just the reserved keywords.
@@ -5362,7 +5370,7 @@ const fR = [
5362
5370
  "YEARS",
5363
5371
  "YES",
5364
5372
  "ZONE"
5365
- ], vR = [
5373
+ ], qR = [
5366
5374
  // https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
5367
5375
  "ARRAY",
5368
5376
  "BIGINT",
@@ -5398,7 +5406,7 @@ const fR = [
5398
5406
  "VARCHAR",
5399
5407
  "VARGRAPHIC",
5400
5408
  "XML"
5401
- ], QR = _(["SELECT [ALL | DISTINCT]"]), ZR = _([
5409
+ ], jR = _(["SELECT [ALL | DISTINCT]"]), kR = _([
5402
5410
  // queries
5403
5411
  "WITH [RECURSIVE]",
5404
5412
  "INTO",
@@ -5524,28 +5532,28 @@ const fR = [
5524
5532
  "TAG",
5525
5533
  "TRANSFER OWNERSHIP OF",
5526
5534
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
5527
- ]), qR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = _([
5535
+ ]), zR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), EA = _([
5528
5536
  "JOIN",
5529
5537
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
5530
5538
  "[LEFT | RIGHT] EXCEPTION JOIN",
5531
5539
  "{INNER | CROSS} JOIN"
5532
- ]), kR = _([
5540
+ ]), TA = _([
5533
5541
  "ON DELETE",
5534
5542
  "ON UPDATE",
5535
5543
  "SET NULL",
5536
5544
  "{ROWS | RANGE} BETWEEN"
5537
- ]), zR = _([]), EA = {
5545
+ ]), RA = _([]), AA = {
5538
5546
  name: "db2i",
5539
5547
  tokenizerOptions: {
5540
- reservedSelect: QR,
5541
- reservedClauses: [...ZR, ...kE, ...rE],
5542
- reservedSetOperations: qR,
5543
- reservedJoins: jR,
5544
- reservedKeywordPhrases: kR,
5545
- reservedDataTypePhrases: zR,
5546
- reservedKeywords: xR,
5547
- reservedDataTypes: vR,
5548
- reservedFunctionNames: JR,
5548
+ reservedSelect: jR,
5549
+ reservedClauses: [...kR, ...kE, ...rE],
5550
+ reservedSetOperations: zR,
5551
+ reservedJoins: EA,
5552
+ reservedKeywordPhrases: TA,
5553
+ reservedDataTypePhrases: RA,
5554
+ reservedKeywords: ZR,
5555
+ reservedDataTypes: qR,
5556
+ reservedFunctionNames: QR,
5549
5557
  nestedBlockComments: !0,
5550
5558
  extraParens: ["[]"],
5551
5559
  stringTypes: [
@@ -5562,7 +5570,7 @@ const fR = [
5562
5570
  onelineClauses: [...kE, ...rE],
5563
5571
  tabularOnelineClauses: rE
5564
5572
  }
5565
- }, TA = [
5573
+ }, eA = [
5566
5574
  // Functions from DuckDB (excluding those that start with an underscore):
5567
5575
  // SELECT DISTINCT upper(function_name) AS function_name
5568
5576
  // FROM duckdb_functions()
@@ -6225,7 +6233,7 @@ const fR = [
6225
6233
  // 'NULL', we really prefer treating it as keyword
6226
6234
  "RANK",
6227
6235
  "ROW_NUMBER"
6228
- ], RA = [
6236
+ ], SA = [
6229
6237
  // Keywords from DuckDB:
6230
6238
  // SELECT upper(keyword_name)
6231
6239
  // FROM duckdb_keywords()
@@ -6307,7 +6315,7 @@ const fR = [
6307
6315
  "WHERE",
6308
6316
  "WINDOW",
6309
6317
  "WITH"
6310
- ], AA = [
6318
+ ], IA = [
6311
6319
  // Types from DuckDB:
6312
6320
  // SELECT DISTINCT upper(type_name)
6313
6321
  // FROM duckdb_types()
@@ -6387,7 +6395,7 @@ const fR = [
6387
6395
  "UUID",
6388
6396
  "VARBINARY",
6389
6397
  "VARCHAR"
6390
- ], eA = _(["SELECT [ALL | DISTINCT]"]), SA = _([
6398
+ ], OA = _(["SELECT [ALL | DISTINCT]"]), NA = _([
6391
6399
  // queries
6392
6400
  "WITH [RECURSIVE]",
6393
6401
  "FROM",
@@ -6491,11 +6499,11 @@ const fR = [
6491
6499
  "PREPARE",
6492
6500
  "EXECUTE",
6493
6501
  "DEALLOCATE [PREPARE]"
6494
- ]), IA = _([
6502
+ ]), tA = _([
6495
6503
  "UNION [ALL | BY NAME]",
6496
6504
  "EXCEPT [ALL]",
6497
6505
  "INTERSECT [ALL]"
6498
- ]), OA = _([
6506
+ ]), sA = _([
6499
6507
  "JOIN",
6500
6508
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6501
6509
  "{INNER | CROSS} JOIN",
@@ -6504,23 +6512,23 @@ const fR = [
6504
6512
  "POSITIONAL JOIN",
6505
6513
  "ANTI JOIN",
6506
6514
  "SEMI JOIN"
6507
- ]), NA = _([
6515
+ ]), CA = _([
6508
6516
  "{ROWS | RANGE | GROUPS} BETWEEN",
6509
6517
  "SIMILAR TO",
6510
6518
  "IS [NOT] DISTINCT FROM"
6511
- ]), tA = _(["TIMESTAMP WITH TIME ZONE"]), sA = {
6519
+ ]), LA = _(["TIMESTAMP WITH TIME ZONE"]), _A = {
6512
6520
  name: "duckdb",
6513
6521
  tokenizerOptions: {
6514
- reservedSelect: eA,
6515
- reservedClauses: [...SA, ...zE, ...nE],
6516
- reservedSetOperations: IA,
6517
- reservedJoins: OA,
6518
- reservedKeywordPhrases: NA,
6519
- reservedDataTypePhrases: tA,
6522
+ reservedSelect: OA,
6523
+ reservedClauses: [...NA, ...zE, ...nE],
6524
+ reservedSetOperations: tA,
6525
+ reservedJoins: sA,
6526
+ reservedKeywordPhrases: CA,
6527
+ reservedDataTypePhrases: LA,
6520
6528
  supportsXor: !0,
6521
- reservedKeywords: RA,
6522
- reservedDataTypes: AA,
6523
- reservedFunctionNames: TA,
6529
+ reservedKeywords: SA,
6530
+ reservedDataTypes: IA,
6531
+ reservedFunctionNames: eA,
6524
6532
  nestedBlockComments: !0,
6525
6533
  extraParens: ["[]", "{}"],
6526
6534
  underscoresInNumbers: !0,
@@ -6584,7 +6592,7 @@ const fR = [
6584
6592
  onelineClauses: [...zE, ...nE],
6585
6593
  tabularOnelineClauses: nE
6586
6594
  }
6587
- }, CA = [
6595
+ }, rA = [
6588
6596
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
6589
6597
  // math
6590
6598
  "ABS",
@@ -6792,7 +6800,7 @@ const fR = [
6792
6800
  "CUME_DIST",
6793
6801
  "PERCENT_RANK",
6794
6802
  "NTILE"
6795
- ], LA = [
6803
+ ], nA = [
6796
6804
  // https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
6797
6805
  // Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
6798
6806
  "ADD",
@@ -7107,7 +7115,7 @@ const fR = [
7107
7115
  "JSONFILE",
7108
7116
  "INPUTFORMAT",
7109
7117
  "OUTPUTFORMAT"
7110
- ], _A = [
7118
+ ], iA = [
7111
7119
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
7112
7120
  "ARRAY",
7113
7121
  "BIGINT",
@@ -7128,7 +7136,7 @@ const fR = [
7128
7136
  "STRUCT",
7129
7137
  "TIMESTAMP",
7130
7138
  "VARCHAR"
7131
- ], rA = _(["SELECT [ALL | DISTINCT]"]), nA = _([
7139
+ ], aA = _(["SELECT [ALL | DISTINCT]"]), oA = _([
7132
7140
  // queries
7133
7141
  "WITH",
7134
7142
  "FROM",
@@ -7189,24 +7197,24 @@ const fR = [
7189
7197
  "STORED AS",
7190
7198
  "STORED BY",
7191
7199
  "ROW FORMAT"
7192
- ]), iA = _(["UNION [ALL | DISTINCT]"]), aA = _([
7200
+ ]), DA = _(["UNION [ALL | DISTINCT]"]), PA = _([
7193
7201
  "JOIN",
7194
7202
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
7195
7203
  "{INNER | CROSS} JOIN",
7196
7204
  // non-standard joins
7197
7205
  "LEFT SEMI JOIN"
7198
- ]), oA = _(["{ROWS | RANGE} BETWEEN"]), DA = _([]), PA = {
7206
+ ]), MA = _(["{ROWS | RANGE} BETWEEN"]), UA = _([]), cA = {
7199
7207
  name: "hive",
7200
7208
  tokenizerOptions: {
7201
- reservedSelect: rA,
7202
- reservedClauses: [...nA, ...ET, ...iE],
7203
- reservedSetOperations: iA,
7204
- reservedJoins: aA,
7205
- reservedKeywordPhrases: oA,
7206
- reservedDataTypePhrases: DA,
7207
- reservedKeywords: LA,
7208
- reservedDataTypes: _A,
7209
- reservedFunctionNames: CA,
7209
+ reservedSelect: aA,
7210
+ reservedClauses: [...oA, ...ET, ...iE],
7211
+ reservedSetOperations: DA,
7212
+ reservedJoins: PA,
7213
+ reservedKeywordPhrases: MA,
7214
+ reservedDataTypePhrases: UA,
7215
+ reservedKeywords: nA,
7216
+ reservedDataTypes: iA,
7217
+ reservedFunctionNames: rA,
7210
7218
  extraParens: ["[]"],
7211
7219
  stringTypes: ['""-bs', "''-bs"],
7212
7220
  identTypes: ["``"],
@@ -7222,12 +7230,12 @@ function AE(R) {
7222
7230
  return R.map((E, T) => {
7223
7231
  const A = R[T + 1] || v;
7224
7232
  if (y.SET(E) && A.text === "(")
7225
- return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
7233
+ return Object.assign(Object.assign({}, E), { type: o.RESERVED_FUNCTION_NAME });
7226
7234
  const e = R[T - 1] || v;
7227
- return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
7235
+ return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: o.RESERVED_FUNCTION_NAME }) : E;
7228
7236
  });
7229
7237
  }
7230
- const MA = [
7238
+ const lA = [
7231
7239
  // https://mariadb.com/kb/en/reserved-words/
7232
7240
  "ACCESSIBLE",
7233
7241
  "ADD",
@@ -7444,7 +7452,7 @@ const MA = [
7444
7452
  "XOR",
7445
7453
  "YEAR_MONTH",
7446
7454
  "ZEROFILL"
7447
- ], UA = [
7455
+ ], GA = [
7448
7456
  // https://mariadb.com/kb/en/data-types/
7449
7457
  "BIGINT",
7450
7458
  "BINARY",
@@ -7495,7 +7503,7 @@ const MA = [
7495
7503
  "YEAR"
7496
7504
  // 'NUMBER', // ?? In oracle mode only
7497
7505
  // 'SET' // handled as special-case in postProcess
7498
- ], cA = [
7506
+ ], uA = [
7499
7507
  // https://mariadb.com/kb/en/information-schema-sql_functions-table/
7500
7508
  "ADDDATE",
7501
7509
  "ADD_MONTHS",
@@ -7733,7 +7741,7 @@ const MA = [
7733
7741
  // CASE expression shorthands
7734
7742
  "COALESCE",
7735
7743
  "NULLIF"
7736
- ], GA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = _([
7744
+ ], HA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), BA = _([
7737
7745
  // queries
7738
7746
  "WITH [RECURSIVE]",
7739
7747
  "FROM",
@@ -7964,12 +7972,12 @@ const MA = [
7964
7972
  "XA RECOVER",
7965
7973
  "XA ROLLBACK",
7966
7974
  "XA START"
7967
- ]), uA = _([
7975
+ ]), dA = _([
7968
7976
  "UNION [ALL | DISTINCT]",
7969
7977
  "EXCEPT [ALL | DISTINCT]",
7970
7978
  "INTERSECT [ALL | DISTINCT]",
7971
7979
  "MINUS [ALL | DISTINCT]"
7972
- ]), HA = _([
7980
+ ]), FA = _([
7973
7981
  "JOIN",
7974
7982
  "{LEFT | RIGHT} [OUTER] JOIN",
7975
7983
  "{INNER | CROSS} JOIN",
@@ -7977,24 +7985,24 @@ const MA = [
7977
7985
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
7978
7986
  // non-standard joins
7979
7987
  "STRAIGHT_JOIN"
7980
- ]), BA = _([
7988
+ ]), pA = _([
7981
7989
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
7982
7990
  "CHARACTER SET",
7983
7991
  "{ROWS | RANGE} BETWEEN",
7984
7992
  "IDENTIFIED BY"
7985
- ]), dA = _([]), FA = {
7993
+ ]), mA = _([]), YA = {
7986
7994
  name: "mariadb",
7987
7995
  tokenizerOptions: {
7988
- reservedSelect: GA,
7989
- reservedClauses: [...lA, ...TT, ...aE],
7990
- reservedSetOperations: uA,
7991
- reservedJoins: HA,
7992
- reservedKeywordPhrases: BA,
7993
- reservedDataTypePhrases: dA,
7996
+ reservedSelect: HA,
7997
+ reservedClauses: [...BA, ...TT, ...aE],
7998
+ reservedSetOperations: dA,
7999
+ reservedJoins: FA,
8000
+ reservedKeywordPhrases: pA,
8001
+ reservedDataTypePhrases: mA,
7994
8002
  supportsXor: !0,
7995
- reservedKeywords: MA,
7996
- reservedDataTypes: UA,
7997
- reservedFunctionNames: cA,
8003
+ reservedKeywords: lA,
8004
+ reservedDataTypes: GA,
8005
+ reservedFunctionNames: uA,
7998
8006
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
7999
8007
  stringTypes: [
8000
8008
  '""-qq-bs',
@@ -8033,7 +8041,7 @@ const MA = [
8033
8041
  onelineClauses: [...TT, ...aE],
8034
8042
  tabularOnelineClauses: aE
8035
8043
  }
8036
- }, mA = [
8044
+ }, hA = [
8037
8045
  // https://dev.mysql.com/doc/refman/8.0/en/keywords.html
8038
8046
  "ACCESSIBLE",
8039
8047
  "ADD",
@@ -8264,7 +8272,7 @@ const MA = [
8264
8272
  "YEAR_MONTH",
8265
8273
  "ZEROFILL"
8266
8274
  // (R)
8267
- ], pA = [
8275
+ ], fA = [
8268
8276
  // https://dev.mysql.com/doc/refman/8.0/en/data-types.html
8269
8277
  "BIGINT",
8270
8278
  "BINARY",
@@ -8316,7 +8324,7 @@ const MA = [
8316
8324
  "VARYING",
8317
8325
  "YEAR"
8318
8326
  // 'SET' // handled as special-case in postProcess
8319
- ], YA = [
8327
+ ], VA = [
8320
8328
  // https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
8321
8329
  "ABS",
8322
8330
  "ACOS",
@@ -8739,7 +8747,7 @@ const MA = [
8739
8747
  // 'XOR',
8740
8748
  "YEAR",
8741
8749
  "YEARWEEK"
8742
- ], hA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = _([
8750
+ ], WA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), XA = _([
8743
8751
  // queries
8744
8752
  "WITH [RECURSIVE]",
8745
8753
  "FROM",
@@ -8940,7 +8948,7 @@ const MA = [
8940
8948
  "REPEAT",
8941
8949
  "RETURN",
8942
8950
  "WHILE"
8943
- ]), VA = _(["UNION [ALL | DISTINCT]"]), WA = _([
8951
+ ]), bA = _(["UNION [ALL | DISTINCT]"]), yA = _([
8944
8952
  "JOIN",
8945
8953
  "{LEFT | RIGHT} [OUTER] JOIN",
8946
8954
  "{INNER | CROSS} JOIN",
@@ -8948,24 +8956,24 @@ const MA = [
8948
8956
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
8949
8957
  // non-standard joins
8950
8958
  "STRAIGHT_JOIN"
8951
- ]), XA = _([
8959
+ ]), KA = _([
8952
8960
  "ON {UPDATE | DELETE} [SET NULL]",
8953
8961
  "CHARACTER SET",
8954
8962
  "{ROWS | RANGE} BETWEEN",
8955
8963
  "IDENTIFIED BY"
8956
- ]), bA = _([]), yA = {
8964
+ ]), gA = _([]), $A = {
8957
8965
  name: "mysql",
8958
8966
  tokenizerOptions: {
8959
- reservedSelect: hA,
8960
- reservedClauses: [...fA, ...RT, ...oE],
8961
- reservedSetOperations: VA,
8962
- reservedJoins: WA,
8963
- reservedKeywordPhrases: XA,
8964
- reservedDataTypePhrases: bA,
8967
+ reservedSelect: WA,
8968
+ reservedClauses: [...XA, ...RT, ...oE],
8969
+ reservedSetOperations: bA,
8970
+ reservedJoins: yA,
8971
+ reservedKeywordPhrases: KA,
8972
+ reservedDataTypePhrases: gA,
8965
8973
  supportsXor: !0,
8966
- reservedKeywords: mA,
8967
- reservedDataTypes: pA,
8968
- reservedFunctionNames: YA,
8974
+ reservedKeywords: hA,
8975
+ reservedDataTypes: fA,
8976
+ reservedFunctionNames: VA,
8969
8977
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
8970
8978
  stringTypes: [
8971
8979
  '""-qq-bs',
@@ -9006,7 +9014,7 @@ const MA = [
9006
9014
  onelineClauses: [...RT, ...oE],
9007
9015
  tabularOnelineClauses: oE
9008
9016
  }
9009
- }, KA = [
9017
+ }, wA = [
9010
9018
  // https://docs.pingcap.com/tidb/stable/keywords
9011
9019
  "ADD",
9012
9020
  "ALL",
@@ -9198,7 +9206,7 @@ const MA = [
9198
9206
  "YEAR_MONTH",
9199
9207
  "ZEROFILL"
9200
9208
  // (R)
9201
- ], $A = [
9209
+ ], JA = [
9202
9210
  // https://docs.pingcap.com/tidb/stable/data-type-overview
9203
9211
  "BIGINT",
9204
9212
  "BINARY",
@@ -9245,7 +9253,7 @@ const MA = [
9245
9253
  "VARYING",
9246
9254
  "YEAR"
9247
9255
  // 'SET' // handled as special-case in postProcess
9248
- ], gA = [
9256
+ ], xA = [
9249
9257
  // https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
9250
9258
  // https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
9251
9259
  // + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
@@ -9571,7 +9579,7 @@ const MA = [
9571
9579
  // 'XOR',
9572
9580
  "YEAR",
9573
9581
  "YEARWEEK"
9574
- ], wA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = _([
9582
+ ], vA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), QA = _([
9575
9583
  // queries
9576
9584
  "WITH [RECURSIVE]",
9577
9585
  "FROM",
@@ -9706,7 +9714,7 @@ const MA = [
9706
9714
  "UNLOCK TABLES",
9707
9715
  // https://docs.pingcap.com/tidb/stable/sql-statement-use
9708
9716
  "USE"
9709
- ]), xA = _(["UNION [ALL | DISTINCT]"]), vA = _([
9717
+ ]), ZA = _(["UNION [ALL | DISTINCT]"]), qA = _([
9710
9718
  "JOIN",
9711
9719
  "{LEFT | RIGHT} [OUTER] JOIN",
9712
9720
  "{INNER | CROSS} JOIN",
@@ -9714,24 +9722,24 @@ const MA = [
9714
9722
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
9715
9723
  // non-standard joins
9716
9724
  "STRAIGHT_JOIN"
9717
- ]), QA = _([
9725
+ ]), jA = _([
9718
9726
  "ON {UPDATE | DELETE} [SET NULL]",
9719
9727
  "CHARACTER SET",
9720
9728
  "{ROWS | RANGE} BETWEEN",
9721
9729
  "IDENTIFIED BY"
9722
- ]), ZA = _([]), qA = {
9730
+ ]), kA = _([]), zA = {
9723
9731
  name: "tidb",
9724
9732
  tokenizerOptions: {
9725
- reservedSelect: wA,
9726
- reservedClauses: [...JA, ...AT, ...DE],
9727
- reservedSetOperations: xA,
9728
- reservedJoins: vA,
9729
- reservedKeywordPhrases: QA,
9730
- reservedDataTypePhrases: ZA,
9733
+ reservedSelect: vA,
9734
+ reservedClauses: [...QA, ...AT, ...DE],
9735
+ reservedSetOperations: ZA,
9736
+ reservedJoins: qA,
9737
+ reservedKeywordPhrases: jA,
9738
+ reservedDataTypePhrases: kA,
9731
9739
  supportsXor: !0,
9732
- reservedKeywords: KA,
9733
- reservedDataTypes: $A,
9734
- reservedFunctionNames: gA,
9740
+ reservedKeywords: wA,
9741
+ reservedDataTypes: JA,
9742
+ reservedFunctionNames: xA,
9735
9743
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
9736
9744
  stringTypes: [
9737
9745
  '""-qq-bs',
@@ -9772,7 +9780,7 @@ const MA = [
9772
9780
  onelineClauses: [...AT, ...DE],
9773
9781
  tabularOnelineClauses: DE
9774
9782
  }
9775
- }, jA = [
9783
+ }, Ee = [
9776
9784
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
9777
9785
  "ABORT",
9778
9786
  "ABS",
@@ -10002,7 +10010,7 @@ const MA = [
10002
10010
  // not implemented in N1QL, but added here now for the sake of tests
10003
10011
  // https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
10004
10012
  "CAST"
10005
- ], kA = [
10013
+ ], Te = [
10006
10014
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
10007
10015
  "ADVISE",
10008
10016
  "ALL",
@@ -10208,7 +10216,7 @@ const MA = [
10208
10216
  "WITHIN",
10209
10217
  "WORK",
10210
10218
  "XOR"
10211
- ], zA = [
10219
+ ], Re = [
10212
10220
  // N1QL does not support any way of declaring types for columns.
10213
10221
  // It does not support the CREATE TABLE statement nor the CAST() expression.
10214
10222
  //
@@ -10217,7 +10225,7 @@ const MA = [
10217
10225
  // which it actually doesn't use.
10218
10226
  //
10219
10227
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
10220
- ], Ee = _(["SELECT [ALL | DISTINCT]"]), Te = _([
10228
+ ], Ae = _(["SELECT [ALL | DISTINCT]"]), ee = _([
10221
10229
  // queries
10222
10230
  "WITH",
10223
10231
  "FROM",
@@ -10284,19 +10292,19 @@ const MA = [
10284
10292
  "SET CURRENT SCHEMA",
10285
10293
  "SHOW",
10286
10294
  "USE [PRIMARY] KEYS"
10287
- ]), Re = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ae = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ee = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), Se = _([]), Ie = {
10295
+ ]), Se = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ie = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), Oe = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), Ne = _([]), te = {
10288
10296
  name: "n1ql",
10289
10297
  tokenizerOptions: {
10290
- reservedSelect: Ee,
10291
- reservedClauses: [...Te, ...eT],
10292
- reservedSetOperations: Re,
10293
- reservedJoins: Ae,
10294
- reservedKeywordPhrases: ee,
10295
- reservedDataTypePhrases: Se,
10298
+ reservedSelect: Ae,
10299
+ reservedClauses: [...ee, ...eT],
10300
+ reservedSetOperations: Se,
10301
+ reservedJoins: Ie,
10302
+ reservedKeywordPhrases: Oe,
10303
+ reservedDataTypePhrases: Ne,
10296
10304
  supportsXor: !0,
10297
- reservedKeywords: kA,
10298
- reservedDataTypes: zA,
10299
- reservedFunctionNames: jA,
10305
+ reservedKeywords: Te,
10306
+ reservedDataTypes: Re,
10307
+ reservedFunctionNames: Ee,
10300
10308
  // NOTE: single quotes are actually not supported in N1QL,
10301
10309
  // but we support them anyway as all other SQL dialects do,
10302
10310
  // which simplifies writing tests that are shared between all dialects.
@@ -10310,7 +10318,7 @@ const MA = [
10310
10318
  formatOptions: {
10311
10319
  onelineClauses: eT
10312
10320
  }
10313
- }, Oe = [
10321
+ }, se = [
10314
10322
  // https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
10315
10323
  // 'A',
10316
10324
  "ADD",
@@ -10615,7 +10623,7 @@ const MA = [
10615
10623
  "WRITE",
10616
10624
  "YEAR",
10617
10625
  "ZONE"
10618
- ], Ne = [
10626
+ ], Ce = [
10619
10627
  // https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
10620
10628
  "ARRAY",
10621
10629
  "BFILE_BASE",
@@ -10653,7 +10661,7 @@ const MA = [
10653
10661
  "UROWID",
10654
10662
  "VARCHAR",
10655
10663
  "VARCHAR2"
10656
- ], te = [
10664
+ ], Le = [
10657
10665
  // https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
10658
10666
  // numeric
10659
10667
  "ABS",
@@ -10918,7 +10926,7 @@ const MA = [
10918
10926
  "PRESENTNNV",
10919
10927
  "PRESENTV",
10920
10928
  "PREVIOUS"
10921
- ], se = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = _([
10929
+ ], _e = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), re = _([
10922
10930
  // queries
10923
10931
  "WITH",
10924
10932
  "FROM",
@@ -10972,7 +10980,7 @@ const MA = [
10972
10980
  "EXCEPTION",
10973
10981
  "LOOP",
10974
10982
  "START WITH"
10975
- ]), Le = _(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = _([
10983
+ ]), ne = _(["UNION [ALL]", "MINUS", "INTERSECT"]), ie = _([
10976
10984
  "JOIN",
10977
10985
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
10978
10986
  "{INNER | CROSS} JOIN",
@@ -10980,23 +10988,23 @@ const MA = [
10980
10988
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
10981
10989
  // non-standard joins
10982
10990
  "{CROSS | OUTER} APPLY"
10983
- ]), re = _([
10991
+ ]), ae = _([
10984
10992
  "ON {UPDATE | DELETE} [SET NULL]",
10985
10993
  "ON COMMIT",
10986
10994
  "{ROWS | RANGE} BETWEEN"
10987
- ]), ne = _([]), ie = {
10995
+ ]), oe = _([]), De = {
10988
10996
  name: "plsql",
10989
10997
  tokenizerOptions: {
10990
- reservedSelect: se,
10991
- reservedClauses: [...Ce, ...ST, ...PE],
10992
- reservedSetOperations: Le,
10993
- reservedJoins: _e,
10994
- reservedKeywordPhrases: re,
10995
- reservedDataTypePhrases: ne,
10998
+ reservedSelect: _e,
10999
+ reservedClauses: [...re, ...ST, ...PE],
11000
+ reservedSetOperations: ne,
11001
+ reservedJoins: ie,
11002
+ reservedKeywordPhrases: ae,
11003
+ reservedDataTypePhrases: oe,
10996
11004
  supportsXor: !0,
10997
- reservedKeywords: Oe,
10998
- reservedDataTypes: Ne,
10999
- reservedFunctionNames: te,
11005
+ reservedKeywords: se,
11006
+ reservedDataTypes: Ce,
11007
+ reservedFunctionNames: Le,
11000
11008
  stringTypes: [
11001
11009
  { quote: "''-qq", prefixes: ["N"] },
11002
11010
  { quote: "q''", prefixes: ["N"] }
@@ -11021,7 +11029,7 @@ const MA = [
11021
11029
  "@",
11022
11030
  "||"
11023
11031
  ],
11024
- postProcess: ae
11032
+ postProcess: Pe
11025
11033
  },
11026
11034
  formatOptions: {
11027
11035
  alwaysDenseOperators: ["@"],
@@ -11029,11 +11037,11 @@ const MA = [
11029
11037
  tabularOnelineClauses: PE
11030
11038
  }
11031
11039
  };
11032
- function ae(R) {
11040
+ function Pe(R) {
11033
11041
  let E = v;
11034
- return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: D.RESERVED_KEYWORD }) : (mT(T.type) && (E = T), T));
11042
+ return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: o.RESERVED_KEYWORD }) : (pT(T.type) && (E = T), T));
11035
11043
  }
11036
- const oe = [
11044
+ const Me = [
11037
11045
  // https://www.postgresql.org/docs/14/functions.html
11038
11046
  //
11039
11047
  // https://www.postgresql.org/docs/14/functions-math.html
@@ -11717,7 +11725,7 @@ const oe = [
11717
11725
  "PG_MCV_LIST_ITEMS",
11718
11726
  // cast
11719
11727
  "CAST"
11720
- ], De = [
11728
+ ], Ue = [
11721
11729
  // https://www.postgresql.org/docs/14/sql-keywords-appendix.html
11722
11730
  "ALL",
11723
11731
  "ANALYSE",
@@ -11836,7 +11844,7 @@ const oe = [
11836
11844
  "WITHOUT",
11837
11845
  "YEAR"
11838
11846
  // requires AS
11839
- ], Pe = [
11847
+ ], ce = [
11840
11848
  // https://www.postgresql.org/docs/current/datatype.html
11841
11849
  "ARRAY",
11842
11850
  "BIGINT",
@@ -11870,7 +11878,7 @@ const oe = [
11870
11878
  "VARCHAR",
11871
11879
  "XML",
11872
11880
  "ZONE"
11873
- ], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
11881
+ ], le = _(["SELECT [ALL | DISTINCT]"]), Ge = _([
11874
11882
  // queries
11875
11883
  "WITH [RECURSIVE]",
11876
11884
  "FROM",
@@ -12093,17 +12101,17 @@ const oe = [
12093
12101
  "START TRANSACTION",
12094
12102
  "UNLISTEN",
12095
12103
  "VACUUM"
12096
- ]), ce = _([
12104
+ ]), ue = _([
12097
12105
  "UNION [ALL | DISTINCT]",
12098
12106
  "EXCEPT [ALL | DISTINCT]",
12099
12107
  "INTERSECT [ALL | DISTINCT]"
12100
- ]), Ge = _([
12108
+ ]), He = _([
12101
12109
  "JOIN",
12102
12110
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12103
12111
  "{INNER | CROSS} JOIN",
12104
12112
  "NATURAL [INNER] JOIN",
12105
12113
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12106
- ]), le = _([
12114
+ ]), Be = _([
12107
12115
  "PRIMARY KEY",
12108
12116
  "GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
12109
12117
  "ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
@@ -12114,21 +12122,21 @@ const oe = [
12114
12122
  "IS [NOT] DISTINCT FROM",
12115
12123
  "NULLS {FIRST | LAST}",
12116
12124
  "WITH ORDINALITY"
12117
- ]), ue = _([
12125
+ ]), de = _([
12118
12126
  // https://www.postgresql.org/docs/current/datatype-datetime.html
12119
12127
  "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
12120
- ]), He = {
12128
+ ]), Fe = {
12121
12129
  name: "postgresql",
12122
12130
  tokenizerOptions: {
12123
- reservedSelect: Me,
12124
- reservedClauses: [...Ue, ...IT, ...ME],
12125
- reservedSetOperations: ce,
12126
- reservedJoins: Ge,
12127
- reservedKeywordPhrases: le,
12128
- reservedDataTypePhrases: ue,
12129
- reservedKeywords: De,
12130
- reservedDataTypes: Pe,
12131
- reservedFunctionNames: oe,
12131
+ reservedSelect: le,
12132
+ reservedClauses: [...Ge, ...IT, ...ME],
12133
+ reservedSetOperations: ue,
12134
+ reservedJoins: He,
12135
+ reservedKeywordPhrases: Be,
12136
+ reservedDataTypePhrases: de,
12137
+ reservedKeywords: Ue,
12138
+ reservedDataTypes: ce,
12139
+ reservedFunctionNames: Me,
12132
12140
  nestedBlockComments: !0,
12133
12141
  extraParens: ["[]"],
12134
12142
  underscoresInNumbers: !0,
@@ -12243,7 +12251,7 @@ const oe = [
12243
12251
  onelineClauses: [...IT, ...ME],
12244
12252
  tabularOnelineClauses: ME
12245
12253
  }
12246
- }, Be = [
12254
+ }, pe = [
12247
12255
  // https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
12248
12256
  "ANY_VALUE",
12249
12257
  "APPROXIMATE PERCENTILE_DISC",
@@ -12589,7 +12597,7 @@ const oe = [
12589
12597
  "SLICE_NUM",
12590
12598
  "USER",
12591
12599
  "VERSION"
12592
- ], de = [
12600
+ ], me = [
12593
12601
  // https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
12594
12602
  "AES128",
12595
12603
  "AES256",
@@ -12778,7 +12786,7 @@ const oe = [
12778
12786
  * SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
12779
12787
  * SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
12780
12788
  */
12781
- ], Fe = [
12789
+ ], Ye = [
12782
12790
  // https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
12783
12791
  "ARRAY",
12784
12792
  "BIGINT",
@@ -12799,7 +12807,7 @@ const oe = [
12799
12807
  "TEXT",
12800
12808
  "VARBYTE",
12801
12809
  "VARCHAR"
12802
- ], me = _(["SELECT [ALL | DISTINCT]"]), pe = _([
12810
+ ], he = _(["SELECT [ALL | DISTINCT]"]), fe = _([
12803
12811
  // queries
12804
12812
  "WITH [RECURSIVE]",
12805
12813
  "FROM",
@@ -12910,13 +12918,13 @@ const oe = [
12910
12918
  "START TRANSACTION",
12911
12919
  "UNLOAD",
12912
12920
  "VACUUM"
12913
- ]), Ye = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = _([
12921
+ ]), Ve = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), We = _([
12914
12922
  "JOIN",
12915
12923
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12916
12924
  "{INNER | CROSS} JOIN",
12917
12925
  "NATURAL [INNER] JOIN",
12918
12926
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12919
- ]), fe = _([
12927
+ ]), Xe = _([
12920
12928
  // https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
12921
12929
  "NULL AS",
12922
12930
  // https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
@@ -12924,18 +12932,18 @@ const oe = [
12924
12932
  "HIVE METASTORE",
12925
12933
  // in window specifications
12926
12934
  "{ROWS | RANGE} BETWEEN"
12927
- ]), Ve = _([]), We = {
12935
+ ]), be = _([]), ye = {
12928
12936
  name: "redshift",
12929
12937
  tokenizerOptions: {
12930
- reservedSelect: me,
12931
- reservedClauses: [...pe, ...OT, ...UE],
12932
- reservedSetOperations: Ye,
12933
- reservedJoins: he,
12934
- reservedKeywordPhrases: fe,
12935
- reservedDataTypePhrases: Ve,
12936
- reservedKeywords: de,
12937
- reservedDataTypes: Fe,
12938
- reservedFunctionNames: Be,
12938
+ reservedSelect: he,
12939
+ reservedClauses: [...fe, ...OT, ...UE],
12940
+ reservedSetOperations: Ve,
12941
+ reservedJoins: We,
12942
+ reservedKeywordPhrases: Xe,
12943
+ reservedDataTypePhrases: be,
12944
+ reservedKeywords: me,
12945
+ reservedDataTypes: Ye,
12946
+ reservedFunctionNames: pe,
12939
12947
  extraParens: ["[]"],
12940
12948
  stringTypes: ["''-qq"],
12941
12949
  identTypes: ['""-qq'],
@@ -12962,7 +12970,7 @@ const oe = [
12962
12970
  onelineClauses: [...OT, ...UE],
12963
12971
  tabularOnelineClauses: UE
12964
12972
  }
12965
- }, Xe = [
12973
+ }, Ke = [
12966
12974
  // https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
12967
12975
  "ADD",
12968
12976
  "AFTER",
@@ -13229,7 +13237,7 @@ const oe = [
13229
13237
  "UNSIGNED",
13230
13238
  "VARIABLES",
13231
13239
  "YEAR_MONTH"
13232
- ], be = [
13240
+ ], ge = [
13233
13241
  // https://spark.apache.org/docs/latest/sql-ref-datatypes.html
13234
13242
  "ARRAY",
13235
13243
  "BIGINT",
@@ -13259,7 +13267,7 @@ const oe = [
13259
13267
  "TINYINT",
13260
13268
  "VARCHAR"
13261
13269
  // No varchar type in Spark, only STRING. Added for the sake of tests
13262
- ], ye = [
13270
+ ], $e = [
13263
13271
  // http://spark.apache.org/docs/latest/sql-ref-functions.html
13264
13272
  //
13265
13273
  // http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
@@ -13580,7 +13588,7 @@ const oe = [
13580
13588
  // Shorthand functions to use in place of CASE expression
13581
13589
  "COALESCE",
13582
13590
  "NULLIF"
13583
- ], Ke = _(["SELECT [ALL | DISTINCT]"]), $e = _([
13591
+ ], we = _(["SELECT [ALL | DISTINCT]"]), Je = _([
13584
13592
  // queries
13585
13593
  "WITH",
13586
13594
  "FROM",
@@ -13661,11 +13669,11 @@ const oe = [
13661
13669
  "SHOW TBLPROPERTIES",
13662
13670
  "SHOW VIEWS",
13663
13671
  "UNCACHE TABLE"
13664
- ]), ge = _([
13672
+ ]), xe = _([
13665
13673
  "UNION [ALL | DISTINCT]",
13666
13674
  "EXCEPT [ALL | DISTINCT]",
13667
13675
  "INTERSECT [ALL | DISTINCT]"
13668
- ]), we = _([
13676
+ ]), ve = _([
13669
13677
  "JOIN",
13670
13678
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13671
13679
  "{INNER | CROSS} JOIN",
@@ -13674,24 +13682,24 @@ const oe = [
13674
13682
  // non-standard-joins
13675
13683
  "[LEFT] {ANTI | SEMI} JOIN",
13676
13684
  "NATURAL [LEFT] {ANTI | SEMI} JOIN"
13677
- ]), Je = _([
13685
+ ]), Qe = _([
13678
13686
  "ON DELETE",
13679
13687
  "ON UPDATE",
13680
13688
  "CURRENT ROW",
13681
13689
  "{ROWS | RANGE} BETWEEN"
13682
- ]), xe = _([]), ve = {
13690
+ ]), Ze = _([]), qe = {
13683
13691
  name: "spark",
13684
13692
  tokenizerOptions: {
13685
- reservedSelect: Ke,
13686
- reservedClauses: [...$e, ...NT, ...cE],
13687
- reservedSetOperations: ge,
13688
- reservedJoins: we,
13689
- reservedKeywordPhrases: Je,
13690
- reservedDataTypePhrases: xe,
13693
+ reservedSelect: we,
13694
+ reservedClauses: [...Je, ...NT, ...cE],
13695
+ reservedSetOperations: xe,
13696
+ reservedJoins: ve,
13697
+ reservedKeywordPhrases: Qe,
13698
+ reservedDataTypePhrases: Ze,
13691
13699
  supportsXor: !0,
13692
- reservedKeywords: Xe,
13693
- reservedDataTypes: be,
13694
- reservedFunctionNames: ye,
13700
+ reservedKeywords: Ke,
13701
+ reservedDataTypes: ge,
13702
+ reservedFunctionNames: $e,
13695
13703
  extraParens: ["[]"],
13696
13704
  stringTypes: [
13697
13705
  "''-bs",
@@ -13703,20 +13711,20 @@ const oe = [
13703
13711
  identChars: { allowFirstCharNumber: !0 },
13704
13712
  variableTypes: [{ quote: "{}", prefixes: ["$"], requirePrefix: !0 }],
13705
13713
  operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||", "->"],
13706
- postProcess: Qe
13714
+ postProcess: je
13707
13715
  },
13708
13716
  formatOptions: {
13709
13717
  onelineClauses: [...NT, ...cE],
13710
13718
  tabularOnelineClauses: cE
13711
13719
  }
13712
13720
  };
13713
- function Qe(R) {
13721
+ function je(R) {
13714
13722
  return R.map((E, T) => {
13715
13723
  const A = R[T - 1] || v, e = R[T + 1] || v;
13716
- return y.WINDOW(E) && e.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" && e.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
13724
+ return y.WINDOW(E) && e.type === o.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: o.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === o.RESERVED_KEYWORD && !(A.text === "COLLECTION" && e.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: o.IDENTIFIER, text: E.raw }) : E;
13717
13725
  });
13718
13726
  }
13719
- const Ze = [
13727
+ const ke = [
13720
13728
  // https://www.sqlite.org/lang_corefunc.html
13721
13729
  "ABS",
13722
13730
  "CHANGES",
@@ -13840,7 +13848,7 @@ const Ze = [
13840
13848
  "JSON_TREE",
13841
13849
  // cast
13842
13850
  "CAST"
13843
- ], qe = [
13851
+ ], ze = [
13844
13852
  // https://www.sqlite.org/lang_keywords.html
13845
13853
  // Note: The keywords listed on that URL are not all reserved keywords.
13846
13854
  // We'll need to clean up this list to only include reserved keywords.
@@ -13993,7 +14001,7 @@ const Ze = [
13993
14001
  "WINDOW",
13994
14002
  "WITH",
13995
14003
  "WITHOUT"
13996
- ], je = [
14004
+ ], ES = [
13997
14005
  // SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
13998
14006
  // Here we just list some common ones as SQL Formatter
13999
14007
  // is only able to detect a predefined list of data types.
@@ -14014,7 +14022,7 @@ const Ze = [
14014
14022
  "TEXT",
14015
14023
  "VARCHAR",
14016
14024
  "VARYING CHARACTER"
14017
- ], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
14025
+ ], TS = _(["SELECT [ALL | DISTINCT]"]), RS = _([
14018
14026
  // queries
14019
14027
  "WITH [RECURSIVE]",
14020
14028
  "FROM",
@@ -14035,7 +14043,7 @@ const Ze = [
14035
14043
  "SET",
14036
14044
  // other:
14037
14045
  "RETURNING"
14038
- ]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = _([
14046
+ ]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), lE = _([
14039
14047
  // - create:
14040
14048
  "CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
14041
14049
  // - update:
@@ -14054,28 +14062,28 @@ const Ze = [
14054
14062
  "RENAME TO",
14055
14063
  // - set schema
14056
14064
  "SET SCHEMA"
14057
- ]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = _([
14065
+ ]), AS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), eS = _([
14058
14066
  "JOIN",
14059
14067
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14060
14068
  "{INNER | CROSS} JOIN",
14061
14069
  "NATURAL [INNER] JOIN",
14062
14070
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14063
- ]), RS = _([
14071
+ ]), SS = _([
14064
14072
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14065
14073
  "{ROWS | RANGE | GROUPS} BETWEEN",
14066
14074
  "DO UPDATE"
14067
- ]), AS = _([]), eS = {
14075
+ ]), IS = _([]), OS = {
14068
14076
  name: "sqlite",
14069
14077
  tokenizerOptions: {
14070
- reservedSelect: ke,
14071
- reservedClauses: [...ze, ...tT, ...GE],
14072
- reservedSetOperations: ES,
14073
- reservedJoins: TS,
14074
- reservedKeywordPhrases: RS,
14075
- reservedDataTypePhrases: AS,
14076
- reservedKeywords: qe,
14077
- reservedDataTypes: je,
14078
- reservedFunctionNames: Ze,
14078
+ reservedSelect: TS,
14079
+ reservedClauses: [...RS, ...tT, ...lE],
14080
+ reservedSetOperations: AS,
14081
+ reservedJoins: eS,
14082
+ reservedKeywordPhrases: SS,
14083
+ reservedDataTypePhrases: IS,
14084
+ reservedKeywords: ze,
14085
+ reservedDataTypes: ES,
14086
+ reservedFunctionNames: ke,
14079
14087
  stringTypes: [
14080
14088
  "''-qq",
14081
14089
  { quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
@@ -14088,10 +14096,10 @@ const Ze = [
14088
14096
  operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
14089
14097
  },
14090
14098
  formatOptions: {
14091
- onelineClauses: [...tT, ...GE],
14092
- tabularOnelineClauses: GE
14099
+ onelineClauses: [...tT, ...lE],
14100
+ tabularOnelineClauses: lE
14093
14101
  }
14094
- }, SS = [
14102
+ }, NS = [
14095
14103
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
14096
14104
  "GROUPING",
14097
14105
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_10_window_function
@@ -14188,7 +14196,7 @@ const Ze = [
14188
14196
  "ASIN",
14189
14197
  "ACOS",
14190
14198
  "ATAN"
14191
- ], IS = [
14199
+ ], tS = [
14192
14200
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
14193
14201
  "ALL",
14194
14202
  "ALLOCATE",
@@ -14386,7 +14394,7 @@ const Ze = [
14386
14394
  "WITHIN",
14387
14395
  "WITHOUT",
14388
14396
  "YEAR"
14389
- ], OS = [
14397
+ ], sS = [
14390
14398
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
14391
14399
  "ARRAY",
14392
14400
  "BIGINT",
@@ -14426,7 +14434,7 @@ const Ze = [
14426
14434
  "TIMESTAMP",
14427
14435
  "VARBINARY",
14428
14436
  "VARCHAR"
14429
- ], NS = _(["SELECT [ALL | DISTINCT]"]), tS = _([
14437
+ ], CS = _(["SELECT [ALL | DISTINCT]"]), LS = _([
14430
14438
  // queries
14431
14439
  "WITH [RECURSIVE]",
14432
14440
  "FROM",
@@ -14445,7 +14453,7 @@ const Ze = [
14445
14453
  "VALUES",
14446
14454
  // - update:
14447
14455
  "SET"
14448
- ]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = _([
14456
+ ]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), GE = _([
14449
14457
  // - create:
14450
14458
  "CREATE [RECURSIVE] VIEW",
14451
14459
  // - update:
@@ -14470,31 +14478,31 @@ const Ze = [
14470
14478
  "TRUNCATE TABLE",
14471
14479
  // other
14472
14480
  "SET SCHEMA"
14473
- ]), sS = _([
14481
+ ]), _S = _([
14474
14482
  "UNION [ALL | DISTINCT]",
14475
14483
  "EXCEPT [ALL | DISTINCT]",
14476
14484
  "INTERSECT [ALL | DISTINCT]"
14477
- ]), CS = _([
14485
+ ]), rS = _([
14478
14486
  "JOIN",
14479
14487
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14480
14488
  "{INNER | CROSS} JOIN",
14481
14489
  "NATURAL [INNER] JOIN",
14482
14490
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14483
- ]), LS = _([
14491
+ ]), nS = _([
14484
14492
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14485
14493
  "{ROWS | RANGE} BETWEEN"
14486
- ]), _S = _([]), rS = {
14494
+ ]), iS = _([]), aS = {
14487
14495
  name: "sql",
14488
14496
  tokenizerOptions: {
14489
- reservedSelect: NS,
14490
- reservedClauses: [...tS, ...sT, ...lE],
14491
- reservedSetOperations: sS,
14492
- reservedJoins: CS,
14493
- reservedKeywordPhrases: LS,
14494
- reservedDataTypePhrases: _S,
14495
- reservedKeywords: IS,
14496
- reservedDataTypes: OS,
14497
- reservedFunctionNames: SS,
14497
+ reservedSelect: CS,
14498
+ reservedClauses: [...LS, ...sT, ...GE],
14499
+ reservedSetOperations: _S,
14500
+ reservedJoins: rS,
14501
+ reservedKeywordPhrases: nS,
14502
+ reservedDataTypePhrases: iS,
14503
+ reservedKeywords: tS,
14504
+ reservedDataTypes: sS,
14505
+ reservedFunctionNames: NS,
14498
14506
  stringTypes: [
14499
14507
  { quote: "''-qq-bs", prefixes: ["N", "U&"] },
14500
14508
  { quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
@@ -14504,10 +14512,10 @@ const Ze = [
14504
14512
  operators: ["||"]
14505
14513
  },
14506
14514
  formatOptions: {
14507
- onelineClauses: [...sT, ...lE],
14508
- tabularOnelineClauses: lE
14515
+ onelineClauses: [...sT, ...GE],
14516
+ tabularOnelineClauses: GE
14509
14517
  }
14510
- }, nS = [
14518
+ }, oS = [
14511
14519
  // https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
14512
14520
  // rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
14513
14521
  // rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
@@ -14941,7 +14949,7 @@ const Ze = [
14941
14949
  "NEXT",
14942
14950
  "PERMUTE",
14943
14951
  "PREV"
14944
- ], iS = [
14952
+ ], DS = [
14945
14953
  // https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
14946
14954
  "ABSENT",
14947
14955
  "ADD",
@@ -15178,7 +15186,7 @@ const Ze = [
15178
15186
  "WRAPPER",
15179
15187
  "WRITE",
15180
15188
  "ZONE"
15181
- ], aS = [
15189
+ ], PS = [
15182
15190
  // https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
15183
15191
  // or https://trino.io/docs/current/language/types.html
15184
15192
  "BIGINT",
@@ -15217,7 +15225,7 @@ const Ze = [
15217
15225
  "CODEPOINTS",
15218
15226
  "FUNCTION",
15219
15227
  "JSONPATH"
15220
- ], oS = _(["SELECT [ALL | DISTINCT]"]), DS = _([
15228
+ ], MS = _(["SELECT [ALL | DISTINCT]"]), US = _([
15221
15229
  // queries
15222
15230
  "WITH [RECURSIVE]",
15223
15231
  "FROM",
@@ -15303,32 +15311,32 @@ const Ze = [
15303
15311
  "SHOW ROLE GRANTS",
15304
15312
  "SHOW FUNCTIONS",
15305
15313
  "SHOW SESSION"
15306
- ]), PS = _([
15314
+ ]), cS = _([
15307
15315
  "UNION [ALL | DISTINCT]",
15308
15316
  "EXCEPT [ALL | DISTINCT]",
15309
15317
  "INTERSECT [ALL | DISTINCT]"
15310
- ]), MS = _([
15318
+ ]), lS = _([
15311
15319
  "JOIN",
15312
15320
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15313
15321
  "{INNER | CROSS} JOIN",
15314
15322
  "NATURAL [INNER] JOIN",
15315
15323
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
15316
- ]), US = _([
15324
+ ]), GS = _([
15317
15325
  "{ROWS | RANGE | GROUPS} BETWEEN",
15318
15326
  // comparison operator
15319
15327
  "IS [NOT] DISTINCT FROM"
15320
- ]), cS = _([]), GS = {
15328
+ ]), uS = _([]), HS = {
15321
15329
  name: "trino",
15322
15330
  tokenizerOptions: {
15323
- reservedSelect: oS,
15324
- reservedClauses: [...DS, ...CT, ...uE],
15325
- reservedSetOperations: PS,
15326
- reservedJoins: MS,
15327
- reservedKeywordPhrases: US,
15328
- reservedDataTypePhrases: cS,
15329
- reservedKeywords: iS,
15330
- reservedDataTypes: aS,
15331
- reservedFunctionNames: nS,
15331
+ reservedSelect: MS,
15332
+ reservedClauses: [...US, ...CT, ...uE],
15333
+ reservedSetOperations: cS,
15334
+ reservedJoins: lS,
15335
+ reservedKeywordPhrases: GS,
15336
+ reservedDataTypePhrases: uS,
15337
+ reservedKeywords: DS,
15338
+ reservedDataTypes: PS,
15339
+ reservedFunctionNames: oS,
15332
15340
  // Trino also supports {- ... -} parenthesis.
15333
15341
  // The formatting of these currently works out as a result of { and -
15334
15342
  // not getting a space added in-between.
@@ -15360,7 +15368,7 @@ const Ze = [
15360
15368
  onelineClauses: [...CT, ...uE],
15361
15369
  tabularOnelineClauses: uE
15362
15370
  }
15363
- }, lS = [
15371
+ }, BS = [
15364
15372
  // https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
15365
15373
  // aggregate
15366
15374
  "APPROX_COUNT_DISTINCT",
@@ -15665,7 +15673,7 @@ const Ze = [
15665
15673
  // Shorthand functions to use in place of CASE expression
15666
15674
  "COALESCE",
15667
15675
  "NULLIF"
15668
- ], uS = [
15676
+ ], dS = [
15669
15677
  // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
15670
15678
  // standard
15671
15679
  "ADD",
@@ -15846,7 +15854,7 @@ const Ze = [
15846
15854
  "WRITETEXT",
15847
15855
  // https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver16#action
15848
15856
  "$ACTION"
15849
- ], HS = [
15857
+ ], FS = [
15850
15858
  // https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15
15851
15859
  "BINARY",
15852
15860
  "BIT",
@@ -15873,7 +15881,7 @@ const Ze = [
15873
15881
  "TIMESTAMP",
15874
15882
  "VARBINARY",
15875
15883
  "VARCHAR"
15876
- ], BS = _(["SELECT [ALL | DISTINCT]"]), dS = _([
15884
+ ], pS = _(["SELECT [ALL | DISTINCT]"]), mS = _([
15877
15885
  // queries
15878
15886
  "WITH",
15879
15887
  "INTO",
@@ -16078,27 +16086,27 @@ const Ze = [
16078
16086
  "XACT_ABORT",
16079
16087
  "XML INDEX",
16080
16088
  "XML SCHEMA COLLECTION"
16081
- ]), FS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = _([
16089
+ ]), YS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), hS = _([
16082
16090
  "JOIN",
16083
16091
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16084
16092
  "{INNER | CROSS} JOIN",
16085
16093
  // non-standard joins
16086
16094
  "{CROSS | OUTER} APPLY"
16087
- ]), pS = _([
16095
+ ]), fS = _([
16088
16096
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
16089
16097
  "{ROWS | RANGE} BETWEEN"
16090
- ]), YS = _([]), hS = {
16098
+ ]), VS = _([]), WS = {
16091
16099
  name: "transactsql",
16092
16100
  tokenizerOptions: {
16093
- reservedSelect: BS,
16094
- reservedClauses: [...dS, ...LT, ...HE],
16095
- reservedSetOperations: FS,
16096
- reservedJoins: mS,
16097
- reservedKeywordPhrases: pS,
16098
- reservedDataTypePhrases: YS,
16099
- reservedKeywords: uS,
16100
- reservedDataTypes: HS,
16101
- reservedFunctionNames: lS,
16101
+ reservedSelect: pS,
16102
+ reservedClauses: [...mS, ...LT, ...HE],
16103
+ reservedSetOperations: YS,
16104
+ reservedJoins: hS,
16105
+ reservedKeywordPhrases: fS,
16106
+ reservedDataTypePhrases: VS,
16107
+ reservedKeywords: dS,
16108
+ reservedDataTypes: FS,
16109
+ reservedFunctionNames: BS,
16102
16110
  nestedBlockComments: !0,
16103
16111
  stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
16104
16112
  identTypes: ['""-qq', "[]"],
@@ -16131,7 +16139,7 @@ const Ze = [
16131
16139
  onelineClauses: [...LT, ...HE],
16132
16140
  tabularOnelineClauses: HE
16133
16141
  }
16134
- }, fS = [
16142
+ }, XS = [
16135
16143
  // List of all keywords taken from:
16136
16144
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
16137
16145
  // Then filtered down to reserved keywords by running
@@ -16344,7 +16352,7 @@ const Ze = [
16344
16352
  "XOR",
16345
16353
  "YEAR_MONTH",
16346
16354
  "ZEROFILL"
16347
- ], VS = [
16355
+ ], bS = [
16348
16356
  // https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
16349
16357
  "BIGINT",
16350
16358
  "BINARY",
@@ -16393,7 +16401,7 @@ const Ze = [
16393
16401
  "VARCHAR",
16394
16402
  "VARCHARACTER",
16395
16403
  "YEAR"
16396
- ], WS = [
16404
+ ], yS = [
16397
16405
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
16398
16406
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
16399
16407
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
@@ -16673,7 +16681,7 @@ const Ze = [
16673
16681
  "WEEKDAY",
16674
16682
  "WEEKOFYEAR",
16675
16683
  "YEAR"
16676
- ], XS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = _([
16684
+ ], KS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), gS = _([
16677
16685
  // queries
16678
16686
  "WITH",
16679
16687
  "FROM",
@@ -16874,36 +16882,36 @@ const Ze = [
16874
16882
  "REPEAT",
16875
16883
  "RETURN",
16876
16884
  "WHILE"
16877
- ]), yS = _([
16885
+ ]), $S = _([
16878
16886
  "UNION [ALL | DISTINCT]",
16879
16887
  "EXCEPT",
16880
16888
  "INTERSECT",
16881
16889
  "MINUS"
16882
- ]), KS = _([
16890
+ ]), wS = _([
16883
16891
  "JOIN",
16884
16892
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16885
16893
  "{INNER | CROSS} JOIN",
16886
16894
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
16887
16895
  // non-standard joins
16888
16896
  "STRAIGHT_JOIN"
16889
- ]), $S = _([
16897
+ ]), JS = _([
16890
16898
  "ON DELETE",
16891
16899
  "ON UPDATE",
16892
16900
  "CHARACTER SET",
16893
16901
  "{ROWS | RANGE} BETWEEN",
16894
16902
  "IDENTIFIED BY"
16895
- ]), gS = _([]), wS = {
16903
+ ]), xS = _([]), vS = {
16896
16904
  name: "singlestoredb",
16897
16905
  tokenizerOptions: {
16898
- reservedSelect: XS,
16899
- reservedClauses: [...bS, ..._T, ...BE],
16900
- reservedSetOperations: yS,
16901
- reservedJoins: KS,
16902
- reservedKeywordPhrases: $S,
16903
- reservedDataTypePhrases: gS,
16904
- reservedKeywords: fS,
16905
- reservedDataTypes: VS,
16906
- reservedFunctionNames: WS,
16906
+ reservedSelect: KS,
16907
+ reservedClauses: [...gS, ..._T, ...BE],
16908
+ reservedSetOperations: $S,
16909
+ reservedJoins: wS,
16910
+ reservedKeywordPhrases: JS,
16911
+ reservedDataTypePhrases: xS,
16912
+ reservedKeywords: XS,
16913
+ reservedDataTypes: bS,
16914
+ reservedFunctionNames: yS,
16907
16915
  // TODO: support _binary"some string" prefix
16908
16916
  stringTypes: [
16909
16917
  '""-qq-bs',
@@ -16943,7 +16951,7 @@ const Ze = [
16943
16951
  onelineClauses: [..._T, ...BE],
16944
16952
  tabularOnelineClauses: BE
16945
16953
  }
16946
- }, JS = [
16954
+ }, QS = [
16947
16955
  // https://docs.snowflake.com/en/sql-reference-functions.html
16948
16956
  //
16949
16957
  // https://docs.snowflake.com/en/sql-reference/functions-all.html
@@ -17551,7 +17559,7 @@ const Ze = [
17551
17559
  "QUARTER",
17552
17560
  "ZEROIFNULL",
17553
17561
  "ZIPF"
17554
- ], xS = [
17562
+ ], ZS = [
17555
17563
  // https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
17556
17564
  //
17557
17565
  // run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
@@ -17648,7 +17656,7 @@ const Ze = [
17648
17656
  "WITH",
17649
17657
  // These are definitely keywords, but haven't found a definite list in the docs
17650
17658
  "COMMENT"
17651
- ], vS = [
17659
+ ], qS = [
17652
17660
  "NUMBER",
17653
17661
  "DECIMAL",
17654
17662
  "NUMERIC",
@@ -17685,7 +17693,7 @@ const Ze = [
17685
17693
  "ARRAY",
17686
17694
  "GEOGRAPHY",
17687
17695
  "GEOMETRY"
17688
- ], QS = _(["SELECT [ALL | DISTINCT]"]), ZS = _([
17696
+ ], jS = _(["SELECT [ALL | DISTINCT]"]), kS = _([
17689
17697
  // queries
17690
17698
  "WITH [RECURSIVE]",
17691
17699
  "FROM",
@@ -17957,25 +17965,25 @@ const Ze = [
17957
17965
  "USE SCHEMA",
17958
17966
  "USE SECONDARY ROLES",
17959
17967
  "USE WAREHOUSE"
17960
- ]), qS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = _([
17968
+ ]), zS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), EI = _([
17961
17969
  "[INNER] JOIN",
17962
17970
  "[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
17963
17971
  "{CROSS | NATURAL} JOIN"
17964
- ]), kS = _([
17972
+ ]), TI = _([
17965
17973
  "{ROWS | RANGE} BETWEEN",
17966
17974
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
17967
- ]), zS = _([]), EI = {
17975
+ ]), RI = _([]), AI = {
17968
17976
  name: "snowflake",
17969
17977
  tokenizerOptions: {
17970
- reservedSelect: QS,
17971
- reservedClauses: [...ZS, ...rT, ...dE],
17972
- reservedSetOperations: qS,
17973
- reservedJoins: jS,
17974
- reservedKeywordPhrases: kS,
17975
- reservedDataTypePhrases: zS,
17976
- reservedKeywords: xS,
17977
- reservedDataTypes: vS,
17978
- reservedFunctionNames: JS,
17978
+ reservedSelect: jS,
17979
+ reservedClauses: [...kS, ...rT, ...dE],
17980
+ reservedSetOperations: zS,
17981
+ reservedJoins: EI,
17982
+ reservedKeywordPhrases: TI,
17983
+ reservedDataTypePhrases: RI,
17984
+ reservedKeywords: ZS,
17985
+ reservedDataTypes: qS,
17986
+ reservedFunctionNames: QS,
17979
17987
  stringTypes: ["$$", "''-qq-bs"],
17980
17988
  identTypes: ['""-qq'],
17981
17989
  variableTypes: [
@@ -18008,43 +18016,43 @@ const Ze = [
18008
18016
  onelineClauses: [...rT, ...dE],
18009
18017
  tabularOnelineClauses: dE
18010
18018
  }
18011
- }, TI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
18019
+ }, eI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
18012
18020
  __proto__: null,
18013
- bigquery: FR,
18014
- db2: wR,
18015
- db2i: EA,
18016
- duckdb: sA,
18017
- hive: PA,
18018
- mariadb: FA,
18019
- mysql: yA,
18020
- n1ql: Ie,
18021
- plsql: ie,
18022
- postgresql: He,
18023
- redshift: We,
18024
- singlestoredb: wS,
18025
- snowflake: EI,
18026
- spark: ve,
18027
- sql: rS,
18028
- sqlite: eS,
18029
- tidb: qA,
18030
- transactsql: hS,
18031
- trino: GS
18032
- }, Symbol.toStringTag, { value: "Module" })), Z = (R) => R[R.length - 1], pT = (R) => R.sort((E, T) => T.length - E.length || E.localeCompare(T)), z = (R) => R.replace(/\s+/gu, " "), FE = (R) => /\n/.test(R), h = (R) => R.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), nT = /\s+/uy, K = (R) => new RegExp(`(?:${R})`, "uy"), RI = (R) => R.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), AI = (R) => R + "(?:-" + R + ")*", eI = ({ prefixes: R, requirePrefix: E }) => `(?:${R.map(RI).join("|")}${E ? "" : "|"})`, SI = (R) => new RegExp(`(?:${R.map(h).join("|")}).*?(?=\r
18021
+ bigquery: YR,
18022
+ db2: vR,
18023
+ db2i: AA,
18024
+ duckdb: _A,
18025
+ hive: cA,
18026
+ mariadb: YA,
18027
+ mysql: $A,
18028
+ n1ql: te,
18029
+ plsql: De,
18030
+ postgresql: Fe,
18031
+ redshift: ye,
18032
+ singlestoredb: vS,
18033
+ snowflake: AI,
18034
+ spark: qe,
18035
+ sql: aS,
18036
+ sqlite: OS,
18037
+ tidb: zA,
18038
+ transactsql: WS,
18039
+ trino: HS
18040
+ }, Symbol.toStringTag, { value: "Module" })), Z = (R) => R[R.length - 1], mT = (R) => R.sort((E, T) => T.length - E.length || E.localeCompare(T)), z = (R) => R.replace(/\s+/gu, " "), FE = (R) => /\n/.test(R), h = (R) => R.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), nT = /\s+/uy, K = (R) => new RegExp(`(?:${R})`, "uy"), SI = (R) => R.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), II = (R) => R + "(?:-" + R + ")*", OI = ({ prefixes: R, requirePrefix: E }) => `(?:${R.map(SI).join("|")}${E ? "" : "|"})`, NI = (R) => new RegExp(`(?:${R.map(h).join("|")}).*?(?=\r
18033
18041
  |\r|
18034
18042
  |$)`, "uy"), iT = (R, E = []) => {
18035
18043
  const T = R === "open" ? 0 : 1, A = ["()", ...E].map((e) => e[T]);
18036
18044
  return K(A.map(h).join("|"));
18037
- }, aT = (R) => K(`${pT(R).map(h).join("|")}`), II = ({ rest: R, dashes: E }) => R || E ? `(?![${R || ""}${E ? "-" : ""}])` : "", V = (R, E = {}) => {
18045
+ }, aT = (R) => K(`${mT(R).map(h).join("|")}`), tI = ({ rest: R, dashes: E }) => R || E ? `(?![${R || ""}${E ? "-" : ""}])` : "", V = (R, E = {}) => {
18038
18046
  if (R.length === 0)
18039
18047
  return /^\b$/u;
18040
- const T = II(E), A = pT(R).map(h).join("|").replace(/ /gu, "\\s+");
18048
+ const T = tI(E), A = mT(R).map(h).join("|").replace(/ /gu, "\\s+");
18041
18049
  return new RegExp(`(?:${A})${T}\\b`, "iuy");
18042
- }, mE = (R, E) => {
18050
+ }, pE = (R, E) => {
18043
18051
  if (!R.length)
18044
18052
  return;
18045
18053
  const T = R.map(h).join("|");
18046
18054
  return K(`(?:${T})(?:${E})`);
18047
- }, OI = () => {
18055
+ }, sI = () => {
18048
18056
  const R = {
18049
18057
  "<": ">",
18050
18058
  "[": "]",
@@ -18076,16 +18084,16 @@ const Ze = [
18076
18084
  // Hive and Spark variables: ${name}
18077
18085
  "{}": String.raw`(?:\{[^\}]*\})`,
18078
18086
  // Oracle q'' strings: q'<text>' q'|text|' ...
18079
- "q''": OI()
18080
- }, YT = (R) => typeof R == "string" ? oT[R] : "regex" in R ? R.regex : eI(R) + oT[R.quote], NI = (R) => K(R.map((E) => "regex" in E ? E.regex : YT(E)).join("|")), hT = (R) => R.map(YT).join("|"), DT = (R) => K(hT(R)), tI = (R = {}) => K(fT(R)), fT = ({ first: R, rest: E, dashes: T, allowFirstCharNumber: A } = {}) => {
18087
+ "q''": sI()
18088
+ }, YT = (R) => typeof R == "string" ? oT[R] : "regex" in R ? R.regex : OI(R) + oT[R.quote], CI = (R) => K(R.map((E) => "regex" in E ? E.regex : YT(E)).join("|")), hT = (R) => R.map(YT).join("|"), DT = (R) => K(hT(R)), LI = (R = {}) => K(fT(R)), fT = ({ first: R, rest: E, dashes: T, allowFirstCharNumber: A } = {}) => {
18081
18089
  const e = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I = h(R ?? ""), t = h(E ?? ""), C = A ? `[${e}${S}${I}][${e}${S}${t}]*` : `[${e}${I}][${e}${S}${t}]*`;
18082
- return T ? AI(C) : C;
18090
+ return T ? II(C) : C;
18083
18091
  };
18084
18092
  function VT(R, E) {
18085
18093
  const T = R.slice(0, E).split(/\n/);
18086
18094
  return { line: T.length, col: T[T.length - 1].length + 1 };
18087
18095
  }
18088
- class sI {
18096
+ class _I {
18089
18097
  constructor(E, T) {
18090
18098
  this.rules = E, this.dialectName = T, this.input = "", this.index = 0;
18091
18099
  }
@@ -18147,8 +18155,8 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
18147
18155
  }
18148
18156
  }
18149
18157
  }
18150
- const PT = /\/\*/uy, CI = /[\s\S]/uy, LI = /\*\//uy;
18151
- class _I {
18158
+ const PT = /\/\*/uy, rI = /[\s\S]/uy, nI = /\*\//uy;
18159
+ class iI {
18152
18160
  constructor() {
18153
18161
  this.lastIndex = 0;
18154
18162
  }
@@ -18161,9 +18169,9 @@ class _I {
18161
18169
  for (; e > 0; )
18162
18170
  if (A = this.matchSection(PT, E))
18163
18171
  T += A, e++;
18164
- else if (A = this.matchSection(LI, E))
18172
+ else if (A = this.matchSection(nI, E))
18165
18173
  T += A, e--;
18166
- else if (A = this.matchSection(CI, E))
18174
+ else if (A = this.matchSection(rI, E))
18167
18175
  T += A;
18168
18176
  else
18169
18177
  return null;
@@ -18175,7 +18183,7 @@ class _I {
18175
18183
  return A && (this.lastIndex += A[0].length), A ? A[0] : null;
18176
18184
  }
18177
18185
  }
18178
- class rI {
18186
+ class aI {
18179
18187
  constructor(E, T) {
18180
18188
  this.cfg = E, this.dialectName = T, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
18181
18189
  }
@@ -18184,7 +18192,7 @@ class rI {
18184
18192
  ...this.rulesBeforeParams,
18185
18193
  ...this.buildParamRules(this.cfg, T),
18186
18194
  ...this.rulesAfterParams
18187
- ], e = new sI(A, this.dialectName).tokenize(E);
18195
+ ], e = new _I(A, this.dialectName).tokenize(E);
18188
18196
  return this.cfg.postProcess ? this.cfg.postProcess(e) : e;
18189
18197
  }
18190
18198
  // These rules can be cached as they only depend on
@@ -18193,125 +18201,125 @@ class rI {
18193
18201
  var T, A, e;
18194
18202
  return this.validRules([
18195
18203
  {
18196
- type: D.DISABLE_COMMENT,
18204
+ type: o.DISABLE_COMMENT,
18197
18205
  regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
18198
18206
  },
18199
18207
  {
18200
- type: D.BLOCK_COMMENT,
18201
- regex: E.nestedBlockComments ? new _I() : /(\/\*[^]*?\*\/)/uy
18208
+ type: o.BLOCK_COMMENT,
18209
+ regex: E.nestedBlockComments ? new iI() : /(\/\*[^]*?\*\/)/uy
18202
18210
  },
18203
18211
  {
18204
- type: D.LINE_COMMENT,
18205
- regex: SI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
18212
+ type: o.LINE_COMMENT,
18213
+ regex: NI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
18206
18214
  },
18207
18215
  {
18208
- type: D.QUOTED_IDENTIFIER,
18216
+ type: o.QUOTED_IDENTIFIER,
18209
18217
  regex: DT(E.identTypes)
18210
18218
  },
18211
18219
  {
18212
- type: D.NUMBER,
18220
+ type: o.NUMBER,
18213
18221
  regex: E.underscoresInNumbers ? /(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy : /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
18214
18222
  },
18215
18223
  // RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
18216
18224
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
18217
18225
  {
18218
- type: D.RESERVED_KEYWORD_PHRASE,
18226
+ type: o.RESERVED_KEYWORD_PHRASE,
18219
18227
  regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
18220
18228
  text: d
18221
18229
  },
18222
18230
  {
18223
- type: D.RESERVED_DATA_TYPE_PHRASE,
18231
+ type: o.RESERVED_DATA_TYPE_PHRASE,
18224
18232
  regex: V((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
18225
18233
  text: d
18226
18234
  },
18227
18235
  {
18228
- type: D.CASE,
18236
+ type: o.CASE,
18229
18237
  regex: /CASE\b/iuy,
18230
18238
  text: d
18231
18239
  },
18232
18240
  {
18233
- type: D.END,
18241
+ type: o.END,
18234
18242
  regex: /END\b/iuy,
18235
18243
  text: d
18236
18244
  },
18237
18245
  {
18238
- type: D.BETWEEN,
18246
+ type: o.BETWEEN,
18239
18247
  regex: /BETWEEN\b/iuy,
18240
18248
  text: d
18241
18249
  },
18242
18250
  {
18243
- type: D.LIMIT,
18251
+ type: o.LIMIT,
18244
18252
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
18245
18253
  text: d
18246
18254
  },
18247
18255
  {
18248
- type: D.RESERVED_CLAUSE,
18256
+ type: o.RESERVED_CLAUSE,
18249
18257
  regex: V(E.reservedClauses, E.identChars),
18250
18258
  text: d
18251
18259
  },
18252
18260
  {
18253
- type: D.RESERVED_SELECT,
18261
+ type: o.RESERVED_SELECT,
18254
18262
  regex: V(E.reservedSelect, E.identChars),
18255
18263
  text: d
18256
18264
  },
18257
18265
  {
18258
- type: D.RESERVED_SET_OPERATION,
18266
+ type: o.RESERVED_SET_OPERATION,
18259
18267
  regex: V(E.reservedSetOperations, E.identChars),
18260
18268
  text: d
18261
18269
  },
18262
18270
  {
18263
- type: D.WHEN,
18271
+ type: o.WHEN,
18264
18272
  regex: /WHEN\b/iuy,
18265
18273
  text: d
18266
18274
  },
18267
18275
  {
18268
- type: D.ELSE,
18276
+ type: o.ELSE,
18269
18277
  regex: /ELSE\b/iuy,
18270
18278
  text: d
18271
18279
  },
18272
18280
  {
18273
- type: D.THEN,
18281
+ type: o.THEN,
18274
18282
  regex: /THEN\b/iuy,
18275
18283
  text: d
18276
18284
  },
18277
18285
  {
18278
- type: D.RESERVED_JOIN,
18286
+ type: o.RESERVED_JOIN,
18279
18287
  regex: V(E.reservedJoins, E.identChars),
18280
18288
  text: d
18281
18289
  },
18282
18290
  {
18283
- type: D.AND,
18291
+ type: o.AND,
18284
18292
  regex: /AND\b/iuy,
18285
18293
  text: d
18286
18294
  },
18287
18295
  {
18288
- type: D.OR,
18296
+ type: o.OR,
18289
18297
  regex: /OR\b/iuy,
18290
18298
  text: d
18291
18299
  },
18292
18300
  {
18293
- type: D.XOR,
18301
+ type: o.XOR,
18294
18302
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18295
18303
  text: d
18296
18304
  },
18297
18305
  ...E.operatorKeyword ? [
18298
18306
  {
18299
- type: D.OPERATOR,
18307
+ type: o.OPERATOR,
18300
18308
  regex: /OPERATOR *\([^)]+\)/iuy
18301
18309
  }
18302
18310
  ] : [],
18303
18311
  {
18304
- type: D.RESERVED_FUNCTION_NAME,
18312
+ type: o.RESERVED_FUNCTION_NAME,
18305
18313
  regex: V(E.reservedFunctionNames, E.identChars),
18306
18314
  text: d
18307
18315
  },
18308
18316
  {
18309
- type: D.RESERVED_DATA_TYPE,
18317
+ type: o.RESERVED_DATA_TYPE,
18310
18318
  regex: V(E.reservedDataTypes, E.identChars),
18311
18319
  text: d
18312
18320
  },
18313
18321
  {
18314
- type: D.RESERVED_KEYWORD,
18322
+ type: o.RESERVED_KEYWORD,
18315
18323
  regex: V(E.reservedKeywords, E.identChars),
18316
18324
  text: d
18317
18325
  }
@@ -18323,26 +18331,26 @@ class rI {
18323
18331
  var T, A;
18324
18332
  return this.validRules([
18325
18333
  {
18326
- type: D.VARIABLE,
18327
- regex: E.variableTypes ? NI(E.variableTypes) : void 0
18334
+ type: o.VARIABLE,
18335
+ regex: E.variableTypes ? CI(E.variableTypes) : void 0
18328
18336
  },
18329
- { type: D.STRING, regex: DT(E.stringTypes) },
18337
+ { type: o.STRING, regex: DT(E.stringTypes) },
18330
18338
  {
18331
- type: D.IDENTIFIER,
18332
- regex: tI(E.identChars)
18339
+ type: o.IDENTIFIER,
18340
+ regex: LI(E.identChars)
18333
18341
  },
18334
- { type: D.DELIMITER, regex: /[;]/uy },
18335
- { type: D.COMMA, regex: /[,]/y },
18342
+ { type: o.DELIMITER, regex: /[;]/uy },
18343
+ { type: o.COMMA, regex: /[,]/y },
18336
18344
  {
18337
- type: D.OPEN_PAREN,
18345
+ type: o.OPEN_PAREN,
18338
18346
  regex: iT("open", E.extraParens)
18339
18347
  },
18340
18348
  {
18341
- type: D.CLOSE_PAREN,
18349
+ type: o.CLOSE_PAREN,
18342
18350
  regex: iT("close", E.extraParens)
18343
18351
  },
18344
18352
  {
18345
- type: D.OPERATOR,
18353
+ type: o.OPERATOR,
18346
18354
  regex: aT([
18347
18355
  // standard operators
18348
18356
  "+",
@@ -18358,9 +18366,9 @@ class rI {
18358
18366
  ...(T = E.operators) !== null && T !== void 0 ? T : []
18359
18367
  ])
18360
18368
  },
18361
- { type: D.ASTERISK, regex: /[*]/uy },
18369
+ { type: o.ASTERISK, regex: /[*]/uy },
18362
18370
  {
18363
- type: D.PROPERTY_ACCESS_OPERATOR,
18371
+ type: o.PROPERTY_ACCESS_OPERATOR,
18364
18372
  regex: aT([".", ...(A = E.propertyAccessOperators) !== null && A !== void 0 ? A : []])
18365
18373
  }
18366
18374
  ]);
@@ -18378,31 +18386,31 @@ class rI {
18378
18386
  };
18379
18387
  return this.validRules([
18380
18388
  {
18381
- type: D.NAMED_PARAMETER,
18382
- regex: mE(C.named, fT(E.paramChars || E.identChars)),
18389
+ type: o.NAMED_PARAMETER,
18390
+ regex: pE(C.named, fT(E.paramChars || E.identChars)),
18383
18391
  key: (O) => O.slice(1)
18384
18392
  },
18385
18393
  {
18386
- type: D.QUOTED_PARAMETER,
18387
- regex: mE(C.quoted, hT(E.identTypes)),
18394
+ type: o.QUOTED_PARAMETER,
18395
+ regex: pE(C.quoted, hT(E.identTypes)),
18388
18396
  key: (O) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(h("\\" + s), "gu"), s))({
18389
18397
  tokenKey: O.slice(2, -1),
18390
18398
  quoteChar: O.slice(-1)
18391
18399
  })
18392
18400
  },
18393
18401
  {
18394
- type: D.NUMBERED_PARAMETER,
18395
- regex: mE(C.numbered, "[0-9]+"),
18402
+ type: o.NUMBERED_PARAMETER,
18403
+ regex: pE(C.numbered, "[0-9]+"),
18396
18404
  key: (O) => O.slice(1)
18397
18405
  },
18398
18406
  {
18399
- type: D.POSITIONAL_PARAMETER,
18407
+ type: o.POSITIONAL_PARAMETER,
18400
18408
  regex: C.positional ? /[?]/y : void 0
18401
18409
  },
18402
18410
  ...C.custom.map((O) => {
18403
18411
  var N;
18404
18412
  return {
18405
- type: D.CUSTOM_PARAMETER,
18413
+ type: o.CUSTOM_PARAMETER,
18406
18414
  regex: K(O.regex),
18407
18415
  key: (N = O.key) !== null && N !== void 0 ? N : ((s) => s)
18408
18416
  };
@@ -18414,13 +18422,13 @@ class rI {
18414
18422
  return E.filter((T) => !!T.regex);
18415
18423
  }
18416
18424
  }
18417
- const d = (R) => z(R.toUpperCase()), MT = /* @__PURE__ */ new Map(), nI = (R) => {
18425
+ const d = (R) => z(R.toUpperCase()), MT = /* @__PURE__ */ new Map(), oI = (R) => {
18418
18426
  let E = MT.get(R);
18419
- return E || (E = iI(R), MT.set(R, E)), E;
18420
- }, iI = (R) => ({
18421
- tokenizer: new rI(R.tokenizerOptions, R.name),
18422
- formatOptions: aI(R.formatOptions)
18423
- }), aI = (R) => {
18427
+ return E || (E = DI(R), MT.set(R, E)), E;
18428
+ }, DI = (R) => ({
18429
+ tokenizer: new aI(R.tokenizerOptions, R.name),
18430
+ formatOptions: PI(R.formatOptions)
18431
+ }), PI = (R) => {
18424
18432
  var E;
18425
18433
  return {
18426
18434
  alwaysDenseOperators: R.alwaysDenseOperators || [],
@@ -18428,13 +18436,13 @@ const d = (R) => z(R.toUpperCase()), MT = /* @__PURE__ */ new Map(), nI = (R) =>
18428
18436
  tabularOnelineClauses: Object.fromEntries(((E = R.tabularOnelineClauses) !== null && E !== void 0 ? E : R.onelineClauses).map((T) => [T, !0]))
18429
18437
  };
18430
18438
  };
18431
- function oI(R) {
18439
+ function MI(R) {
18432
18440
  return R.indentStyle === "tabularLeft" || R.indentStyle === "tabularRight" ? " ".repeat(10) : R.useTabs ? " " : " ".repeat(R.tabWidth);
18433
18441
  }
18434
18442
  function J(R) {
18435
18443
  return R.indentStyle === "tabularLeft" || R.indentStyle === "tabularRight";
18436
18444
  }
18437
- class DI {
18445
+ class UI {
18438
18446
  constructor(E) {
18439
18447
  this.params = E, this.index = 0;
18440
18448
  }
@@ -18457,15 +18465,15 @@ class DI {
18457
18465
  this.index = E;
18458
18466
  }
18459
18467
  }
18460
- function PI(R) {
18468
+ function cI(R) {
18461
18469
  return R && R.__esModule && Object.prototype.hasOwnProperty.call(R, "default") ? R.default : R;
18462
18470
  }
18463
- var EE = { exports: {} }, MI = EE.exports, UT;
18464
- function UI() {
18471
+ var EE = { exports: {} }, lI = EE.exports, UT;
18472
+ function GI() {
18465
18473
  return UT || (UT = 1, (function(R) {
18466
18474
  (function(E, T) {
18467
18475
  R.exports ? R.exports = T() : E.nearley = T();
18468
- })(MI, function() {
18476
+ })(lI, function() {
18469
18477
  function E(O, N, s) {
18470
18478
  return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = s, this;
18471
18479
  }
@@ -18498,8 +18506,8 @@ function UI() {
18498
18506
  var i = N[L];
18499
18507
  if (i.isComplete) {
18500
18508
  if (i.finish(), i.data !== I.fail) {
18501
- for (var o = i.wantedBy, l = o.length; l--; ) {
18502
- var P = o[l];
18509
+ for (var D = i.wantedBy, l = D.length; l--; ) {
18510
+ var P = D[l];
18503
18511
  this.complete(P, i);
18504
18512
  }
18505
18513
  if (i.reference === this.index) {
@@ -18573,14 +18581,14 @@ function UI() {
18573
18581
  ), L = s.indexOf(`
18574
18582
  `, this.index);
18575
18583
  L === -1 && (L = s.length);
18576
- var i = this.index - this.lastLineBreak, o = String(this.line).length;
18584
+ var i = this.index - this.lastLineBreak, D = String(this.line).length;
18577
18585
  return N += " at line " + this.line + " col " + i + `:
18578
18586
 
18579
18587
  `, N += r.map(function(P, c) {
18580
- return l(this.line - r.length + c + 1, o) + " " + P;
18588
+ return l(this.line - r.length + c + 1, D) + " " + P;
18581
18589
  }, this).join(`
18582
18590
  `), N += `
18583
- ` + l("", o + i) + `^
18591
+ ` + l("", D + i) + `^
18584
18592
  `, N;
18585
18593
  } else
18586
18594
  return N + " at index " + (this.index - 1);
@@ -18612,23 +18620,23 @@ function UI() {
18612
18620
  if (s = N.next(), !s)
18613
18621
  break;
18614
18622
  } catch (Y) {
18615
- var o = new A(this.grammar, this.current + 1);
18616
- this.table.push(o);
18623
+ var D = new A(this.grammar, this.current + 1);
18624
+ this.table.push(D);
18617
18625
  var r = new Error(this.reportLexerError(Y));
18618
18626
  throw r.offset = this.current, r.token = Y.token, r;
18619
18627
  }
18620
18628
  var L = this.table[this.current];
18621
18629
  this.options.keepHistory || delete this.table[this.current - 1];
18622
- var i = this.current + 1, o = new A(this.grammar, i);
18623
- this.table.push(o);
18630
+ var i = this.current + 1, D = new A(this.grammar, i);
18631
+ this.table.push(D);
18624
18632
  for (var l = s.text !== void 0 ? s.text : s.value, P = N.constructor === S ? s.value : s, c = L.scannable, M = c.length; M--; ) {
18625
18633
  var u = c[M], H = u.rule.symbols[u.dot];
18626
18634
  if (H.test ? H.test(P) : H.type ? H.type === s.type : H.literal === l) {
18627
18635
  var B = u.nextState({ data: P, token: s, isToken: !0, reference: i - 1 });
18628
- o.states.push(B);
18636
+ D.states.push(B);
18629
18637
  }
18630
18638
  }
18631
- if (o.process(), o.states.length === 0) {
18639
+ if (D.process(), D.states.length === 0) {
18632
18640
  var r = new Error(this.reportError(s));
18633
18641
  throw r.offset = this.current, r.token = s, r;
18634
18642
  }
@@ -18654,10 +18662,10 @@ function UI() {
18654
18662
  else {
18655
18663
  s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
18656
18664
  `);
18657
- var o = i.map(function(l) {
18665
+ var D = i.map(function(l) {
18658
18666
  return this.buildFirstStateStack(l, []) || [l];
18659
18667
  }, this);
18660
- o.forEach(function(l) {
18668
+ D.forEach(function(l) {
18661
18669
  var P = l[0], c = P.rule.symbols[P.dot], M = this.getSymbolDisplay(c);
18662
18670
  s.push("A " + M + " based on:"), this.displayStateStack(l, s);
18663
18671
  }, this);
@@ -18666,8 +18674,8 @@ function UI() {
18666
18674
  `);
18667
18675
  }, I.prototype.displayStateStack = function(O, N) {
18668
18676
  for (var s, r = 0, L = 0; L < O.length; L++) {
18669
- var i = O[L], o = i.rule.toString(i.dot);
18670
- o === s ? r++ : (r > 0 && N.push(" ^ " + r + " more lines identical to this"), r = 0, N.push(" " + o)), s = o;
18677
+ var i = O[L], D = i.rule.toString(i.dot);
18678
+ D === s ? r++ : (r > 0 && N.push(" ^ " + r + " more lines identical to this"), r = 0, N.push(" " + D)), s = D;
18671
18679
  }
18672
18680
  }, I.prototype.getSymbolDisplay = function(O) {
18673
18681
  return t(O);
@@ -18736,55 +18744,55 @@ function UI() {
18736
18744
  });
18737
18745
  })(EE)), EE.exports;
18738
18746
  }
18739
- var cI = UI();
18740
- const GI = /* @__PURE__ */ PI(cI);
18741
- function lI(R) {
18742
- return R.map(uI).map(HI).map(BI).map(dI).map(FI);
18747
+ var uI = GI();
18748
+ const HI = /* @__PURE__ */ cI(uI);
18749
+ function BI(R) {
18750
+ return R.map(dI).map(FI).map(pI).map(mI).map(YI);
18743
18751
  }
18744
- const uI = (R, E, T) => {
18745
- if (mT(R.type)) {
18746
- const A = mI(T, E);
18747
- if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
18748
- return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18752
+ const dI = (R, E, T) => {
18753
+ if (pT(R.type)) {
18754
+ const A = hI(T, E);
18755
+ if (A && A.type === o.PROPERTY_ACCESS_OPERATOR)
18756
+ return Object.assign(Object.assign({}, R), { type: o.IDENTIFIER, text: R.raw });
18749
18757
  const e = Q(T, E);
18750
- if (e && e.type === D.PROPERTY_ACCESS_OPERATOR)
18751
- return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18758
+ if (e && e.type === o.PROPERTY_ACCESS_OPERATOR)
18759
+ return Object.assign(Object.assign({}, R), { type: o.IDENTIFIER, text: R.raw });
18752
18760
  }
18753
18761
  return R;
18754
- }, HI = (R, E, T) => {
18755
- if (R.type === D.RESERVED_FUNCTION_NAME) {
18762
+ }, FI = (R, E, T) => {
18763
+ if (R.type === o.RESERVED_FUNCTION_NAME) {
18756
18764
  const A = Q(T, E);
18757
18765
  if (!A || !WT(A))
18758
- return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
18766
+ return Object.assign(Object.assign({}, R), { type: o.IDENTIFIER, text: R.raw });
18759
18767
  }
18760
18768
  return R;
18761
- }, BI = (R, E, T) => {
18762
- if (R.type === D.RESERVED_DATA_TYPE) {
18769
+ }, pI = (R, E, T) => {
18770
+ if (R.type === o.RESERVED_DATA_TYPE) {
18763
18771
  const A = Q(T, E);
18764
18772
  if (A && WT(A))
18765
- return Object.assign(Object.assign({}, R), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
18773
+ return Object.assign(Object.assign({}, R), { type: o.RESERVED_PARAMETERIZED_DATA_TYPE });
18766
18774
  }
18767
18775
  return R;
18768
- }, dI = (R, E, T) => {
18769
- if (R.type === D.IDENTIFIER) {
18776
+ }, mI = (R, E, T) => {
18777
+ if (R.type === o.IDENTIFIER) {
18770
18778
  const A = Q(T, E);
18771
18779
  if (A && XT(A))
18772
- return Object.assign(Object.assign({}, R), { type: D.ARRAY_IDENTIFIER });
18780
+ return Object.assign(Object.assign({}, R), { type: o.ARRAY_IDENTIFIER });
18773
18781
  }
18774
18782
  return R;
18775
- }, FI = (R, E, T) => {
18776
- if (R.type === D.RESERVED_DATA_TYPE) {
18783
+ }, YI = (R, E, T) => {
18784
+ if (R.type === o.RESERVED_DATA_TYPE) {
18777
18785
  const A = Q(T, E);
18778
18786
  if (A && XT(A))
18779
- return Object.assign(Object.assign({}, R), { type: D.ARRAY_KEYWORD });
18787
+ return Object.assign(Object.assign({}, R), { type: o.ARRAY_KEYWORD });
18780
18788
  }
18781
18789
  return R;
18782
- }, mI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
18790
+ }, hI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
18783
18791
  let A = 1;
18784
- for (; R[E + A * T] && pI(R[E + A * T]); )
18792
+ for (; R[E + A * T] && fI(R[E + A * T]); )
18785
18793
  A++;
18786
18794
  return R[E + A * T];
18787
- }, WT = (R) => R.type === D.OPEN_PAREN && R.text === "(", XT = (R) => R.type === D.OPEN_PAREN && R.text === "[", pI = (R) => R.type === D.BLOCK_COMMENT || R.type === D.LINE_COMMENT;
18795
+ }, WT = (R) => R.type === o.OPEN_PAREN && R.text === "(", XT = (R) => R.type === o.OPEN_PAREN && R.text === "[", fI = (R) => R.type === o.BLOCK_COMMENT || R.type === o.LINE_COMMENT;
18788
18796
  class bT {
18789
18797
  constructor(E) {
18790
18798
  this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
@@ -18802,14 +18810,14 @@ class bT {
18802
18810
  return `Parse error at token: ${E.text} at line ${T} column ${A}`;
18803
18811
  }
18804
18812
  has(E) {
18805
- return E in D;
18813
+ return E in o;
18806
18814
  }
18807
18815
  }
18808
18816
  var U;
18809
18817
  (function(R) {
18810
18818
  R.statement = "statement", R.clause = "clause", R.set_operation = "set_operation", R.function_call = "function_call", R.parameterized_data_type = "parameterized_data_type", R.array_subscript = "array_subscript", R.property_access = "property_access", R.parenthesis = "parenthesis", R.between_predicate = "between_predicate", R.case_expression = "case_expression", R.case_when = "case_when", R.case_else = "case_else", R.limit_clause = "limit_clause", R.all_columns_asterisk = "all_columns_asterisk", R.literal = "literal", R.identifier = "identifier", R.keyword = "keyword", R.data_type = "data_type", R.parameter = "parameter", R.operator = "operator", R.comma = "comma", R.line_comment = "line_comment", R.block_comment = "block_comment", R.disable_comment = "disable_comment";
18811
18819
  })(U = U || (U = {}));
18812
- function pE(R) {
18820
+ function mE(R) {
18813
18821
  return R[0];
18814
18822
  }
18815
18823
  const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
@@ -18821,17 +18829,17 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18821
18829
  type: U.data_type,
18822
18830
  text: R.text,
18823
18831
  raw: R.raw
18824
- }), m = (R, { leading: E, trailing: T }) => (E?.length && (R = Object.assign(Object.assign({}, R), { leadingComments: E })), T?.length && (R = Object.assign(Object.assign({}, R), { trailingComments: T })), R), YI = (R, { leading: E, trailing: T }) => {
18832
+ }), p = (R, { leading: E, trailing: T }) => (E?.length && (R = Object.assign(Object.assign({}, R), { leadingComments: E })), T?.length && (R = Object.assign(Object.assign({}, R), { trailingComments: T })), R), VI = (R, { leading: E, trailing: T }) => {
18825
18833
  if (E?.length) {
18826
18834
  const [A, ...e] = R;
18827
- R = [m(A, { leading: E }), ...e];
18835
+ R = [p(A, { leading: E }), ...e];
18828
18836
  }
18829
18837
  if (T?.length) {
18830
18838
  const A = R.slice(0, -1), e = R[R.length - 1];
18831
- R = [...A, m(e, { trailing: T })];
18839
+ R = [...A, p(e, { trailing: T })];
18832
18840
  }
18833
18841
  return R;
18834
- }, hI = {
18842
+ }, WI = {
18835
18843
  Lexer: G,
18836
18844
  ParserRules: [
18837
18845
  { name: "main$ebnf$1", symbols: [] },
@@ -18852,7 +18860,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18852
18860
  postprocess: ([R, [E]]) => ({
18853
18861
  type: U.statement,
18854
18862
  children: R,
18855
- hasSemicolon: E.type === D.DELIMITER
18863
+ hasSemicolon: E.type === o.DELIMITER
18856
18864
  })
18857
18865
  },
18858
18866
  { name: "expressions_or_clauses$ebnf$1", symbols: [] },
@@ -18872,7 +18880,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18872
18880
  { name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
18873
18881
  { name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (R) => R[0].concat([R[1]]) },
18874
18882
  { name: "limit_clause$ebnf$1$subexpression$1", symbols: [G.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
18875
- { name: "limit_clause$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1"], postprocess: pE },
18883
+ { name: "limit_clause$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1"], postprocess: mE },
18876
18884
  { name: "limit_clause$ebnf$1", symbols: [], postprocess: () => null },
18877
18885
  {
18878
18886
  name: "limit_clause",
@@ -18882,14 +18890,14 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18882
18890
  const [e, S] = A;
18883
18891
  return {
18884
18892
  type: U.limit_clause,
18885
- limitKw: m(F(R), { trailing: E }),
18893
+ limitKw: p(F(R), { trailing: E }),
18886
18894
  offset: T,
18887
18895
  count: S
18888
18896
  };
18889
18897
  } else
18890
18898
  return {
18891
18899
  type: U.limit_clause,
18892
- limitKw: m(F(R), { trailing: E }),
18900
+ limitKw: p(F(R), { trailing: E }),
18893
18901
  count: T
18894
18902
  };
18895
18903
  }
@@ -18947,7 +18955,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18947
18955
  },
18948
18956
  { name: "expression_chain_$ebnf$1", symbols: ["expression_with_comments_"] },
18949
18957
  { name: "expression_chain_$ebnf$1", symbols: ["expression_chain_$ebnf$1", "expression_with_comments_"], postprocess: (R) => R[0].concat([R[1]]) },
18950
- { name: "expression_chain_", symbols: ["expression_chain_$ebnf$1"], postprocess: pE },
18958
+ { name: "expression_chain_", symbols: ["expression_chain_$ebnf$1"], postprocess: mE },
18951
18959
  { name: "expression_chain$ebnf$1", symbols: [] },
18952
18960
  { name: "expression_chain$ebnf$1", symbols: ["expression_chain$ebnf$1", "_expression_with_comments"], postprocess: (R) => R[0].concat([R[1]]) },
18953
18961
  {
@@ -18965,17 +18973,17 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
18965
18973
  {
18966
18974
  name: "expression_with_comments_",
18967
18975
  symbols: ["expression", "_"],
18968
- postprocess: ([R, E]) => m(R, { trailing: E })
18976
+ postprocess: ([R, E]) => p(R, { trailing: E })
18969
18977
  },
18970
18978
  {
18971
18979
  name: "_expression_with_comments",
18972
18980
  symbols: ["_", "expression"],
18973
- postprocess: ([R, E]) => m(E, { leading: R })
18981
+ postprocess: ([R, E]) => p(E, { leading: R })
18974
18982
  },
18975
18983
  {
18976
18984
  name: "_andless_expression_with_comments",
18977
18985
  symbols: ["_", "andless_expression"],
18978
- postprocess: ([R, E]) => m(E, { leading: R })
18986
+ postprocess: ([R, E]) => p(E, { leading: R })
18979
18987
  },
18980
18988
  { name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
18981
18989
  { name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
@@ -19014,7 +19022,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19014
19022
  symbols: [G.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
19015
19023
  postprocess: ([R, E, T]) => ({
19016
19024
  type: U.array_subscript,
19017
- array: m({ type: U.identifier, quoted: !1, text: R.text }, { trailing: E }),
19025
+ array: p({ type: U.identifier, quoted: !1, text: R.text }, { trailing: E }),
19018
19026
  parenthesis: T
19019
19027
  })
19020
19028
  },
@@ -19023,7 +19031,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19023
19031
  symbols: [G.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
19024
19032
  postprocess: ([R, E, T]) => ({
19025
19033
  type: U.array_subscript,
19026
- array: m(F(R), { trailing: E }),
19034
+ array: p(F(R), { trailing: E }),
19027
19035
  parenthesis: T
19028
19036
  })
19029
19037
  },
@@ -19032,7 +19040,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19032
19040
  symbols: [G.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
19033
19041
  postprocess: ([R, E, T]) => ({
19034
19042
  type: U.function_call,
19035
- nameKw: m(F(R), { trailing: E }),
19043
+ nameKw: p(F(R), { trailing: E }),
19036
19044
  parenthesis: T
19037
19045
  })
19038
19046
  },
@@ -19084,9 +19092,9 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19084
19092
  // %ARRAY_IDENTIFIER on the left side of <array_subscript>.
19085
19093
  ([R, E, T, A, [e]]) => ({
19086
19094
  type: U.property_access,
19087
- object: m(R, { trailing: E }),
19095
+ object: p(R, { trailing: E }),
19088
19096
  operator: T.text,
19089
- property: m(e, { leading: A })
19097
+ property: p(e, { leading: A })
19090
19098
  })
19091
19099
  )
19092
19100
  },
@@ -19096,12 +19104,12 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19096
19104
  postprocess: ([R, E, T, A, e, S, I]) => ({
19097
19105
  type: U.between_predicate,
19098
19106
  betweenKw: F(R),
19099
- expr1: YI(T, { leading: E, trailing: A }),
19107
+ expr1: VI(T, { leading: E, trailing: A }),
19100
19108
  andKw: F(e),
19101
- expr2: [m(I, { leading: S })]
19109
+ expr2: [p(I, { leading: S })]
19102
19110
  })
19103
19111
  },
19104
- { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: pE },
19112
+ { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: mE },
19105
19113
  { name: "case_expression$ebnf$1", symbols: [], postprocess: () => null },
19106
19114
  { name: "case_expression$ebnf$2", symbols: [] },
19107
19115
  { name: "case_expression$ebnf$2", symbols: ["case_expression$ebnf$2", "case_clause"], postprocess: (R) => R[0].concat([R[1]]) },
@@ -19110,7 +19118,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19110
19118
  symbols: [G.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", G.has("END") ? { type: "END" } : END],
19111
19119
  postprocess: ([R, E, T, A, e]) => ({
19112
19120
  type: U.case_expression,
19113
- caseKw: m(F(R), { trailing: E }),
19121
+ caseKw: p(F(R), { trailing: E }),
19114
19122
  endKw: F(e),
19115
19123
  expr: T || [],
19116
19124
  clauses: A
@@ -19121,8 +19129,8 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19121
19129
  symbols: [G.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", G.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
19122
19130
  postprocess: ([R, E, T, A, e, S]) => ({
19123
19131
  type: U.case_when,
19124
- whenKw: m(F(R), { trailing: E }),
19125
- thenKw: m(F(A), { trailing: e }),
19132
+ whenKw: p(F(R), { trailing: E }),
19133
+ thenKw: p(F(A), { trailing: e }),
19126
19134
  condition: T,
19127
19135
  result: S
19128
19136
  })
@@ -19132,7 +19140,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19132
19140
  symbols: [G.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
19133
19141
  postprocess: ([R, E, T]) => ({
19134
19142
  type: U.case_else,
19135
- elseKw: m(F(R), { trailing: E }),
19143
+ elseKw: p(F(R), { trailing: E }),
19136
19144
  result: T
19137
19145
  })
19138
19146
  },
@@ -19175,7 +19183,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19175
19183
  symbols: [G.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
19176
19184
  postprocess: ([R, E, T]) => ({
19177
19185
  type: U.parameterized_data_type,
19178
- dataType: m(cT(R), { trailing: E }),
19186
+ dataType: p(cT(R), { trailing: E }),
19179
19187
  parenthesis: T
19180
19188
  })
19181
19189
  },
@@ -19228,13 +19236,13 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
19228
19236
  }
19229
19237
  ],
19230
19238
  ParserStart: "main"
19231
- }, { Parser: fI, Grammar: VI } = GI;
19232
- function WI(R) {
19239
+ }, { Parser: XI, Grammar: bI } = HI;
19240
+ function yI(R) {
19233
19241
  let E = {};
19234
19242
  const T = new bT((e) => [
19235
- ...lI(R.tokenize(e, E)),
19243
+ ...BI(R.tokenize(e, E)),
19236
19244
  FT(e.length)
19237
- ]), A = new fI(VI.fromCompiled(hI), { lexer: T });
19245
+ ]), A = new XI(bI.fromCompiled(WI), { lexer: T });
19238
19246
  return {
19239
19247
  parse: (e, S) => {
19240
19248
  E = S;
@@ -19286,11 +19294,11 @@ class yT {
19286
19294
  }
19287
19295
  }
19288
19296
  trimHorizontalWhitespace() {
19289
- for (; XI(Z(this.items)); )
19297
+ for (; KI(Z(this.items)); )
19290
19298
  this.items.pop();
19291
19299
  }
19292
19300
  trimWhitespace() {
19293
- for (; bI(Z(this.items)); )
19301
+ for (; gI(Z(this.items)); )
19294
19302
  this.items.pop();
19295
19303
  }
19296
19304
  addNewline(E) {
@@ -19337,17 +19345,17 @@ class yT {
19337
19345
  }
19338
19346
  }
19339
19347
  }
19340
- const XI = (R) => R === a.SPACE || R === a.SINGLE_INDENT, bI = (R) => R === a.SPACE || R === a.SINGLE_INDENT || R === a.NEWLINE;
19341
- function GT(R, E) {
19348
+ const KI = (R) => R === a.SPACE || R === a.SINGLE_INDENT, gI = (R) => R === a.SPACE || R === a.SINGLE_INDENT || R === a.NEWLINE;
19349
+ function lT(R, E) {
19342
19350
  if (E === "standard")
19343
19351
  return R;
19344
19352
  let T = [];
19345
19353
  return R.length >= 10 && R.includes(" ") && ([R, ...T] = R.split(" ")), E === "tabularLeft" ? R = R.padEnd(9, " ") : R = R.padStart(9, " "), R + ["", ...T].join(" ");
19346
19354
  }
19347
- function lT(R) {
19348
- return PR(R) || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.LIMIT;
19355
+ function GT(R) {
19356
+ return cR(R) || R === o.RESERVED_CLAUSE || R === o.RESERVED_SELECT || R === o.RESERVED_SET_OPERATION || R === o.RESERVED_JOIN || R === o.LIMIT;
19349
19357
  }
19350
- const YE = "top-level", yI = "block-level";
19358
+ const YE = "top-level", $I = "block-level";
19351
19359
  class KT {
19352
19360
  /**
19353
19361
  * @param {string} indent A string to indent with
@@ -19377,7 +19385,7 @@ class KT {
19377
19385
  * Increases indentation by one block-level indent.
19378
19386
  */
19379
19387
  increaseBlockLevel() {
19380
- this.indentTypes.push(yI);
19388
+ this.indentTypes.push($I);
19381
19389
  }
19382
19390
  /**
19383
19391
  * Decreases indentation by one top-level indent.
@@ -19396,7 +19404,7 @@ class KT {
19396
19404
  ;
19397
19405
  }
19398
19406
  }
19399
- class KI extends yT {
19407
+ class wI extends yT {
19400
19408
  constructor(E) {
19401
19409
  super(new KT("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
19402
19410
  }
@@ -19640,7 +19648,7 @@ class RE {
19640
19648
  cfg: this.cfg,
19641
19649
  dialectCfg: this.dialectCfg,
19642
19650
  params: this.params,
19643
- layout: new KI(this.cfg.expressionWidth),
19651
+ layout: new wI(this.cfg.expressionWidth),
19644
19652
  inline: !0
19645
19653
  }).format(E);
19646
19654
  } catch (A) {
@@ -19653,11 +19661,11 @@ class RE {
19653
19661
  }
19654
19662
  formatKeywordNode(E) {
19655
19663
  switch (E.tokenType) {
19656
- case D.RESERVED_JOIN:
19664
+ case o.RESERVED_JOIN:
19657
19665
  return this.formatJoin(E);
19658
- case D.AND:
19659
- case D.OR:
19660
- case D.XOR:
19666
+ case o.AND:
19667
+ case o.OR:
19668
+ case o.XOR:
19661
19669
  return this.formatLogicalOperator(E);
19662
19670
  default:
19663
19671
  return this.formatKeyword(E);
@@ -19676,7 +19684,7 @@ class RE {
19676
19684
  this.layout.add(this.showDataType(E), a.SPACE);
19677
19685
  }
19678
19686
  showKw(E) {
19679
- return lT(E.tokenType) ? GT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
19687
+ return GT(E.tokenType) ? lT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
19680
19688
  }
19681
19689
  // Like showKw(), but skips tabular formatting
19682
19690
  showNonTabularKw(E) {
@@ -19690,7 +19698,7 @@ class RE {
19690
19698
  }
19691
19699
  }
19692
19700
  showFunctionKw(E) {
19693
- return lT(E.tokenType) ? GT(this.showNonTabularFunctionKw(E), this.cfg.indentStyle) : this.showNonTabularFunctionKw(E);
19701
+ return GT(E.tokenType) ? lT(this.showNonTabularFunctionKw(E), this.cfg.indentStyle) : this.showNonTabularFunctionKw(E);
19694
19702
  }
19695
19703
  // Like showFunctionKw(), but skips tabular formatting
19696
19704
  showNonTabularFunctionKw(E) {
@@ -19726,9 +19734,9 @@ class RE {
19726
19734
  }
19727
19735
  }
19728
19736
  }
19729
- class $I {
19737
+ class JI {
19730
19738
  constructor(E, T) {
19731
- this.dialect = E, this.cfg = T, this.params = new DI(this.cfg.params);
19739
+ this.dialect = E, this.cfg = T, this.params = new UI(this.cfg.params);
19732
19740
  }
19733
19741
  /**
19734
19742
  * Formats an SQL query.
@@ -19740,7 +19748,7 @@ class $I {
19740
19748
  return this.formatAst(T).trimEnd();
19741
19749
  }
19742
19750
  parse(E) {
19743
- return WI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
19751
+ return yI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
19744
19752
  }
19745
19753
  formatAst(E) {
19746
19754
  return E.map((T) => this.formatStatement(T)).join(`
@@ -19751,14 +19759,14 @@ class $I {
19751
19759
  cfg: this.cfg,
19752
19760
  dialectCfg: this.dialect.formatOptions,
19753
19761
  params: this.params,
19754
- layout: new yT(new KT(oI(this.cfg)))
19762
+ layout: new yT(new KT(MI(this.cfg)))
19755
19763
  }).format(E.children);
19756
19764
  return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(a.NEWLINE, ";") : T.add(a.NO_NEWLINE, ";")), T.toString();
19757
19765
  }
19758
19766
  }
19759
19767
  class TE extends Error {
19760
19768
  }
19761
- function gI(R) {
19769
+ function xI(R) {
19762
19770
  const E = [
19763
19771
  "multilineLists",
19764
19772
  "newlineBeforeOpenParen",
@@ -19772,17 +19780,17 @@ function gI(R) {
19772
19780
  throw new TE(`${T} config is no more supported.`);
19773
19781
  if (R.expressionWidth <= 0)
19774
19782
  throw new TE(`expressionWidth config must be positive number. Received ${R.expressionWidth} instead.`);
19775
- if (R.params && !wI(R.params) && console.warn('WARNING: All "params" option values should be strings.'), R.paramTypes && !JI(R.paramTypes))
19783
+ if (R.params && !vI(R.params) && console.warn('WARNING: All "params" option values should be strings.'), R.paramTypes && !QI(R.paramTypes))
19776
19784
  throw new TE("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
19777
19785
  return R;
19778
19786
  }
19779
- function wI(R) {
19787
+ function vI(R) {
19780
19788
  return (R instanceof Array ? R : Object.values(R)).every((T) => typeof T == "string");
19781
19789
  }
19782
- function JI(R) {
19790
+ function QI(R) {
19783
19791
  return R.custom && Array.isArray(R.custom) ? R.custom.every((E) => E.regex !== "") : !0;
19784
19792
  }
19785
- var xI = function(R, E) {
19793
+ var ZI = function(R, E) {
19786
19794
  var T = {};
19787
19795
  for (var A in R) Object.prototype.hasOwnProperty.call(R, A) && E.indexOf(A) < 0 && (T[A] = R[A]);
19788
19796
  if (R != null && typeof Object.getOwnPropertySymbols == "function")
@@ -19790,7 +19798,7 @@ var xI = function(R, E) {
19790
19798
  E.indexOf(A[e]) < 0 && Object.prototype.propertyIsEnumerable.call(R, A[e]) && (T[A[e]] = R[A[e]]);
19791
19799
  return T;
19792
19800
  };
19793
- const $T = {
19801
+ const gT = {
19794
19802
  bigquery: "bigquery",
19795
19803
  db2: "db2",
19796
19804
  db2i: "db2i",
@@ -19811,7 +19819,7 @@ const $T = {
19811
19819
  tsql: "transactsql",
19812
19820
  singlestoredb: "singlestoredb",
19813
19821
  snowflake: "snowflake"
19814
- }, vI = Object.keys($T), QI = {
19822
+ }, qI = Object.keys(gT), jI = {
19815
19823
  tabWidth: 2,
19816
19824
  useTabs: !1,
19817
19825
  keywordCase: "preserve",
@@ -19824,21 +19832,21 @@ const $T = {
19824
19832
  linesBetweenQueries: 1,
19825
19833
  denseOperators: !1,
19826
19834
  newlineBeforeSemicolon: !1
19827
- }, ZI = (R, E = {}) => {
19828
- if (typeof E.language == "string" && !vI.includes(E.language))
19835
+ }, kI = (R, E = {}) => {
19836
+ if (typeof E.language == "string" && !qI.includes(E.language))
19829
19837
  throw new TE(`Unsupported SQL dialect: ${E.language}`);
19830
- const T = $T[E.language || "sql"];
19831
- return qI(R, Object.assign(Object.assign({}, E), { dialect: TI[T] }));
19832
- }, qI = (R, E) => {
19833
- var { dialect: T } = E, A = xI(E, ["dialect"]);
19838
+ const T = gT[E.language || "sql"];
19839
+ return zI(R, Object.assign(Object.assign({}, E), { dialect: eI[T] }));
19840
+ }, zI = (R, E) => {
19841
+ var { dialect: T } = E, A = ZI(E, ["dialect"]);
19834
19842
  if (typeof R != "string")
19835
19843
  throw new Error("Invalid query argument. Expected string, instead got " + typeof R);
19836
- const e = gI(Object.assign(Object.assign({}, QI), A));
19837
- return new $I(nI(T), e).format(R);
19844
+ const e = xI(Object.assign(Object.assign({}, jI), A));
19845
+ return new JI(oI(T), e).format(R);
19838
19846
  };
19839
19847
  function uT(R, E) {
19840
19848
  try {
19841
- return ZI(R, {
19849
+ return kI(R, {
19842
19850
  language: {
19843
19851
  postgres: "postgresql",
19844
19852
  mysql: "mysql",
@@ -19913,7 +19921,7 @@ class bE {
19913
19921
  );
19914
19922
  continue;
19915
19923
  }
19916
- const S = tR(e.calculatedSql);
19924
+ const S = LR(e.calculatedSql);
19917
19925
  if (!S.isValid) {
19918
19926
  T.push(
19919
19927
  `Invalid calculatedSql syntax in '${E.name}.${A}': ${S.errors.join(", ")}`
@@ -20131,10 +20139,10 @@ ${T.join(`
20131
20139
  * Ensures all referenced cubes and fields exist
20132
20140
  */
20133
20141
  validateQuery(E) {
20134
- return gT(this.cubes, E);
20142
+ return $T(this.cubes, E);
20135
20143
  }
20136
20144
  }
20137
- function gT(R, E) {
20145
+ function $T(R, E) {
20138
20146
  const T = [], A = /* @__PURE__ */ new Set();
20139
20147
  if (E.measures)
20140
20148
  for (const e of E.measures) {
@@ -20213,17 +20221,17 @@ function wT(R, E, T, A) {
20213
20221
  }
20214
20222
  !I.dimensions[S] && !I.measures[S] && T.push(`Filter field '${S}' not found on cube '${e}' (must be a dimension or measure)`);
20215
20223
  }
20216
- function TO(R) {
20224
+ function eO(R) {
20217
20225
  return new bE(R);
20218
20226
  }
20219
- const jI = new bE(), RO = jI;
20220
- function AO(R) {
20227
+ const EO = new bE(), SO = EO;
20228
+ function IO(R) {
20221
20229
  return new bE({
20222
20230
  drizzle: R.drizzle,
20223
20231
  schema: R.schema
20224
20232
  });
20225
20233
  }
20226
- const eO = {
20234
+ const OO = {
20227
20235
  /**
20228
20236
  * Create a simple query builder
20229
20237
  */
@@ -20332,24 +20340,24 @@ const eO = {
20332
20340
  export {
20333
20341
  VE as BaseDatabaseExecutor,
20334
20342
  BT as MySQLExecutor,
20335
- ER as PostgresExecutor,
20336
- sR as QueryBuilder,
20343
+ AR as PostgresExecutor,
20344
+ _R as QueryBuilder,
20337
20345
  CE as QueryExecutor,
20338
- CR as QueryPlanner,
20339
- RR as SQLiteExecutor,
20346
+ rR as QueryPlanner,
20347
+ SR as SQLiteExecutor,
20340
20348
  bE as SemanticLayerCompiler,
20341
- eO as SemanticLayerUtils,
20349
+ OO as SemanticLayerUtils,
20342
20350
  vE as createDatabaseExecutor,
20343
- AO as createDrizzleSemanticLayer,
20344
- zI as createMultiCubeContext,
20345
- TR as createMySQLExecutor,
20351
+ IO as createDrizzleSemanticLayer,
20352
+ RO as createMultiCubeContext,
20353
+ eR as createMySQLExecutor,
20346
20354
  JE as createPostgresExecutor,
20347
20355
  xE as createSQLiteExecutor,
20348
- TO as createSemanticLayer,
20349
- RO as defaultSemanticLayer,
20350
- EO as defineCube,
20356
+ eO as createSemanticLayer,
20357
+ SO as defaultSemanticLayer,
20358
+ AO as defineCube,
20351
20359
  dT as getJoinType,
20352
20360
  QE as resolveCubeReference,
20353
20361
  X as resolveSqlExpression,
20354
- jI as semanticLayer
20362
+ EO as semanticLayer
20355
20363
  };