drizzle-cube 0.1.31 → 0.1.33

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,17 +1,17 @@
1
- const f = Symbol.for("drizzle:entityKind");
1
+ const h = Symbol.for("drizzle:entityKind");
2
2
  function H(T, E) {
3
3
  if (!T || typeof T != "object")
4
4
  return !1;
5
5
  if (T instanceof E)
6
6
  return !0;
7
- if (!Object.prototype.hasOwnProperty.call(E, f))
7
+ if (!Object.prototype.hasOwnProperty.call(E, h))
8
8
  throw new Error(
9
9
  `Class "${E.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
10
10
  );
11
11
  let R = Object.getPrototypeOf(T).constructor;
12
12
  if (R)
13
13
  for (; R; ) {
14
- if (f in R && R[f] === E[f])
14
+ if (h in R && R[h] === E[h])
15
15
  return !0;
16
16
  R = Object.getPrototypeOf(R);
17
17
  }
@@ -21,7 +21,7 @@ class TE {
21
21
  constructor(E, R) {
22
22
  this.table = E, this.config = R, this.name = R.name, this.keyAsName = R.keyAsName, this.notNull = R.notNull, this.default = R.default, this.defaultFn = R.defaultFn, this.onUpdateFn = R.onUpdateFn, this.hasDefault = R.hasDefault, this.primary = R.primaryKey, this.isUnique = R.isUnique, this.uniqueName = R.uniqueName, this.uniqueType = R.uniqueType, this.dataType = R.dataType, this.columnType = R.columnType, this.generated = R.generated, this.generatedIdentity = R.generatedIdentity;
23
23
  }
24
- static [f] = "Column";
24
+ static [h] = "Column";
25
25
  name;
26
26
  keyAsName;
27
27
  primary;
@@ -55,7 +55,7 @@ function _R(T) {
55
55
  return !!T && typeof T == "function" && kE in T && T[kE] === !0;
56
56
  }
57
57
  class gT {
58
- static [f] = "Subquery";
58
+ static [h] = "Subquery";
59
59
  constructor(E, R, A, e = !1, S = []) {
60
60
  this._ = {
61
61
  brand: "Subquery",
@@ -76,7 +76,7 @@ const rR = {
76
76
  }
77
77
  }, z = Symbol.for("drizzle:ViewBaseConfig"), rE = Symbol.for("drizzle:Schema"), zE = Symbol.for("drizzle:Columns"), ET = Symbol.for("drizzle:ExtraConfigColumns"), nE = Symbol.for("drizzle:OriginalName"), iE = Symbol.for("drizzle:BaseName"), IE = Symbol.for("drizzle:IsAlias"), TT = Symbol.for("drizzle:ExtraConfigBuilder"), nR = Symbol.for("drizzle:IsDrizzleTable");
78
78
  class W {
79
- static [f] = "Table";
79
+ static [h] = "Table";
80
80
  /** @internal */
81
81
  static Symbol = {
82
82
  Name: _E,
@@ -119,7 +119,7 @@ class W {
119
119
  this[_E] = this[nE] = E, this[rE] = R, this[iE] = A;
120
120
  }
121
121
  }
122
- function JT(T) {
122
+ function wT(T) {
123
123
  return T != null && typeof T.getSQL == "function";
124
124
  }
125
125
  function iR(T) {
@@ -129,7 +129,7 @@ function iR(T) {
129
129
  return E;
130
130
  }
131
131
  class d {
132
- static [f] = "StringChunk";
132
+ static [h] = "StringChunk";
133
133
  value;
134
134
  constructor(E) {
135
135
  this.value = Array.isArray(E) ? E : [E];
@@ -149,9 +149,9 @@ class u {
149
149
  );
150
150
  }
151
151
  }
152
- static [f] = "SQL";
152
+ static [h] = "SQL";
153
153
  /** @internal */
154
- decoder = wT;
154
+ decoder = JT;
155
155
  shouldInlineParams = !1;
156
156
  /** @internal */
157
157
  usedTables = [];
@@ -175,73 +175,73 @@ class u {
175
175
  casing: e,
176
176
  escapeName: S,
177
177
  escapeParam: N,
178
- prepareTyping: s,
179
- inlineParams: _,
178
+ prepareTyping: t,
179
+ inlineParams: r,
180
180
  paramStartIndex: I
181
181
  } = A;
182
182
  return iR(E.map((O) => {
183
183
  if (H(O, d))
184
184
  return { sql: O.value.join(""), params: [] };
185
- if (H(O, wE))
185
+ if (H(O, JE))
186
186
  return { sql: S(O.value), params: [] };
187
187
  if (O === void 0)
188
188
  return { sql: "", params: [] };
189
189
  if (Array.isArray(O)) {
190
- const t = [new d("(")];
190
+ const s = [new d("(")];
191
191
  for (const [L, a] of O.entries())
192
- t.push(a), L < O.length - 1 && t.push(new d(", "));
193
- return t.push(new d(")")), this.buildQueryFromSourceParams(t, A);
192
+ s.push(a), L < O.length - 1 && s.push(new d(", "));
193
+ return s.push(new d(")")), this.buildQueryFromSourceParams(s, A);
194
194
  }
195
195
  if (H(O, u))
196
196
  return this.buildQueryFromSourceParams(O.queryChunks, {
197
197
  ...A,
198
- inlineParams: _ || O.shouldInlineParams
198
+ inlineParams: r || O.shouldInlineParams
199
199
  });
200
200
  if (H(O, W)) {
201
- const t = O[W.Symbol.Schema], L = O[W.Symbol.Name];
201
+ const s = O[W.Symbol.Schema], L = O[W.Symbol.Name];
202
202
  return {
203
- sql: t === void 0 || O[IE] ? S(L) : S(t) + "." + S(L),
203
+ sql: s === void 0 || O[IE] ? S(L) : S(s) + "." + S(L),
204
204
  params: []
205
205
  };
206
206
  }
207
207
  if (H(O, TE)) {
208
- const t = e.getColumnCasing(O);
208
+ const s = e.getColumnCasing(O);
209
209
  if (R.invokeSource === "indexes")
210
- return { sql: S(t), params: [] };
210
+ return { sql: S(s), params: [] };
211
211
  const L = O.table[W.Symbol.Schema];
212
212
  return {
213
- sql: O.table[IE] || L === void 0 ? S(O.table[W.Symbol.Name]) + "." + S(t) : S(L) + "." + S(O.table[W.Symbol.Name]) + "." + S(t),
213
+ sql: O.table[IE] || L === void 0 ? S(O.table[W.Symbol.Name]) + "." + S(s) : S(L) + "." + S(O.table[W.Symbol.Name]) + "." + S(s),
214
214
  params: []
215
215
  };
216
216
  }
217
217
  if (H(O, vT)) {
218
- const t = O[z].schema, L = O[z].name;
218
+ const s = O[z].schema, L = O[z].name;
219
219
  return {
220
- sql: t === void 0 || O[z].isAlias ? S(L) : S(t) + "." + S(L),
220
+ sql: s === void 0 || O[z].isAlias ? S(L) : S(s) + "." + S(L),
221
221
  params: []
222
222
  };
223
223
  }
224
224
  if (H(O, OE)) {
225
225
  if (H(O.value, NE))
226
226
  return { sql: N(I.value++, O), params: [O], typings: ["none"] };
227
- const t = O.value === null ? null : O.encoder.mapToDriverValue(O.value);
228
- if (H(t, u))
229
- return this.buildQueryFromSourceParams([t], A);
230
- if (_)
231
- return { sql: this.mapInlineParam(t, A), params: [] };
227
+ const s = O.value === null ? null : O.encoder.mapToDriverValue(O.value);
228
+ if (H(s, u))
229
+ return this.buildQueryFromSourceParams([s], A);
230
+ if (r)
231
+ return { sql: this.mapInlineParam(s, A), params: [] };
232
232
  let L = ["none"];
233
- return s && (L = [s(O.encoder)]), { sql: N(I.value++, t), params: [t], typings: L };
233
+ return t && (L = [t(O.encoder)]), { sql: N(I.value++, s), params: [s], typings: L };
234
234
  }
235
235
  return H(O, NE) ? { sql: N(I.value++, O), params: [O], typings: ["none"] } : H(O, u.Aliased) && O.fieldAlias !== void 0 ? { sql: S(O.fieldAlias), params: [] } : H(O, gT) ? O._.isWith ? { sql: S(O._.alias), params: [] } : this.buildQueryFromSourceParams([
236
236
  new d("("),
237
237
  O._.sql,
238
238
  new d(") "),
239
- new wE(O._.alias)
240
- ], A) : _R(O) ? O.schema ? { sql: S(O.schema) + "." + S(O.enumName), params: [] } : { sql: S(O.enumName), params: [] } : JT(O) ? O.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([O.getSQL()], A) : this.buildQueryFromSourceParams([
239
+ new JE(O._.alias)
240
+ ], A) : _R(O) ? O.schema ? { sql: S(O.schema) + "." + S(O.enumName), params: [] } : { sql: S(O.enumName), params: [] } : wT(O) ? O.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([O.getSQL()], A) : this.buildQueryFromSourceParams([
241
241
  new d("("),
242
242
  O.getSQL(),
243
243
  new d(")")
244
- ], A) : _ ? { sql: this.mapInlineParam(O, A), params: [] } : { sql: N(I.value++, O), params: [O], typings: ["none"] };
244
+ ], A) : r ? { sql: this.mapInlineParam(O, A), params: [] } : { sql: N(I.value++, O), params: [O], typings: ["none"] };
245
245
  }));
246
246
  }
247
247
  mapInlineParam(E, { escapeString: R }) {
@@ -279,11 +279,11 @@ class u {
279
279
  return E ? this : void 0;
280
280
  }
281
281
  }
282
- class wE {
282
+ class JE {
283
283
  constructor(E) {
284
284
  this.value = E;
285
285
  }
286
- static [f] = "Name";
286
+ static [h] = "Name";
287
287
  brand;
288
288
  getSQL() {
289
289
  return new u([this]);
@@ -292,13 +292,13 @@ class wE {
292
292
  function DR(T) {
293
293
  return typeof T == "object" && T !== null && "mapToDriverValue" in T && typeof T.mapToDriverValue == "function";
294
294
  }
295
- const wT = {
295
+ const JT = {
296
296
  mapFromDriverValue: (T) => T
297
297
  }, xT = {
298
298
  mapToDriverValue: (T) => T
299
299
  };
300
300
  ({
301
- ...wT,
301
+ ...JT,
302
302
  ...xT
303
303
  });
304
304
  class OE {
@@ -309,7 +309,7 @@ class OE {
309
309
  constructor(E, R = xT) {
310
310
  this.value = E, this.encoder = R;
311
311
  }
312
- static [f] = "Param";
312
+ static [h] = "Param";
313
313
  brand;
314
314
  getSQL() {
315
315
  return new u([this]);
@@ -327,40 +327,40 @@ function C(T, ...E) {
327
327
  return new u([]);
328
328
  }
329
329
  T.empty = E;
330
- function R(_) {
331
- return new u(_);
330
+ function R(r) {
331
+ return new u(r);
332
332
  }
333
333
  T.fromList = R;
334
- function A(_) {
335
- return new u([new d(_)]);
334
+ function A(r) {
335
+ return new u([new d(r)]);
336
336
  }
337
337
  T.raw = A;
338
- function e(_, I) {
338
+ function e(r, I) {
339
339
  const O = [];
340
- for (const [t, L] of _.entries())
341
- t > 0 && I !== void 0 && O.push(I), O.push(L);
340
+ for (const [s, L] of r.entries())
341
+ s > 0 && I !== void 0 && O.push(I), O.push(L);
342
342
  return new u(O);
343
343
  }
344
344
  T.join = e;
345
- function S(_) {
346
- return new wE(_);
345
+ function S(r) {
346
+ return new JE(r);
347
347
  }
348
348
  T.identifier = S;
349
- function N(_) {
350
- return new NE(_);
349
+ function N(r) {
350
+ return new NE(r);
351
351
  }
352
352
  T.placeholder = N;
353
- function s(_, I) {
354
- return new OE(_, I);
353
+ function t(r, I) {
354
+ return new OE(r, I);
355
355
  }
356
- T.param = s;
356
+ T.param = t;
357
357
  })(C || (C = {}));
358
358
  ((T) => {
359
359
  class E {
360
360
  constructor(A, e) {
361
361
  this.sql = A, this.fieldAlias = e;
362
362
  }
363
- static [f] = "SQL.Aliased";
363
+ static [h] = "SQL.Aliased";
364
364
  /** @internal */
365
365
  isSelectionField = !1;
366
366
  getSQL() {
@@ -377,14 +377,14 @@ class NE {
377
377
  constructor(E) {
378
378
  this.name = E;
379
379
  }
380
- static [f] = "Placeholder";
380
+ static [h] = "Placeholder";
381
381
  getSQL() {
382
382
  return new u([this]);
383
383
  }
384
384
  }
385
385
  const aR = Symbol.for("drizzle:IsDrizzleView");
386
386
  class vT {
387
- static [f] = "View";
387
+ static [h] = "View";
388
388
  /** @internal */
389
389
  [z];
390
390
  /** @internal */
@@ -414,10 +414,10 @@ gT.prototype.getSQL = function() {
414
414
  return new u([this]);
415
415
  };
416
416
  function b(T, E) {
417
- return DR(E) && !JT(T) && !H(T, OE) && !H(T, NE) && !H(T, TE) && !H(T, W) && !H(T, vT) ? new OE(T, E) : T;
417
+ return DR(E) && !wT(T) && !H(T, OE) && !H(T, NE) && !H(T, TE) && !H(T, W) && !H(T, vT) ? new OE(T, E) : T;
418
418
  }
419
- const tE = (T, E) => C`${T} = ${b(E, T)}`, RT = (T, E) => C`${T} <> ${b(E, T)}`;
420
- function h(...T) {
419
+ const sE = (T, E) => C`${T} = ${b(E, T)}`, RT = (T, E) => C`${T} <> ${b(E, T)}`;
420
+ function f(...T) {
421
421
  const E = T.filter(
422
422
  (R) => R !== void 0
423
423
  );
@@ -1067,7 +1067,7 @@ class BR extends ZT {
1067
1067
  function mR(T, E) {
1068
1068
  return new BR(T, E);
1069
1069
  }
1070
- function tT(T, E, R) {
1070
+ function sT(T, E, R) {
1071
1071
  if (R)
1072
1072
  switch (R) {
1073
1073
  case "postgres":
@@ -1085,7 +1085,7 @@ function tT(T, E, R) {
1085
1085
  return OT(T, E);
1086
1086
  throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
1087
1087
  }
1088
- function sT(T) {
1088
+ function tT(T) {
1089
1089
  return typeof T == "function" ? T() : T;
1090
1090
  }
1091
1091
  function FR(T, E) {
@@ -1119,30 +1119,30 @@ class YR {
1119
1119
  const e = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1120
1120
  if (R.dimensions)
1121
1121
  for (const N of R.dimensions) {
1122
- const [s, _] = N.split("."), I = S.get(s);
1123
- if (I && I.dimensions && I.dimensions[_]) {
1124
- const O = I.dimensions[_], t = $(O.sql, A);
1125
- e[N] = C`${t}`.as(N);
1122
+ const [t, r] = N.split("."), I = S.get(t);
1123
+ if (I && I.dimensions && I.dimensions[r]) {
1124
+ const O = I.dimensions[r], s = $(O.sql, A);
1125
+ e[N] = C`${s}`.as(N);
1126
1126
  }
1127
1127
  }
1128
1128
  if (R.measures)
1129
1129
  for (const N of R.measures) {
1130
- const [s, _] = N.split("."), I = S.get(s);
1131
- if (I && I.measures && I.measures[_]) {
1132
- const O = I.measures[_], t = this.buildMeasureExpression(O, A);
1133
- e[N] = C`${t}`.as(N);
1130
+ const [t, r] = N.split("."), I = S.get(t);
1131
+ if (I && I.measures && I.measures[r]) {
1132
+ const O = I.measures[r], s = this.buildMeasureExpression(O, A);
1133
+ e[N] = C`${s}`.as(N);
1134
1134
  }
1135
1135
  }
1136
1136
  if (R.timeDimensions)
1137
1137
  for (const N of R.timeDimensions) {
1138
- const [s, _] = N.dimension.split("."), I = S.get(s);
1139
- if (I && I.dimensions && I.dimensions[_]) {
1140
- const O = I.dimensions[_], t = this.buildTimeDimensionExpression(
1138
+ const [t, r] = N.dimension.split("."), I = S.get(t);
1139
+ if (I && I.dimensions && I.dimensions[r]) {
1140
+ const O = I.dimensions[r], s = this.buildTimeDimensionExpression(
1141
1141
  O.sql,
1142
1142
  N.granularity,
1143
1143
  A
1144
1144
  );
1145
- e[N.dimension] = C`${t}`.as(N.dimension);
1145
+ e[N.dimension] = C`${s}`.as(N.dimension);
1146
1146
  }
1147
1147
  }
1148
1148
  return Object.keys(e).length === 0 && (e.count = ME()), e;
@@ -1152,24 +1152,24 @@ class YR {
1152
1152
  */
1153
1153
  buildHavingMeasureExpression(E, R, A, e, S) {
1154
1154
  if (S && S.preAggregationCTEs) {
1155
- const N = S.preAggregationCTEs.find((s) => s.cube.name === E);
1155
+ const N = S.preAggregationCTEs.find((t) => t.cube.name === E);
1156
1156
  if (N && N.measures.includes(`${E}.${R}`)) {
1157
- const s = C`${C.identifier(N.cteAlias)}.${C.identifier(R)}`;
1157
+ const t = C`${C.identifier(N.cteAlias)}.${C.identifier(R)}`;
1158
1158
  switch (A.type) {
1159
1159
  case "count":
1160
1160
  case "countDistinct":
1161
1161
  case "sum":
1162
- return g(s);
1162
+ return g(t);
1163
1163
  case "avg":
1164
- return this.databaseAdapter.buildAvg(s);
1164
+ return this.databaseAdapter.buildAvg(t);
1165
1165
  case "min":
1166
- return vE(s);
1166
+ return vE(t);
1167
1167
  case "max":
1168
- return xE(s);
1168
+ return xE(t);
1169
1169
  case "number":
1170
- return g(s);
1170
+ return g(t);
1171
1171
  default:
1172
- return g(s);
1172
+ return g(t);
1173
1173
  }
1174
1174
  }
1175
1175
  }
@@ -1183,7 +1183,7 @@ class YR {
1183
1183
  if (E.filters && E.filters.length > 0) {
1184
1184
  const e = E.filters.map((S) => S(R)).filter(Boolean);
1185
1185
  if (e.length > 0) {
1186
- const S = e.length === 1 ? e[0] : h(...e);
1186
+ const S = e.length === 1 ? e[0] : f(...e);
1187
1187
  A = this.databaseAdapter.buildCaseWhen([
1188
1188
  { when: S, then: A }
1189
1189
  ]);
@@ -1222,17 +1222,17 @@ class YR {
1222
1222
  buildWhereConditions(E, R, A, e) {
1223
1223
  const S = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1224
1224
  if (R.filters && R.filters.length > 0)
1225
- for (const s of R.filters) {
1226
- const _ = this.processFilter(s, N, A, "where", e);
1227
- _ && S.push(_);
1225
+ for (const t of R.filters) {
1226
+ const r = this.processFilter(t, N, A, "where", e);
1227
+ r && S.push(r);
1228
1228
  }
1229
1229
  if (R.timeDimensions)
1230
- for (const s of R.timeDimensions) {
1231
- const [_, I] = s.dimension.split("."), O = N.get(_);
1232
- if (O && O.dimensions[I] && s.dateRange) {
1233
- if (e?.preAggregationCTEs && e.preAggregationCTEs.some((n) => n.cube.name === _))
1230
+ for (const t of R.timeDimensions) {
1231
+ const [r, I] = t.dimension.split("."), O = N.get(r);
1232
+ if (O && O.dimensions[I] && t.dateRange) {
1233
+ if (e?.preAggregationCTEs && e.preAggregationCTEs.some((n) => n.cube.name === r))
1234
1234
  continue;
1235
- const t = O.dimensions[I], L = $(t.sql, A), a = this.buildDateRangeCondition(L, s.dateRange);
1235
+ const s = O.dimensions[I], L = $(s.sql, A), a = this.buildDateRangeCondition(L, t.dateRange);
1236
1236
  a && S.push(a);
1237
1237
  }
1238
1238
  }
@@ -1245,9 +1245,9 @@ class YR {
1245
1245
  buildHavingConditions(E, R, A, e) {
1246
1246
  const S = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1247
1247
  if (R.filters && R.filters.length > 0)
1248
- for (const s of R.filters) {
1249
- const _ = this.processFilter(s, N, A, "having", e);
1250
- _ && S.push(_);
1248
+ for (const t of R.filters) {
1249
+ const r = this.processFilter(t, N, A, "having", e);
1250
+ r && S.push(r);
1251
1251
  }
1252
1252
  return S;
1253
1253
  }
@@ -1260,27 +1260,27 @@ class YR {
1260
1260
  const a = E;
1261
1261
  if (a.and) {
1262
1262
  const o = a.and.map((n) => this.processFilter(n, R, A, e, S)).filter((n) => n !== null);
1263
- return o.length > 0 ? h(...o) : null;
1263
+ return o.length > 0 ? f(...o) : null;
1264
1264
  }
1265
1265
  if (a.or) {
1266
1266
  const o = a.or.map((n) => this.processFilter(n, R, A, e, S)).filter((n) => n !== null);
1267
1267
  return o.length > 0 ? DE(...o) : null;
1268
1268
  }
1269
1269
  }
1270
- const N = E, [s, _] = N.member.split("."), I = R.get(s);
1270
+ const N = E, [t, r] = N.member.split("."), I = R.get(t);
1271
1271
  if (!I) return null;
1272
- const O = I.dimensions[_], t = I.measures[_], L = O || t;
1272
+ const O = I.dimensions[r], s = I.measures[r], L = O || s;
1273
1273
  if (!L) return null;
1274
1274
  if (e === "where" && O) {
1275
- if (S?.preAggregationCTEs && S.preAggregationCTEs.some((n) => n.cube.name === s))
1275
+ if (S?.preAggregationCTEs && S.preAggregationCTEs.some((n) => n.cube.name === t))
1276
1276
  return null;
1277
1277
  const a = $(O.sql, A);
1278
1278
  return this.buildFilterCondition(a, N.operator, N.values, L);
1279
1279
  } else {
1280
- if (e === "where" && t)
1280
+ if (e === "where" && s)
1281
1281
  return null;
1282
- if (e === "having" && t) {
1283
- const a = this.buildHavingMeasureExpression(s, _, t, A, S);
1282
+ if (e === "having" && s) {
1283
+ const a = this.buildHavingMeasureExpression(t, r, s, A, S);
1284
1284
  return this.buildFilterCondition(a, N.operator, N.values, L);
1285
1285
  }
1286
1286
  }
@@ -1292,7 +1292,7 @@ class YR {
1292
1292
  buildFilterCondition(E, R, A, e) {
1293
1293
  if (!A || A.length === 0)
1294
1294
  return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1295
- const S = A.filter((s) => !(s == null || s === "" || typeof s == "string" && s.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1295
+ const S = A.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1296
1296
  if (S.length === 0 && !["set", "notSet"].includes(R))
1297
1297
  return R === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1298
1298
  const N = S[0];
@@ -1300,13 +1300,13 @@ class YR {
1300
1300
  case "equals":
1301
1301
  if (S.length > 1) {
1302
1302
  if (e?.type === "time") {
1303
- const s = S.map((_) => this.normalizeDate(_) || _);
1304
- return PE(E, s);
1303
+ const t = S.map((r) => this.normalizeDate(r) || r);
1304
+ return PE(E, t);
1305
1305
  }
1306
1306
  return PE(E, S);
1307
1307
  } else if (S.length === 1) {
1308
- const s = e?.type === "time" && this.normalizeDate(N) || N;
1309
- return tE(E, s);
1308
+ const t = e?.type === "time" && this.normalizeDate(N) || N;
1309
+ return sE(E, t);
1310
1310
  }
1311
1311
  return this.databaseAdapter.buildBooleanLiteral(!1);
1312
1312
  case "notEquals":
@@ -1333,24 +1333,24 @@ class YR {
1333
1333
  return eT(E);
1334
1334
  case "inDateRange":
1335
1335
  if (S.length >= 2) {
1336
- const s = this.normalizeDate(S[0]), _ = this.normalizeDate(S[1]);
1337
- if (s && _)
1338
- return h(
1339
- v(E, s),
1340
- Q(E, _)
1336
+ const t = this.normalizeDate(S[0]), r = this.normalizeDate(S[1]);
1337
+ if (t && r)
1338
+ return f(
1339
+ v(E, t),
1340
+ Q(E, r)
1341
1341
  );
1342
1342
  }
1343
1343
  return null;
1344
1344
  case "beforeDate": {
1345
- const s = this.normalizeDate(N);
1346
- return s ? oE(E, s) : null;
1345
+ const t = this.normalizeDate(N);
1346
+ return t ? oE(E, t) : null;
1347
1347
  }
1348
1348
  case "afterDate": {
1349
- const s = this.normalizeDate(N);
1350
- return s ? aE(E, s) : null;
1349
+ const t = this.normalizeDate(N);
1350
+ return t ? aE(E, t) : null;
1351
1351
  }
1352
1352
  case "between":
1353
- return S.length >= 2 ? h(
1353
+ return S.length >= 2 ? f(
1354
1354
  v(E, S[0]),
1355
1355
  Q(E, S[1])
1356
1356
  ) : null;
@@ -1376,10 +1376,10 @@ class YR {
1376
1376
  case "isEmpty":
1377
1377
  return DE(
1378
1378
  eT(E),
1379
- tE(E, "")
1379
+ sE(E, "")
1380
1380
  );
1381
1381
  case "isNotEmpty":
1382
- return h(
1382
+ return f(
1383
1383
  ST(E),
1384
1384
  RT(E, "")
1385
1385
  );
@@ -1394,7 +1394,7 @@ class YR {
1394
1394
  if (!R) return null;
1395
1395
  if (Array.isArray(R) && R.length >= 2) {
1396
1396
  const A = this.normalizeDate(R[0]), e = this.normalizeDate(R[1]);
1397
- return !A || !e ? null : h(
1397
+ return !A || !e ? null : f(
1398
1398
  v(E, A),
1399
1399
  Q(E, e)
1400
1400
  );
@@ -1402,7 +1402,7 @@ class YR {
1402
1402
  if (typeof R == "string") {
1403
1403
  const A = this.parseRelativeDateRange(R);
1404
1404
  if (A)
1405
- return h(
1405
+ return f(
1406
1406
  v(E, A.start),
1407
1407
  Q(E, A.end)
1408
1408
  );
@@ -1411,7 +1411,7 @@ class YR {
1411
1411
  const S = new Date(e);
1412
1412
  S.setUTCHours(0, 0, 0, 0);
1413
1413
  const N = new Date(e);
1414
- return N.setUTCHours(23, 59, 59, 999), h(
1414
+ return N.setUTCHours(23, 59, 59, 999), f(
1415
1415
  v(E, S),
1416
1416
  Q(E, N)
1417
1417
  );
@@ -1423,74 +1423,74 @@ class YR {
1423
1423
  * Handles all 14 DATE_RANGE_OPTIONS from the client
1424
1424
  */
1425
1425
  parseRelativeDateRange(E) {
1426
- const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = R.getUTCFullYear(), S = R.getUTCMonth(), N = R.getUTCDate(), s = R.getUTCDay();
1426
+ const R = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = R.getUTCFullYear(), S = R.getUTCMonth(), N = R.getUTCDate(), t = R.getUTCDay();
1427
1427
  if (A === "today") {
1428
- const t = new Date(R);
1429
- t.setUTCHours(0, 0, 0, 0);
1428
+ const s = new Date(R);
1429
+ s.setUTCHours(0, 0, 0, 0);
1430
1430
  const L = new Date(R);
1431
- return L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
1431
+ return L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
1432
1432
  }
1433
1433
  if (A === "yesterday") {
1434
- const t = new Date(R);
1435
- t.setUTCDate(N - 1), t.setUTCHours(0, 0, 0, 0);
1434
+ const s = new Date(R);
1435
+ s.setUTCDate(N - 1), s.setUTCHours(0, 0, 0, 0);
1436
1436
  const L = new Date(R);
1437
- return L.setUTCDate(N - 1), L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
1437
+ return L.setUTCDate(N - 1), L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
1438
1438
  }
1439
1439
  if (A === "this week") {
1440
- const t = s === 0 ? -6 : 1 - s, L = new Date(R);
1441
- L.setUTCDate(N + t), L.setUTCHours(0, 0, 0, 0);
1440
+ const s = t === 0 ? -6 : 1 - t, L = new Date(R);
1441
+ L.setUTCDate(N + s), L.setUTCHours(0, 0, 0, 0);
1442
1442
  const a = new Date(L);
1443
1443
  return a.setUTCDate(L.getUTCDate() + 6), a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1444
1444
  }
1445
1445
  if (A === "this month") {
1446
- const t = new Date(Date.UTC(e, S, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S + 1, 0, 23, 59, 59, 999));
1447
- return { start: t, end: L };
1446
+ const s = new Date(Date.UTC(e, S, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S + 1, 0, 23, 59, 59, 999));
1447
+ return { start: s, end: L };
1448
1448
  }
1449
1449
  if (A === "this quarter") {
1450
- const t = Math.floor(S / 3), L = new Date(Date.UTC(e, t * 3, 1, 0, 0, 0, 0)), a = new Date(Date.UTC(e, t * 3 + 3, 0, 23, 59, 59, 999));
1450
+ const s = Math.floor(S / 3), L = new Date(Date.UTC(e, s * 3, 1, 0, 0, 0, 0)), a = new Date(Date.UTC(e, s * 3 + 3, 0, 23, 59, 59, 999));
1451
1451
  return { start: L, end: a };
1452
1452
  }
1453
1453
  if (A === "this year") {
1454
- const t = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
1455
- return { start: t, end: L };
1454
+ const s = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
1455
+ return { start: s, end: L };
1456
1456
  }
1457
- const _ = A.match(/^last\s+(\d+)\s+days?$/);
1458
- if (_) {
1459
- const t = parseInt(_[1], 10), L = new Date(R);
1460
- L.setUTCDate(N - t + 1), L.setUTCHours(0, 0, 0, 0);
1457
+ const r = A.match(/^last\s+(\d+)\s+days?$/);
1458
+ if (r) {
1459
+ const s = parseInt(r[1], 10), L = new Date(R);
1460
+ L.setUTCDate(N - s + 1), L.setUTCHours(0, 0, 0, 0);
1461
1461
  const a = new Date(R);
1462
1462
  return a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1463
1463
  }
1464
1464
  if (A === "last week") {
1465
- const t = s === 0 ? -13 : -6 - s, L = new Date(R);
1466
- L.setUTCDate(N + t), L.setUTCHours(0, 0, 0, 0);
1465
+ const s = t === 0 ? -13 : -6 - t, L = new Date(R);
1466
+ L.setUTCDate(N + s), L.setUTCHours(0, 0, 0, 0);
1467
1467
  const a = new Date(L);
1468
1468
  return a.setUTCDate(L.getUTCDate() + 6), a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1469
1469
  }
1470
1470
  if (A === "last month") {
1471
- const t = new Date(Date.UTC(e, S - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S, 0, 23, 59, 59, 999));
1472
- return { start: t, end: L };
1471
+ const s = new Date(Date.UTC(e, S - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S, 0, 23, 59, 59, 999));
1472
+ return { start: s, end: L };
1473
1473
  }
1474
1474
  if (A === "last quarter") {
1475
- const t = Math.floor(S / 3), L = t === 0 ? 3 : t - 1, a = t === 0 ? e - 1 : e, o = new Date(Date.UTC(a, L * 3, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(a, L * 3 + 3, 0, 23, 59, 59, 999));
1475
+ const s = Math.floor(S / 3), L = s === 0 ? 3 : s - 1, a = s === 0 ? e - 1 : e, o = new Date(Date.UTC(a, L * 3, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(a, L * 3 + 3, 0, 23, 59, 59, 999));
1476
1476
  return { start: o, end: n };
1477
1477
  }
1478
1478
  if (A === "last year") {
1479
- const t = 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));
1480
- return { start: t, end: L };
1479
+ const s = 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));
1480
+ return { start: s, end: L };
1481
1481
  }
1482
1482
  if (A === "last 12 months") {
1483
- const t = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), L = new Date(R);
1484
- return L.setUTCHours(23, 59, 59, 999), { start: t, end: L };
1483
+ const s = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), L = new Date(R);
1484
+ return L.setUTCHours(23, 59, 59, 999), { start: s, end: L };
1485
1485
  }
1486
1486
  const I = A.match(/^last\s+(\d+)\s+months?$/);
1487
1487
  if (I) {
1488
- const t = parseInt(I[1], 10), L = new Date(Date.UTC(e, S - t + 1, 1, 0, 0, 0, 0)), a = new Date(R);
1488
+ const s = parseInt(I[1], 10), L = new Date(Date.UTC(e, S - s + 1, 1, 0, 0, 0, 0)), a = new Date(R);
1489
1489
  return a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1490
1490
  }
1491
1491
  const O = A.match(/^last\s+(\d+)\s+years?$/);
1492
1492
  if (O) {
1493
- const t = parseInt(O[1], 10), L = new Date(Date.UTC(e - t, 0, 1, 0, 0, 0, 0)), a = new Date(R);
1493
+ const s = parseInt(O[1], 10), L = new Date(Date.UTC(e - s, 0, 1, 0, 0, 0, 0)), a = new Date(R);
1494
1494
  return a.setUTCHours(23, 59, 59, 999), { start: L, end: a };
1495
1495
  }
1496
1496
  return null;
@@ -1523,11 +1523,11 @@ class YR {
1523
1523
  const S = [];
1524
1524
  if (!(R.measures && R.measures.length > 0))
1525
1525
  return [];
1526
- const s = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1526
+ const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1527
1527
  if (R.dimensions)
1528
- for (const _ of R.dimensions) {
1529
- const [I, O] = _.split("."), t = s.get(I);
1530
- if (t && t.dimensions && t.dimensions[O])
1528
+ for (const r of R.dimensions) {
1529
+ const [I, O] = r.split("."), s = t.get(I);
1530
+ if (s && s.dimensions && s.dimensions[O])
1531
1531
  if (e?.preAggregationCTEs?.some((a) => a.cube.name === I)) {
1532
1532
  const a = e.preAggregationCTEs.find((n) => n.cube.name === I), o = a.joinKeys.find((n) => n.targetColumn === O);
1533
1533
  if (o && o.sourceColumnObj)
@@ -1537,20 +1537,20 @@ class YR {
1537
1537
  S.push(n);
1538
1538
  }
1539
1539
  } else {
1540
- const a = t.dimensions[O], o = $(a.sql, A);
1540
+ const a = s.dimensions[O], o = $(a.sql, A);
1541
1541
  S.push(o);
1542
1542
  }
1543
1543
  }
1544
1544
  if (R.timeDimensions)
1545
- for (const _ of R.timeDimensions) {
1546
- const [I, O] = _.dimension.split("."), t = s.get(I);
1547
- if (t && t.dimensions && t.dimensions[O])
1545
+ for (const r of R.timeDimensions) {
1546
+ const [I, O] = r.dimension.split("."), s = t.get(I);
1547
+ if (s && s.dimensions && s.dimensions[O])
1548
1548
  if (e?.preAggregationCTEs?.some((a) => a.cube.name === I)) {
1549
1549
  const a = e.preAggregationCTEs.find((n) => n.cube.name === I), o = a.joinKeys.find((n) => n.targetColumn === O);
1550
1550
  if (o && o.sourceColumnObj) {
1551
1551
  const n = this.buildTimeDimensionExpression(
1552
1552
  o.sourceColumnObj,
1553
- _.granularity,
1553
+ r.granularity,
1554
1554
  A
1555
1555
  );
1556
1556
  S.push(n);
@@ -1559,9 +1559,9 @@ class YR {
1559
1559
  S.push(n);
1560
1560
  }
1561
1561
  } else {
1562
- const a = t.dimensions[O], o = this.buildTimeDimensionExpression(
1562
+ const a = s.dimensions[O], o = this.buildTimeDimensionExpression(
1563
1563
  a.sql,
1564
- _.granularity,
1564
+ r.granularity,
1565
1565
  A
1566
1566
  );
1567
1567
  S.push(o);
@@ -1582,15 +1582,15 @@ class YR {
1582
1582
  for (const [S, N] of Object.entries(E.order)) {
1583
1583
  if (!e.includes(S))
1584
1584
  throw new Error(`Cannot order by '${S}': field is not selected in the query`);
1585
- const s = N === "desc" ? oR(C.identifier(S)) : IT(C.identifier(S));
1586
- A.push(s);
1585
+ const t = N === "desc" ? oR(C.identifier(S)) : IT(C.identifier(S));
1586
+ A.push(t);
1587
1587
  }
1588
1588
  if (E.timeDimensions && E.timeDimensions.length > 0) {
1589
1589
  const S = new Set(Object.keys(E.order || {})), N = [...E.timeDimensions].sort(
1590
- (s, _) => s.dimension.localeCompare(_.dimension)
1590
+ (t, r) => t.dimension.localeCompare(r.dimension)
1591
1591
  );
1592
- for (const s of N)
1593
- S.has(s.dimension) || A.push(IT(C.identifier(s.dimension)));
1592
+ for (const t of N)
1593
+ S.has(t.dimension) || A.push(IT(C.identifier(t.dimension)));
1594
1594
  }
1595
1595
  return A;
1596
1596
  }
@@ -1602,9 +1602,9 @@ class YR {
1602
1602
  const A = [], e = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1603
1603
  if (R.measures && A.push(...R.measures), R.dimensions)
1604
1604
  for (const S of R.dimensions) {
1605
- const [N, s] = S.split("."), _ = e.get(N);
1606
- if (_) {
1607
- const I = _.dimensions[s];
1605
+ const [N, t] = S.split("."), r = e.get(N);
1606
+ if (r) {
1607
+ const I = r.dimensions[t];
1608
1608
  I && I.type === "number" && A.push(S);
1609
1609
  }
1610
1610
  }
@@ -1705,12 +1705,12 @@ class pR {
1705
1705
  const e = this.analyzeCubeUsage(R), S = Array.from(e);
1706
1706
  if (S.length === 0)
1707
1707
  throw new Error("No cubes found in query");
1708
- const N = this.choosePrimaryCube(S, R, E), s = E.get(N);
1709
- if (!s)
1708
+ const N = this.choosePrimaryCube(S, R, E), t = E.get(N);
1709
+ if (!t)
1710
1710
  throw new Error(`Primary cube '${N}' not found`);
1711
1711
  if (S.length === 1)
1712
1712
  return {
1713
- primaryCube: s,
1713
+ primaryCube: t,
1714
1714
  joinCubes: [],
1715
1715
  // Empty for single cube
1716
1716
  selections: {},
@@ -1720,10 +1720,10 @@ class pR {
1720
1720
  groupByFields: []
1721
1721
  // Will be built by QueryBuilder
1722
1722
  };
1723
- const _ = this.buildJoinPlan(E, s, S), I = this.planPreAggregationCTEs(E, s, _, R);
1723
+ const r = this.buildJoinPlan(E, t, S), I = this.planPreAggregationCTEs(E, t, r, R);
1724
1724
  return {
1725
- primaryCube: s,
1726
- joinCubes: _,
1725
+ primaryCube: t,
1726
+ joinCubes: r,
1727
1727
  selections: {},
1728
1728
  // Will be built by QueryBuilder
1729
1729
  whereConditions: [],
@@ -1743,22 +1743,22 @@ class pR {
1743
1743
  for (const N of e)
1744
1744
  S.set(N, (S.get(N) || 0) + 1);
1745
1745
  if (S.size > 0) {
1746
- const N = Math.max(...S.values()), s = [...S.entries()].filter(([, _]) => _ === N).map(([_]) => _).sort();
1747
- for (const _ of s)
1748
- if (this.canReachAllCubes(_, E, A))
1749
- return _;
1746
+ const N = Math.max(...S.values()), t = [...S.entries()].filter(([, r]) => r === N).map(([r]) => r).sort();
1747
+ for (const r of t)
1748
+ if (this.canReachAllCubes(r, E, A))
1749
+ return r;
1750
1750
  }
1751
1751
  }
1752
1752
  if (A) {
1753
1753
  const e = /* @__PURE__ */ new Map();
1754
1754
  for (const S of E)
1755
1755
  if (this.canReachAllCubes(S, E, A)) {
1756
- const N = A.get(S), s = N?.joins ? Object.keys(N.joins).length : 0;
1757
- e.set(S, s);
1756
+ const N = A.get(S), t = N?.joins ? Object.keys(N.joins).length : 0;
1757
+ e.set(S, t);
1758
1758
  }
1759
1759
  if (e.size > 0) {
1760
1760
  const S = Math.max(...e.values());
1761
- return [...e.entries()].filter(([, s]) => s === S).map(([s]) => s).sort()[0];
1761
+ return [...e.entries()].filter(([, t]) => t === S).map(([t]) => t).sort()[0];
1762
1762
  }
1763
1763
  }
1764
1764
  return [...E].sort()[0];
@@ -1780,18 +1780,18 @@ class pR {
1780
1780
  * Supports both direct joins and transitive joins through intermediate cubes
1781
1781
  */
1782
1782
  buildJoinPlan(E, R, A) {
1783
- const e = [], S = /* @__PURE__ */ new Set([R.name]), N = A.filter((s) => s !== R.name);
1784
- for (const s of N) {
1785
- if (S.has(s))
1783
+ const e = [], S = /* @__PURE__ */ new Set([R.name]), N = A.filter((t) => t !== R.name);
1784
+ for (const t of N) {
1785
+ if (S.has(t))
1786
1786
  continue;
1787
- const _ = this.findJoinPath(E, R.name, s, S);
1788
- if (!_ || _.length === 0)
1789
- throw new Error(`No join path found from '${R.name}' to '${s}'`);
1790
- for (const { toCube: I, joinDef: O } of _) {
1787
+ const r = this.findJoinPath(E, R.name, t, S);
1788
+ if (!r || r.length === 0)
1789
+ throw new Error(`No join path found from '${R.name}' to '${t}'`);
1790
+ for (const { toCube: I, joinDef: O } of r) {
1791
1791
  if (S.has(I))
1792
1792
  continue;
1793
- const t = E.get(I);
1794
- if (!t)
1793
+ const s = E.get(I);
1794
+ if (!s)
1795
1795
  throw new Error(`Cube '${I}' not found`);
1796
1796
  const L = this.buildJoinCondition(
1797
1797
  O,
@@ -1801,7 +1801,7 @@ class pR {
1801
1801
  // No target alias needed - use the actual column
1802
1802
  ), a = FR(O.relationship, O.sqlJoinType);
1803
1803
  e.push({
1804
- cube: t,
1804
+ cube: s,
1805
1805
  alias: `${I.toLowerCase()}_cube`,
1806
1806
  joinType: a,
1807
1807
  joinCondition: L
@@ -1816,10 +1816,10 @@ class pR {
1816
1816
  buildJoinCondition(E, R, A) {
1817
1817
  const e = [];
1818
1818
  for (const S of E.on) {
1819
- const N = R ? C`${C.identifier(R)}.${C.identifier(S.source.name)}` : S.source, s = A ? C`${C.identifier(A)}.${C.identifier(S.target.name)}` : S.target, _ = S.as || tE;
1820
- e.push(_(N, s));
1819
+ const N = R ? C`${C.identifier(R)}.${C.identifier(S.source.name)}` : S.source, t = A ? C`${C.identifier(A)}.${C.identifier(S.target.name)}` : S.target, r = S.as || sE;
1820
+ e.push(r(N, t));
1821
1821
  }
1822
- return h(...e);
1822
+ return f(...e);
1823
1823
  }
1824
1824
  /**
1825
1825
  * Find join path from source cube to target cube
@@ -1832,14 +1832,14 @@ class pR {
1832
1832
  { cube: R, path: [] }
1833
1833
  ], N = /* @__PURE__ */ new Set([R, ...e]);
1834
1834
  for (; S.length > 0; ) {
1835
- const { cube: s, path: _ } = S.shift(), I = E.get(s);
1835
+ const { cube: t, path: r } = S.shift(), I = E.get(t);
1836
1836
  if (I?.joins)
1837
1837
  for (const [, O] of Object.entries(I.joins)) {
1838
- const L = sT(O.targetCube).name;
1838
+ const L = tT(O.targetCube).name;
1839
1839
  if (N.has(L))
1840
1840
  continue;
1841
- const a = [..._, {
1842
- fromCube: s,
1841
+ const a = [...r, {
1842
+ fromCube: t,
1843
1843
  toCube: L,
1844
1844
  joinDef: O
1845
1845
  }];
@@ -1858,15 +1858,15 @@ class pR {
1858
1858
  if (!e.measures || e.measures.length === 0)
1859
1859
  return S;
1860
1860
  for (const N of A) {
1861
- const s = this.findHasManyJoinDef(R, N.cube.name);
1862
- if (!s)
1861
+ const t = this.findHasManyJoinDef(R, N.cube.name);
1862
+ if (!t)
1863
1863
  continue;
1864
- const _ = e.measures ? e.measures.filter(
1864
+ const r = e.measures ? e.measures.filter(
1865
1865
  (L) => L.startsWith(N.cube.name + ".")
1866
- ) : [], I = this.extractMeasuresFromFilters(e, N.cube.name), O = [.../* @__PURE__ */ new Set([..._, ...I])];
1866
+ ) : [], I = this.extractMeasuresFromFilters(e, N.cube.name), O = [.../* @__PURE__ */ new Set([...r, ...I])];
1867
1867
  if (O.length === 0)
1868
1868
  continue;
1869
- const t = s.on.map((L) => ({
1869
+ const s = t.on.map((L) => ({
1870
1870
  sourceColumn: L.source.name,
1871
1871
  targetColumn: L.target.name,
1872
1872
  sourceColumnObj: L.source,
@@ -1876,7 +1876,7 @@ class pR {
1876
1876
  cube: N.cube,
1877
1877
  alias: N.alias,
1878
1878
  cteAlias: `${N.cube.name.toLowerCase()}_agg`,
1879
- joinKeys: t,
1879
+ joinKeys: s,
1880
1880
  measures: O
1881
1881
  });
1882
1882
  }
@@ -1889,7 +1889,7 @@ class pR {
1889
1889
  if (!E.joins)
1890
1890
  return null;
1891
1891
  for (const [, A] of Object.entries(E.joins))
1892
- if (sT(A.targetCube).name === R && A.relationship === "hasMany")
1892
+ if (tT(A.targetCube).name === R && A.relationship === "hasMany")
1893
1893
  return A;
1894
1894
  return null;
1895
1895
  }
@@ -1908,14 +1908,14 @@ class UE {
1908
1908
  */
1909
1909
  async execute(E, R, A) {
1910
1910
  try {
1911
- const e = sR(E, R);
1911
+ const e = tR(E, R);
1912
1912
  if (!e.isValid)
1913
1913
  throw new Error(`Query validation failed: ${e.errors.join(", ")}`);
1914
1914
  const S = {
1915
1915
  db: this.dbExecutor.db,
1916
1916
  schema: this.dbExecutor.schema,
1917
1917
  securityContext: A
1918
- }, N = this.queryPlanner.createQueryPlan(E, R, S), s = this.buildUnifiedQuery(N, R, S), _ = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(s, _), O = Array.isArray(I) ? I.map((L) => {
1918
+ }, N = this.queryPlanner.createQueryPlan(E, R, S), t = this.buildUnifiedQuery(N, R, S), r = this.queryBuilder.collectNumericFields(E, R), I = await this.dbExecutor.execute(t, r), O = Array.isArray(I) ? I.map((L) => {
1919
1919
  const a = { ...L };
1920
1920
  if (R.timeDimensions) {
1921
1921
  for (const o of R.timeDimensions)
@@ -1929,10 +1929,10 @@ class UE {
1929
1929
  }
1930
1930
  }
1931
1931
  return a;
1932
- }) : [I], t = this.generateAnnotations(N, R);
1932
+ }) : [I], s = this.generateAnnotations(N, R);
1933
1933
  return {
1934
1934
  data: O,
1935
- annotation: t
1935
+ annotation: s
1936
1936
  };
1937
1937
  } catch (e) {
1938
1938
  throw new Error(`Query execution failed: ${e instanceof Error ? e.message : "Unknown error"}`);
@@ -1949,68 +1949,68 @@ class UE {
1949
1949
  * Build pre-aggregation CTE for hasMany relationships
1950
1950
  */
1951
1951
  buildPreAggregationCTE(E, R, A, e) {
1952
- const S = E.cube, N = S.sql(A), s = {};
1952
+ const S = E.cube, N = S.sql(A), t = {};
1953
1953
  for (const n of E.joinKeys)
1954
1954
  if (n.targetColumnObj) {
1955
- s[n.targetColumn] = n.targetColumnObj;
1955
+ t[n.targetColumn] = n.targetColumnObj;
1956
1956
  for (const [U, P] of Object.entries(S.dimensions || {}))
1957
- P.sql === n.targetColumnObj && U !== n.targetColumn && (s[U] = C`${n.targetColumnObj}`.as(U));
1957
+ P.sql === n.targetColumnObj && U !== n.targetColumn && (t[U] = C`${n.targetColumnObj}`.as(U));
1958
1958
  }
1959
1959
  for (const n of E.measures) {
1960
1960
  const [, U] = n.split(".");
1961
1961
  if (S.measures && S.measures[U]) {
1962
1962
  const P = S.measures[U], l = this.queryBuilder.buildMeasureExpression(P, A);
1963
- s[U] = C`${l}`.as(U);
1963
+ t[U] = C`${l}`.as(U);
1964
1964
  }
1965
1965
  }
1966
- const _ = S.name;
1966
+ const r = S.name;
1967
1967
  if (R.dimensions)
1968
1968
  for (const n of R.dimensions) {
1969
1969
  const [U, P] = n.split(".");
1970
- if (U === _ && S.dimensions && S.dimensions[P]) {
1970
+ if (U === r && S.dimensions && S.dimensions[P]) {
1971
1971
  const l = S.dimensions[P], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A);
1972
- s[P] = C`${c}`.as(P);
1972
+ t[P] = C`${c}`.as(P);
1973
1973
  }
1974
1974
  }
1975
1975
  if (R.timeDimensions)
1976
1976
  for (const n of R.timeDimensions) {
1977
1977
  const [U, P] = n.dimension.split(".");
1978
- if (U === _ && S.dimensions && S.dimensions[P]) {
1978
+ if (U === r && S.dimensions && S.dimensions[P]) {
1979
1979
  const l = S.dimensions[P], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, n.granularity, A);
1980
- s[P] = C`${c}`.as(P);
1980
+ t[P] = C`${c}`.as(P);
1981
1981
  }
1982
1982
  }
1983
- if (Object.keys(s).length === 0)
1983
+ if (Object.keys(t).length === 0)
1984
1984
  return null;
1985
- let I = A.db.select(s).from(N.from);
1985
+ let I = A.db.select(t).from(N.from);
1986
1986
  const O = e ? {
1987
1987
  ...e,
1988
1988
  preAggregationCTEs: e.preAggregationCTEs?.filter((n) => n.cube.name !== S.name)
1989
- } : void 0, t = this.queryBuilder.buildWhereConditions(S, R, A, O), L = [];
1989
+ } : void 0, s = this.queryBuilder.buildWhereConditions(S, R, A, O), L = [];
1990
1990
  if (R.timeDimensions)
1991
1991
  for (const n of R.timeDimensions) {
1992
1992
  const [U, P] = n.dimension.split(".");
1993
- if (U === _ && S.dimensions && S.dimensions[P] && n.dateRange) {
1994
- const l = S.dimensions[P], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(c, n.dateRange);
1995
- B && L.push(B);
1993
+ if (U === r && S.dimensions && S.dimensions[P] && n.dateRange) {
1994
+ const l = S.dimensions[P], c = this.queryBuilder.buildMeasureExpression({ sql: l.sql, type: "number" }, A), m = this.queryBuilder.buildDateRangeCondition(c, n.dateRange);
1995
+ m && L.push(m);
1996
1996
  }
1997
1997
  }
1998
1998
  if (R.filters) {
1999
1999
  for (const n of R.filters)
2000
2000
  if (!("and" in n) && !("or" in n) && "member" in n && "operator" in n) {
2001
2001
  const U = n, [P, l] = U.member.split(".");
2002
- if (P === _ && S.dimensions && S.dimensions[l]) {
2002
+ if (P === r && S.dimensions && S.dimensions[l]) {
2003
2003
  const c = S.dimensions[l];
2004
2004
  if (U.operator === "inDateRange") {
2005
- const B = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), p = this.queryBuilder.buildDateRangeCondition(B, U.values);
2005
+ const m = this.queryBuilder.buildMeasureExpression({ sql: c.sql, type: "number" }, A), p = this.queryBuilder.buildDateRangeCondition(m, U.values);
2006
2006
  p && L.push(p);
2007
2007
  }
2008
2008
  }
2009
2009
  }
2010
2010
  }
2011
2011
  const a = [];
2012
- if (N.where && a.push(N.where), a.push(...t, ...L), a.length > 0) {
2013
- const n = a.length === 1 ? a[0] : h(...a);
2012
+ if (N.where && a.push(N.where), a.push(...s, ...L), a.length > 0) {
2013
+ const n = a.length === 1 ? a[0] : f(...a);
2014
2014
  I = I.where(n);
2015
2015
  }
2016
2016
  const o = [];
@@ -2019,7 +2019,7 @@ class UE {
2019
2019
  if (R.dimensions)
2020
2020
  for (const n of R.dimensions) {
2021
2021
  const [U, P] = n.split(".");
2022
- if (U === _ && S.dimensions && S.dimensions[P]) {
2022
+ if (U === r && S.dimensions && S.dimensions[P]) {
2023
2023
  const l = S.dimensions[P], c = $(l.sql, A);
2024
2024
  o.push(c);
2025
2025
  }
@@ -2027,7 +2027,7 @@ class UE {
2027
2027
  if (R.timeDimensions)
2028
2028
  for (const n of R.timeDimensions) {
2029
2029
  const [U, P] = n.dimension.split(".");
2030
- if (U === _ && S.dimensions && S.dimensions[P]) {
2030
+ if (U === r && S.dimensions && S.dimensions[P]) {
2031
2031
  const l = S.dimensions[P], c = this.queryBuilder.buildTimeDimensionExpression(l.sql, n.granularity, A);
2032
2032
  o.push(c);
2033
2033
  }
@@ -2044,10 +2044,10 @@ class UE {
2044
2044
  throw new Error(`CTE info not found for cube ${E.cube.name}`);
2045
2045
  const S = [];
2046
2046
  for (const N of e.joinKeys) {
2047
- const s = N.sourceColumnObj || C.identifier(N.sourceColumn), _ = C`${C.identifier(R)}.${C.identifier(N.targetColumn)}`;
2048
- S.push(tE(s, _));
2047
+ const t = N.sourceColumnObj || C.identifier(N.sourceColumn), r = C`${C.identifier(R)}.${C.identifier(N.targetColumn)}`;
2048
+ S.push(sE(t, r));
2049
2049
  }
2050
- return S.length === 1 ? S[0] : h(...S);
2050
+ return S.length === 1 ? S[0] : f(...S);
2051
2051
  }
2052
2052
  /**
2053
2053
  * Build unified query that works for both single and multi-cube queries
@@ -2059,7 +2059,7 @@ class UE {
2059
2059
  const U = this.buildPreAggregationCTE(n, R, A, E);
2060
2060
  U && (e.push(U), S.set(n.cube.name, n.cteAlias));
2061
2061
  }
2062
- const N = E.primaryCube.sql(A), _ = { ...this.queryBuilder.buildSelections(
2062
+ const N = E.primaryCube.sql(A), r = { ...this.queryBuilder.buildSelections(
2063
2063
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2064
2064
  // Single cube
2065
2065
  R,
@@ -2069,12 +2069,12 @@ class UE {
2069
2069
  for (const n of E.preAggregationCTEs) {
2070
2070
  const U = n.cube.name;
2071
2071
  for (const P of n.measures)
2072
- if (_[P]) {
2072
+ if (r[P]) {
2073
2073
  const [, l] = P.split("."), c = this.getCubesFromPlan(E).get(U);
2074
2074
  if (c && c.measures && c.measures[l]) {
2075
- const B = c.measures[l], p = C`${C.identifier(n.cteAlias)}.${C.identifier(l)}`;
2075
+ const m = c.measures[l], p = C`${C.identifier(n.cteAlias)}.${C.identifier(l)}`;
2076
2076
  let V;
2077
- switch (B.type) {
2077
+ switch (m.type) {
2078
2078
  case "count":
2079
2079
  case "countDistinct":
2080
2080
  case "sum":
@@ -2095,26 +2095,26 @@ class UE {
2095
2095
  default:
2096
2096
  V = g(p);
2097
2097
  }
2098
- _[P] = C`${V}`.as(P);
2098
+ r[P] = C`${V}`.as(P);
2099
2099
  }
2100
2100
  }
2101
- for (const P in _) {
2101
+ for (const P in r) {
2102
2102
  const [l, c] = P.split(".");
2103
2103
  if (l === U) {
2104
- const B = this.getCubesFromPlan(E).get(U), p = B && B.dimensions?.[c], V = P.startsWith(U + ".");
2104
+ const m = this.getCubesFromPlan(E).get(U), p = m && m.dimensions?.[c], V = P.startsWith(U + ".");
2105
2105
  if (p || V) {
2106
2106
  let x = n.joinKeys.find((LE) => LE.targetColumn === c);
2107
- if (!x && B?.dimensions?.[c]) {
2108
- const LE = B.dimensions[c].sql;
2107
+ if (!x && m?.dimensions?.[c]) {
2108
+ const LE = m.dimensions[c].sql;
2109
2109
  x = n.joinKeys.find((LR) => LR.targetColumnObj === LE);
2110
2110
  }
2111
- x ? _[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P) : V && B?.dimensions?.[c] && (_[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P));
2111
+ x ? r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P) : V && m?.dimensions?.[c] && (r[P] = C`${C.identifier(n.cteAlias)}.${C.identifier(c)}`.as(P));
2112
2112
  }
2113
2113
  }
2114
2114
  }
2115
2115
  }
2116
- let I = A.db.select(_).from(N.from);
2117
- if (e.length > 0 && (I = A.db.with(...e).select(_).from(N.from)), N.joins)
2116
+ let I = A.db.select(r).from(N.from);
2117
+ if (e.length > 0 && (I = A.db.with(...e).select(r).from(N.from)), N.joins)
2118
2118
  for (const n of N.joins)
2119
2119
  switch (n.type || "left") {
2120
2120
  case "left":
@@ -2161,7 +2161,7 @@ class UE {
2161
2161
  const P = n.cube.sql(A);
2162
2162
  P.where && O.push(P.where);
2163
2163
  }
2164
- const t = this.queryBuilder.buildWhereConditions(
2164
+ const s = this.queryBuilder.buildWhereConditions(
2165
2165
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2166
2166
  // Single cube
2167
2167
  R,
@@ -2169,8 +2169,8 @@ class UE {
2169
2169
  E
2170
2170
  // Pass the queryPlan to handle CTE scenarios
2171
2171
  );
2172
- if (t.length > 0 && O.push(...t), O.length > 0) {
2173
- const n = O.length === 1 ? O[0] : h(...O);
2172
+ if (s.length > 0 && O.push(...s), O.length > 0) {
2173
+ const n = O.length === 1 ? O[0] : f(...O);
2174
2174
  I = I.where(n);
2175
2175
  }
2176
2176
  const L = this.queryBuilder.buildGroupByFields(
@@ -2191,7 +2191,7 @@ class UE {
2191
2191
  // Pass the queryPlan to handle CTE scenarios
2192
2192
  );
2193
2193
  if (a.length > 0) {
2194
- const n = a.length === 1 ? a[0] : h(...a);
2194
+ const n = a.length === 1 ? a[0] : f(...a);
2195
2195
  I = I.having(n);
2196
2196
  }
2197
2197
  const o = this.queryBuilder.buildOrderBy(R);
@@ -2228,10 +2228,10 @@ class UE {
2228
2228
  db: this.dbExecutor.db,
2229
2229
  schema: this.dbExecutor.schema,
2230
2230
  securityContext: A
2231
- }, S = this.queryPlanner.createQueryPlan(E, R, e), s = this.buildUnifiedQuery(S, R, e).toSQL();
2231
+ }, S = this.queryPlanner.createQueryPlan(E, R, e), t = this.buildUnifiedQuery(S, R, e).toSQL();
2232
2232
  return {
2233
- sql: s.sql,
2234
- params: s.params
2233
+ sql: t.sql,
2234
+ params: t.params
2235
2235
  };
2236
2236
  }
2237
2237
  /**
@@ -2239,40 +2239,40 @@ class UE {
2239
2239
  */
2240
2240
  generateAnnotations(E, R) {
2241
2241
  const A = {}, e = {}, S = {}, N = [E.primaryCube];
2242
- if (E.joinCubes && E.joinCubes.length > 0 && N.push(...E.joinCubes.map((s) => s.cube)), R.measures)
2243
- for (const s of R.measures) {
2244
- const [_, I] = s.split("."), O = N.find((t) => t.name === _);
2242
+ if (E.joinCubes && E.joinCubes.length > 0 && N.push(...E.joinCubes.map((t) => t.cube)), R.measures)
2243
+ for (const t of R.measures) {
2244
+ const [r, I] = t.split("."), O = N.find((s) => s.name === r);
2245
2245
  if (O && O.measures[I]) {
2246
- const t = O.measures[I];
2247
- A[s] = {
2248
- title: t.title || I,
2249
- shortTitle: t.title || I,
2250
- type: t.type
2246
+ const s = O.measures[I];
2247
+ A[t] = {
2248
+ title: s.title || I,
2249
+ shortTitle: s.title || I,
2250
+ type: s.type
2251
2251
  };
2252
2252
  }
2253
2253
  }
2254
2254
  if (R.dimensions)
2255
- for (const s of R.dimensions) {
2256
- const [_, I] = s.split("."), O = N.find((t) => t.name === _);
2255
+ for (const t of R.dimensions) {
2256
+ const [r, I] = t.split("."), O = N.find((s) => s.name === r);
2257
2257
  if (O && O.dimensions[I]) {
2258
- const t = O.dimensions[I];
2259
- e[s] = {
2260
- title: t.title || I,
2261
- shortTitle: t.title || I,
2262
- type: t.type
2258
+ const s = O.dimensions[I];
2259
+ e[t] = {
2260
+ title: s.title || I,
2261
+ shortTitle: s.title || I,
2262
+ type: s.type
2263
2263
  };
2264
2264
  }
2265
2265
  }
2266
2266
  if (R.timeDimensions)
2267
- for (const s of R.timeDimensions) {
2268
- const [_, I] = s.dimension.split("."), O = N.find((t) => t.name === _);
2267
+ for (const t of R.timeDimensions) {
2268
+ const [r, I] = t.dimension.split("."), O = N.find((s) => s.name === r);
2269
2269
  if (O && O.dimensions && O.dimensions[I]) {
2270
- const t = O.dimensions[I];
2271
- S[s.dimension] = {
2272
- title: t.title || I,
2273
- shortTitle: t.title || I,
2274
- type: t.type,
2275
- granularity: s.granularity
2270
+ const s = O.dimensions[I];
2271
+ S[t.dimension] = {
2272
+ title: s.title || I,
2273
+ shortTitle: s.title || I,
2274
+ type: s.type,
2275
+ granularity: t.granularity
2276
2276
  };
2277
2277
  }
2278
2278
  }
@@ -2284,7 +2284,7 @@ class UE {
2284
2284
  };
2285
2285
  }
2286
2286
  }
2287
- const r = (T) => T.flatMap(dR), dR = (T) => RE(hR(T)).map(fR), fR = (T) => T.replace(/ +/g, " ").trim(), hR = (T) => ({
2287
+ const _ = (T) => T.flatMap(dR), dR = (T) => RE(fR(T)).map(hR), hR = (T) => T.replace(/ +/g, " ").trim(), fR = (T) => ({
2288
2288
  type: "mandatory_block",
2289
2289
  items: jE(T, 0)[0]
2290
2290
  }), jE = (T, E, R) => {
@@ -2351,21 +2351,21 @@ const r = (T) => T.flatMap(dR), dR = (T) => RE(hR(T)).map(fR), fR = (T) => T.rep
2351
2351
  };
2352
2352
  var D;
2353
2353
  (function(T) {
2354
- T.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", T.IDENTIFIER = "IDENTIFIER", T.STRING = "STRING", T.VARIABLE = "VARIABLE", T.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", T.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", T.RESERVED_KEYWORD = "RESERVED_KEYWORD", T.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", T.RESERVED_PHRASE = "RESERVED_PHRASE", T.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", T.RESERVED_CLAUSE = "RESERVED_CLAUSE", T.RESERVED_SELECT = "RESERVED_SELECT", T.RESERVED_JOIN = "RESERVED_JOIN", T.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", T.ARRAY_KEYWORD = "ARRAY_KEYWORD", T.CASE = "CASE", T.END = "END", T.WHEN = "WHEN", T.ELSE = "ELSE", T.THEN = "THEN", T.LIMIT = "LIMIT", T.BETWEEN = "BETWEEN", T.AND = "AND", T.OR = "OR", T.XOR = "XOR", T.OPERATOR = "OPERATOR", T.COMMA = "COMMA", T.ASTERISK = "ASTERISK", T.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", T.OPEN_PAREN = "OPEN_PAREN", T.CLOSE_PAREN = "CLOSE_PAREN", T.LINE_COMMENT = "LINE_COMMENT", T.BLOCK_COMMENT = "BLOCK_COMMENT", T.DISABLE_COMMENT = "DISABLE_COMMENT", T.NUMBER = "NUMBER", T.NAMED_PARAMETER = "NAMED_PARAMETER", T.QUOTED_PARAMETER = "QUOTED_PARAMETER", T.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", T.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", T.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", T.DELIMITER = "DELIMITER", T.EOF = "EOF";
2354
+ T.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", T.IDENTIFIER = "IDENTIFIER", T.STRING = "STRING", T.VARIABLE = "VARIABLE", T.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", T.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", T.RESERVED_KEYWORD = "RESERVED_KEYWORD", T.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", T.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", T.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", T.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", T.RESERVED_CLAUSE = "RESERVED_CLAUSE", T.RESERVED_SELECT = "RESERVED_SELECT", T.RESERVED_JOIN = "RESERVED_JOIN", T.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", T.ARRAY_KEYWORD = "ARRAY_KEYWORD", T.CASE = "CASE", T.END = "END", T.WHEN = "WHEN", T.ELSE = "ELSE", T.THEN = "THEN", T.LIMIT = "LIMIT", T.BETWEEN = "BETWEEN", T.AND = "AND", T.OR = "OR", T.XOR = "XOR", T.OPERATOR = "OPERATOR", T.COMMA = "COMMA", T.ASTERISK = "ASTERISK", T.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", T.OPEN_PAREN = "OPEN_PAREN", T.CLOSE_PAREN = "CLOSE_PAREN", T.LINE_COMMENT = "LINE_COMMENT", T.BLOCK_COMMENT = "BLOCK_COMMENT", T.DISABLE_COMMENT = "DISABLE_COMMENT", T.NUMBER = "NUMBER", T.NAMED_PARAMETER = "NAMED_PARAMETER", T.QUOTED_PARAMETER = "QUOTED_PARAMETER", T.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", T.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", T.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", T.DELIMITER = "DELIMITER", T.EOF = "EOF";
2355
2355
  })(D = D || (D = {}));
2356
2356
  const qT = (T) => ({
2357
2357
  type: D.EOF,
2358
2358
  raw: "«EOF»",
2359
2359
  text: "«EOF»",
2360
2360
  start: T
2361
- }), j = qT(1 / 0), Z = (T) => (E) => E.type === T.type && E.text === T.text, J = {
2361
+ }), j = qT(1 / 0), Z = (T) => (E) => E.type === T.type && E.text === T.text, w = {
2362
2362
  ARRAY: Z({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
2363
2363
  BY: Z({ text: "BY", type: D.RESERVED_KEYWORD }),
2364
2364
  SET: Z({ text: "SET", type: D.RESERVED_CLAUSE }),
2365
2365
  STRUCT: Z({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
2366
2366
  WINDOW: Z({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
2367
2367
  VALUES: Z({ text: "VALUES", type: D.RESERVED_CLAUSE })
2368
- }, jT = (T) => T === D.RESERVED_DATA_TYPE || T === D.RESERVED_KEYWORD || T === D.RESERVED_FUNCTION_NAME || T === D.RESERVED_PHRASE || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.ARRAY_KEYWORD || T === D.CASE || T === D.END || T === D.WHEN || T === D.ELSE || T === D.THEN || T === D.LIMIT || T === D.BETWEEN || T === D.AND || T === D.OR || T === D.XOR, KR = (T) => T === D.AND || T === D.OR || T === D.XOR, $R = [
2368
+ }, jT = (T) => T === D.RESERVED_DATA_TYPE || T === D.RESERVED_KEYWORD || T === D.RESERVED_FUNCTION_NAME || T === D.RESERVED_KEYWORD_PHRASE || T === D.RESERVED_DATA_TYPE_PHRASE || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.ARRAY_KEYWORD || T === D.CASE || T === D.END || T === D.WHEN || T === D.ELSE || T === D.THEN || T === D.LIMIT || T === D.BETWEEN || T === D.AND || T === D.OR || T === D.XOR, KR = (T) => T === D.AND || T === D.OR || T === D.XOR, $R = [
2369
2369
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
2370
2370
  "KEYS.NEW_KEYSET",
2371
2371
  "KEYS.ADD_KEY_FROM_RAW_BYTES",
@@ -3017,7 +3017,7 @@ const qT = (T) => ({
3017
3017
  "CASCADE",
3018
3018
  "RESTRICT",
3019
3019
  "DETERMINISTIC"
3020
- ], JR = [
3020
+ ], wR = [
3021
3021
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
3022
3022
  "ARRAY",
3023
3023
  "BOOL",
@@ -3042,7 +3042,7 @@ const qT = (T) => ({
3042
3042
  "STRUCT",
3043
3043
  "TIME",
3044
3044
  "TIMEZONE"
3045
- ], wR = r(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), xR = r([
3045
+ ], JR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), xR = _([
3046
3046
  // Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
3047
3047
  "WITH [RECURSIVE]",
3048
3048
  "FROM",
@@ -3071,9 +3071,9 @@ const qT = (T) => ({
3071
3071
  "WITH CONNECTION",
3072
3072
  "WITH PARTITION COLUMNS",
3073
3073
  "REMOTE WITH CONNECTION"
3074
- ]), CT = r([
3074
+ ]), CT = _([
3075
3075
  "CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
3076
- ]), GE = r([
3076
+ ]), GE = _([
3077
3077
  // - create:
3078
3078
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
3079
3079
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -3161,15 +3161,15 @@ const qT = (T) => ({
3161
3161
  "ASSERT",
3162
3162
  // Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
3163
3163
  "EXPORT DATA"
3164
- ]), vR = r([
3164
+ ]), vR = _([
3165
3165
  "UNION {ALL | DISTINCT}",
3166
3166
  "EXCEPT DISTINCT",
3167
3167
  "INTERSECT DISTINCT"
3168
- ]), QR = r([
3168
+ ]), QR = _([
3169
3169
  "JOIN",
3170
3170
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
3171
3171
  "{INNER | CROSS} JOIN"
3172
- ]), ZR = r([
3172
+ ]), ZR = _([
3173
3173
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
3174
3174
  "TABLESAMPLE SYSTEM",
3175
3175
  // From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
@@ -3180,16 +3180,17 @@ const qT = (T) => ({
3180
3180
  "{ROWS | RANGE} BETWEEN",
3181
3181
  // comparison operator
3182
3182
  "IS [NOT] DISTINCT FROM"
3183
- ]), qR = {
3183
+ ]), qR = _([]), jR = {
3184
3184
  name: "bigquery",
3185
3185
  tokenizerOptions: {
3186
- reservedSelect: wR,
3186
+ reservedSelect: JR,
3187
3187
  reservedClauses: [...xR, ...GE, ...CT],
3188
3188
  reservedSetOperations: vR,
3189
3189
  reservedJoins: QR,
3190
- reservedPhrases: ZR,
3190
+ reservedKeywordPhrases: ZR,
3191
+ reservedDataTypePhrases: qR,
3191
3192
  reservedKeywords: gR,
3192
- reservedDataTypes: JR,
3193
+ reservedDataTypes: wR,
3193
3194
  reservedFunctionNames: $R,
3194
3195
  extraParens: ["[]"],
3195
3196
  stringTypes: [
@@ -3208,27 +3209,27 @@ const qT = (T) => ({
3208
3209
  variableTypes: [{ regex: String.raw`@@\w+` }],
3209
3210
  lineCommentTypes: ["--", "#"],
3210
3211
  operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
3211
- postProcess: jR
3212
+ postProcess: kR
3212
3213
  },
3213
3214
  formatOptions: {
3214
3215
  onelineClauses: [...CT, ...GE],
3215
3216
  tabularOnelineClauses: GE
3216
3217
  }
3217
3218
  };
3218
- function jR(T) {
3219
- return kR(zR(T));
3220
- }
3221
3219
  function kR(T) {
3220
+ return zR(EA(T));
3221
+ }
3222
+ function zR(T) {
3222
3223
  let E = j;
3223
3224
  return T.map((R) => R.text === "OFFSET" && E.text === "[" ? (E = R, Object.assign(Object.assign({}, R), { type: D.RESERVED_FUNCTION_NAME })) : (E = R, R));
3224
3225
  }
3225
- function zR(T) {
3226
+ function EA(T) {
3226
3227
  var E;
3227
3228
  const R = [];
3228
3229
  for (let A = 0; A < T.length; A++) {
3229
3230
  const e = T[A];
3230
- if ((J.ARRAY(e) || J.STRUCT(e)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3231
- const S = EA(T, A + 1), N = T.slice(A, S + 1);
3231
+ if ((w.ARRAY(e) || w.STRUCT(e)) && ((E = T[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3232
+ const S = TA(T, A + 1), N = T.slice(A, S + 1);
3232
3233
  R.push({
3233
3234
  type: D.IDENTIFIER,
3234
3235
  raw: N.map(LT("raw")).join(""),
@@ -3241,7 +3242,7 @@ function zR(T) {
3241
3242
  return R;
3242
3243
  }
3243
3244
  const LT = (T) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[T] + " " : E[T];
3244
- function EA(T, E) {
3245
+ function TA(T, E) {
3245
3246
  let R = 0;
3246
3247
  for (let A = E; A < T.length; A++) {
3247
3248
  const e = T[A];
@@ -3250,7 +3251,7 @@ function EA(T, E) {
3250
3251
  }
3251
3252
  return T.length - 1;
3252
3253
  }
3253
- const TA = [
3254
+ const RA = [
3254
3255
  // https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
3255
3256
  "ARRAY_AGG",
3256
3257
  "AVG",
@@ -3570,7 +3571,7 @@ const TA = [
3570
3571
  "RATIO_TO_REPORT",
3571
3572
  // Type casting
3572
3573
  "CAST"
3573
- ], RA = [
3574
+ ], AA = [
3574
3575
  // https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
3575
3576
  "ACTIVATE",
3576
3577
  "ADD",
@@ -3971,7 +3972,7 @@ const TA = [
3971
3972
  "XMLNAMESPACES",
3972
3973
  "YEAR",
3973
3974
  "YEARS"
3974
- ], AA = [
3975
+ ], eA = [
3975
3976
  // https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
3976
3977
  "ARRAY",
3977
3978
  "BIGINT",
@@ -4013,7 +4014,7 @@ const TA = [
4013
4014
  "VARBINARY",
4014
4015
  "VARCHAR",
4015
4016
  "VARGRAPHIC"
4016
- ], eA = r(["SELECT [ALL | DISTINCT]"]), SA = r([
4017
+ ], SA = _(["SELECT [ALL | DISTINCT]"]), IA = _([
4017
4018
  // queries
4018
4019
  "WITH",
4019
4020
  "FROM",
@@ -4042,9 +4043,9 @@ const TA = [
4042
4043
  "WHEN [NOT] MATCHED [THEN]",
4043
4044
  "UPDATE SET",
4044
4045
  "INSERT"
4045
- ]), _T = r([
4046
+ ]), _T = _([
4046
4047
  "CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
4047
- ]), lE = r([
4048
+ ]), lE = _([
4048
4049
  // - create:
4049
4050
  "CREATE [OR REPLACE] VIEW",
4050
4051
  // - update:
@@ -4247,26 +4248,27 @@ const TA = [
4247
4248
  "TRANSFER OWNERSHIP OF",
4248
4249
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
4249
4250
  "WHILE"
4250
- ]), IA = r(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), OA = r([
4251
+ ]), OA = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), NA = _([
4251
4252
  "JOIN",
4252
4253
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
4253
4254
  "{INNER | CROSS} JOIN"
4254
- ]), NA = r([
4255
+ ]), sA = _([
4255
4256
  "ON DELETE",
4256
4257
  "ON UPDATE",
4257
4258
  "SET NULL",
4258
4259
  "{ROWS | RANGE} BETWEEN"
4259
- ]), tA = {
4260
+ ]), tA = _([]), CA = {
4260
4261
  name: "db2",
4261
4262
  tokenizerOptions: {
4262
- reservedSelect: eA,
4263
- reservedClauses: [...SA, ..._T, ...lE],
4264
- reservedSetOperations: IA,
4265
- reservedJoins: OA,
4266
- reservedPhrases: NA,
4267
- reservedKeywords: RA,
4268
- reservedDataTypes: AA,
4269
- reservedFunctionNames: TA,
4263
+ reservedSelect: SA,
4264
+ reservedClauses: [...IA, ..._T, ...lE],
4265
+ reservedSetOperations: OA,
4266
+ reservedJoins: NA,
4267
+ reservedKeywordPhrases: sA,
4268
+ reservedDataTypePhrases: tA,
4269
+ reservedKeywords: AA,
4270
+ reservedDataTypes: eA,
4271
+ reservedFunctionNames: RA,
4270
4272
  extraParens: ["[]"],
4271
4273
  stringTypes: [
4272
4274
  { quote: "''-qq", prefixes: ["G", "N", "U&"] },
@@ -4300,7 +4302,7 @@ const TA = [
4300
4302
  onelineClauses: [..._T, ...lE],
4301
4303
  tabularOnelineClauses: lE
4302
4304
  }
4303
- }, sA = [
4305
+ }, LA = [
4304
4306
  // https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
4305
4307
  // TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
4306
4308
  "ARRAY_AGG",
@@ -4634,7 +4636,7 @@ const TA = [
4634
4636
  "ROW_NUMBER",
4635
4637
  // Type casting
4636
4638
  "CAST"
4637
- ], CA = [
4639
+ ], _A = [
4638
4640
  // https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
4639
4641
  // TODO: This list likely contains all keywords, not only the reserved ones,
4640
4642
  // try to filter it down to just the reserved keywords.
@@ -5130,7 +5132,7 @@ const TA = [
5130
5132
  "YEARS",
5131
5133
  "YES",
5132
5134
  "ZONE"
5133
- ], LA = [
5135
+ ], rA = [
5134
5136
  // https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
5135
5137
  "ARRAY",
5136
5138
  "BIGINT",
@@ -5166,7 +5168,7 @@ const TA = [
5166
5168
  "VARCHAR",
5167
5169
  "VARGRAPHIC",
5168
5170
  "XML"
5169
- ], _A = r(["SELECT [ALL | DISTINCT]"]), rA = r([
5171
+ ], nA = _(["SELECT [ALL | DISTINCT]"]), iA = _([
5170
5172
  // queries
5171
5173
  "WITH [RECURSIVE]",
5172
5174
  "INTO",
@@ -5196,7 +5198,7 @@ const TA = [
5196
5198
  "INSERT",
5197
5199
  // Data definition - table
5198
5200
  "FOR SYSTEM NAME"
5199
- ]), rT = r(["CREATE [OR REPLACE] TABLE"]), cE = r([
5201
+ ]), rT = _(["CREATE [OR REPLACE] TABLE"]), cE = _([
5200
5202
  // - create:
5201
5203
  "CREATE [OR REPLACE] [RECURSIVE] VIEW",
5202
5204
  // - update:
@@ -5292,27 +5294,28 @@ const TA = [
5292
5294
  "TAG",
5293
5295
  "TRANSFER OWNERSHIP OF",
5294
5296
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
5295
- ]), nA = r(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), iA = r([
5297
+ ]), DA = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), aA = _([
5296
5298
  "JOIN",
5297
5299
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
5298
5300
  "[LEFT | RIGHT] EXCEPTION JOIN",
5299
5301
  "{INNER | CROSS} JOIN"
5300
- ]), DA = r([
5302
+ ]), oA = _([
5301
5303
  "ON DELETE",
5302
5304
  "ON UPDATE",
5303
5305
  "SET NULL",
5304
5306
  "{ROWS | RANGE} BETWEEN"
5305
- ]), aA = {
5307
+ ]), PA = _([]), MA = {
5306
5308
  name: "db2i",
5307
5309
  tokenizerOptions: {
5308
- reservedSelect: _A,
5309
- reservedClauses: [...rA, ...rT, ...cE],
5310
- reservedSetOperations: nA,
5311
- reservedJoins: iA,
5312
- reservedPhrases: DA,
5313
- reservedKeywords: CA,
5314
- reservedDataTypes: LA,
5315
- reservedFunctionNames: sA,
5310
+ reservedSelect: nA,
5311
+ reservedClauses: [...iA, ...rT, ...cE],
5312
+ reservedSetOperations: DA,
5313
+ reservedJoins: aA,
5314
+ reservedKeywordPhrases: oA,
5315
+ reservedDataTypePhrases: PA,
5316
+ reservedKeywords: _A,
5317
+ reservedDataTypes: rA,
5318
+ reservedFunctionNames: LA,
5316
5319
  nestedBlockComments: !0,
5317
5320
  extraParens: ["[]"],
5318
5321
  stringTypes: [
@@ -5329,7 +5332,7 @@ const TA = [
5329
5332
  onelineClauses: [...rT, ...cE],
5330
5333
  tabularOnelineClauses: cE
5331
5334
  }
5332
- }, oA = [
5335
+ }, UA = [
5333
5336
  // Functions from DuckDB (excluding those that start with an underscore):
5334
5337
  // SELECT DISTINCT upper(function_name) AS function_name
5335
5338
  // FROM duckdb_functions()
@@ -5992,7 +5995,7 @@ const TA = [
5992
5995
  // 'NULL', we really prefer treating it as keyword
5993
5996
  "RANK",
5994
5997
  "ROW_NUMBER"
5995
- ], PA = [
5998
+ ], GA = [
5996
5999
  // Keywords from DuckDB:
5997
6000
  // SELECT upper(keyword_name)
5998
6001
  // FROM duckdb_keywords()
@@ -6074,7 +6077,7 @@ const TA = [
6074
6077
  "WHERE",
6075
6078
  "WINDOW",
6076
6079
  "WITH"
6077
- ], MA = [
6080
+ ], lA = [
6078
6081
  // Types from DuckDB:
6079
6082
  // SELECT DISTINCT upper(type_name)
6080
6083
  // FROM duckdb_types()
@@ -6154,7 +6157,7 @@ const TA = [
6154
6157
  "UUID",
6155
6158
  "VARBINARY",
6156
6159
  "VARCHAR"
6157
- ], UA = r(["SELECT [ALL | DISTINCT]"]), GA = r([
6160
+ ], cA = _(["SELECT [ALL | DISTINCT]"]), uA = _([
6158
6161
  // queries
6159
6162
  "WITH [RECURSIVE]",
6160
6163
  "FROM",
@@ -6178,9 +6181,9 @@ const TA = [
6178
6181
  "SET",
6179
6182
  // other:
6180
6183
  "RETURNING"
6181
- ]), nT = r([
6184
+ ]), nT = _([
6182
6185
  "CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
6183
- ]), uE = r([
6186
+ ]), uE = _([
6184
6187
  // TABLE
6185
6188
  // - update:
6186
6189
  "UPDATE",
@@ -6258,11 +6261,11 @@ const TA = [
6258
6261
  "PREPARE",
6259
6262
  "EXECUTE",
6260
6263
  "DEALLOCATE [PREPARE]"
6261
- ]), lA = r([
6264
+ ]), HA = _([
6262
6265
  "UNION [ALL | BY NAME]",
6263
6266
  "EXCEPT [ALL]",
6264
6267
  "INTERSECT [ALL]"
6265
- ]), cA = r([
6268
+ ]), BA = _([
6266
6269
  "JOIN",
6267
6270
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6268
6271
  "{INNER | CROSS} JOIN",
@@ -6271,25 +6274,26 @@ const TA = [
6271
6274
  "POSITIONAL JOIN",
6272
6275
  "ANTI JOIN",
6273
6276
  "SEMI JOIN"
6274
- ]), uA = r([
6277
+ ]), mA = _([
6275
6278
  "{ROWS | RANGE | GROUPS} BETWEEN",
6276
6279
  "SIMILAR TO",
6277
- "IS [NOT] DISTINCT FROM",
6278
- "TIMESTAMP WITH TIME ZONE"
6279
- ]), HA = {
6280
+ "IS [NOT] DISTINCT FROM"
6281
+ ]), FA = _(["TIMESTAMP WITH TIME ZONE"]), YA = {
6280
6282
  name: "duckdb",
6281
6283
  tokenizerOptions: {
6282
- reservedSelect: UA,
6283
- reservedClauses: [...GA, ...nT, ...uE],
6284
- reservedSetOperations: lA,
6285
- reservedJoins: cA,
6286
- reservedPhrases: uA,
6284
+ reservedSelect: cA,
6285
+ reservedClauses: [...uA, ...nT, ...uE],
6286
+ reservedSetOperations: HA,
6287
+ reservedJoins: BA,
6288
+ reservedKeywordPhrases: mA,
6289
+ reservedDataTypePhrases: FA,
6287
6290
  supportsXor: !0,
6288
- reservedKeywords: PA,
6289
- reservedDataTypes: MA,
6290
- reservedFunctionNames: oA,
6291
+ reservedKeywords: GA,
6292
+ reservedDataTypes: lA,
6293
+ reservedFunctionNames: UA,
6291
6294
  nestedBlockComments: !0,
6292
6295
  extraParens: ["[]", "{}"],
6296
+ underscoresInNumbers: !0,
6293
6297
  stringTypes: [
6294
6298
  "$$",
6295
6299
  "''-qq",
@@ -6350,7 +6354,7 @@ const TA = [
6350
6354
  onelineClauses: [...nT, ...uE],
6351
6355
  tabularOnelineClauses: uE
6352
6356
  }
6353
- }, BA = [
6357
+ }, pA = [
6354
6358
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
6355
6359
  // math
6356
6360
  "ABS",
@@ -6558,7 +6562,7 @@ const TA = [
6558
6562
  "CUME_DIST",
6559
6563
  "PERCENT_RANK",
6560
6564
  "NTILE"
6561
- ], mA = [
6565
+ ], dA = [
6562
6566
  // https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
6563
6567
  // Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
6564
6568
  "ADD",
@@ -6873,7 +6877,7 @@ const TA = [
6873
6877
  "JSONFILE",
6874
6878
  "INPUTFORMAT",
6875
6879
  "OUTPUTFORMAT"
6876
- ], FA = [
6880
+ ], hA = [
6877
6881
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
6878
6882
  "ARRAY",
6879
6883
  "BIGINT",
@@ -6894,7 +6898,7 @@ const TA = [
6894
6898
  "STRUCT",
6895
6899
  "TIMESTAMP",
6896
6900
  "VARCHAR"
6897
- ], YA = r(["SELECT [ALL | DISTINCT]"]), pA = r([
6901
+ ], fA = _(["SELECT [ALL | DISTINCT]"]), VA = _([
6898
6902
  // queries
6899
6903
  "WITH",
6900
6904
  "FROM",
@@ -6928,9 +6932,9 @@ const TA = [
6928
6932
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
6929
6933
  "LOAD DATA [LOCAL] INPATH",
6930
6934
  "[OVERWRITE] INTO TABLE"
6931
- ]), iT = r([
6935
+ ]), iT = _([
6932
6936
  "CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
6933
- ]), HE = r([
6937
+ ]), HE = _([
6934
6938
  // - create:
6935
6939
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
6936
6940
  // - update:
@@ -6955,23 +6959,24 @@ const TA = [
6955
6959
  "STORED AS",
6956
6960
  "STORED BY",
6957
6961
  "ROW FORMAT"
6958
- ]), dA = r(["UNION [ALL | DISTINCT]"]), fA = r([
6962
+ ]), WA = _(["UNION [ALL | DISTINCT]"]), XA = _([
6959
6963
  "JOIN",
6960
6964
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6961
6965
  "{INNER | CROSS} JOIN",
6962
6966
  // non-standard joins
6963
6967
  "LEFT SEMI JOIN"
6964
- ]), hA = r(["{ROWS | RANGE} BETWEEN"]), VA = {
6968
+ ]), bA = _(["{ROWS | RANGE} BETWEEN"]), yA = _([]), KA = {
6965
6969
  name: "hive",
6966
6970
  tokenizerOptions: {
6967
- reservedSelect: YA,
6968
- reservedClauses: [...pA, ...iT, ...HE],
6969
- reservedSetOperations: dA,
6970
- reservedJoins: fA,
6971
- reservedPhrases: hA,
6972
- reservedKeywords: mA,
6973
- reservedDataTypes: FA,
6974
- reservedFunctionNames: BA,
6971
+ reservedSelect: fA,
6972
+ reservedClauses: [...VA, ...iT, ...HE],
6973
+ reservedSetOperations: WA,
6974
+ reservedJoins: XA,
6975
+ reservedKeywordPhrases: bA,
6976
+ reservedDataTypePhrases: yA,
6977
+ reservedKeywords: dA,
6978
+ reservedDataTypes: hA,
6979
+ reservedFunctionNames: pA,
6975
6980
  extraParens: ["[]"],
6976
6981
  stringTypes: ['""-bs', "''-bs"],
6977
6982
  identTypes: ["``"],
@@ -6986,13 +6991,13 @@ const TA = [
6986
6991
  function CE(T) {
6987
6992
  return T.map((E, R) => {
6988
6993
  const A = T[R + 1] || j;
6989
- if (J.SET(E) && A.text === "(")
6994
+ if (w.SET(E) && A.text === "(")
6990
6995
  return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
6991
6996
  const e = T[R - 1] || j;
6992
- return J.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
6997
+ return w.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
6993
6998
  });
6994
6999
  }
6995
- const WA = [
7000
+ const $A = [
6996
7001
  // https://mariadb.com/kb/en/reserved-words/
6997
7002
  "ACCESSIBLE",
6998
7003
  "ADD",
@@ -7209,7 +7214,7 @@ const WA = [
7209
7214
  "XOR",
7210
7215
  "YEAR_MONTH",
7211
7216
  "ZEROFILL"
7212
- ], XA = [
7217
+ ], gA = [
7213
7218
  // https://mariadb.com/kb/en/data-types/
7214
7219
  "BIGINT",
7215
7220
  "BINARY",
@@ -7260,7 +7265,7 @@ const WA = [
7260
7265
  "YEAR"
7261
7266
  // 'NUMBER', // ?? In oracle mode only
7262
7267
  // 'SET' // handled as special-case in postProcess
7263
- ], bA = [
7268
+ ], wA = [
7264
7269
  // https://mariadb.com/kb/en/information-schema-sql_functions-table/
7265
7270
  "ADDDATE",
7266
7271
  "ADD_MONTHS",
@@ -7498,7 +7503,7 @@ const WA = [
7498
7503
  // CASE expression shorthands
7499
7504
  "COALESCE",
7500
7505
  "NULLIF"
7501
- ], yA = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), KA = r([
7506
+ ], JA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), xA = _([
7502
7507
  // queries
7503
7508
  "WITH [RECURSIVE]",
7504
7509
  "FROM",
@@ -7520,9 +7525,9 @@ const WA = [
7520
7525
  "SET",
7521
7526
  // other
7522
7527
  "RETURNING"
7523
- ]), DT = r([
7528
+ ]), DT = _([
7524
7529
  "CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
7525
- ]), BE = r([
7530
+ ]), BE = _([
7526
7531
  // - create:
7527
7532
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
7528
7533
  // - update:
@@ -7729,12 +7734,12 @@ const WA = [
7729
7734
  "XA RECOVER",
7730
7735
  "XA ROLLBACK",
7731
7736
  "XA START"
7732
- ]), $A = r([
7737
+ ]), vA = _([
7733
7738
  "UNION [ALL | DISTINCT]",
7734
7739
  "EXCEPT [ALL | DISTINCT]",
7735
7740
  "INTERSECT [ALL | DISTINCT]",
7736
7741
  "MINUS [ALL | DISTINCT]"
7737
- ]), gA = r([
7742
+ ]), QA = _([
7738
7743
  "JOIN",
7739
7744
  "{LEFT | RIGHT} [OUTER] JOIN",
7740
7745
  "{INNER | CROSS} JOIN",
@@ -7742,23 +7747,24 @@ const WA = [
7742
7747
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
7743
7748
  // non-standard joins
7744
7749
  "STRAIGHT_JOIN"
7745
- ]), JA = r([
7750
+ ]), ZA = _([
7746
7751
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
7747
7752
  "CHARACTER SET",
7748
7753
  "{ROWS | RANGE} BETWEEN",
7749
7754
  "IDENTIFIED BY"
7750
- ]), wA = {
7755
+ ]), qA = _([]), jA = {
7751
7756
  name: "mariadb",
7752
7757
  tokenizerOptions: {
7753
- reservedSelect: yA,
7754
- reservedClauses: [...KA, ...DT, ...BE],
7755
- reservedSetOperations: $A,
7756
- reservedJoins: gA,
7757
- reservedPhrases: JA,
7758
+ reservedSelect: JA,
7759
+ reservedClauses: [...xA, ...DT, ...BE],
7760
+ reservedSetOperations: vA,
7761
+ reservedJoins: QA,
7762
+ reservedKeywordPhrases: ZA,
7763
+ reservedDataTypePhrases: qA,
7758
7764
  supportsXor: !0,
7759
- reservedKeywords: WA,
7760
- reservedDataTypes: XA,
7761
- reservedFunctionNames: bA,
7765
+ reservedKeywords: $A,
7766
+ reservedDataTypes: gA,
7767
+ reservedFunctionNames: wA,
7762
7768
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
7763
7769
  stringTypes: [
7764
7770
  '""-qq-bs',
@@ -7797,7 +7803,7 @@ const WA = [
7797
7803
  onelineClauses: [...DT, ...BE],
7798
7804
  tabularOnelineClauses: BE
7799
7805
  }
7800
- }, xA = [
7806
+ }, kA = [
7801
7807
  // https://dev.mysql.com/doc/refman/8.0/en/keywords.html
7802
7808
  "ACCESSIBLE",
7803
7809
  "ADD",
@@ -8028,7 +8034,7 @@ const WA = [
8028
8034
  "YEAR_MONTH",
8029
8035
  "ZEROFILL"
8030
8036
  // (R)
8031
- ], vA = [
8037
+ ], zA = [
8032
8038
  // https://dev.mysql.com/doc/refman/8.0/en/data-types.html
8033
8039
  "BIGINT",
8034
8040
  "BINARY",
@@ -8080,7 +8086,7 @@ const WA = [
8080
8086
  "VARYING",
8081
8087
  "YEAR"
8082
8088
  // 'SET' // handled as special-case in postProcess
8083
- ], QA = [
8089
+ ], Ee = [
8084
8090
  // https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
8085
8091
  "ABS",
8086
8092
  "ACOS",
@@ -8503,7 +8509,7 @@ const WA = [
8503
8509
  // 'XOR',
8504
8510
  "YEAR",
8505
8511
  "YEARWEEK"
8506
- ], ZA = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), qA = r([
8512
+ ], Te = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), Re = _([
8507
8513
  // queries
8508
8514
  "WITH [RECURSIVE]",
8509
8515
  "FROM",
@@ -8523,7 +8529,7 @@ const WA = [
8523
8529
  "ON DUPLICATE KEY UPDATE",
8524
8530
  // - update:
8525
8531
  "SET"
8526
- ]), aT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), mE = r([
8532
+ ]), aT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), mE = _([
8527
8533
  // - create:
8528
8534
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
8529
8535
  // - update:
@@ -8704,7 +8710,7 @@ const WA = [
8704
8710
  "REPEAT",
8705
8711
  "RETURN",
8706
8712
  "WHILE"
8707
- ]), jA = r(["UNION [ALL | DISTINCT]"]), kA = r([
8713
+ ]), Ae = _(["UNION [ALL | DISTINCT]"]), ee = _([
8708
8714
  "JOIN",
8709
8715
  "{LEFT | RIGHT} [OUTER] JOIN",
8710
8716
  "{INNER | CROSS} JOIN",
@@ -8712,23 +8718,24 @@ const WA = [
8712
8718
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
8713
8719
  // non-standard joins
8714
8720
  "STRAIGHT_JOIN"
8715
- ]), zA = r([
8721
+ ]), Se = _([
8716
8722
  "ON {UPDATE | DELETE} [SET NULL]",
8717
8723
  "CHARACTER SET",
8718
8724
  "{ROWS | RANGE} BETWEEN",
8719
8725
  "IDENTIFIED BY"
8720
- ]), Ee = {
8726
+ ]), Ie = _([]), Oe = {
8721
8727
  name: "mysql",
8722
8728
  tokenizerOptions: {
8723
- reservedSelect: ZA,
8724
- reservedClauses: [...qA, ...aT, ...mE],
8725
- reservedSetOperations: jA,
8726
- reservedJoins: kA,
8727
- reservedPhrases: zA,
8729
+ reservedSelect: Te,
8730
+ reservedClauses: [...Re, ...aT, ...mE],
8731
+ reservedSetOperations: Ae,
8732
+ reservedJoins: ee,
8733
+ reservedKeywordPhrases: Se,
8734
+ reservedDataTypePhrases: Ie,
8728
8735
  supportsXor: !0,
8729
- reservedKeywords: xA,
8730
- reservedDataTypes: vA,
8731
- reservedFunctionNames: QA,
8736
+ reservedKeywords: kA,
8737
+ reservedDataTypes: zA,
8738
+ reservedFunctionNames: Ee,
8732
8739
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
8733
8740
  stringTypes: [
8734
8741
  '""-qq-bs',
@@ -8769,7 +8776,7 @@ const WA = [
8769
8776
  onelineClauses: [...aT, ...mE],
8770
8777
  tabularOnelineClauses: mE
8771
8778
  }
8772
- }, Te = [
8779
+ }, Ne = [
8773
8780
  // https://docs.pingcap.com/tidb/stable/keywords
8774
8781
  "ADD",
8775
8782
  "ALL",
@@ -8961,7 +8968,7 @@ const WA = [
8961
8968
  "YEAR_MONTH",
8962
8969
  "ZEROFILL"
8963
8970
  // (R)
8964
- ], Re = [
8971
+ ], se = [
8965
8972
  // https://docs.pingcap.com/tidb/stable/data-type-overview
8966
8973
  "BIGINT",
8967
8974
  "BINARY",
@@ -9008,7 +9015,7 @@ const WA = [
9008
9015
  "VARYING",
9009
9016
  "YEAR"
9010
9017
  // 'SET' // handled as special-case in postProcess
9011
- ], Ae = [
9018
+ ], te = [
9012
9019
  // https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
9013
9020
  // https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
9014
9021
  // + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
@@ -9334,7 +9341,7 @@ const WA = [
9334
9341
  // 'XOR',
9335
9342
  "YEAR",
9336
9343
  "YEARWEEK"
9337
- ], ee = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), Se = r([
9344
+ ], Ce = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), Le = _([
9338
9345
  // queries
9339
9346
  "WITH [RECURSIVE]",
9340
9347
  "FROM",
@@ -9354,7 +9361,7 @@ const WA = [
9354
9361
  "ON DUPLICATE KEY UPDATE",
9355
9362
  // - update:
9356
9363
  "SET"
9357
- ]), oT = r(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), FE = r([
9364
+ ]), oT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), FE = _([
9358
9365
  // https://docs.pingcap.com/tidb/stable/sql-statement-create-view
9359
9366
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
9360
9367
  // https://docs.pingcap.com/tidb/stable/sql-statement-update
@@ -9469,7 +9476,7 @@ const WA = [
9469
9476
  "UNLOCK TABLES",
9470
9477
  // https://docs.pingcap.com/tidb/stable/sql-statement-use
9471
9478
  "USE"
9472
- ]), Ie = r(["UNION [ALL | DISTINCT]"]), Oe = r([
9479
+ ]), _e = _(["UNION [ALL | DISTINCT]"]), re = _([
9473
9480
  "JOIN",
9474
9481
  "{LEFT | RIGHT} [OUTER] JOIN",
9475
9482
  "{INNER | CROSS} JOIN",
@@ -9477,23 +9484,24 @@ const WA = [
9477
9484
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
9478
9485
  // non-standard joins
9479
9486
  "STRAIGHT_JOIN"
9480
- ]), Ne = r([
9487
+ ]), ne = _([
9481
9488
  "ON {UPDATE | DELETE} [SET NULL]",
9482
9489
  "CHARACTER SET",
9483
9490
  "{ROWS | RANGE} BETWEEN",
9484
9491
  "IDENTIFIED BY"
9485
- ]), te = {
9492
+ ]), ie = _([]), De = {
9486
9493
  name: "tidb",
9487
9494
  tokenizerOptions: {
9488
- reservedSelect: ee,
9489
- reservedClauses: [...Se, ...oT, ...FE],
9490
- reservedSetOperations: Ie,
9491
- reservedJoins: Oe,
9492
- reservedPhrases: Ne,
9495
+ reservedSelect: Ce,
9496
+ reservedClauses: [...Le, ...oT, ...FE],
9497
+ reservedSetOperations: _e,
9498
+ reservedJoins: re,
9499
+ reservedKeywordPhrases: ne,
9500
+ reservedDataTypePhrases: ie,
9493
9501
  supportsXor: !0,
9494
- reservedKeywords: Te,
9495
- reservedDataTypes: Re,
9496
- reservedFunctionNames: Ae,
9502
+ reservedKeywords: Ne,
9503
+ reservedDataTypes: se,
9504
+ reservedFunctionNames: te,
9497
9505
  // TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
9498
9506
  stringTypes: [
9499
9507
  '""-qq-bs',
@@ -9534,7 +9542,7 @@ const WA = [
9534
9542
  onelineClauses: [...oT, ...FE],
9535
9543
  tabularOnelineClauses: FE
9536
9544
  }
9537
- }, se = [
9545
+ }, ae = [
9538
9546
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
9539
9547
  "ABORT",
9540
9548
  "ABS",
@@ -9764,7 +9772,7 @@ const WA = [
9764
9772
  // not implemented in N1QL, but added here now for the sake of tests
9765
9773
  // https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
9766
9774
  "CAST"
9767
- ], Ce = [
9775
+ ], oe = [
9768
9776
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
9769
9777
  "ADVISE",
9770
9778
  "ALL",
@@ -9970,7 +9978,7 @@ const WA = [
9970
9978
  "WITHIN",
9971
9979
  "WORK",
9972
9980
  "XOR"
9973
- ], Le = [
9981
+ ], Pe = [
9974
9982
  // N1QL does not support any way of declaring types for columns.
9975
9983
  // It does not support the CREATE TABLE statement nor the CAST() expression.
9976
9984
  //
@@ -9979,7 +9987,7 @@ const WA = [
9979
9987
  // which it actually doesn't use.
9980
9988
  //
9981
9989
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
9982
- ], _e = r(["SELECT [ALL | DISTINCT]"]), re = r([
9990
+ ], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
9983
9991
  // queries
9984
9992
  "WITH",
9985
9993
  "FROM",
@@ -10006,7 +10014,7 @@ const WA = [
10006
10014
  "NEST",
10007
10015
  "UNNEST",
10008
10016
  "RETURNING"
10009
- ]), PT = r([
10017
+ ]), PT = _([
10010
10018
  // - update:
10011
10019
  "UPDATE",
10012
10020
  // - delete:
@@ -10046,18 +10054,19 @@ const WA = [
10046
10054
  "SET CURRENT SCHEMA",
10047
10055
  "SHOW",
10048
10056
  "USE [PRIMARY] KEYS"
10049
- ]), ne = r(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), ie = r(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), De = r(["{ROWS | RANGE | GROUPS} BETWEEN"]), ae = {
10057
+ ]), Ge = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), le = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ce = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), ue = _([]), He = {
10050
10058
  name: "n1ql",
10051
10059
  tokenizerOptions: {
10052
- reservedSelect: _e,
10053
- reservedClauses: [...re, ...PT],
10054
- reservedSetOperations: ne,
10055
- reservedJoins: ie,
10056
- reservedPhrases: De,
10060
+ reservedSelect: Me,
10061
+ reservedClauses: [...Ue, ...PT],
10062
+ reservedSetOperations: Ge,
10063
+ reservedJoins: le,
10064
+ reservedKeywordPhrases: ce,
10065
+ reservedDataTypePhrases: ue,
10057
10066
  supportsXor: !0,
10058
- reservedKeywords: Ce,
10059
- reservedDataTypes: Le,
10060
- reservedFunctionNames: se,
10067
+ reservedKeywords: oe,
10068
+ reservedDataTypes: Pe,
10069
+ reservedFunctionNames: ae,
10061
10070
  // NOTE: single quotes are actually not supported in N1QL,
10062
10071
  // but we support them anyway as all other SQL dialects do,
10063
10072
  // which simplifies writing tests that are shared between all dialects.
@@ -10071,7 +10080,7 @@ const WA = [
10071
10080
  formatOptions: {
10072
10081
  onelineClauses: PT
10073
10082
  }
10074
- }, oe = [
10083
+ }, Be = [
10075
10084
  // https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
10076
10085
  // 'A',
10077
10086
  "ADD",
@@ -10376,7 +10385,7 @@ const WA = [
10376
10385
  "WRITE",
10377
10386
  "YEAR",
10378
10387
  "ZONE"
10379
- ], Pe = [
10388
+ ], me = [
10380
10389
  // https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
10381
10390
  "ARRAY",
10382
10391
  "BFILE_BASE",
@@ -10414,7 +10423,7 @@ const WA = [
10414
10423
  "UROWID",
10415
10424
  "VARCHAR",
10416
10425
  "VARCHAR2"
10417
- ], Me = [
10426
+ ], Fe = [
10418
10427
  // https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
10419
10428
  // numeric
10420
10429
  "ABS",
@@ -10679,7 +10688,7 @@ const WA = [
10679
10688
  "PRESENTNNV",
10680
10689
  "PRESENTV",
10681
10690
  "PREVIOUS"
10682
- ], Ue = r(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ge = r([
10691
+ ], Ye = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), pe = _([
10683
10692
  // queries
10684
10693
  "WITH",
10685
10694
  "FROM",
@@ -10703,9 +10712,9 @@ const WA = [
10703
10712
  "UPDATE SET",
10704
10713
  // other
10705
10714
  "RETURNING"
10706
- ]), MT = r([
10715
+ ]), MT = _([
10707
10716
  "CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
10708
- ]), YE = r([
10717
+ ]), YE = _([
10709
10718
  // - create:
10710
10719
  "CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
10711
10720
  "CREATE MATERIALIZED VIEW",
@@ -10733,7 +10742,7 @@ const WA = [
10733
10742
  "EXCEPTION",
10734
10743
  "LOOP",
10735
10744
  "START WITH"
10736
- ]), le = r(["UNION [ALL]", "MINUS", "INTERSECT"]), ce = r([
10745
+ ]), de = _(["UNION [ALL]", "MINUS", "INTERSECT"]), he = _([
10737
10746
  "JOIN",
10738
10747
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
10739
10748
  "{INNER | CROSS} JOIN",
@@ -10741,22 +10750,23 @@ const WA = [
10741
10750
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
10742
10751
  // non-standard joins
10743
10752
  "{CROSS | OUTER} APPLY"
10744
- ]), ue = r([
10753
+ ]), fe = _([
10745
10754
  "ON {UPDATE | DELETE} [SET NULL]",
10746
10755
  "ON COMMIT",
10747
10756
  "{ROWS | RANGE} BETWEEN"
10748
- ]), He = {
10757
+ ]), Ve = _([]), We = {
10749
10758
  name: "plsql",
10750
10759
  tokenizerOptions: {
10751
- reservedSelect: Ue,
10752
- reservedClauses: [...Ge, ...MT, ...YE],
10753
- reservedSetOperations: le,
10754
- reservedJoins: ce,
10755
- reservedPhrases: ue,
10760
+ reservedSelect: Ye,
10761
+ reservedClauses: [...pe, ...MT, ...YE],
10762
+ reservedSetOperations: de,
10763
+ reservedJoins: he,
10764
+ reservedKeywordPhrases: fe,
10765
+ reservedDataTypePhrases: Ve,
10756
10766
  supportsXor: !0,
10757
- reservedKeywords: oe,
10758
- reservedDataTypes: Pe,
10759
- reservedFunctionNames: Me,
10767
+ reservedKeywords: Be,
10768
+ reservedDataTypes: me,
10769
+ reservedFunctionNames: Fe,
10760
10770
  stringTypes: [
10761
10771
  { quote: "''-qq", prefixes: ["N"] },
10762
10772
  { quote: "q''", prefixes: ["N"] }
@@ -10781,7 +10791,7 @@ const WA = [
10781
10791
  "@",
10782
10792
  "||"
10783
10793
  ],
10784
- postProcess: Be
10794
+ postProcess: Xe
10785
10795
  },
10786
10796
  formatOptions: {
10787
10797
  alwaysDenseOperators: ["@"],
@@ -10789,11 +10799,11 @@ const WA = [
10789
10799
  tabularOnelineClauses: YE
10790
10800
  }
10791
10801
  };
10792
- function Be(T) {
10802
+ function Xe(T) {
10793
10803
  let E = j;
10794
- return T.map((R) => J.SET(R) && J.BY(E) ? Object.assign(Object.assign({}, R), { type: D.RESERVED_KEYWORD }) : (jT(R.type) && (E = R), R));
10804
+ return T.map((R) => w.SET(R) && w.BY(E) ? Object.assign(Object.assign({}, R), { type: D.RESERVED_KEYWORD }) : (jT(R.type) && (E = R), R));
10795
10805
  }
10796
- const me = [
10806
+ const be = [
10797
10807
  // https://www.postgresql.org/docs/14/functions.html
10798
10808
  //
10799
10809
  // https://www.postgresql.org/docs/14/functions-math.html
@@ -11477,7 +11487,7 @@ const me = [
11477
11487
  "PG_MCV_LIST_ITEMS",
11478
11488
  // cast
11479
11489
  "CAST"
11480
- ], Fe = [
11490
+ ], ye = [
11481
11491
  // https://www.postgresql.org/docs/14/sql-keywords-appendix.html
11482
11492
  "ALL",
11483
11493
  "ANALYSE",
@@ -11596,7 +11606,7 @@ const me = [
11596
11606
  "WITHOUT",
11597
11607
  "YEAR"
11598
11608
  // requires AS
11599
- ], Ye = [
11609
+ ], Ke = [
11600
11610
  // https://www.postgresql.org/docs/current/datatype.html
11601
11611
  "ARRAY",
11602
11612
  "BIGINT",
@@ -11630,7 +11640,7 @@ const me = [
11630
11640
  "VARCHAR",
11631
11641
  "XML",
11632
11642
  "ZONE"
11633
- ], pe = r(["SELECT [ALL | DISTINCT]"]), de = r([
11643
+ ], $e = _(["SELECT [ALL | DISTINCT]"]), ge = _([
11634
11644
  // queries
11635
11645
  "WITH [RECURSIVE]",
11636
11646
  "FROM",
@@ -11653,9 +11663,9 @@ const me = [
11653
11663
  "SET",
11654
11664
  // other
11655
11665
  "RETURNING"
11656
- ]), UT = r([
11666
+ ]), UT = _([
11657
11667
  "CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
11658
- ]), pE = r([
11668
+ ]), pE = _([
11659
11669
  // - create
11660
11670
  "CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
11661
11671
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -11853,42 +11863,45 @@ const me = [
11853
11863
  "START TRANSACTION",
11854
11864
  "UNLISTEN",
11855
11865
  "VACUUM"
11856
- ]), fe = r([
11866
+ ]), we = _([
11857
11867
  "UNION [ALL | DISTINCT]",
11858
11868
  "EXCEPT [ALL | DISTINCT]",
11859
11869
  "INTERSECT [ALL | DISTINCT]"
11860
- ]), he = r([
11870
+ ]), Je = _([
11861
11871
  "JOIN",
11862
11872
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
11863
11873
  "{INNER | CROSS} JOIN",
11864
11874
  "NATURAL [INNER] JOIN",
11865
11875
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
11866
- ]), Ve = r([
11876
+ ]), xe = _([
11867
11877
  "PRIMARY KEY",
11868
11878
  "GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
11869
11879
  "ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
11870
11880
  "DO {NOTHING | UPDATE}",
11871
11881
  "AS MATERIALIZED",
11872
11882
  "{ROWS | RANGE | GROUPS} BETWEEN",
11873
- // https://www.postgresql.org/docs/current/datatype-datetime.html
11874
- "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE",
11875
11883
  // comparison operator
11876
11884
  "IS [NOT] DISTINCT FROM",
11877
11885
  "NULLS {FIRST | LAST}",
11878
11886
  "WITH ORDINALITY"
11879
- ]), We = {
11887
+ ]), ve = _([
11888
+ // https://www.postgresql.org/docs/current/datatype-datetime.html
11889
+ "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
11890
+ ]), Qe = {
11880
11891
  name: "postgresql",
11881
11892
  tokenizerOptions: {
11882
- reservedSelect: pe,
11883
- reservedClauses: [...de, ...UT, ...pE],
11884
- reservedSetOperations: fe,
11885
- reservedJoins: he,
11886
- reservedPhrases: Ve,
11887
- reservedKeywords: Fe,
11888
- reservedDataTypes: Ye,
11889
- reservedFunctionNames: me,
11893
+ reservedSelect: $e,
11894
+ reservedClauses: [...ge, ...UT, ...pE],
11895
+ reservedSetOperations: we,
11896
+ reservedJoins: Je,
11897
+ reservedKeywordPhrases: xe,
11898
+ reservedDataTypePhrases: ve,
11899
+ reservedKeywords: ye,
11900
+ reservedDataTypes: Ke,
11901
+ reservedFunctionNames: be,
11890
11902
  nestedBlockComments: !0,
11891
11903
  extraParens: ["[]"],
11904
+ underscoresInNumbers: !0,
11892
11905
  stringTypes: [
11893
11906
  "$$",
11894
11907
  { quote: "''-qq", prefixes: ["U&"] },
@@ -12000,7 +12013,7 @@ const me = [
12000
12013
  onelineClauses: [...UT, ...pE],
12001
12014
  tabularOnelineClauses: pE
12002
12015
  }
12003
- }, Xe = [
12016
+ }, Ze = [
12004
12017
  // https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
12005
12018
  "ANY_VALUE",
12006
12019
  "APPROXIMATE PERCENTILE_DISC",
@@ -12017,7 +12030,7 @@ const me = [
12017
12030
  "VAR_SAMP",
12018
12031
  "VAR_POP",
12019
12032
  // https://docs.aws.amazon.com/redshift/latest/dg/c_Array_Functions.html
12020
- "array",
12033
+ // 'array',
12021
12034
  "array_concat",
12022
12035
  "array_flatten",
12023
12036
  "get_array_length",
@@ -12346,7 +12359,7 @@ const me = [
12346
12359
  "SLICE_NUM",
12347
12360
  "USER",
12348
12361
  "VERSION"
12349
- ], be = [
12362
+ ], qe = [
12350
12363
  // https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
12351
12364
  "AES128",
12352
12365
  "AES256",
@@ -12535,7 +12548,7 @@ const me = [
12535
12548
  * SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
12536
12549
  * SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
12537
12550
  */
12538
- ], ye = [
12551
+ ], je = [
12539
12552
  // https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
12540
12553
  "ARRAY",
12541
12554
  "BIGINT",
@@ -12556,7 +12569,7 @@ const me = [
12556
12569
  "TEXT",
12557
12570
  "VARBYTE",
12558
12571
  "VARCHAR"
12559
- ], Ke = r(["SELECT [ALL | DISTINCT]"]), $e = r([
12572
+ ], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
12560
12573
  // queries
12561
12574
  "WITH [RECURSIVE]",
12562
12575
  "FROM",
@@ -12574,9 +12587,9 @@ const me = [
12574
12587
  "VALUES",
12575
12588
  // - update:
12576
12589
  "SET"
12577
- ]), GT = r([
12590
+ ]), GT = _([
12578
12591
  "CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
12579
- ]), dE = r([
12592
+ ]), dE = _([
12580
12593
  // - create:
12581
12594
  "CREATE [OR REPLACE | MATERIALIZED] VIEW",
12582
12595
  // - update:
@@ -12667,13 +12680,13 @@ const me = [
12667
12680
  "START TRANSACTION",
12668
12681
  "UNLOAD",
12669
12682
  "VACUUM"
12670
- ]), ge = r(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), Je = r([
12683
+ ]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), TS = _([
12671
12684
  "JOIN",
12672
12685
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12673
12686
  "{INNER | CROSS} JOIN",
12674
12687
  "NATURAL [INNER] JOIN",
12675
12688
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12676
- ]), we = r([
12689
+ ]), RS = _([
12677
12690
  // https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
12678
12691
  "NULL AS",
12679
12692
  // https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
@@ -12681,17 +12694,19 @@ const me = [
12681
12694
  "HIVE METASTORE",
12682
12695
  // in window specifications
12683
12696
  "{ROWS | RANGE} BETWEEN"
12684
- ]), xe = {
12697
+ ]), AS = _([]), eS = {
12685
12698
  name: "redshift",
12686
12699
  tokenizerOptions: {
12687
- reservedSelect: Ke,
12688
- reservedClauses: [...$e, ...GT, ...dE],
12689
- reservedSetOperations: ge,
12690
- reservedJoins: Je,
12691
- reservedPhrases: we,
12692
- reservedKeywords: be,
12693
- reservedDataTypes: ye,
12694
- reservedFunctionNames: Xe,
12700
+ reservedSelect: ke,
12701
+ reservedClauses: [...ze, ...GT, ...dE],
12702
+ reservedSetOperations: ES,
12703
+ reservedJoins: TS,
12704
+ reservedKeywordPhrases: RS,
12705
+ reservedDataTypePhrases: AS,
12706
+ reservedKeywords: qe,
12707
+ reservedDataTypes: je,
12708
+ reservedFunctionNames: Ze,
12709
+ extraParens: ["[]"],
12695
12710
  stringTypes: ["''-qq"],
12696
12711
  identTypes: ['""-qq'],
12697
12712
  identChars: { first: "#" },
@@ -12717,7 +12732,7 @@ const me = [
12717
12732
  onelineClauses: [...GT, ...dE],
12718
12733
  tabularOnelineClauses: dE
12719
12734
  }
12720
- }, ve = [
12735
+ }, SS = [
12721
12736
  // https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
12722
12737
  "ADD",
12723
12738
  "AFTER",
@@ -12984,7 +12999,7 @@ const me = [
12984
12999
  "UNSIGNED",
12985
13000
  "VARIABLES",
12986
13001
  "YEAR_MONTH"
12987
- ], Qe = [
13002
+ ], IS = [
12988
13003
  // https://spark.apache.org/docs/latest/sql-ref-datatypes.html
12989
13004
  "ARRAY",
12990
13005
  "BIGINT",
@@ -13014,7 +13029,7 @@ const me = [
13014
13029
  "TINYINT",
13015
13030
  "VARCHAR"
13016
13031
  // No varchar type in Spark, only STRING. Added for the sake of tests
13017
- ], Ze = [
13032
+ ], OS = [
13018
13033
  // http://spark.apache.org/docs/latest/sql-ref-functions.html
13019
13034
  //
13020
13035
  // http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
@@ -13335,7 +13350,7 @@ const me = [
13335
13350
  // Shorthand functions to use in place of CASE expression
13336
13351
  "COALESCE",
13337
13352
  "NULLIF"
13338
- ], qe = r(["SELECT [ALL | DISTINCT]"]), je = r([
13353
+ ], NS = _(["SELECT [ALL | DISTINCT]"]), sS = _([
13339
13354
  // queries
13340
13355
  "WITH",
13341
13356
  "FROM",
@@ -13360,7 +13375,7 @@ const me = [
13360
13375
  // https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
13361
13376
  "LOAD DATA [LOCAL] INPATH",
13362
13377
  "[OVERWRITE] INTO TABLE"
13363
- ]), lT = r(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), fE = r([
13378
+ ]), lT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), hE = _([
13364
13379
  // - create:
13365
13380
  "CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
13366
13381
  // - drop table:
@@ -13416,11 +13431,11 @@ const me = [
13416
13431
  "SHOW TBLPROPERTIES",
13417
13432
  "SHOW VIEWS",
13418
13433
  "UNCACHE TABLE"
13419
- ]), ke = r([
13434
+ ]), tS = _([
13420
13435
  "UNION [ALL | DISTINCT]",
13421
13436
  "EXCEPT [ALL | DISTINCT]",
13422
13437
  "INTERSECT [ALL | DISTINCT]"
13423
- ]), ze = r([
13438
+ ]), CS = _([
13424
13439
  "JOIN",
13425
13440
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13426
13441
  "{INNER | CROSS} JOIN",
@@ -13429,23 +13444,24 @@ const me = [
13429
13444
  // non-standard-joins
13430
13445
  "[LEFT] {ANTI | SEMI} JOIN",
13431
13446
  "NATURAL [LEFT] {ANTI | SEMI} JOIN"
13432
- ]), ES = r([
13447
+ ]), LS = _([
13433
13448
  "ON DELETE",
13434
13449
  "ON UPDATE",
13435
13450
  "CURRENT ROW",
13436
13451
  "{ROWS | RANGE} BETWEEN"
13437
- ]), TS = {
13452
+ ]), _S = _([]), rS = {
13438
13453
  name: "spark",
13439
13454
  tokenizerOptions: {
13440
- reservedSelect: qe,
13441
- reservedClauses: [...je, ...lT, ...fE],
13442
- reservedSetOperations: ke,
13443
- reservedJoins: ze,
13444
- reservedPhrases: ES,
13455
+ reservedSelect: NS,
13456
+ reservedClauses: [...sS, ...lT, ...hE],
13457
+ reservedSetOperations: tS,
13458
+ reservedJoins: CS,
13459
+ reservedKeywordPhrases: LS,
13460
+ reservedDataTypePhrases: _S,
13445
13461
  supportsXor: !0,
13446
- reservedKeywords: ve,
13447
- reservedDataTypes: Qe,
13448
- reservedFunctionNames: Ze,
13462
+ reservedKeywords: SS,
13463
+ reservedDataTypes: IS,
13464
+ reservedFunctionNames: OS,
13449
13465
  extraParens: ["[]"],
13450
13466
  stringTypes: [
13451
13467
  "''-bs",
@@ -13457,20 +13473,20 @@ const me = [
13457
13473
  identChars: { allowFirstCharNumber: !0 },
13458
13474
  variableTypes: [{ quote: "{}", prefixes: ["$"], requirePrefix: !0 }],
13459
13475
  operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||", "->"],
13460
- postProcess: RS
13476
+ postProcess: nS
13461
13477
  },
13462
13478
  formatOptions: {
13463
- onelineClauses: [...lT, ...fE],
13464
- tabularOnelineClauses: fE
13479
+ onelineClauses: [...lT, ...hE],
13480
+ tabularOnelineClauses: hE
13465
13481
  }
13466
13482
  };
13467
- function RS(T) {
13483
+ function nS(T) {
13468
13484
  return T.map((E, R) => {
13469
13485
  const A = T[R - 1] || j, e = T[R + 1] || j;
13470
- return J.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;
13486
+ return w.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;
13471
13487
  });
13472
13488
  }
13473
- const AS = [
13489
+ const iS = [
13474
13490
  // https://www.sqlite.org/lang_corefunc.html
13475
13491
  "ABS",
13476
13492
  "CHANGES",
@@ -13594,7 +13610,7 @@ const AS = [
13594
13610
  "JSON_TREE",
13595
13611
  // cast
13596
13612
  "CAST"
13597
- ], eS = [
13613
+ ], DS = [
13598
13614
  // https://www.sqlite.org/lang_keywords.html
13599
13615
  // Note: The keywords listed on that URL are not all reserved keywords.
13600
13616
  // We'll need to clean up this list to only include reserved keywords.
@@ -13747,7 +13763,7 @@ const AS = [
13747
13763
  "WINDOW",
13748
13764
  "WITH",
13749
13765
  "WITHOUT"
13750
- ], SS = [
13766
+ ], aS = [
13751
13767
  // SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
13752
13768
  // Here we just list some common ones as SQL Formatter
13753
13769
  // is only able to detect a predefined list of data types.
@@ -13768,7 +13784,7 @@ const AS = [
13768
13784
  "TEXT",
13769
13785
  "VARCHAR",
13770
13786
  "VARYING CHARACTER"
13771
- ], IS = r(["SELECT [ALL | DISTINCT]"]), OS = r([
13787
+ ], oS = _(["SELECT [ALL | DISTINCT]"]), PS = _([
13772
13788
  // queries
13773
13789
  "WITH [RECURSIVE]",
13774
13790
  "FROM",
@@ -13786,8 +13802,10 @@ const AS = [
13786
13802
  "REPLACE INTO",
13787
13803
  "VALUES",
13788
13804
  // - update:
13789
- "SET"
13790
- ]), cT = r(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), hE = r([
13805
+ "SET",
13806
+ // other:
13807
+ "RETURNING"
13808
+ ]), cT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), fE = _([
13791
13809
  // - create:
13792
13810
  "CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
13793
13811
  // - update:
@@ -13806,27 +13824,28 @@ const AS = [
13806
13824
  "RENAME TO",
13807
13825
  // - set schema
13808
13826
  "SET SCHEMA"
13809
- ]), NS = r(["UNION [ALL]", "EXCEPT", "INTERSECT"]), tS = r([
13827
+ ]), MS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), US = _([
13810
13828
  "JOIN",
13811
13829
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13812
13830
  "{INNER | CROSS} JOIN",
13813
13831
  "NATURAL [INNER] JOIN",
13814
13832
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
13815
- ]), sS = r([
13833
+ ]), GS = _([
13816
13834
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
13817
13835
  "{ROWS | RANGE | GROUPS} BETWEEN",
13818
13836
  "DO UPDATE"
13819
- ]), CS = {
13837
+ ]), lS = _([]), cS = {
13820
13838
  name: "sqlite",
13821
13839
  tokenizerOptions: {
13822
- reservedSelect: IS,
13823
- reservedClauses: [...OS, ...cT, ...hE],
13824
- reservedSetOperations: NS,
13825
- reservedJoins: tS,
13826
- reservedPhrases: sS,
13827
- reservedKeywords: eS,
13828
- reservedDataTypes: SS,
13829
- reservedFunctionNames: AS,
13840
+ reservedSelect: oS,
13841
+ reservedClauses: [...PS, ...cT, ...fE],
13842
+ reservedSetOperations: MS,
13843
+ reservedJoins: US,
13844
+ reservedKeywordPhrases: GS,
13845
+ reservedDataTypePhrases: lS,
13846
+ reservedKeywords: DS,
13847
+ reservedDataTypes: aS,
13848
+ reservedFunctionNames: iS,
13830
13849
  stringTypes: [
13831
13850
  "''-qq",
13832
13851
  { quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
@@ -13839,10 +13858,10 @@ const AS = [
13839
13858
  operators: ["%", "~", "&", "|", "<<", ">>", "==", "->", "->>", "||"]
13840
13859
  },
13841
13860
  formatOptions: {
13842
- onelineClauses: [...cT, ...hE],
13843
- tabularOnelineClauses: hE
13861
+ onelineClauses: [...cT, ...fE],
13862
+ tabularOnelineClauses: fE
13844
13863
  }
13845
- }, LS = [
13864
+ }, uS = [
13846
13865
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
13847
13866
  "GROUPING",
13848
13867
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_10_window_function
@@ -13939,7 +13958,7 @@ const AS = [
13939
13958
  "ASIN",
13940
13959
  "ACOS",
13941
13960
  "ATAN"
13942
- ], _S = [
13961
+ ], HS = [
13943
13962
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
13944
13963
  "ALL",
13945
13964
  "ALLOCATE",
@@ -14137,7 +14156,7 @@ const AS = [
14137
14156
  "WITHIN",
14138
14157
  "WITHOUT",
14139
14158
  "YEAR"
14140
- ], rS = [
14159
+ ], BS = [
14141
14160
  // https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
14142
14161
  "ARRAY",
14143
14162
  "BIGINT",
@@ -14177,7 +14196,7 @@ const AS = [
14177
14196
  "TIMESTAMP",
14178
14197
  "VARBINARY",
14179
14198
  "VARCHAR"
14180
- ], nS = r(["SELECT [ALL | DISTINCT]"]), iS = r([
14199
+ ], mS = _(["SELECT [ALL | DISTINCT]"]), FS = _([
14181
14200
  // queries
14182
14201
  "WITH [RECURSIVE]",
14183
14202
  "FROM",
@@ -14196,7 +14215,7 @@ const AS = [
14196
14215
  "VALUES",
14197
14216
  // - update:
14198
14217
  "SET"
14199
- ]), uT = r(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), VE = r([
14218
+ ]), uT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), VE = _([
14200
14219
  // - create:
14201
14220
  "CREATE [RECURSIVE] VIEW",
14202
14221
  // - update:
@@ -14221,30 +14240,31 @@ const AS = [
14221
14240
  "TRUNCATE TABLE",
14222
14241
  // other
14223
14242
  "SET SCHEMA"
14224
- ]), DS = r([
14243
+ ]), YS = _([
14225
14244
  "UNION [ALL | DISTINCT]",
14226
14245
  "EXCEPT [ALL | DISTINCT]",
14227
14246
  "INTERSECT [ALL | DISTINCT]"
14228
- ]), aS = r([
14247
+ ]), pS = _([
14229
14248
  "JOIN",
14230
14249
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14231
14250
  "{INNER | CROSS} JOIN",
14232
14251
  "NATURAL [INNER] JOIN",
14233
14252
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14234
- ]), oS = r([
14253
+ ]), dS = _([
14235
14254
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14236
14255
  "{ROWS | RANGE} BETWEEN"
14237
- ]), PS = {
14256
+ ]), hS = _([]), fS = {
14238
14257
  name: "sql",
14239
14258
  tokenizerOptions: {
14240
- reservedSelect: nS,
14241
- reservedClauses: [...iS, ...uT, ...VE],
14242
- reservedSetOperations: DS,
14243
- reservedJoins: aS,
14244
- reservedPhrases: oS,
14245
- reservedKeywords: _S,
14246
- reservedDataTypes: rS,
14247
- reservedFunctionNames: LS,
14259
+ reservedSelect: mS,
14260
+ reservedClauses: [...FS, ...uT, ...VE],
14261
+ reservedSetOperations: YS,
14262
+ reservedJoins: pS,
14263
+ reservedKeywordPhrases: dS,
14264
+ reservedDataTypePhrases: hS,
14265
+ reservedKeywords: HS,
14266
+ reservedDataTypes: BS,
14267
+ reservedFunctionNames: uS,
14248
14268
  stringTypes: [
14249
14269
  { quote: "''-qq-bs", prefixes: ["N", "U&"] },
14250
14270
  { quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
@@ -14257,7 +14277,7 @@ const AS = [
14257
14277
  onelineClauses: [...uT, ...VE],
14258
14278
  tabularOnelineClauses: VE
14259
14279
  }
14260
- }, MS = [
14280
+ }, VS = [
14261
14281
  // https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
14262
14282
  // rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
14263
14283
  // rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
@@ -14691,7 +14711,7 @@ const AS = [
14691
14711
  "NEXT",
14692
14712
  "PERMUTE",
14693
14713
  "PREV"
14694
- ], US = [
14714
+ ], WS = [
14695
14715
  // https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
14696
14716
  "ABSENT",
14697
14717
  "ADD",
@@ -14928,7 +14948,7 @@ const AS = [
14928
14948
  "WRAPPER",
14929
14949
  "WRITE",
14930
14950
  "ZONE"
14931
- ], GS = [
14951
+ ], XS = [
14932
14952
  // https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
14933
14953
  // or https://trino.io/docs/current/language/types.html
14934
14954
  "BIGINT",
@@ -14967,7 +14987,7 @@ const AS = [
14967
14987
  "CODEPOINTS",
14968
14988
  "FUNCTION",
14969
14989
  "JSONPATH"
14970
- ], lS = r(["SELECT [ALL | DISTINCT]"]), cS = r([
14990
+ ], bS = _(["SELECT [ALL | DISTINCT]"]), yS = _([
14971
14991
  // queries
14972
14992
  "WITH [RECURSIVE]",
14973
14993
  "FROM",
@@ -14995,7 +15015,7 @@ const AS = [
14995
15015
  "PATTERN",
14996
15016
  "SUBSET",
14997
15017
  "DEFINE"
14998
- ]), HT = r(["CREATE TABLE [IF NOT EXISTS]"]), WE = r([
15018
+ ]), HT = _(["CREATE TABLE [IF NOT EXISTS]"]), WE = _([
14999
15019
  // - create:
15000
15020
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW",
15001
15021
  // - update:
@@ -15053,31 +15073,32 @@ const AS = [
15053
15073
  "SHOW ROLE GRANTS",
15054
15074
  "SHOW FUNCTIONS",
15055
15075
  "SHOW SESSION"
15056
- ]), uS = r([
15076
+ ]), KS = _([
15057
15077
  "UNION [ALL | DISTINCT]",
15058
15078
  "EXCEPT [ALL | DISTINCT]",
15059
15079
  "INTERSECT [ALL | DISTINCT]"
15060
- ]), HS = r([
15080
+ ]), $S = _([
15061
15081
  "JOIN",
15062
15082
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15063
15083
  "{INNER | CROSS} JOIN",
15064
15084
  "NATURAL [INNER] JOIN",
15065
15085
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
15066
- ]), BS = r([
15086
+ ]), gS = _([
15067
15087
  "{ROWS | RANGE | GROUPS} BETWEEN",
15068
15088
  // comparison operator
15069
15089
  "IS [NOT] DISTINCT FROM"
15070
- ]), mS = {
15090
+ ]), wS = _([]), JS = {
15071
15091
  name: "trino",
15072
15092
  tokenizerOptions: {
15073
- reservedSelect: lS,
15074
- reservedClauses: [...cS, ...HT, ...WE],
15075
- reservedSetOperations: uS,
15076
- reservedJoins: HS,
15077
- reservedPhrases: BS,
15078
- reservedKeywords: US,
15079
- reservedDataTypes: GS,
15080
- reservedFunctionNames: MS,
15093
+ reservedSelect: bS,
15094
+ reservedClauses: [...yS, ...HT, ...WE],
15095
+ reservedSetOperations: KS,
15096
+ reservedJoins: $S,
15097
+ reservedKeywordPhrases: gS,
15098
+ reservedDataTypePhrases: wS,
15099
+ reservedKeywords: WS,
15100
+ reservedDataTypes: XS,
15101
+ reservedFunctionNames: VS,
15081
15102
  // Trino also supports {- ... -} parenthesis.
15082
15103
  // The formatting of these currently works out as a result of { and -
15083
15104
  // not getting a space added in-between.
@@ -15109,7 +15130,7 @@ const AS = [
15109
15130
  onelineClauses: [...HT, ...WE],
15110
15131
  tabularOnelineClauses: WE
15111
15132
  }
15112
- }, FS = [
15133
+ }, xS = [
15113
15134
  // https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
15114
15135
  // aggregate
15115
15136
  "APPROX_COUNT_DISTINCT",
@@ -15414,7 +15435,7 @@ const AS = [
15414
15435
  // Shorthand functions to use in place of CASE expression
15415
15436
  "COALESCE",
15416
15437
  "NULLIF"
15417
- ], YS = [
15438
+ ], vS = [
15418
15439
  // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
15419
15440
  // standard
15420
15441
  "ADD",
@@ -15595,7 +15616,7 @@ const AS = [
15595
15616
  "WRITETEXT",
15596
15617
  // https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver16#action
15597
15618
  "$ACTION"
15598
- ], pS = [
15619
+ ], QS = [
15599
15620
  // https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15
15600
15621
  "BINARY",
15601
15622
  "BIT",
@@ -15622,7 +15643,7 @@ const AS = [
15622
15643
  "TIMESTAMP",
15623
15644
  "VARBINARY",
15624
15645
  "VARCHAR"
15625
- ], dS = r(["SELECT [ALL | DISTINCT]"]), fS = r([
15646
+ ], ZS = _(["SELECT [ALL | DISTINCT]"]), qS = _([
15626
15647
  // queries
15627
15648
  "WITH",
15628
15649
  "INTO",
@@ -15646,10 +15667,8 @@ const AS = [
15646
15667
  // - merge:
15647
15668
  "MERGE [INTO]",
15648
15669
  "WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
15649
- "UPDATE SET",
15650
- // Data definition
15651
- "CREATE [OR ALTER] {PROC | PROCEDURE}"
15652
- ]), BT = r(["CREATE TABLE"]), XE = r([
15670
+ "UPDATE SET"
15671
+ ]), BT = _(["CREATE TABLE"]), XE = _([
15653
15672
  // - create:
15654
15673
  "CREATE [OR ALTER] [MATERIALIZED] VIEW",
15655
15674
  // - update:
@@ -15672,6 +15691,10 @@ const AS = [
15672
15691
  "CREATE DATABASE",
15673
15692
  "ALTER DATABASE",
15674
15693
  "DROP DATABASE [IF EXISTS]",
15694
+ // functions/procedures
15695
+ "CREATE [OR ALTER] [PARTITION] {FUNCTION | PROCEDURE | PROC}",
15696
+ "ALTER [PARTITION] {FUNCTION | PROCEDURE | PROC}",
15697
+ "DROP [PARTITION] {FUNCTION | PROCEDURE | PROC} [IF EXISTS]",
15675
15698
  // other statements
15676
15699
  "GO",
15677
15700
  "USE",
@@ -15703,7 +15726,6 @@ const AS = [
15703
15726
  "CERTIFICATE",
15704
15727
  "CLOSE MASTER KEY",
15705
15728
  "CLOSE SYMMETRIC KEY",
15706
- "COLLATE",
15707
15729
  "COLUMN ENCRYPTION KEY",
15708
15730
  "COLUMN MASTER KEY",
15709
15731
  "COLUMNSTORE INDEX",
@@ -15744,7 +15766,6 @@ const AS = [
15744
15766
  "FULLTEXT CATALOG",
15745
15767
  "FULLTEXT INDEX",
15746
15768
  "FULLTEXT STOPLIST",
15747
- "FUNCTION",
15748
15769
  "GET CONVERSATION GROUP",
15749
15770
  "GET_TRANSMISSION_STATUS",
15750
15771
  "GRANT",
@@ -15765,9 +15786,7 @@ const AS = [
15765
15786
  "OPEN MASTER KEY",
15766
15787
  "OPEN SYMMETRIC KEY",
15767
15788
  "PARSEONLY",
15768
- "PARTITION FUNCTION",
15769
15789
  "PARTITION SCHEME",
15770
- "PROCEDURE",
15771
15790
  "QUERY_GOVERNOR_COST_LIMIT",
15772
15791
  "QUEUE",
15773
15792
  "QUOTED_IDENTIFIER",
@@ -15829,26 +15848,27 @@ const AS = [
15829
15848
  "XACT_ABORT",
15830
15849
  "XML INDEX",
15831
15850
  "XML SCHEMA COLLECTION"
15832
- ]), hS = r(["UNION [ALL]", "EXCEPT", "INTERSECT"]), VS = r([
15851
+ ]), jS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), kS = _([
15833
15852
  "JOIN",
15834
15853
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15835
15854
  "{INNER | CROSS} JOIN",
15836
15855
  // non-standard joins
15837
15856
  "{CROSS | OUTER} APPLY"
15838
- ]), WS = r([
15857
+ ]), zS = _([
15839
15858
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
15840
15859
  "{ROWS | RANGE} BETWEEN"
15841
- ]), XS = {
15860
+ ]), EI = _([]), TI = {
15842
15861
  name: "transactsql",
15843
15862
  tokenizerOptions: {
15844
- reservedSelect: dS,
15845
- reservedClauses: [...fS, ...BT, ...XE],
15846
- reservedSetOperations: hS,
15847
- reservedJoins: VS,
15848
- reservedPhrases: WS,
15849
- reservedKeywords: YS,
15850
- reservedDataTypes: pS,
15851
- reservedFunctionNames: FS,
15863
+ reservedSelect: ZS,
15864
+ reservedClauses: [...qS, ...BT, ...XE],
15865
+ reservedSetOperations: jS,
15866
+ reservedJoins: kS,
15867
+ reservedKeywordPhrases: zS,
15868
+ reservedDataTypePhrases: EI,
15869
+ reservedKeywords: vS,
15870
+ reservedDataTypes: QS,
15871
+ reservedFunctionNames: xS,
15852
15872
  nestedBlockComments: !0,
15853
15873
  stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
15854
15874
  identTypes: ['""-qq', "[]"],
@@ -15881,7 +15901,7 @@ const AS = [
15881
15901
  onelineClauses: [...BT, ...XE],
15882
15902
  tabularOnelineClauses: XE
15883
15903
  }
15884
- }, bS = [
15904
+ }, RI = [
15885
15905
  // List of all keywords taken from:
15886
15906
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
15887
15907
  // Then filtered down to reserved keywords by running
@@ -16094,7 +16114,7 @@ const AS = [
16094
16114
  "XOR",
16095
16115
  "YEAR_MONTH",
16096
16116
  "ZEROFILL"
16097
- ], yS = [
16117
+ ], AI = [
16098
16118
  // https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
16099
16119
  "BIGINT",
16100
16120
  "BINARY",
@@ -16143,7 +16163,7 @@ const AS = [
16143
16163
  "VARCHAR",
16144
16164
  "VARCHARACTER",
16145
16165
  "YEAR"
16146
- ], KS = [
16166
+ ], eI = [
16147
16167
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
16148
16168
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
16149
16169
  // https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
@@ -16423,7 +16443,7 @@ const AS = [
16423
16443
  "WEEKDAY",
16424
16444
  "WEEKOFYEAR",
16425
16445
  "YEAR"
16426
- ], $S = r(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), gS = r([
16446
+ ], SI = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), II = _([
16427
16447
  // queries
16428
16448
  "WITH",
16429
16449
  "FROM",
@@ -16445,9 +16465,9 @@ const AS = [
16445
16465
  // Data definition
16446
16466
  "CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
16447
16467
  "CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
16448
- ]), mT = r([
16468
+ ]), mT = _([
16449
16469
  "CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
16450
- ]), bE = r([
16470
+ ]), bE = _([
16451
16471
  // - create:
16452
16472
  "CREATE VIEW",
16453
16473
  // - update:
@@ -16624,35 +16644,36 @@ const AS = [
16624
16644
  "REPEAT",
16625
16645
  "RETURN",
16626
16646
  "WHILE"
16627
- ]), JS = r([
16647
+ ]), OI = _([
16628
16648
  "UNION [ALL | DISTINCT]",
16629
16649
  "EXCEPT",
16630
16650
  "INTERSECT",
16631
16651
  "MINUS"
16632
- ]), wS = r([
16652
+ ]), NI = _([
16633
16653
  "JOIN",
16634
16654
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16635
16655
  "{INNER | CROSS} JOIN",
16636
16656
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
16637
16657
  // non-standard joins
16638
16658
  "STRAIGHT_JOIN"
16639
- ]), xS = r([
16659
+ ]), sI = _([
16640
16660
  "ON DELETE",
16641
16661
  "ON UPDATE",
16642
16662
  "CHARACTER SET",
16643
16663
  "{ROWS | RANGE} BETWEEN",
16644
16664
  "IDENTIFIED BY"
16645
- ]), vS = {
16665
+ ]), tI = _([]), CI = {
16646
16666
  name: "singlestoredb",
16647
16667
  tokenizerOptions: {
16648
- reservedSelect: $S,
16649
- reservedClauses: [...gS, ...mT, ...bE],
16650
- reservedSetOperations: JS,
16651
- reservedJoins: wS,
16652
- reservedPhrases: xS,
16653
- reservedKeywords: bS,
16654
- reservedDataTypes: yS,
16655
- reservedFunctionNames: KS,
16668
+ reservedSelect: SI,
16669
+ reservedClauses: [...II, ...mT, ...bE],
16670
+ reservedSetOperations: OI,
16671
+ reservedJoins: NI,
16672
+ reservedKeywordPhrases: sI,
16673
+ reservedDataTypePhrases: tI,
16674
+ reservedKeywords: RI,
16675
+ reservedDataTypes: AI,
16676
+ reservedFunctionNames: eI,
16656
16677
  // TODO: support _binary"some string" prefix
16657
16678
  stringTypes: [
16658
16679
  '""-qq-bs',
@@ -16692,7 +16713,7 @@ const AS = [
16692
16713
  onelineClauses: [...mT, ...bE],
16693
16714
  tabularOnelineClauses: bE
16694
16715
  }
16695
- }, QS = [
16716
+ }, LI = [
16696
16717
  // https://docs.snowflake.com/en/sql-reference-functions.html
16697
16718
  //
16698
16719
  // https://docs.snowflake.com/en/sql-reference/functions-all.html
@@ -16913,6 +16934,7 @@ const AS = [
16913
16934
  "HOUR",
16914
16935
  "MINUTE",
16915
16936
  "SECOND",
16937
+ "IDENTIFIER",
16916
16938
  "IFF",
16917
16939
  "IFNULL",
16918
16940
  "ILIKE",
@@ -17299,7 +17321,7 @@ const AS = [
17299
17321
  "QUARTER",
17300
17322
  "ZEROIFNULL",
17301
17323
  "ZIPF"
17302
- ], ZS = [
17324
+ ], _I = [
17303
17325
  // https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
17304
17326
  //
17305
17327
  // run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
@@ -17396,7 +17418,7 @@ const AS = [
17396
17418
  "WITH",
17397
17419
  // These are definitely keywords, but haven't found a definite list in the docs
17398
17420
  "COMMENT"
17399
- ], qS = [
17421
+ ], rI = [
17400
17422
  "NUMBER",
17401
17423
  "DECIMAL",
17402
17424
  "NUMERIC",
@@ -17433,7 +17455,7 @@ const AS = [
17433
17455
  "ARRAY",
17434
17456
  "GEOGRAPHY",
17435
17457
  "GEOMETRY"
17436
- ], jS = r(["SELECT [ALL | DISTINCT]"]), kS = r([
17458
+ ], nI = _(["SELECT [ALL | DISTINCT]"]), iI = _([
17437
17459
  // queries
17438
17460
  "WITH [RECURSIVE]",
17439
17461
  "FROM",
@@ -17461,10 +17483,10 @@ const AS = [
17461
17483
  "WHEN MATCHED [AND]",
17462
17484
  "THEN {UPDATE SET | DELETE}",
17463
17485
  "WHEN NOT MATCHED THEN INSERT"
17464
- ]), FT = r([
17486
+ ]), FT = _([
17465
17487
  "CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
17466
17488
  "CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
17467
- ]), yE = r([
17489
+ ]), yE = _([
17468
17490
  // - create:
17469
17491
  "CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
17470
17492
  // - update:
@@ -17705,24 +17727,25 @@ const AS = [
17705
17727
  "USE SCHEMA",
17706
17728
  "USE SECONDARY ROLES",
17707
17729
  "USE WAREHOUSE"
17708
- ]), zS = r(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), EI = r([
17730
+ ]), DI = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), aI = _([
17709
17731
  "[INNER] JOIN",
17710
17732
  "[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
17711
17733
  "{CROSS | NATURAL} JOIN"
17712
- ]), TI = r([
17734
+ ]), oI = _([
17713
17735
  "{ROWS | RANGE} BETWEEN",
17714
17736
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
17715
- ]), RI = {
17737
+ ]), PI = _([]), MI = {
17716
17738
  name: "snowflake",
17717
17739
  tokenizerOptions: {
17718
- reservedSelect: jS,
17719
- reservedClauses: [...kS, ...FT, ...yE],
17720
- reservedSetOperations: zS,
17721
- reservedJoins: EI,
17722
- reservedPhrases: TI,
17723
- reservedKeywords: ZS,
17724
- reservedDataTypes: qS,
17725
- reservedFunctionNames: QS,
17740
+ reservedSelect: nI,
17741
+ reservedClauses: [...iI, ...FT, ...yE],
17742
+ reservedSetOperations: DI,
17743
+ reservedJoins: aI,
17744
+ reservedKeywordPhrases: oI,
17745
+ reservedDataTypePhrases: PI,
17746
+ reservedKeywords: _I,
17747
+ reservedDataTypes: rI,
17748
+ reservedFunctionNames: LI,
17726
17749
  stringTypes: ["$$", "''-qq-bs"],
17727
17750
  identTypes: ['""-qq'],
17728
17751
  variableTypes: [
@@ -17755,51 +17778,51 @@ const AS = [
17755
17778
  onelineClauses: [...FT, ...yE],
17756
17779
  tabularOnelineClauses: yE
17757
17780
  }
17758
- }, AI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17781
+ }, UI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
17759
17782
  __proto__: null,
17760
- bigquery: qR,
17761
- db2: tA,
17762
- db2i: aA,
17763
- duckdb: HA,
17764
- hive: VA,
17765
- mariadb: wA,
17766
- mysql: Ee,
17767
- n1ql: ae,
17768
- plsql: He,
17769
- postgresql: We,
17770
- redshift: xe,
17771
- singlestoredb: vS,
17772
- snowflake: RI,
17773
- spark: TS,
17774
- sql: PS,
17775
- sqlite: CS,
17776
- tidb: te,
17777
- transactsql: XS,
17778
- trino: mS
17779
- }, Symbol.toStringTag, { value: "Module" })), EE = (T) => T[T.length - 1], kT = (T) => T.sort((E, R) => R.length - E.length || E.localeCompare(R)), AE = (T) => T.replace(/\s+/gu, " "), KE = (T) => /\n/.test(T), X = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), YT = /\s+/uy, w = (T) => new RegExp(`(?:${T})`, "uy"), eI = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), SI = (T) => T + "(?:-" + T + ")*", II = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(eI).join("|")}${E ? "" : "|"})`, OI = (T) => new RegExp(`(?:${T.map(X).join("|")}).*?(?=\r
17783
+ bigquery: jR,
17784
+ db2: CA,
17785
+ db2i: MA,
17786
+ duckdb: YA,
17787
+ hive: KA,
17788
+ mariadb: jA,
17789
+ mysql: Oe,
17790
+ n1ql: He,
17791
+ plsql: We,
17792
+ postgresql: Qe,
17793
+ redshift: eS,
17794
+ singlestoredb: CI,
17795
+ snowflake: MI,
17796
+ spark: rS,
17797
+ sql: fS,
17798
+ sqlite: cS,
17799
+ tidb: De,
17800
+ transactsql: TI,
17801
+ trino: JS
17802
+ }, Symbol.toStringTag, { value: "Module" })), EE = (T) => T[T.length - 1], kT = (T) => T.sort((E, R) => R.length - E.length || E.localeCompare(R)), AE = (T) => T.replace(/\s+/gu, " "), KE = (T) => /\n/.test(T), X = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), YT = /\s+/uy, J = (T) => new RegExp(`(?:${T})`, "uy"), GI = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), lI = (T) => T + "(?:-" + T + ")*", cI = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(GI).join("|")}${E ? "" : "|"})`, uI = (T) => new RegExp(`(?:${T.map(X).join("|")}).*?(?=\r
17780
17803
  |\r|
17781
17804
  |$)`, "uy"), pT = (T, E = []) => {
17782
17805
  const R = T === "open" ? 0 : 1, A = ["()", ...E].map((e) => e[R]);
17783
- return w(A.map(X).join("|"));
17784
- }, dT = (T) => w(`${kT(T).map(X).join("|")}`), NI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", y = (T, E = {}) => {
17806
+ return J(A.map(X).join("|"));
17807
+ }, dT = (T) => J(`${kT(T).map(X).join("|")}`), HI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", y = (T, E = {}) => {
17785
17808
  if (T.length === 0)
17786
17809
  return /^\b$/u;
17787
- const R = NI(E), A = kT(T).map(X).join("|").replace(/ /gu, "\\s+");
17810
+ const R = HI(E), A = kT(T).map(X).join("|").replace(/ /gu, "\\s+");
17788
17811
  return new RegExp(`(?:${A})${R}\\b`, "iuy");
17789
17812
  }, $E = (T, E) => {
17790
17813
  if (!T.length)
17791
17814
  return;
17792
17815
  const R = T.map(X).join("|");
17793
- return w(`(?:${R})(?:${E})`);
17794
- }, tI = () => {
17816
+ return J(`(?:${R})(?:${E})`);
17817
+ }, BI = () => {
17795
17818
  const T = {
17796
17819
  "<": ">",
17797
17820
  "[": "]",
17798
17821
  "(": ")",
17799
17822
  "{": "}"
17800
- }, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([N, s]) => E.replace(/{left}/g, X(N)).replace(/{right}/g, X(s))), A = X(Object.keys(T).join(""));
17823
+ }, E = "{left}(?:(?!{right}').)*?{right}", R = Object.entries(T).map(([N, t]) => E.replace(/{left}/g, X(N)).replace(/{right}/g, X(t))), A = X(Object.keys(T).join(""));
17801
17824
  return `[Qq]'(?:${String.raw`(?<tag>[^\s${A}])(?:(?!\k<tag>').)*?\k<tag>`}|${R.join("|")})'`;
17802
- }, fT = {
17825
+ }, hT = {
17803
17826
  // - backtick quoted (using `` to escape)
17804
17827
  "``": "(?:`[^`]*`)+",
17805
17828
  // - Transact-SQL square bracket quoted (using ]] to escape)
@@ -17823,16 +17846,16 @@ const AS = [
17823
17846
  // Hive and Spark variables: ${name}
17824
17847
  "{}": String.raw`(?:\{[^\}]*\})`,
17825
17848
  // Oracle q'' strings: q'<text>' q'|text|' ...
17826
- "q''": tI()
17827
- }, zT = (T) => typeof T == "string" ? fT[T] : "regex" in T ? T.regex : II(T) + fT[T.quote], sI = (T) => w(T.map((E) => "regex" in E ? E.regex : zT(E)).join("|")), ER = (T) => T.map(zT).join("|"), hT = (T) => w(ER(T)), CI = (T = {}) => w(TR(T)), TR = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
17828
- const e = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", N = X(T ?? ""), s = X(E ?? ""), _ = A ? `[${e}${S}${N}][${e}${S}${s}]*` : `[${e}${N}][${e}${S}${s}]*`;
17829
- return R ? SI(_) : _;
17849
+ "q''": BI()
17850
+ }, zT = (T) => typeof T == "string" ? hT[T] : "regex" in T ? T.regex : cI(T) + hT[T.quote], mI = (T) => J(T.map((E) => "regex" in E ? E.regex : zT(E)).join("|")), ER = (T) => T.map(zT).join("|"), fT = (T) => J(ER(T)), FI = (T = {}) => J(TR(T)), TR = ({ first: T, rest: E, dashes: R, allowFirstCharNumber: A } = {}) => {
17851
+ const e = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", N = X(T ?? ""), t = X(E ?? ""), r = A ? `[${e}${S}${N}][${e}${S}${t}]*` : `[${e}${N}][${e}${S}${t}]*`;
17852
+ return R ? lI(r) : r;
17830
17853
  };
17831
17854
  function RR(T, E) {
17832
17855
  const R = T.slice(0, E).split(/\n/);
17833
17856
  return { line: R.length, col: R[R.length - 1].length + 1 };
17834
17857
  }
17835
- class LI {
17858
+ class YI {
17836
17859
  constructor(E, R) {
17837
17860
  this.rules = E, this.dialectName = R, this.input = "", this.index = 0;
17838
17861
  }
@@ -17894,8 +17917,8 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
17894
17917
  }
17895
17918
  }
17896
17919
  }
17897
- const VT = /\/\*/uy, _I = /[\s\S]/uy, rI = /\*\//uy;
17898
- class nI {
17920
+ const VT = /\/\*/uy, pI = /[\s\S]/uy, dI = /\*\//uy;
17921
+ class hI {
17899
17922
  constructor() {
17900
17923
  this.lastIndex = 0;
17901
17924
  }
@@ -17908,9 +17931,9 @@ class nI {
17908
17931
  for (; e > 0; )
17909
17932
  if (A = this.matchSection(VT, E))
17910
17933
  R += A, e++;
17911
- else if (A = this.matchSection(rI, E))
17934
+ else if (A = this.matchSection(dI, E))
17912
17935
  R += A, e--;
17913
- else if (A = this.matchSection(_I, E))
17936
+ else if (A = this.matchSection(pI, E))
17914
17937
  R += A;
17915
17938
  else
17916
17939
  return null;
@@ -17922,7 +17945,7 @@ class nI {
17922
17945
  return A && (this.lastIndex += A[0].length), A ? A[0] : null;
17923
17946
  }
17924
17947
  }
17925
- class iI {
17948
+ class fI {
17926
17949
  constructor(E, R) {
17927
17950
  this.cfg = E, this.dialectName = R, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
17928
17951
  }
@@ -17931,110 +17954,115 @@ class iI {
17931
17954
  ...this.rulesBeforeParams,
17932
17955
  ...this.buildParamRules(this.cfg, R),
17933
17956
  ...this.rulesAfterParams
17934
- ], e = new LI(A, this.dialectName).tokenize(E);
17957
+ ], e = new YI(A, this.dialectName).tokenize(E);
17935
17958
  return this.cfg.postProcess ? this.cfg.postProcess(e) : e;
17936
17959
  }
17937
17960
  // These rules can be cached as they only depend on
17938
17961
  // the Tokenizer config options specified for each SQL dialect
17939
17962
  buildRulesBeforeParams(E) {
17940
- var R, A;
17963
+ var R, A, e;
17941
17964
  return this.validRules([
17942
17965
  {
17943
- type: D.BLOCK_COMMENT,
17966
+ type: D.DISABLE_COMMENT,
17944
17967
  regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
17945
17968
  },
17946
17969
  {
17947
17970
  type: D.BLOCK_COMMENT,
17948
- regex: E.nestedBlockComments ? new nI() : /(\/\*[^]*?\*\/)/uy
17971
+ regex: E.nestedBlockComments ? new hI() : /(\/\*[^]*?\*\/)/uy
17949
17972
  },
17950
17973
  {
17951
17974
  type: D.LINE_COMMENT,
17952
- regex: OI((R = E.lineCommentTypes) !== null && R !== void 0 ? R : ["--"])
17975
+ regex: uI((R = E.lineCommentTypes) !== null && R !== void 0 ? R : ["--"])
17953
17976
  },
17954
17977
  {
17955
17978
  type: D.QUOTED_IDENTIFIER,
17956
- regex: hT(E.identTypes)
17979
+ regex: fT(E.identTypes)
17957
17980
  },
17958
17981
  {
17959
17982
  type: D.NUMBER,
17960
- regex: /(?: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
17983
+ 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
17961
17984
  },
17962
- // RESERVED_PHRASE is matched before all other keyword tokens
17985
+ // RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
17963
17986
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
17964
17987
  {
17965
- type: D.RESERVED_PHRASE,
17966
- regex: y((A = E.reservedPhrases) !== null && A !== void 0 ? A : [], E.identChars),
17967
- text: m
17988
+ type: D.RESERVED_KEYWORD_PHRASE,
17989
+ regex: y((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
17990
+ text: B
17991
+ },
17992
+ {
17993
+ type: D.RESERVED_DATA_TYPE_PHRASE,
17994
+ regex: y((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
17995
+ text: B
17968
17996
  },
17969
17997
  {
17970
17998
  type: D.CASE,
17971
17999
  regex: /CASE\b/iuy,
17972
- text: m
18000
+ text: B
17973
18001
  },
17974
18002
  {
17975
18003
  type: D.END,
17976
18004
  regex: /END\b/iuy,
17977
- text: m
18005
+ text: B
17978
18006
  },
17979
18007
  {
17980
18008
  type: D.BETWEEN,
17981
18009
  regex: /BETWEEN\b/iuy,
17982
- text: m
18010
+ text: B
17983
18011
  },
17984
18012
  {
17985
18013
  type: D.LIMIT,
17986
18014
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
17987
- text: m
18015
+ text: B
17988
18016
  },
17989
18017
  {
17990
18018
  type: D.RESERVED_CLAUSE,
17991
18019
  regex: y(E.reservedClauses, E.identChars),
17992
- text: m
18020
+ text: B
17993
18021
  },
17994
18022
  {
17995
18023
  type: D.RESERVED_SELECT,
17996
18024
  regex: y(E.reservedSelect, E.identChars),
17997
- text: m
18025
+ text: B
17998
18026
  },
17999
18027
  {
18000
18028
  type: D.RESERVED_SET_OPERATION,
18001
18029
  regex: y(E.reservedSetOperations, E.identChars),
18002
- text: m
18030
+ text: B
18003
18031
  },
18004
18032
  {
18005
18033
  type: D.WHEN,
18006
18034
  regex: /WHEN\b/iuy,
18007
- text: m
18035
+ text: B
18008
18036
  },
18009
18037
  {
18010
18038
  type: D.ELSE,
18011
18039
  regex: /ELSE\b/iuy,
18012
- text: m
18040
+ text: B
18013
18041
  },
18014
18042
  {
18015
18043
  type: D.THEN,
18016
18044
  regex: /THEN\b/iuy,
18017
- text: m
18045
+ text: B
18018
18046
  },
18019
18047
  {
18020
18048
  type: D.RESERVED_JOIN,
18021
18049
  regex: y(E.reservedJoins, E.identChars),
18022
- text: m
18050
+ text: B
18023
18051
  },
18024
18052
  {
18025
18053
  type: D.AND,
18026
18054
  regex: /AND\b/iuy,
18027
- text: m
18055
+ text: B
18028
18056
  },
18029
18057
  {
18030
18058
  type: D.OR,
18031
18059
  regex: /OR\b/iuy,
18032
- text: m
18060
+ text: B
18033
18061
  },
18034
18062
  {
18035
18063
  type: D.XOR,
18036
18064
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18037
- text: m
18065
+ text: B
18038
18066
  },
18039
18067
  ...E.operatorKeyword ? [
18040
18068
  {
@@ -18045,17 +18073,17 @@ class iI {
18045
18073
  {
18046
18074
  type: D.RESERVED_FUNCTION_NAME,
18047
18075
  regex: y(E.reservedFunctionNames, E.identChars),
18048
- text: m
18076
+ text: B
18049
18077
  },
18050
18078
  {
18051
18079
  type: D.RESERVED_DATA_TYPE,
18052
18080
  regex: y(E.reservedDataTypes, E.identChars),
18053
- text: m
18081
+ text: B
18054
18082
  },
18055
18083
  {
18056
18084
  type: D.RESERVED_KEYWORD,
18057
18085
  regex: y(E.reservedKeywords, E.identChars),
18058
- text: m
18086
+ text: B
18059
18087
  }
18060
18088
  ]);
18061
18089
  }
@@ -18066,12 +18094,12 @@ class iI {
18066
18094
  return this.validRules([
18067
18095
  {
18068
18096
  type: D.VARIABLE,
18069
- regex: E.variableTypes ? sI(E.variableTypes) : void 0
18097
+ regex: E.variableTypes ? mI(E.variableTypes) : void 0
18070
18098
  },
18071
- { type: D.STRING, regex: hT(E.stringTypes) },
18099
+ { type: D.STRING, regex: fT(E.stringTypes) },
18072
18100
  {
18073
18101
  type: D.IDENTIFIER,
18074
- regex: CI(E.identChars)
18102
+ regex: FI(E.identChars)
18075
18103
  },
18076
18104
  { type: D.DELIMITER, regex: /[;]/uy },
18077
18105
  { type: D.COMMA, regex: /[,]/y },
@@ -18110,43 +18138,43 @@ class iI {
18110
18138
  // These rules can't be blindly cached as the paramTypesOverrides object
18111
18139
  // can differ on each invocation of the format() function.
18112
18140
  buildParamRules(E, R) {
18113
- var A, e, S, N, s;
18114
- const _ = {
18141
+ var A, e, S, N, t;
18142
+ const r = {
18115
18143
  named: R?.named || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.named) || [],
18116
18144
  quoted: R?.quoted || ((e = E.paramTypes) === null || e === void 0 ? void 0 : e.quoted) || [],
18117
18145
  numbered: R?.numbered || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.numbered) || [],
18118
18146
  positional: typeof R?.positional == "boolean" ? R.positional : (N = E.paramTypes) === null || N === void 0 ? void 0 : N.positional,
18119
- custom: R?.custom || ((s = E.paramTypes) === null || s === void 0 ? void 0 : s.custom) || []
18147
+ custom: R?.custom || ((t = E.paramTypes) === null || t === void 0 ? void 0 : t.custom) || []
18120
18148
  };
18121
18149
  return this.validRules([
18122
18150
  {
18123
18151
  type: D.NAMED_PARAMETER,
18124
- regex: $E(_.named, TR(E.paramChars || E.identChars)),
18152
+ regex: $E(r.named, TR(E.paramChars || E.identChars)),
18125
18153
  key: (I) => I.slice(1)
18126
18154
  },
18127
18155
  {
18128
18156
  type: D.QUOTED_PARAMETER,
18129
- regex: $E(_.quoted, ER(E.identTypes)),
18130
- key: (I) => (({ tokenKey: O, quoteChar: t }) => O.replace(new RegExp(X("\\" + t), "gu"), t))({
18157
+ regex: $E(r.quoted, ER(E.identTypes)),
18158
+ key: (I) => (({ tokenKey: O, quoteChar: s }) => O.replace(new RegExp(X("\\" + s), "gu"), s))({
18131
18159
  tokenKey: I.slice(2, -1),
18132
18160
  quoteChar: I.slice(-1)
18133
18161
  })
18134
18162
  },
18135
18163
  {
18136
18164
  type: D.NUMBERED_PARAMETER,
18137
- regex: $E(_.numbered, "[0-9]+"),
18165
+ regex: $E(r.numbered, "[0-9]+"),
18138
18166
  key: (I) => I.slice(1)
18139
18167
  },
18140
18168
  {
18141
18169
  type: D.POSITIONAL_PARAMETER,
18142
- regex: _.positional ? /[?]/y : void 0
18170
+ regex: r.positional ? /[?]/y : void 0
18143
18171
  },
18144
- ..._.custom.map((I) => {
18172
+ ...r.custom.map((I) => {
18145
18173
  var O;
18146
18174
  return {
18147
18175
  type: D.CUSTOM_PARAMETER,
18148
- regex: w(I.regex),
18149
- key: (O = I.key) !== null && O !== void 0 ? O : ((t) => t)
18176
+ regex: J(I.regex),
18177
+ key: (O = I.key) !== null && O !== void 0 ? O : ((s) => s)
18150
18178
  };
18151
18179
  })
18152
18180
  ]);
@@ -18156,13 +18184,13 @@ class iI {
18156
18184
  return E.filter((R) => !!R.regex);
18157
18185
  }
18158
18186
  }
18159
- const m = (T) => AE(T.toUpperCase()), WT = /* @__PURE__ */ new Map(), DI = (T) => {
18187
+ const B = (T) => AE(T.toUpperCase()), WT = /* @__PURE__ */ new Map(), VI = (T) => {
18160
18188
  let E = WT.get(T);
18161
- return E || (E = aI(T), WT.set(T, E)), E;
18162
- }, aI = (T) => ({
18163
- tokenizer: new iI(T.tokenizerOptions, T.name),
18164
- formatOptions: oI(T.formatOptions)
18165
- }), oI = (T) => {
18189
+ return E || (E = WI(T), WT.set(T, E)), E;
18190
+ }, WI = (T) => ({
18191
+ tokenizer: new fI(T.tokenizerOptions, T.name),
18192
+ formatOptions: XI(T.formatOptions)
18193
+ }), XI = (T) => {
18166
18194
  var E;
18167
18195
  return {
18168
18196
  alwaysDenseOperators: T.alwaysDenseOperators || [],
@@ -18170,13 +18198,13 @@ const m = (T) => AE(T.toUpperCase()), WT = /* @__PURE__ */ new Map(), DI = (T) =
18170
18198
  tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((R) => [R, !0]))
18171
18199
  };
18172
18200
  };
18173
- function PI(T) {
18201
+ function bI(T) {
18174
18202
  return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
18175
18203
  }
18176
18204
  function q(T) {
18177
18205
  return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
18178
18206
  }
18179
- class MI {
18207
+ class yI {
18180
18208
  constructor(E) {
18181
18209
  this.params = E, this.index = 0;
18182
18210
  }
@@ -18199,24 +18227,24 @@ class MI {
18199
18227
  this.index = E;
18200
18228
  }
18201
18229
  }
18202
- function UI(T) {
18230
+ function KI(T) {
18203
18231
  return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
18204
18232
  }
18205
- var eE = { exports: {} }, GI = eE.exports, XT;
18206
- function lI() {
18233
+ var eE = { exports: {} }, $I = eE.exports, XT;
18234
+ function gI() {
18207
18235
  return XT || (XT = 1, (function(T) {
18208
18236
  (function(E, R) {
18209
18237
  T.exports ? T.exports = R() : E.nearley = R();
18210
- })(GI, function() {
18211
- function E(I, O, t) {
18212
- return this.id = ++E.highestId, this.name = I, this.symbols = O, this.postprocess = t, this;
18238
+ })($I, function() {
18239
+ function E(I, O, s) {
18240
+ return this.id = ++E.highestId, this.name = I, this.symbols = O, this.postprocess = s, this;
18213
18241
  }
18214
18242
  E.highestId = 0, E.prototype.toString = function(I) {
18215
- var O = typeof I > "u" ? this.symbols.map(_).join(" ") : this.symbols.slice(0, I).map(_).join(" ") + " ● " + this.symbols.slice(I).map(_).join(" ");
18243
+ var O = typeof I > "u" ? this.symbols.map(r).join(" ") : this.symbols.slice(0, I).map(r).join(" ") + " ● " + this.symbols.slice(I).map(r).join(" ");
18216
18244
  return this.name + " → " + O;
18217
18245
  };
18218
- function R(I, O, t, L) {
18219
- this.rule = I, this.dot = O, this.reference = t, this.data = [], this.wantedBy = L, this.isComplete = this.dot === I.symbols.length;
18246
+ function R(I, O, s, L) {
18247
+ this.rule = I, this.dot = O, this.reference = s, this.data = [], this.wantedBy = L, this.isComplete = this.dot === I.symbols.length;
18220
18248
  }
18221
18249
  R.prototype.toString = function() {
18222
18250
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
@@ -18236,7 +18264,7 @@ function lI() {
18236
18264
  this.grammar = I, this.index = O, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18237
18265
  }
18238
18266
  A.prototype.process = function(I) {
18239
- for (var O = this.states, t = this.wants, L = this.completed, a = 0; a < O.length; a++) {
18267
+ for (var O = this.states, s = this.wants, L = this.completed, a = 0; a < O.length; a++) {
18240
18268
  var o = O[a];
18241
18269
  if (o.isComplete) {
18242
18270
  if (o.finish(), o.data !== N.fail) {
@@ -18255,39 +18283,39 @@ function lI() {
18255
18283
  this.scannable.push(o);
18256
18284
  continue;
18257
18285
  }
18258
- if (t[l]) {
18259
- if (t[l].push(o), L.hasOwnProperty(l))
18286
+ if (s[l]) {
18287
+ if (s[l].push(o), L.hasOwnProperty(l))
18260
18288
  for (var c = L[l], U = 0; U < c.length; U++) {
18261
- var B = c[U];
18262
- this.complete(o, B);
18289
+ var m = c[U];
18290
+ this.complete(o, m);
18263
18291
  }
18264
18292
  } else
18265
- t[l] = [o], this.predict(l);
18293
+ s[l] = [o], this.predict(l);
18266
18294
  }
18267
18295
  }
18268
18296
  }, A.prototype.predict = function(I) {
18269
- for (var O = this.grammar.byName[I] || [], t = 0; t < O.length; t++) {
18270
- var L = O[t], a = this.wants[I], o = new R(L, 0, this.index, a);
18297
+ for (var O = this.grammar.byName[I] || [], s = 0; s < O.length; s++) {
18298
+ var L = O[s], a = this.wants[I], o = new R(L, 0, this.index, a);
18271
18299
  this.states.push(o);
18272
18300
  }
18273
18301
  }, A.prototype.complete = function(I, O) {
18274
- var t = I.nextState(O);
18275
- this.states.push(t);
18302
+ var s = I.nextState(O);
18303
+ this.states.push(s);
18276
18304
  };
18277
18305
  function e(I, O) {
18278
18306
  this.rules = I, this.start = O || this.rules[0].name;
18279
- var t = this.byName = {};
18307
+ var s = this.byName = {};
18280
18308
  this.rules.forEach(function(L) {
18281
- t.hasOwnProperty(L.name) || (t[L.name] = []), t[L.name].push(L);
18309
+ s.hasOwnProperty(L.name) || (s[L.name] = []), s[L.name].push(L);
18282
18310
  });
18283
18311
  }
18284
18312
  e.fromCompiled = function(L, O) {
18285
- var t = L.Lexer;
18313
+ var s = L.Lexer;
18286
18314
  L.ParserStart && (O = L.ParserStart, L = L.ParserRules);
18287
18315
  var L = L.map(function(o) {
18288
18316
  return new E(o.name, o.symbols, o.postprocess);
18289
18317
  }), a = new e(L, O);
18290
- return a.lexer = t, a;
18318
+ return a.lexer = s, a;
18291
18319
  };
18292
18320
  function S() {
18293
18321
  this.reset("");
@@ -18306,15 +18334,15 @@ function lI() {
18306
18334
  col: this.index - this.lastLineBreak
18307
18335
  };
18308
18336
  }, S.prototype.formatError = function(I, O) {
18309
- var t = this.buffer;
18310
- if (typeof t == "string") {
18311
- var L = t.split(`
18337
+ var s = this.buffer;
18338
+ if (typeof s == "string") {
18339
+ var L = s.split(`
18312
18340
  `).slice(
18313
18341
  Math.max(0, this.line - 5),
18314
18342
  this.line
18315
- ), a = t.indexOf(`
18343
+ ), a = s.indexOf(`
18316
18344
  `, this.index);
18317
- a === -1 && (a = t.length);
18345
+ a === -1 && (a = s.length);
18318
18346
  var o = this.index - this.lastLineBreak, n = String(this.line).length;
18319
18347
  return O += " at line " + this.line + " col " + o + `:
18320
18348
 
@@ -18331,17 +18359,17 @@ function lI() {
18331
18359
  return Array(l - c.length + 1).join(" ") + c;
18332
18360
  }
18333
18361
  };
18334
- function N(I, O, t) {
18362
+ function N(I, O, s) {
18335
18363
  if (I instanceof e)
18336
- var L = I, t = O;
18364
+ var L = I, s = O;
18337
18365
  else
18338
18366
  var L = e.fromCompiled(I, O);
18339
18367
  this.grammar = L, this.options = {
18340
18368
  keepHistory: !1,
18341
18369
  lexer: L.lexer || new S()
18342
18370
  };
18343
- for (var a in t || {})
18344
- this.options[a] = t[a];
18371
+ for (var a in s || {})
18372
+ this.options[a] = s[a];
18345
18373
  this.lexer = this.options.lexer, this.lexerState = void 0;
18346
18374
  var o = new A(L, 0);
18347
18375
  this.table = [o], o.wants[L.start] = [], o.predict(L.start), o.process(), this.current = 0;
@@ -18349,9 +18377,9 @@ function lI() {
18349
18377
  N.fail = {}, N.prototype.feed = function(I) {
18350
18378
  var O = this.lexer;
18351
18379
  O.reset(I, this.lexerState);
18352
- for (var t; ; ) {
18380
+ for (var s; ; ) {
18353
18381
  try {
18354
- if (t = O.next(), !t)
18382
+ if (s = O.next(), !s)
18355
18383
  break;
18356
18384
  } catch (x) {
18357
18385
  var n = new A(this.grammar, this.current + 1);
@@ -18363,62 +18391,62 @@ function lI() {
18363
18391
  this.options.keepHistory || delete this.table[this.current - 1];
18364
18392
  var o = this.current + 1, n = new A(this.grammar, o);
18365
18393
  this.table.push(n);
18366
- for (var U = t.text !== void 0 ? t.text : t.value, P = O.constructor === S ? t.value : t, l = a.scannable, c = l.length; c--; ) {
18367
- var B = l[c], p = B.rule.symbols[B.dot];
18368
- if (p.test ? p.test(P) : p.type ? p.type === t.type : p.literal === U) {
18369
- var V = B.nextState({ data: P, token: t, isToken: !0, reference: o - 1 });
18394
+ for (var U = s.text !== void 0 ? s.text : s.value, P = O.constructor === S ? s.value : s, l = a.scannable, c = l.length; c--; ) {
18395
+ var m = l[c], p = m.rule.symbols[m.dot];
18396
+ if (p.test ? p.test(P) : p.type ? p.type === s.type : p.literal === U) {
18397
+ var V = m.nextState({ data: P, token: s, isToken: !0, reference: o - 1 });
18370
18398
  n.states.push(V);
18371
18399
  }
18372
18400
  }
18373
18401
  if (n.process(), n.states.length === 0) {
18374
- var L = new Error(this.reportError(t));
18375
- throw L.offset = this.current, L.token = t, L;
18402
+ var L = new Error(this.reportError(s));
18403
+ throw L.offset = this.current, L.token = s, L;
18376
18404
  }
18377
18405
  this.options.keepHistory && (a.lexerState = O.save()), this.current++;
18378
18406
  }
18379
18407
  return a && (this.lexerState = O.save()), this.results = this.finish(), this;
18380
18408
  }, N.prototype.reportLexerError = function(I) {
18381
- var O, t, L = I.token;
18382
- return L ? (O = "input " + JSON.stringify(L.text[0]) + " (lexer error)", t = this.lexer.formatError(L, "Syntax error")) : (O = "input (lexer error)", t = I.message), this.reportErrorCommon(t, O);
18409
+ var O, s, L = I.token;
18410
+ return L ? (O = "input " + JSON.stringify(L.text[0]) + " (lexer error)", s = this.lexer.formatError(L, "Syntax error")) : (O = "input (lexer error)", s = I.message), this.reportErrorCommon(s, O);
18383
18411
  }, N.prototype.reportError = function(I) {
18384
- var O = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), t = this.lexer.formatError(I, "Syntax error");
18385
- return this.reportErrorCommon(t, O);
18412
+ var O = (I.type ? I.type + " token: " : "") + JSON.stringify(I.value !== void 0 ? I.value : I), s = this.lexer.formatError(I, "Syntax error");
18413
+ return this.reportErrorCommon(s, O);
18386
18414
  }, N.prototype.reportErrorCommon = function(I, O) {
18387
- var t = [];
18388
- t.push(I);
18415
+ var s = [];
18416
+ s.push(I);
18389
18417
  var L = this.table.length - 2, a = this.table[L], o = a.states.filter(function(U) {
18390
18418
  var P = U.rule.symbols[U.dot];
18391
18419
  return P && typeof P != "string";
18392
18420
  });
18393
18421
  if (o.length === 0)
18394
- t.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18395
- `), this.displayStateStack(a.states, t);
18422
+ s.push("Unexpected " + O + `. I did not expect any more input. Here is the state of my parse table:
18423
+ `), this.displayStateStack(a.states, s);
18396
18424
  else {
18397
- t.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
18425
+ s.push("Unexpected " + O + `. Instead, I was expecting to see one of the following:
18398
18426
  `);
18399
18427
  var n = o.map(function(U) {
18400
18428
  return this.buildFirstStateStack(U, []) || [U];
18401
18429
  }, this);
18402
18430
  n.forEach(function(U) {
18403
18431
  var P = U[0], l = P.rule.symbols[P.dot], c = this.getSymbolDisplay(l);
18404
- t.push("A " + c + " based on:"), this.displayStateStack(U, t);
18432
+ s.push("A " + c + " based on:"), this.displayStateStack(U, s);
18405
18433
  }, this);
18406
18434
  }
18407
- return t.push(""), t.join(`
18435
+ return s.push(""), s.join(`
18408
18436
  `);
18409
18437
  }, N.prototype.displayStateStack = function(I, O) {
18410
- for (var t, L = 0, a = 0; a < I.length; a++) {
18438
+ for (var s, L = 0, a = 0; a < I.length; a++) {
18411
18439
  var o = I[a], n = o.rule.toString(o.dot);
18412
- n === t ? L++ : (L > 0 && O.push(" ^ " + L + " more lines identical to this"), L = 0, O.push(" " + n)), t = n;
18440
+ n === s ? L++ : (L > 0 && O.push(" ^ " + L + " more lines identical to this"), L = 0, O.push(" " + n)), s = n;
18413
18441
  }
18414
18442
  }, N.prototype.getSymbolDisplay = function(I) {
18415
- return s(I);
18443
+ return t(I);
18416
18444
  }, N.prototype.buildFirstStateStack = function(I, O) {
18417
18445
  if (O.indexOf(I) !== -1)
18418
18446
  return null;
18419
18447
  if (I.wantedBy.length === 0)
18420
18448
  return [I];
18421
- var t = I.wantedBy[0], L = [I].concat(O), a = this.buildFirstStateStack(t, L);
18449
+ var s = I.wantedBy[0], L = [I].concat(O), a = this.buildFirstStateStack(s, L);
18422
18450
  return a === null ? null : [I].concat(a);
18423
18451
  }, N.prototype.save = function() {
18424
18452
  var I = this.table[this.current];
@@ -18431,14 +18459,14 @@ function lI() {
18431
18459
  throw new Error("set option `keepHistory` to enable rewinding");
18432
18460
  this.restore(this.table[I]);
18433
18461
  }, N.prototype.finish = function() {
18434
- var I = [], O = this.grammar.start, t = this.table[this.table.length - 1];
18435
- return t.states.forEach(function(L) {
18462
+ var I = [], O = this.grammar.start, s = this.table[this.table.length - 1];
18463
+ return s.states.forEach(function(L) {
18436
18464
  L.rule.name === O && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== N.fail && I.push(L);
18437
18465
  }), I.map(function(L) {
18438
18466
  return L.data;
18439
18467
  });
18440
18468
  };
18441
- function s(I) {
18469
+ function t(I) {
18442
18470
  var O = typeof I;
18443
18471
  if (O === "string")
18444
18472
  return I;
@@ -18454,7 +18482,7 @@ function lI() {
18454
18482
  throw new Error("Unknown symbol type: " + I);
18455
18483
  }
18456
18484
  }
18457
- function _(I) {
18485
+ function r(I) {
18458
18486
  var O = typeof I;
18459
18487
  if (O === "string")
18460
18488
  return I;
@@ -18478,14 +18506,14 @@ function lI() {
18478
18506
  });
18479
18507
  })(eE)), eE.exports;
18480
18508
  }
18481
- var cI = lI();
18482
- const uI = /* @__PURE__ */ UI(cI);
18483
- function HI(T) {
18484
- return T.map(BI).map(mI).map(FI).map(YI).map(pI);
18509
+ var wI = gI();
18510
+ const JI = /* @__PURE__ */ KI(wI);
18511
+ function xI(T) {
18512
+ return T.map(vI).map(QI).map(ZI).map(qI).map(jI);
18485
18513
  }
18486
- const BI = (T, E, R) => {
18514
+ const vI = (T, E, R) => {
18487
18515
  if (jT(T.type)) {
18488
- const A = dI(R, E);
18516
+ const A = kI(R, E);
18489
18517
  if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
18490
18518
  return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
18491
18519
  const e = k(R, E);
@@ -18493,40 +18521,40 @@ const BI = (T, E, R) => {
18493
18521
  return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
18494
18522
  }
18495
18523
  return T;
18496
- }, mI = (T, E, R) => {
18524
+ }, QI = (T, E, R) => {
18497
18525
  if (T.type === D.RESERVED_FUNCTION_NAME) {
18498
18526
  const A = k(R, E);
18499
18527
  if (!A || !AR(A))
18500
18528
  return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
18501
18529
  }
18502
18530
  return T;
18503
- }, FI = (T, E, R) => {
18531
+ }, ZI = (T, E, R) => {
18504
18532
  if (T.type === D.RESERVED_DATA_TYPE) {
18505
18533
  const A = k(R, E);
18506
18534
  if (A && AR(A))
18507
18535
  return Object.assign(Object.assign({}, T), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
18508
18536
  }
18509
18537
  return T;
18510
- }, YI = (T, E, R) => {
18538
+ }, qI = (T, E, R) => {
18511
18539
  if (T.type === D.IDENTIFIER) {
18512
18540
  const A = k(R, E);
18513
18541
  if (A && eR(A))
18514
18542
  return Object.assign(Object.assign({}, T), { type: D.ARRAY_IDENTIFIER });
18515
18543
  }
18516
18544
  return T;
18517
- }, pI = (T, E, R) => {
18545
+ }, jI = (T, E, R) => {
18518
18546
  if (T.type === D.RESERVED_DATA_TYPE) {
18519
18547
  const A = k(R, E);
18520
18548
  if (A && eR(A))
18521
18549
  return Object.assign(Object.assign({}, T), { type: D.ARRAY_KEYWORD });
18522
18550
  }
18523
18551
  return T;
18524
- }, dI = (T, E) => k(T, E, -1), k = (T, E, R = 1) => {
18552
+ }, kI = (T, E) => k(T, E, -1), k = (T, E, R = 1) => {
18525
18553
  let A = 1;
18526
- for (; T[E + A * R] && fI(T[E + A * R]); )
18554
+ for (; T[E + A * R] && zI(T[E + A * R]); )
18527
18555
  A++;
18528
18556
  return T[E + A * R];
18529
- }, AR = (T) => T.type === D.OPEN_PAREN && T.text === "(", eR = (T) => T.type === D.OPEN_PAREN && T.text === "[", fI = (T) => T.type === D.BLOCK_COMMENT || T.type === D.LINE_COMMENT;
18557
+ }, AR = (T) => T.type === D.OPEN_PAREN && T.text === "(", eR = (T) => T.type === D.OPEN_PAREN && T.text === "[", zI = (T) => T.type === D.BLOCK_COMMENT || T.type === D.LINE_COMMENT;
18530
18558
  class SR {
18531
18559
  constructor(E) {
18532
18560
  this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
@@ -18563,7 +18591,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18563
18591
  type: M.data_type,
18564
18592
  text: T.text,
18565
18593
  raw: T.raw
18566
- }), Y = (T, { leading: E, trailing: R }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), hI = (T, { leading: E, trailing: R }) => {
18594
+ }), Y = (T, { leading: E, trailing: R }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), R?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: R })), T), EO = (T, { leading: E, trailing: R }) => {
18567
18595
  if (E?.length) {
18568
18596
  const [A, ...e] = T;
18569
18597
  T = [Y(A, { leading: E }), ...e];
@@ -18573,7 +18601,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18573
18601
  T = [...A, Y(e, { trailing: R })];
18574
18602
  }
18575
18603
  return T;
18576
- }, VI = {
18604
+ }, TO = {
18577
18605
  Lexer: G,
18578
18606
  ParserRules: [
18579
18607
  { name: "main$ebnf$1", symbols: [] },
@@ -18838,7 +18866,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18838
18866
  postprocess: ([T, E, R, A, e, S, N]) => ({
18839
18867
  type: M.between_predicate,
18840
18868
  betweenKw: F(T),
18841
- expr1: hI(R, { leading: E, trailing: A }),
18869
+ expr1: EO(R, { leading: E, trailing: A }),
18842
18870
  andKw: F(e),
18843
18871
  expr2: [Y(N, { leading: S })]
18844
18872
  })
@@ -18898,7 +18926,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18898
18926
  { name: "literal$subexpression$1", symbols: [G.has("STRING") ? { type: "STRING" } : STRING] },
18899
18927
  { name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[T]]) => ({ type: M.literal, text: T.text }) },
18900
18928
  { name: "keyword$subexpression$1", symbols: [G.has("RESERVED_KEYWORD") ? { type: "RESERVED_KEYWORD" } : RESERVED_KEYWORD] },
18901
- { name: "keyword$subexpression$1", symbols: [G.has("RESERVED_PHRASE") ? { type: "RESERVED_PHRASE" } : RESERVED_PHRASE] },
18929
+ { name: "keyword$subexpression$1", symbols: [G.has("RESERVED_KEYWORD_PHRASE") ? { type: "RESERVED_KEYWORD_PHRASE" } : RESERVED_KEYWORD_PHRASE] },
18902
18930
  { name: "keyword$subexpression$1", symbols: [G.has("RESERVED_JOIN") ? { type: "RESERVED_JOIN" } : RESERVED_JOIN] },
18903
18931
  {
18904
18932
  name: "keyword",
@@ -18906,6 +18934,7 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18906
18934
  postprocess: ([[T]]) => F(T)
18907
18935
  },
18908
18936
  { name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
18937
+ { name: "data_type$subexpression$1", symbols: [G.has("RESERVED_DATA_TYPE_PHRASE") ? { type: "RESERVED_DATA_TYPE_PHRASE" } : RESERVED_DATA_TYPE_PHRASE] },
18909
18938
  {
18910
18939
  name: "data_type",
18911
18940
  symbols: ["data_type$subexpression$1"],
@@ -18969,13 +18998,13 @@ const G = new SR((T) => []), K = ([[T]]) => T, F = (T) => ({
18969
18998
  }
18970
18999
  ],
18971
19000
  ParserStart: "main"
18972
- }, { Parser: WI, Grammar: XI } = uI;
18973
- function bI(T) {
19001
+ }, { Parser: RO, Grammar: AO } = JI;
19002
+ function eO(T) {
18974
19003
  let E = {};
18975
19004
  const R = new SR((e) => [
18976
- ...HI(T.tokenize(e, E)),
19005
+ ...xI(T.tokenize(e, E)),
18977
19006
  qT(e.length)
18978
- ]), A = new WI(XI.fromCompiled(VI), { lexer: R });
19007
+ ]), A = new RO(AO.fromCompiled(TO), { lexer: R });
18979
19008
  return {
18980
19009
  parse: (e, S) => {
18981
19010
  E = S;
@@ -19027,11 +19056,11 @@ class IR {
19027
19056
  }
19028
19057
  }
19029
19058
  trimHorizontalWhitespace() {
19030
- for (; yI(EE(this.items)); )
19059
+ for (; SO(EE(this.items)); )
19031
19060
  this.items.pop();
19032
19061
  }
19033
19062
  trimWhitespace() {
19034
- for (; KI(EE(this.items)); )
19063
+ for (; IO(EE(this.items)); )
19035
19064
  this.items.pop();
19036
19065
  }
19037
19066
  addNewline(E) {
@@ -19078,7 +19107,7 @@ class IR {
19078
19107
  }
19079
19108
  }
19080
19109
  }
19081
- const yI = (T) => T === i.SPACE || T === i.SINGLE_INDENT, KI = (T) => T === i.SPACE || T === i.SINGLE_INDENT || T === i.NEWLINE;
19110
+ const SO = (T) => T === i.SPACE || T === i.SINGLE_INDENT, IO = (T) => T === i.SPACE || T === i.SINGLE_INDENT || T === i.NEWLINE;
19082
19111
  function yT(T, E) {
19083
19112
  if (E === "standard")
19084
19113
  return T;
@@ -19088,7 +19117,7 @@ function yT(T, E) {
19088
19117
  function KT(T) {
19089
19118
  return KR(T) || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.LIMIT;
19090
19119
  }
19091
- const JE = "top-level", $I = "block-level";
19120
+ const wE = "top-level", OO = "block-level";
19092
19121
  class NR {
19093
19122
  /**
19094
19123
  * @param {string} indent A string to indent with
@@ -19112,20 +19141,20 @@ class NR {
19112
19141
  * Increases indentation by one top-level indent.
19113
19142
  */
19114
19143
  increaseTopLevel() {
19115
- this.indentTypes.push(JE);
19144
+ this.indentTypes.push(wE);
19116
19145
  }
19117
19146
  /**
19118
19147
  * Increases indentation by one block-level indent.
19119
19148
  */
19120
19149
  increaseBlockLevel() {
19121
- this.indentTypes.push($I);
19150
+ this.indentTypes.push(OO);
19122
19151
  }
19123
19152
  /**
19124
19153
  * Decreases indentation by one top-level indent.
19125
19154
  * Does nothing when the previous indent is not top-level.
19126
19155
  */
19127
19156
  decreaseTopLevel() {
19128
- this.indentTypes.length > 0 && EE(this.indentTypes) === JE && this.indentTypes.pop();
19157
+ this.indentTypes.length > 0 && EE(this.indentTypes) === wE && this.indentTypes.pop();
19129
19158
  }
19130
19159
  /**
19131
19160
  * Decreases indentation by one block-level indent.
@@ -19133,11 +19162,11 @@ class NR {
19133
19162
  * throws away these as well.
19134
19163
  */
19135
19164
  decreaseBlockLevel() {
19136
- for (; this.indentTypes.length > 0 && this.indentTypes.pop() === JE; )
19165
+ for (; this.indentTypes.length > 0 && this.indentTypes.pop() === wE; )
19137
19166
  ;
19138
19167
  }
19139
19168
  }
19140
- class gI extends IR {
19169
+ class NO extends IR {
19141
19170
  constructor(E) {
19142
19171
  super(new NR("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
19143
19172
  }
@@ -19158,7 +19187,7 @@ class gI extends IR {
19158
19187
  }
19159
19188
  class QE extends Error {
19160
19189
  }
19161
- class sE {
19190
+ class tE {
19162
19191
  constructor({ cfg: E, dialectCfg: R, params: A, layout: e, inline: S = !1 }) {
19163
19192
  this.inline = !1, this.nodes = [], this.index = -1, this.cfg = E, this.dialectCfg = R, this.inline = S, this.params = A, this.layout = e;
19164
19193
  }
@@ -19366,7 +19395,7 @@ class sE {
19366
19395
  return this.isDocComment(E) ? E.split(/\n/).map((R) => /^\s*\*/.test(R) ? " " + R.replace(/^\s*/, "") : R) : E.split(/\n/).map((R) => R.replace(/^\s*/, ""));
19367
19396
  }
19368
19397
  formatSubExpression(E) {
19369
- return new sE({
19398
+ return new tE({
19370
19399
  cfg: this.cfg,
19371
19400
  dialectCfg: this.dialectCfg,
19372
19401
  params: this.params,
@@ -19377,11 +19406,11 @@ class sE {
19377
19406
  formatInlineExpression(E) {
19378
19407
  const R = this.params.getPositionalParameterIndex();
19379
19408
  try {
19380
- return new sE({
19409
+ return new tE({
19381
19410
  cfg: this.cfg,
19382
19411
  dialectCfg: this.dialectCfg,
19383
19412
  params: this.params,
19384
- layout: new gI(this.cfg.expressionWidth),
19413
+ layout: new NO(this.cfg.expressionWidth),
19385
19414
  inline: !0
19386
19415
  }).format(E);
19387
19416
  } catch (A) {
@@ -19467,9 +19496,9 @@ class sE {
19467
19496
  }
19468
19497
  }
19469
19498
  }
19470
- class JI {
19499
+ class sO {
19471
19500
  constructor(E, R) {
19472
- this.dialect = E, this.cfg = R, this.params = new MI(this.cfg.params);
19501
+ this.dialect = E, this.cfg = R, this.params = new yI(this.cfg.params);
19473
19502
  }
19474
19503
  /**
19475
19504
  * Formats an SQL query.
@@ -19481,25 +19510,25 @@ class JI {
19481
19510
  return this.formatAst(R).trimEnd();
19482
19511
  }
19483
19512
  parse(E) {
19484
- return bI(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
19513
+ return eO(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
19485
19514
  }
19486
19515
  formatAst(E) {
19487
19516
  return E.map((R) => this.formatStatement(R)).join(`
19488
19517
  `.repeat(this.cfg.linesBetweenQueries + 1));
19489
19518
  }
19490
19519
  formatStatement(E) {
19491
- const R = new sE({
19520
+ const R = new tE({
19492
19521
  cfg: this.cfg,
19493
19522
  dialectCfg: this.dialect.formatOptions,
19494
19523
  params: this.params,
19495
- layout: new IR(new NR(PI(this.cfg)))
19524
+ layout: new IR(new NR(bI(this.cfg)))
19496
19525
  }).format(E.children);
19497
19526
  return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? R.add(i.NEWLINE, ";") : R.add(i.NO_NEWLINE, ";")), R.toString();
19498
19527
  }
19499
19528
  }
19500
19529
  class SE extends Error {
19501
19530
  }
19502
- function wI(T) {
19531
+ function tO(T) {
19503
19532
  const E = [
19504
19533
  "multilineLists",
19505
19534
  "newlineBeforeOpenParen",
@@ -19513,17 +19542,17 @@ function wI(T) {
19513
19542
  throw new SE(`${R} config is no more supported.`);
19514
19543
  if (T.expressionWidth <= 0)
19515
19544
  throw new SE(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
19516
- if (T.params && !xI(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !vI(T.paramTypes))
19545
+ if (T.params && !CO(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !LO(T.paramTypes))
19517
19546
  throw new SE("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
19518
19547
  return T;
19519
19548
  }
19520
- function xI(T) {
19549
+ function CO(T) {
19521
19550
  return (T instanceof Array ? T : Object.values(T)).every((R) => typeof R == "string");
19522
19551
  }
19523
- function vI(T) {
19552
+ function LO(T) {
19524
19553
  return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
19525
19554
  }
19526
- var QI = function(T, E) {
19555
+ var _O = function(T, E) {
19527
19556
  var R = {};
19528
19557
  for (var A in T) Object.prototype.hasOwnProperty.call(T, A) && E.indexOf(A) < 0 && (R[A] = T[A]);
19529
19558
  if (T != null && typeof Object.getOwnPropertySymbols == "function")
@@ -19531,7 +19560,7 @@ var QI = function(T, E) {
19531
19560
  E.indexOf(A[e]) < 0 && Object.prototype.propertyIsEnumerable.call(T, A[e]) && (R[A[e]] = T[A[e]]);
19532
19561
  return R;
19533
19562
  };
19534
- const tR = {
19563
+ const sR = {
19535
19564
  bigquery: "bigquery",
19536
19565
  db2: "db2",
19537
19566
  db2i: "db2i",
@@ -19552,7 +19581,7 @@ const tR = {
19552
19581
  tsql: "transactsql",
19553
19582
  singlestoredb: "singlestoredb",
19554
19583
  snowflake: "snowflake"
19555
- }, ZI = Object.keys(tR), qI = {
19584
+ }, rO = Object.keys(sR), nO = {
19556
19585
  tabWidth: 2,
19557
19586
  useTabs: !1,
19558
19587
  keywordCase: "preserve",
@@ -19565,27 +19594,27 @@ const tR = {
19565
19594
  linesBetweenQueries: 1,
19566
19595
  denseOperators: !1,
19567
19596
  newlineBeforeSemicolon: !1
19568
- }, jI = (T, E = {}) => {
19569
- if (typeof E.language == "string" && !ZI.includes(E.language))
19597
+ }, iO = (T, E = {}) => {
19598
+ if (typeof E.language == "string" && !rO.includes(E.language))
19570
19599
  throw new SE(`Unsupported SQL dialect: ${E.language}`);
19571
- const R = tR[E.language || "sql"];
19572
- return kI(T, Object.assign(Object.assign({}, E), { dialect: AI[R] }));
19573
- }, kI = (T, E) => {
19574
- var { dialect: R } = E, A = QI(E, ["dialect"]);
19600
+ const R = sR[E.language || "sql"];
19601
+ return DO(T, Object.assign(Object.assign({}, E), { dialect: UI[R] }));
19602
+ }, DO = (T, E) => {
19603
+ var { dialect: R } = E, A = _O(E, ["dialect"]);
19575
19604
  if (typeof T != "string")
19576
19605
  throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
19577
- const e = wI(Object.assign(Object.assign({}, qI), A));
19578
- return new JI(DI(R), e).format(T);
19606
+ const e = tO(Object.assign(Object.assign({}, nO), A));
19607
+ return new sO(VI(R), e).format(T);
19579
19608
  };
19580
- function zI(T) {
19609
+ function aO(T) {
19581
19610
  let E = 0;
19582
19611
  return E += (T.measures?.length || 0) * 1, E += (T.dimensions?.length || 0) * 1, E += (T.filters?.length || 0) * 2, E += (T.timeDimensions?.length || 0) * 3, E <= 5 ? "low" : E <= 15 ? "medium" : "high";
19583
19612
  }
19584
- function EO() {
19613
+ function oO() {
19585
19614
  const T = Date.now(), E = Math.random().toString(36).substring(2, 9);
19586
19615
  return `${T}-${E}`;
19587
19616
  }
19588
- function TO(T) {
19617
+ function PO(T) {
19589
19618
  const E = T.dimensions || [], R = T.timeDimensions || [], A = T.measures || [];
19590
19619
  return {
19591
19620
  sortedDimensions: E,
@@ -19610,7 +19639,7 @@ function TO(T) {
19610
19639
  hasMultiStage: !1
19611
19640
  };
19612
19641
  }
19613
- function RO(T) {
19642
+ function MO(T) {
19614
19643
  if (T.hasExecutor()) {
19615
19644
  const E = T.databaseExecutor;
19616
19645
  if (E?.engineType)
@@ -19618,23 +19647,23 @@ function RO(T) {
19618
19647
  }
19619
19648
  return "postgres";
19620
19649
  }
19621
- async function eO(T, E, R) {
19650
+ async function GO(T, E, R) {
19622
19651
  const A = R.validateQuery(T);
19623
19652
  if (!A.isValid)
19624
19653
  throw new Error(`Query validation failed: ${A.errors.join(", ")}`);
19625
19654
  const e = /* @__PURE__ */ new Set();
19626
- T.measures?.forEach((_) => {
19627
- const I = _.split(".")[0];
19655
+ T.measures?.forEach((r) => {
19656
+ const I = r.split(".")[0];
19628
19657
  e.add(I);
19629
- }), T.dimensions?.forEach((_) => {
19630
- const I = _.split(".")[0];
19658
+ }), T.dimensions?.forEach((r) => {
19659
+ const I = r.split(".")[0];
19631
19660
  e.add(I);
19632
- }), T.timeDimensions?.forEach((_) => {
19633
- const I = _.dimension.split(".")[0];
19661
+ }), T.timeDimensions?.forEach((r) => {
19662
+ const I = r.dimension.split(".")[0];
19634
19663
  e.add(I);
19635
- }), T.filters?.forEach((_) => {
19636
- if ("member" in _) {
19637
- const I = _.member.split(".")[0];
19664
+ }), T.filters?.forEach((r) => {
19665
+ if ("member" in r) {
19666
+ const I = r.member.split(".")[0];
19638
19667
  e.add(I);
19639
19668
  }
19640
19669
  });
@@ -19643,14 +19672,14 @@ async function eO(T, E, R) {
19643
19672
  if (S)
19644
19673
  N = await R.generateMultiCubeSQL(T, E);
19645
19674
  else {
19646
- const _ = Array.from(e)[0];
19647
- N = await R.generateSQL(_, T, E);
19675
+ const r = Array.from(e)[0];
19676
+ N = await R.generateSQL(r, T, E);
19648
19677
  }
19649
- const s = Array.from(e).map((_) => ({
19650
- cube: _,
19678
+ const t = Array.from(e).map((r) => ({
19679
+ cube: r,
19651
19680
  query: {
19652
- measures: T.measures?.filter((I) => I.startsWith(_ + ".")) || [],
19653
- dimensions: T.dimensions?.filter((I) => I.startsWith(_ + ".")) || [],
19681
+ measures: T.measures?.filter((I) => I.startsWith(r + ".")) || [],
19682
+ dimensions: T.dimensions?.filter((I) => I.startsWith(r + ".")) || [],
19654
19683
  filters: T.filters || [],
19655
19684
  timeDimensions: T.timeDimensions || [],
19656
19685
  order: T.order || {},
@@ -19660,9 +19689,9 @@ async function eO(T, E, R) {
19660
19689
  }));
19661
19690
  return {
19662
19691
  queryType: "regularQuery",
19663
- normalizedQueries: s,
19692
+ normalizedQueries: t,
19664
19693
  queryOrder: Array.from(e),
19665
- transformedQueries: s,
19694
+ transformedQueries: t,
19666
19695
  pivotQuery: {
19667
19696
  query: T,
19668
19697
  cubes: Array.from(e)
@@ -19671,15 +19700,15 @@ async function eO(T, E, R) {
19671
19700
  sql: [N.sql],
19672
19701
  params: N.params || []
19673
19702
  },
19674
- complexity: zI(T),
19703
+ complexity: aO(T),
19675
19704
  valid: !0,
19676
19705
  cubesUsed: Array.from(e),
19677
19706
  joinType: S ? "multi_cube_join" : "single_cube",
19678
19707
  query: T
19679
19708
  };
19680
19709
  }
19681
- function SO(T, E, R) {
19682
- const A = RO(R), e = EO(), S = (/* @__PURE__ */ new Date()).toISOString(), N = TO(T);
19710
+ function lO(T, E, R) {
19711
+ const A = MO(R), e = oO(), S = (/* @__PURE__ */ new Date()).toISOString(), N = PO(T);
19683
19712
  return {
19684
19713
  queryType: "regularQuery",
19685
19714
  results: [{
@@ -19705,7 +19734,7 @@ function SO(T, E, R) {
19705
19734
  }
19706
19735
  function $T(T, E) {
19707
19736
  try {
19708
- return jI(T, {
19737
+ return iO(T, {
19709
19738
  language: {
19710
19739
  postgres: "postgresql",
19711
19740
  mysql: "mysql",
@@ -19721,25 +19750,25 @@ function $T(T, E) {
19721
19750
  return console.warn("SQL formatting failed:", R), T;
19722
19751
  }
19723
19752
  }
19724
- function IO(T, E) {
19753
+ function cO(T, E) {
19725
19754
  return {
19726
19755
  sql: E.sql,
19727
19756
  params: E.params || [],
19728
19757
  query: T
19729
19758
  };
19730
19759
  }
19731
- function OO(T) {
19760
+ function uO(T) {
19732
19761
  return {
19733
19762
  cubes: T
19734
19763
  };
19735
19764
  }
19736
- function NO(T, E = 500) {
19765
+ function HO(T, E = 500) {
19737
19766
  return {
19738
19767
  error: T instanceof Error ? T.message : T,
19739
19768
  status: E
19740
19769
  };
19741
19770
  }
19742
- class AO {
19771
+ class UO {
19743
19772
  cubes = /* @__PURE__ */ new Map();
19744
19773
  dbExecutor;
19745
19774
  metadataCache;
@@ -19747,7 +19776,7 @@ class AO {
19747
19776
  METADATA_CACHE_TTL = 300 * 1e3;
19748
19777
  // 5 minutes in milliseconds
19749
19778
  constructor(E) {
19750
- E?.databaseExecutor ? this.dbExecutor = E.databaseExecutor : E?.drizzle && (this.dbExecutor = tT(
19779
+ E?.databaseExecutor ? this.dbExecutor = E.databaseExecutor : E?.drizzle && (this.dbExecutor = sT(
19751
19780
  E.drizzle,
19752
19781
  E.schema,
19753
19782
  E.engineType
@@ -19769,7 +19798,7 @@ class AO {
19769
19798
  * Set Drizzle instance and schema directly
19770
19799
  */
19771
19800
  setDrizzle(E, R, A) {
19772
- this.dbExecutor = tT(E, R, A);
19801
+ this.dbExecutor = sT(E, R, A);
19773
19802
  }
19774
19803
  /**
19775
19804
  * Check if database executor is configured
@@ -19856,24 +19885,24 @@ class AO {
19856
19885
  */
19857
19886
  generateCubeMetadata(E) {
19858
19887
  const R = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(R.length), S = new Array(A.length);
19859
- for (let s = 0; s < R.length; s++) {
19860
- const _ = R[s], I = E.measures[_];
19861
- e[s] = {
19862
- name: `${E.name}.${_}`,
19863
- title: I.title || _,
19864
- shortTitle: I.title || _,
19888
+ for (let t = 0; t < R.length; t++) {
19889
+ const r = R[t], I = E.measures[r];
19890
+ e[t] = {
19891
+ name: `${E.name}.${r}`,
19892
+ title: I.title || r,
19893
+ shortTitle: I.title || r,
19865
19894
  type: I.type,
19866
19895
  format: void 0,
19867
19896
  // Measure doesn't have format field
19868
19897
  description: I.description
19869
19898
  };
19870
19899
  }
19871
- for (let s = 0; s < A.length; s++) {
19872
- const _ = A[s], I = E.dimensions[_];
19873
- S[s] = {
19874
- name: `${E.name}.${_}`,
19875
- title: I.title || _,
19876
- shortTitle: I.title || _,
19900
+ for (let t = 0; t < A.length; t++) {
19901
+ const r = A[t], I = E.dimensions[r];
19902
+ S[t] = {
19903
+ name: `${E.name}.${r}`,
19904
+ title: I.title || r,
19905
+ shortTitle: I.title || r,
19877
19906
  type: I.type,
19878
19907
  format: void 0,
19879
19908
  // Dimension doesn't have format field
@@ -19882,12 +19911,12 @@ class AO {
19882
19911
  }
19883
19912
  const N = [];
19884
19913
  if (E.joins)
19885
- for (const [, s] of Object.entries(E.joins)) {
19886
- const _ = typeof s.targetCube == "function" ? s.targetCube() : s.targetCube;
19914
+ for (const [, t] of Object.entries(E.joins)) {
19915
+ const r = typeof t.targetCube == "function" ? t.targetCube() : t.targetCube;
19887
19916
  N.push({
19888
- targetCube: _.name,
19889
- relationship: s.relationship,
19890
- joinFields: s.on.map((I) => ({
19917
+ targetCube: r.name,
19918
+ relationship: t.relationship,
19919
+ joinFields: t.on.map((I) => ({
19891
19920
  sourceField: this.getColumnName(I.source),
19892
19921
  targetField: this.getColumnName(I.target)
19893
19922
  }))
@@ -19913,9 +19942,9 @@ class AO {
19913
19942
  throw new Error(`Cube '${E}' not found`);
19914
19943
  if (!this.dbExecutor)
19915
19944
  throw new Error("Database executor not configured");
19916
- const N = await new UE(this.dbExecutor).generateSQL(e, R, A), s = this.dbExecutor.getEngineType();
19945
+ const N = await new UE(this.dbExecutor).generateSQL(e, R, A), t = this.dbExecutor.getEngineType();
19917
19946
  return {
19918
- sql: $T(N.sql, s),
19947
+ sql: $T(N.sql, t),
19919
19948
  params: N.params
19920
19949
  };
19921
19950
  }
@@ -19968,10 +19997,10 @@ class AO {
19968
19997
  * Ensures all referenced cubes and fields exist
19969
19998
  */
19970
19999
  validateQuery(E) {
19971
- return sR(this.cubes, E);
20000
+ return tR(this.cubes, E);
19972
20001
  }
19973
20002
  }
19974
- function sR(T, E) {
20003
+ function tR(T, E) {
19975
20004
  const R = [], A = /* @__PURE__ */ new Set();
19976
20005
  if (E.measures)
19977
20006
  for (const e of E.measures) {
@@ -19981,12 +20010,12 @@ function sR(T, E) {
19981
20010
  continue;
19982
20011
  }
19983
20012
  A.add(S);
19984
- const s = T.get(S);
19985
- if (!s) {
20013
+ const t = T.get(S);
20014
+ if (!t) {
19986
20015
  R.push(`Cube '${S}' not found (referenced in measure '${e}')`);
19987
20016
  continue;
19988
20017
  }
19989
- s.measures[N] || R.push(`Measure '${N}' not found on cube '${S}'`);
20018
+ t.measures[N] || R.push(`Measure '${N}' not found on cube '${S}'`);
19990
20019
  }
19991
20020
  if (E.dimensions)
19992
20021
  for (const e of E.dimensions) {
@@ -19996,12 +20025,12 @@ function sR(T, E) {
19996
20025
  continue;
19997
20026
  }
19998
20027
  A.add(S);
19999
- const s = T.get(S);
20000
- if (!s) {
20028
+ const t = T.get(S);
20029
+ if (!t) {
20001
20030
  R.push(`Cube '${S}' not found (referenced in dimension '${e}')`);
20002
20031
  continue;
20003
20032
  }
20004
- s.dimensions[N] || R.push(`Dimension '${N}' not found on cube '${S}'`);
20033
+ t.dimensions[N] || R.push(`Dimension '${N}' not found on cube '${S}'`);
20005
20034
  }
20006
20035
  if (E.timeDimensions)
20007
20036
  for (const e of E.timeDimensions) {
@@ -20011,12 +20040,12 @@ function sR(T, E) {
20011
20040
  continue;
20012
20041
  }
20013
20042
  A.add(S);
20014
- const s = T.get(S);
20015
- if (!s) {
20043
+ const t = T.get(S);
20044
+ if (!t) {
20016
20045
  R.push(`Cube '${S}' not found (referenced in timeDimension '${e.dimension}')`);
20017
20046
  continue;
20018
20047
  }
20019
- s.dimensions[N] || R.push(`TimeDimension '${N}' not found on cube '${S}' (must be a dimension with time type)`);
20048
+ t.dimensions[N] || R.push(`TimeDimension '${N}' not found on cube '${S}' (must be a dimension with time type)`);
20020
20049
  }
20021
20050
  if (E.filters)
20022
20051
  for (const e of E.filters)
@@ -20028,9 +20057,9 @@ function sR(T, E) {
20028
20057
  }
20029
20058
  function CR(T, E, R, A) {
20030
20059
  if ("and" in T || "or" in T) {
20031
- const s = T.and || T.or || [];
20032
- for (const _ of s)
20033
- CR(_, E, R, A);
20060
+ const t = T.and || T.or || [];
20061
+ for (const r of t)
20062
+ CR(r, E, R, A);
20034
20063
  return;
20035
20064
  }
20036
20065
  if (!("member" in T)) {
@@ -20050,12 +20079,12 @@ function CR(T, E, R, A) {
20050
20079
  }
20051
20080
  !N.dimensions[S] && !N.measures[S] && R.push(`Filter field '${S}' not found on cube '${e}' (must be a dimension or measure)`);
20052
20081
  }
20053
- new AO();
20082
+ new UO();
20054
20083
  export {
20055
- AO as S,
20056
- OO as a,
20057
- IO as b,
20058
- NO as c,
20059
- SO as f,
20060
- eO as h
20084
+ UO as S,
20085
+ uO as a,
20086
+ cO as b,
20087
+ HO as c,
20088
+ lO as f,
20089
+ GO as h
20061
20090
  };