drizzle-cube 0.1.62 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/compiler-CGImvJqY.cjs +22 -0
- package/dist/adapters/{compiler-D85rCgej.js → compiler-tWqDBXA3.js} +952 -795
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/utils.d.ts +2 -0
- package/dist/client/chunks/{components-D0RvU3X3.js → components-DsDLdI8c.js} +37 -15
- package/dist/client/chunks/components-DsDLdI8c.js.map +1 -0
- package/dist/client/components/charts/KpiDelta.d.ts +1 -1
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +16 -16
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.js +1754 -1597
- package/package.json +1 -1
- package/dist/adapters/compiler-BJmK13HP.cjs +0 -22
- package/dist/client/chunks/components-D0RvU3X3.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const W = Symbol.for("drizzle:entityKind");
|
|
2
|
-
function
|
|
2
|
+
function H(T, E) {
|
|
3
3
|
if (!T || typeof T != "object")
|
|
4
4
|
return !1;
|
|
5
5
|
if (T instanceof E)
|
|
@@ -51,10 +51,10 @@ class RE {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
const iE = Symbol.for("drizzle:Name"), TT = Symbol.for("drizzle:isPgEnum");
|
|
54
|
-
function
|
|
54
|
+
function ae(T) {
|
|
55
55
|
return !!T && typeof T == "function" && TT in T && T[TT] === !0;
|
|
56
56
|
}
|
|
57
|
-
class
|
|
57
|
+
class vT {
|
|
58
58
|
static [W] = "Subquery";
|
|
59
59
|
constructor(E, e, R, A = !1, S = []) {
|
|
60
60
|
this._ = {
|
|
@@ -70,11 +70,11 @@ class xT {
|
|
|
70
70
|
// return new SQL([this]);
|
|
71
71
|
// }
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const oe = {
|
|
74
74
|
startActiveSpan(T, E) {
|
|
75
75
|
return E();
|
|
76
76
|
}
|
|
77
|
-
}, TE = Symbol.for("drizzle:ViewBaseConfig"), aE = Symbol.for("drizzle:Schema"), eT = Symbol.for("drizzle:Columns"), RT = Symbol.for("drizzle:ExtraConfigColumns"), oE = Symbol.for("drizzle:OriginalName"), DE = Symbol.for("drizzle:BaseName"), sE = Symbol.for("drizzle:IsAlias"), AT = Symbol.for("drizzle:ExtraConfigBuilder"),
|
|
77
|
+
}, TE = Symbol.for("drizzle:ViewBaseConfig"), aE = Symbol.for("drizzle:Schema"), eT = Symbol.for("drizzle:Columns"), RT = Symbol.for("drizzle:ExtraConfigColumns"), oE = Symbol.for("drizzle:OriginalName"), DE = Symbol.for("drizzle:BaseName"), sE = Symbol.for("drizzle:IsAlias"), AT = Symbol.for("drizzle:ExtraConfigBuilder"), De = Symbol.for("drizzle:IsDrizzleTable");
|
|
78
78
|
class b {
|
|
79
79
|
static [W] = "Table";
|
|
80
80
|
/** @internal */
|
|
@@ -112,17 +112,17 @@ class b {
|
|
|
112
112
|
/** @internal */
|
|
113
113
|
[sE] = !1;
|
|
114
114
|
/** @internal */
|
|
115
|
-
[
|
|
115
|
+
[De] = !0;
|
|
116
116
|
/** @internal */
|
|
117
117
|
[AT] = void 0;
|
|
118
118
|
constructor(E, e, R) {
|
|
119
119
|
this[iE] = this[oE] = E, this[aE] = e, this[DE] = R;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function QT(T) {
|
|
123
123
|
return T != null && typeof T.getSQL == "function";
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Pe(T) {
|
|
126
126
|
const E = { sql: "", params: [] };
|
|
127
127
|
for (const e of T)
|
|
128
128
|
E.sql += e.sql, E.params.push(...e.params), e.typings?.length && (E.typings || (E.typings = []), E.typings.push(...e.typings));
|
|
@@ -135,14 +135,14 @@ class f {
|
|
|
135
135
|
this.value = Array.isArray(E) ? E : [E];
|
|
136
136
|
}
|
|
137
137
|
getSQL() {
|
|
138
|
-
return new
|
|
138
|
+
return new d([this]);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
class
|
|
141
|
+
class d {
|
|
142
142
|
constructor(E) {
|
|
143
143
|
this.queryChunks = E;
|
|
144
144
|
for (const e of E)
|
|
145
|
-
if (
|
|
145
|
+
if (H(e, b)) {
|
|
146
146
|
const R = e[b.Symbol.Schema];
|
|
147
147
|
this.usedTables.push(
|
|
148
148
|
R === void 0 ? e[b.Symbol.Name] : R + "." + e[b.Symbol.Name]
|
|
@@ -151,7 +151,7 @@ class H {
|
|
|
151
151
|
}
|
|
152
152
|
static [W] = "SQL";
|
|
153
153
|
/** @internal */
|
|
154
|
-
decoder =
|
|
154
|
+
decoder = ZT;
|
|
155
155
|
shouldInlineParams = !1;
|
|
156
156
|
/** @internal */
|
|
157
157
|
usedTables = [];
|
|
@@ -159,7 +159,7 @@ class H {
|
|
|
159
159
|
return this.queryChunks.push(...E.queryChunks), this;
|
|
160
160
|
}
|
|
161
161
|
toQuery(E) {
|
|
162
|
-
return
|
|
162
|
+
return oe.startActiveSpan("drizzle.buildSQL", (e) => {
|
|
163
163
|
const R = this.buildQueryFromSourceParams(this.queryChunks, E);
|
|
164
164
|
return e?.setAttributes({
|
|
165
165
|
"drizzle.query.text": R.sql,
|
|
@@ -179,10 +179,10 @@ class H {
|
|
|
179
179
|
inlineParams: s,
|
|
180
180
|
paramStartIndex: O
|
|
181
181
|
} = R;
|
|
182
|
-
return
|
|
183
|
-
if (
|
|
182
|
+
return Pe(E.map((N) => {
|
|
183
|
+
if (H(N, f))
|
|
184
184
|
return { sql: N.value.join(""), params: [] };
|
|
185
|
-
if (
|
|
185
|
+
if (H(N, ZE))
|
|
186
186
|
return { sql: S(N.value), params: [] };
|
|
187
187
|
if (N === void 0)
|
|
188
188
|
return { sql: "", params: [] };
|
|
@@ -192,19 +192,19 @@ class H {
|
|
|
192
192
|
r.push(L), n < N.length - 1 && r.push(new f(", "));
|
|
193
193
|
return r.push(new f(")")), this.buildQueryFromSourceParams(r, R);
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
195
|
+
if (H(N, d))
|
|
196
196
|
return this.buildQueryFromSourceParams(N.queryChunks, {
|
|
197
197
|
...R,
|
|
198
198
|
inlineParams: s || N.shouldInlineParams
|
|
199
199
|
});
|
|
200
|
-
if (
|
|
200
|
+
if (H(N, b)) {
|
|
201
201
|
const r = N[b.Symbol.Schema], n = N[b.Symbol.Name];
|
|
202
202
|
return {
|
|
203
203
|
sql: r === void 0 || N[sE] ? S(n) : S(r) + "." + S(n),
|
|
204
204
|
params: []
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
if (
|
|
207
|
+
if (H(N, RE)) {
|
|
208
208
|
const r = A.getColumnCasing(N);
|
|
209
209
|
if (e.invokeSource === "indexes")
|
|
210
210
|
return { sql: S(r), params: [] };
|
|
@@ -214,30 +214,30 @@ class H {
|
|
|
214
214
|
params: []
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (H(N, jT)) {
|
|
218
218
|
const r = N[TE].schema, n = N[TE].name;
|
|
219
219
|
return {
|
|
220
220
|
sql: r === void 0 || N[TE].isAlias ? S(n) : S(r) + "." + S(n),
|
|
221
221
|
params: []
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
if (
|
|
225
|
-
if (
|
|
224
|
+
if (H(N, rE)) {
|
|
225
|
+
if (H(N.value, CE))
|
|
226
226
|
return { sql: I(O.value++, N), params: [N], typings: ["none"] };
|
|
227
227
|
const r = N.value === null ? null : N.encoder.mapToDriverValue(N.value);
|
|
228
|
-
if (
|
|
228
|
+
if (H(r, d))
|
|
229
229
|
return this.buildQueryFromSourceParams([r], R);
|
|
230
230
|
if (s)
|
|
231
231
|
return { sql: this.mapInlineParam(r, R), params: [] };
|
|
232
232
|
let n = ["none"];
|
|
233
233
|
return t && (n = [t(N.encoder)]), { sql: I(O.value++, r), params: [r], typings: n };
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return H(N, CE) ? { sql: I(O.value++, N), params: [N], typings: ["none"] } : H(N, d.Aliased) && N.fieldAlias !== void 0 ? { sql: S(N.fieldAlias), params: [] } : H(N, vT) ? N._.isWith ? { sql: S(N._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
236
236
|
new f("("),
|
|
237
237
|
N._.sql,
|
|
238
238
|
new f(") "),
|
|
239
239
|
new ZE(N._.alias)
|
|
240
|
-
], R) :
|
|
240
|
+
], R) : ae(N) ? N.schema ? { sql: S(N.schema) + "." + S(N.enumName), params: [] } : { sql: S(N.enumName), params: [] } : QT(N) ? N.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([N.getSQL()], R) : this.buildQueryFromSourceParams([
|
|
241
241
|
new f("("),
|
|
242
242
|
N.getSQL(),
|
|
243
243
|
new f(")")
|
|
@@ -261,7 +261,7 @@ class H {
|
|
|
261
261
|
return this;
|
|
262
262
|
}
|
|
263
263
|
as(E) {
|
|
264
|
-
return E === void 0 ? this : new
|
|
264
|
+
return E === void 0 ? this : new d.Aliased(this, E);
|
|
265
265
|
}
|
|
266
266
|
mapWith(E) {
|
|
267
267
|
return this.decoder = typeof E == "function" ? { mapFromDriverValue: E } : E, this;
|
|
@@ -286,33 +286,33 @@ class ZE {
|
|
|
286
286
|
static [W] = "Name";
|
|
287
287
|
brand;
|
|
288
288
|
getSQL() {
|
|
289
|
-
return new
|
|
289
|
+
return new d([this]);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Me(T) {
|
|
293
293
|
return typeof T == "object" && T !== null && "mapToDriverValue" in T && typeof T.mapToDriverValue == "function";
|
|
294
294
|
}
|
|
295
|
-
const
|
|
295
|
+
const ZT = {
|
|
296
296
|
mapFromDriverValue: (T) => T
|
|
297
|
-
},
|
|
297
|
+
}, qT = {
|
|
298
298
|
mapToDriverValue: (T) => T
|
|
299
299
|
};
|
|
300
300
|
({
|
|
301
|
-
...
|
|
302
|
-
...
|
|
301
|
+
...ZT,
|
|
302
|
+
...qT
|
|
303
303
|
});
|
|
304
304
|
class rE {
|
|
305
305
|
/**
|
|
306
306
|
* @param value - Parameter value
|
|
307
307
|
* @param encoder - Encoder to convert the value to a driver parameter
|
|
308
308
|
*/
|
|
309
|
-
constructor(E, e =
|
|
309
|
+
constructor(E, e = qT) {
|
|
310
310
|
this.value = E, this.encoder = e;
|
|
311
311
|
}
|
|
312
312
|
static [W] = "Param";
|
|
313
313
|
brand;
|
|
314
314
|
getSQL() {
|
|
315
|
-
return new
|
|
315
|
+
return new d([this]);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
function C(T, ...E) {
|
|
@@ -320,26 +320,26 @@ function C(T, ...E) {
|
|
|
320
320
|
(E.length > 0 || T.length > 0 && T[0] !== "") && e.push(new f(T[0]));
|
|
321
321
|
for (const [R, A] of E.entries())
|
|
322
322
|
e.push(A, new f(T[R + 1]));
|
|
323
|
-
return new
|
|
323
|
+
return new d(e);
|
|
324
324
|
}
|
|
325
325
|
((T) => {
|
|
326
326
|
function E() {
|
|
327
|
-
return new
|
|
327
|
+
return new d([]);
|
|
328
328
|
}
|
|
329
329
|
T.empty = E;
|
|
330
330
|
function e(s) {
|
|
331
|
-
return new
|
|
331
|
+
return new d(s);
|
|
332
332
|
}
|
|
333
333
|
T.fromList = e;
|
|
334
334
|
function R(s) {
|
|
335
|
-
return new
|
|
335
|
+
return new d([new f(s)]);
|
|
336
336
|
}
|
|
337
337
|
T.raw = R;
|
|
338
338
|
function A(s, O) {
|
|
339
339
|
const N = [];
|
|
340
340
|
for (const [r, n] of s.entries())
|
|
341
341
|
r > 0 && O !== void 0 && N.push(O), N.push(n);
|
|
342
|
-
return new
|
|
342
|
+
return new d(N);
|
|
343
343
|
}
|
|
344
344
|
T.join = A;
|
|
345
345
|
function S(s) {
|
|
@@ -372,23 +372,23 @@ function C(T, ...E) {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
T.Aliased = E;
|
|
375
|
-
})(
|
|
375
|
+
})(d || (d = {}));
|
|
376
376
|
class CE {
|
|
377
377
|
constructor(E) {
|
|
378
378
|
this.name = E;
|
|
379
379
|
}
|
|
380
380
|
static [W] = "Placeholder";
|
|
381
381
|
getSQL() {
|
|
382
|
-
return new
|
|
382
|
+
return new d([this]);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
const
|
|
386
|
-
class
|
|
385
|
+
const Ue = Symbol.for("drizzle:IsDrizzleView");
|
|
386
|
+
class jT {
|
|
387
387
|
static [W] = "View";
|
|
388
388
|
/** @internal */
|
|
389
389
|
[TE];
|
|
390
390
|
/** @internal */
|
|
391
|
-
[
|
|
391
|
+
[Ue] = !0;
|
|
392
392
|
constructor({ name: E, schema: e, selectedFields: R, query: A }) {
|
|
393
393
|
this[TE] = {
|
|
394
394
|
name: E,
|
|
@@ -401,20 +401,20 @@ class qT {
|
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
getSQL() {
|
|
404
|
-
return new
|
|
404
|
+
return new d([this]);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
RE.prototype.getSQL = function() {
|
|
408
|
-
return new
|
|
408
|
+
return new d([this]);
|
|
409
409
|
};
|
|
410
410
|
b.prototype.getSQL = function() {
|
|
411
|
-
return new
|
|
411
|
+
return new d([this]);
|
|
412
412
|
};
|
|
413
|
-
|
|
414
|
-
return new
|
|
413
|
+
vT.prototype.getSQL = function() {
|
|
414
|
+
return new d([this]);
|
|
415
415
|
};
|
|
416
416
|
function h(T, E) {
|
|
417
|
-
return
|
|
417
|
+
return Me(E) && !QT(T) && !H(T, rE) && !H(T, CE) && !H(T, RE) && !H(T, b) && !H(T, jT) ? new rE(T, E) : T;
|
|
418
418
|
}
|
|
419
419
|
const k = (T, E) => C`${T} = ${h(E, T)}`, ST = (T, E) => C`${T} <> ${h(E, T)}`;
|
|
420
420
|
function V(...T) {
|
|
@@ -422,7 +422,7 @@ function V(...T) {
|
|
|
422
422
|
(e) => e !== void 0
|
|
423
423
|
);
|
|
424
424
|
if (E.length !== 0)
|
|
425
|
-
return E.length === 1 ? new
|
|
425
|
+
return E.length === 1 ? new d(E) : new d([
|
|
426
426
|
new f("("),
|
|
427
427
|
C.join(E, new f(" and ")),
|
|
428
428
|
new f(")")
|
|
@@ -433,14 +433,14 @@ function PE(...T) {
|
|
|
433
433
|
(e) => e !== void 0
|
|
434
434
|
);
|
|
435
435
|
if (E.length !== 0)
|
|
436
|
-
return E.length === 1 ? new
|
|
436
|
+
return E.length === 1 ? new d(E) : new d([
|
|
437
437
|
new f("("),
|
|
438
438
|
C.join(E, new f(" or ")),
|
|
439
439
|
new f(")")
|
|
440
440
|
]);
|
|
441
441
|
}
|
|
442
442
|
const ME = (T, E) => C`${T} > ${h(E, T)}`, Q = (T, E) => C`${T} >= ${h(E, T)}`, UE = (T, E) => C`${T} < ${h(E, T)}`, Z = (T, E) => C`${T} <= ${h(E, T)}`;
|
|
443
|
-
function
|
|
443
|
+
function cE(T, E) {
|
|
444
444
|
return Array.isArray(E) ? E.length === 0 ? C`false` : C`${T} in ${E.map((e) => h(e, T))}` : C`${T} in ${h(E, T)}`;
|
|
445
445
|
}
|
|
446
446
|
function IT(T, E) {
|
|
@@ -452,7 +452,7 @@ function NT(T) {
|
|
|
452
452
|
function OT(T) {
|
|
453
453
|
return C`${T} is not null`;
|
|
454
454
|
}
|
|
455
|
-
function
|
|
455
|
+
function ce(T, E) {
|
|
456
456
|
if (Array.isArray(E)) {
|
|
457
457
|
if (E.length === 0)
|
|
458
458
|
throw new Error("arrayContains requires at least one value");
|
|
@@ -470,7 +470,7 @@ function le(T, E) {
|
|
|
470
470
|
}
|
|
471
471
|
return C`${T} <@ ${h(E, T)}`;
|
|
472
472
|
}
|
|
473
|
-
function
|
|
473
|
+
function ue(T, E) {
|
|
474
474
|
if (Array.isArray(E)) {
|
|
475
475
|
if (E.length === 0)
|
|
476
476
|
throw new Error("arrayOverlaps requires at least one value");
|
|
@@ -482,23 +482,23 @@ function ce(T, E) {
|
|
|
482
482
|
function tT(T) {
|
|
483
483
|
return C`${T} asc`;
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function Ge(T) {
|
|
486
486
|
return C`${T} desc`;
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function lE(T) {
|
|
489
489
|
return C`count(${T || C.raw("*")})`.mapWith(Number);
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function me(T) {
|
|
492
492
|
return C`count(distinct ${T})`.mapWith(Number);
|
|
493
493
|
}
|
|
494
494
|
function g(T) {
|
|
495
495
|
return C`sum(${T})`.mapWith(String);
|
|
496
496
|
}
|
|
497
497
|
function AE(T) {
|
|
498
|
-
return C`max(${T})`.mapWith(
|
|
498
|
+
return C`max(${T})`.mapWith(H(T, RE) ? T : String);
|
|
499
499
|
}
|
|
500
500
|
function SE(T) {
|
|
501
|
-
return C`min(${T})`.mapWith(
|
|
501
|
+
return C`min(${T})`.mapWith(H(T, RE) ? T : String);
|
|
502
502
|
}
|
|
503
503
|
class jE {
|
|
504
504
|
/**
|
|
@@ -526,7 +526,7 @@ class jE {
|
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
class
|
|
529
|
+
class de extends jE {
|
|
530
530
|
getEngineType() {
|
|
531
531
|
return "postgres";
|
|
532
532
|
}
|
|
@@ -650,7 +650,7 @@ class me extends jE {
|
|
|
650
650
|
return E;
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
class
|
|
653
|
+
class kT extends jE {
|
|
654
654
|
getEngineType() {
|
|
655
655
|
return "mysql";
|
|
656
656
|
}
|
|
@@ -927,7 +927,7 @@ class He extends jE {
|
|
|
927
927
|
return E;
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
|
-
class
|
|
930
|
+
class Be extends kT {
|
|
931
931
|
getEngineType() {
|
|
932
932
|
return "singlestore";
|
|
933
933
|
}
|
|
@@ -940,16 +940,16 @@ class de extends jT {
|
|
|
940
940
|
// These limitations are typically handled at the query building level
|
|
941
941
|
// rather than in the adapter, but can be addressed here if needed
|
|
942
942
|
}
|
|
943
|
-
function
|
|
943
|
+
function pe(T) {
|
|
944
944
|
switch (T) {
|
|
945
945
|
case "postgres":
|
|
946
|
-
return new
|
|
946
|
+
return new de();
|
|
947
947
|
case "mysql":
|
|
948
|
-
return new
|
|
948
|
+
return new kT();
|
|
949
949
|
case "sqlite":
|
|
950
950
|
return new He();
|
|
951
951
|
case "singlestore":
|
|
952
|
-
return new
|
|
952
|
+
return new Be();
|
|
953
953
|
default:
|
|
954
954
|
throw new Error(`Unsupported database engine: ${T}`);
|
|
955
955
|
}
|
|
@@ -958,11 +958,11 @@ class kE {
|
|
|
958
958
|
constructor(E, e, R) {
|
|
959
959
|
this.db = E, this.schema = e;
|
|
960
960
|
const A = R || this.getEngineType();
|
|
961
|
-
this.databaseAdapter =
|
|
961
|
+
this.databaseAdapter = pe(A);
|
|
962
962
|
}
|
|
963
963
|
databaseAdapter;
|
|
964
964
|
}
|
|
965
|
-
class
|
|
965
|
+
class Fe extends kE {
|
|
966
966
|
async execute(E, e) {
|
|
967
967
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
968
968
|
const A = await E.execute();
|
|
@@ -1014,9 +1014,9 @@ class pe extends kE {
|
|
|
1014
1014
|
}
|
|
1015
1015
|
}
|
|
1016
1016
|
function sT(T, E) {
|
|
1017
|
-
return new
|
|
1017
|
+
return new Fe(T, E, "postgres");
|
|
1018
1018
|
}
|
|
1019
|
-
class
|
|
1019
|
+
class zT extends kE {
|
|
1020
1020
|
async execute(E, e) {
|
|
1021
1021
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
1022
1022
|
const A = await E.execute();
|
|
@@ -1054,10 +1054,10 @@ class kT extends kE {
|
|
|
1054
1054
|
return "mysql";
|
|
1055
1055
|
}
|
|
1056
1056
|
}
|
|
1057
|
-
function
|
|
1058
|
-
return new
|
|
1057
|
+
function Ye(T, E) {
|
|
1058
|
+
return new zT(T, E, "mysql");
|
|
1059
1059
|
}
|
|
1060
|
-
class
|
|
1060
|
+
class fe extends kE {
|
|
1061
1061
|
async execute(E, e) {
|
|
1062
1062
|
if (E && typeof E == "object" && typeof E.execute == "function") {
|
|
1063
1063
|
const R = await E.execute();
|
|
@@ -1104,9 +1104,9 @@ class Ye extends kE {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
1106
|
function rT(T, E) {
|
|
1107
|
-
return new
|
|
1107
|
+
return new fe(T, E, "sqlite");
|
|
1108
1108
|
}
|
|
1109
|
-
class
|
|
1109
|
+
class he extends zT {
|
|
1110
1110
|
getEngineType() {
|
|
1111
1111
|
return "singlestore";
|
|
1112
1112
|
}
|
|
@@ -1114,8 +1114,8 @@ class fe extends kT {
|
|
|
1114
1114
|
// For now, we inherit all behavior from MySQLExecutor since
|
|
1115
1115
|
// SingleStore is largely MySQL-compatible
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1118
|
-
return new
|
|
1117
|
+
function Ve(T, E) {
|
|
1118
|
+
return new he(T, E);
|
|
1119
1119
|
}
|
|
1120
1120
|
function CT(T, E, e) {
|
|
1121
1121
|
if (e)
|
|
@@ -1123,11 +1123,11 @@ function CT(T, E, e) {
|
|
|
1123
1123
|
case "postgres":
|
|
1124
1124
|
return sT(T, E);
|
|
1125
1125
|
case "mysql":
|
|
1126
|
-
return
|
|
1126
|
+
return Ye(T, E);
|
|
1127
1127
|
case "sqlite":
|
|
1128
1128
|
return rT(T, E);
|
|
1129
1129
|
case "singlestore":
|
|
1130
|
-
return
|
|
1130
|
+
return Ve(T, E);
|
|
1131
1131
|
}
|
|
1132
1132
|
if (T.all && T.run)
|
|
1133
1133
|
return rT(T, E);
|
|
@@ -1138,7 +1138,7 @@ function CT(T, E, e) {
|
|
|
1138
1138
|
function nT(T) {
|
|
1139
1139
|
return typeof T == "function" ? T() : T;
|
|
1140
1140
|
}
|
|
1141
|
-
function
|
|
1141
|
+
function Ee(T, E) {
|
|
1142
1142
|
if (E) return E;
|
|
1143
1143
|
switch (T) {
|
|
1144
1144
|
case "belongsTo":
|
|
@@ -1157,14 +1157,14 @@ function zT(T, E) {
|
|
|
1157
1157
|
return "left";
|
|
1158
1158
|
}
|
|
1159
1159
|
}
|
|
1160
|
-
function
|
|
1160
|
+
function We(T) {
|
|
1161
1161
|
return T && typeof T == "object" ? C`${C`${T}`}` : T;
|
|
1162
1162
|
}
|
|
1163
1163
|
function w(T, E) {
|
|
1164
1164
|
const e = typeof T == "function" ? T(E) : T;
|
|
1165
|
-
return
|
|
1165
|
+
return We(e);
|
|
1166
1166
|
}
|
|
1167
|
-
function
|
|
1167
|
+
function be(T, E) {
|
|
1168
1168
|
if (T.relationship !== "belongsToMany" || !T.through)
|
|
1169
1169
|
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
1170
1170
|
const { table: e, sourceKey: R, targetKey: A, securitySql: S } = T.through, I = [];
|
|
@@ -1182,7 +1182,7 @@ function We(T, E) {
|
|
|
1182
1182
|
const N = S(E);
|
|
1183
1183
|
s = Array.isArray(N) ? N : [N];
|
|
1184
1184
|
}
|
|
1185
|
-
const O =
|
|
1185
|
+
const O = Ee("belongsToMany", T.sqlJoinType);
|
|
1186
1186
|
return {
|
|
1187
1187
|
junctionJoins: [
|
|
1188
1188
|
{
|
|
@@ -1420,7 +1420,7 @@ class J {
|
|
|
1420
1420
|
return E.type === "calculated" && !!E.calculatedSql;
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
|
-
function
|
|
1423
|
+
function Xe(T, E) {
|
|
1424
1424
|
const { cube: e, allCubes: R, resolvedMeasures: A } = E, S = zE(T), I = /* @__PURE__ */ new Map();
|
|
1425
1425
|
for (const r of S) {
|
|
1426
1426
|
const { originalRef: n, cubeName: L, fieldName: i } = r, D = L || e.name;
|
|
@@ -1428,12 +1428,12 @@ function be(T, E) {
|
|
|
1428
1428
|
throw new Error(
|
|
1429
1429
|
`Cannot substitute {${n}}: cube '${D}' not found`
|
|
1430
1430
|
);
|
|
1431
|
-
const P = `${D}.${i}`,
|
|
1432
|
-
if (!
|
|
1431
|
+
const P = `${D}.${i}`, U = A.get(P);
|
|
1432
|
+
if (!U)
|
|
1433
1433
|
throw new Error(
|
|
1434
1434
|
`Cannot substitute {${n}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
1435
1435
|
);
|
|
1436
|
-
const M =
|
|
1436
|
+
const M = U(), G = C`${M}`;
|
|
1437
1437
|
I.set(n, G);
|
|
1438
1438
|
}
|
|
1439
1439
|
const t = [], s = [];
|
|
@@ -1473,7 +1473,7 @@ function zE(T) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
return R;
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function ye(T) {
|
|
1477
1477
|
const E = [];
|
|
1478
1478
|
let e = 0;
|
|
1479
1479
|
for (let I = 0; I < T.length; I++)
|
|
@@ -1506,7 +1506,7 @@ function uE(T, E) {
|
|
|
1506
1506
|
}
|
|
1507
1507
|
return Array.from(R);
|
|
1508
1508
|
}
|
|
1509
|
-
class
|
|
1509
|
+
class ge {
|
|
1510
1510
|
constructor(E) {
|
|
1511
1511
|
this.databaseAdapter = E;
|
|
1512
1512
|
}
|
|
@@ -1530,10 +1530,10 @@ class ye {
|
|
|
1530
1530
|
if (L && L.measures && L.measures[n]) {
|
|
1531
1531
|
const i = L.measures[n];
|
|
1532
1532
|
J.isCalculatedMeasure(i) ? (t.push(N), uE(i.calculatedSql, r).forEach((P) => s.add(P)), O.getAllDependencies(N).forEach((P) => {
|
|
1533
|
-
const [
|
|
1533
|
+
const [U, M] = P.split("."), G = e.get(U);
|
|
1534
1534
|
if (G && G.measures[M]) {
|
|
1535
1535
|
const m = G.measures[M];
|
|
1536
|
-
J.isCalculatedMeasure(m) && uE(m.calculatedSql,
|
|
1536
|
+
J.isCalculatedMeasure(m) && uE(m.calculatedSql, U).forEach((X) => s.add(X));
|
|
1537
1537
|
}
|
|
1538
1538
|
})) : I.push(N);
|
|
1539
1539
|
}
|
|
@@ -1609,7 +1609,7 @@ class ye {
|
|
|
1609
1609
|
A[I.dimension] = C`${r}`.as(I.dimension);
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
|
-
return Object.keys(A).length === 0 && (A.count =
|
|
1612
|
+
return Object.keys(A).length === 0 && (A.count = lE()), A;
|
|
1613
1613
|
}
|
|
1614
1614
|
/**
|
|
1615
1615
|
* Build calculated measure expression by substituting {member} references
|
|
@@ -1621,7 +1621,7 @@ class ye {
|
|
|
1621
1621
|
`Calculated measure '${e.name}.${E.name}' missing calculatedSql property`
|
|
1622
1622
|
);
|
|
1623
1623
|
const I = this.databaseAdapter.preprocessCalculatedTemplate(E.calculatedSql);
|
|
1624
|
-
return
|
|
1624
|
+
return Xe(I, {
|
|
1625
1625
|
cube: e,
|
|
1626
1626
|
allCubes: R,
|
|
1627
1627
|
resolvedMeasures: A
|
|
@@ -1759,9 +1759,9 @@ class ye {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
switch (E.type) {
|
|
1761
1761
|
case "count":
|
|
1762
|
-
return
|
|
1762
|
+
return lE(R);
|
|
1763
1763
|
case "countDistinct":
|
|
1764
|
-
return
|
|
1764
|
+
return me(R);
|
|
1765
1765
|
case "sum":
|
|
1766
1766
|
return g(R);
|
|
1767
1767
|
case "avg":
|
|
@@ -1773,7 +1773,7 @@ class ye {
|
|
|
1773
1773
|
case "number":
|
|
1774
1774
|
return R;
|
|
1775
1775
|
default:
|
|
1776
|
-
return
|
|
1776
|
+
return lE(R);
|
|
1777
1777
|
}
|
|
1778
1778
|
}
|
|
1779
1779
|
/**
|
|
@@ -1781,7 +1781,7 @@ class ye {
|
|
|
1781
1781
|
*/
|
|
1782
1782
|
buildTimeDimensionExpression(E, e, R) {
|
|
1783
1783
|
const A = w(E, R);
|
|
1784
|
-
return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof
|
|
1784
|
+
return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof d ? A : C`${A}`;
|
|
1785
1785
|
}
|
|
1786
1786
|
/**
|
|
1787
1787
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -1840,7 +1840,7 @@ class ye {
|
|
|
1840
1840
|
const N = O.dimensions[s], r = O.measures[s], n = N || r;
|
|
1841
1841
|
if (!n) return null;
|
|
1842
1842
|
if (A === "where" && N) {
|
|
1843
|
-
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((
|
|
1843
|
+
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((l) => l.cube.name === t))
|
|
1844
1844
|
return null;
|
|
1845
1845
|
const i = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(I.operator) ? typeof N.sql == "function" ? N.sql(R) : N.sql : w(N.sql, R);
|
|
1846
1846
|
return this.buildFilterCondition(
|
|
@@ -1892,9 +1892,9 @@ class ye {
|
|
|
1892
1892
|
if (I.length > 1) {
|
|
1893
1893
|
if (A?.type === "time") {
|
|
1894
1894
|
const s = I.map((O) => this.normalizeDate(O) || O);
|
|
1895
|
-
return
|
|
1895
|
+
return cE(E, s);
|
|
1896
1896
|
}
|
|
1897
|
-
return
|
|
1897
|
+
return cE(E, I);
|
|
1898
1898
|
} else if (I.length === 1) {
|
|
1899
1899
|
const s = A?.type === "time" && this.normalizeDate(t) || t;
|
|
1900
1900
|
return k(E, s);
|
|
@@ -1958,7 +1958,7 @@ class ye {
|
|
|
1958
1958
|
ME(E, I[1])
|
|
1959
1959
|
) : null;
|
|
1960
1960
|
case "in":
|
|
1961
|
-
return I.length > 0 ?
|
|
1961
|
+
return I.length > 0 ? cE(E, I) : null;
|
|
1962
1962
|
case "notIn":
|
|
1963
1963
|
return I.length > 0 ? IT(E, I) : null;
|
|
1964
1964
|
case "like":
|
|
@@ -1984,9 +1984,9 @@ class ye {
|
|
|
1984
1984
|
// PostgreSQL array operators - silent no-op for other databases
|
|
1985
1985
|
// These use Drizzle's built-in array operator functions
|
|
1986
1986
|
case "arrayContains":
|
|
1987
|
-
return this.databaseAdapter.getEngineType() === "postgres" ? Ue(E, I) : null;
|
|
1988
|
-
case "arrayOverlaps":
|
|
1989
1987
|
return this.databaseAdapter.getEngineType() === "postgres" ? ce(E, I) : null;
|
|
1988
|
+
case "arrayOverlaps":
|
|
1989
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? ue(E, I) : null;
|
|
1990
1990
|
case "arrayContained":
|
|
1991
1991
|
return this.databaseAdapter.getEngineType() === "postgres" ? le(E, I) : null;
|
|
1992
1992
|
default:
|
|
@@ -2095,8 +2095,8 @@ class ye {
|
|
|
2095
2095
|
return { start: n, end: L };
|
|
2096
2096
|
}
|
|
2097
2097
|
if (R === "last quarter") {
|
|
2098
|
-
const n = Math.floor(S / 3), L = n === 0 ? 3 : n - 1, i = n === 0 ? A - 1 : A, D = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)),
|
|
2099
|
-
return { start: D, end:
|
|
2098
|
+
const n = Math.floor(S / 3), L = n === 0 ? 3 : n - 1, i = n === 0 ? A - 1 : A, D = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, L * 3 + 3, 0, 23, 59, 59, 999));
|
|
2099
|
+
return { start: D, end: l };
|
|
2100
2100
|
}
|
|
2101
2101
|
if (R === "last year") {
|
|
2102
2102
|
const n = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(A - 1, 11, 31, 23, 59, 59, 999));
|
|
@@ -2209,7 +2209,7 @@ class ye {
|
|
|
2209
2209
|
for (const [S, I] of Object.entries(E.order)) {
|
|
2210
2210
|
if (!A.includes(S))
|
|
2211
2211
|
throw new Error(`Cannot order by '${S}': field is not selected in the query`);
|
|
2212
|
-
const t = I === "desc" ?
|
|
2212
|
+
const t = I === "desc" ? Ge(C.identifier(S)) : tT(C.identifier(S));
|
|
2213
2213
|
R.push(t);
|
|
2214
2214
|
}
|
|
2215
2215
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
@@ -2258,7 +2258,7 @@ class ye {
|
|
|
2258
2258
|
return A;
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
class
|
|
2261
|
+
class Ke {
|
|
2262
2262
|
/**
|
|
2263
2263
|
* Analyze a semantic query to determine which cubes are involved
|
|
2264
2264
|
*/
|
|
@@ -2421,7 +2421,7 @@ class ge {
|
|
|
2421
2421
|
if (!n)
|
|
2422
2422
|
throw new Error(`Cube '${N}' not found`);
|
|
2423
2423
|
if (r.relationship === "belongsToMany" && r.through) {
|
|
2424
|
-
const L =
|
|
2424
|
+
const L = be(r, A.securityContext);
|
|
2425
2425
|
S.push({
|
|
2426
2426
|
cube: n,
|
|
2427
2427
|
alias: `${N.toLowerCase()}_cube`,
|
|
@@ -2444,7 +2444,7 @@ class ge {
|
|
|
2444
2444
|
// No source alias needed - use the actual column
|
|
2445
2445
|
null
|
|
2446
2446
|
// No target alias needed - use the actual column
|
|
2447
|
-
), i =
|
|
2447
|
+
), i = Ee(r.relationship, r.sqlJoinType);
|
|
2448
2448
|
S.push({
|
|
2449
2449
|
cube: n,
|
|
2450
2450
|
alias: `${N.toLowerCase()}_cube`,
|
|
@@ -2579,11 +2579,167 @@ class ge {
|
|
|
2579
2579
|
return null;
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
|
+
function $e(T, E, e) {
|
|
2583
|
+
const R = [];
|
|
2584
|
+
let A = LT(new Date(T), e);
|
|
2585
|
+
const S = LT(new Date(E), e), I = 1e4;
|
|
2586
|
+
for (; A <= S && R.length < I; )
|
|
2587
|
+
R.push(new Date(A)), A = we(A, e);
|
|
2588
|
+
return R;
|
|
2589
|
+
}
|
|
2590
|
+
function LT(T, E) {
|
|
2591
|
+
const e = new Date(T);
|
|
2592
|
+
switch (E) {
|
|
2593
|
+
case "second":
|
|
2594
|
+
e.setUTCMilliseconds(0);
|
|
2595
|
+
break;
|
|
2596
|
+
case "minute":
|
|
2597
|
+
e.setUTCSeconds(0, 0);
|
|
2598
|
+
break;
|
|
2599
|
+
case "hour":
|
|
2600
|
+
e.setUTCMinutes(0, 0, 0);
|
|
2601
|
+
break;
|
|
2602
|
+
case "day":
|
|
2603
|
+
e.setUTCHours(0, 0, 0, 0);
|
|
2604
|
+
break;
|
|
2605
|
+
case "week": {
|
|
2606
|
+
const R = e.getUTCDay(), A = R === 0 ? 6 : R - 1;
|
|
2607
|
+
e.setUTCDate(e.getUTCDate() - A), e.setUTCHours(0, 0, 0, 0);
|
|
2608
|
+
break;
|
|
2609
|
+
}
|
|
2610
|
+
case "month":
|
|
2611
|
+
e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0);
|
|
2612
|
+
break;
|
|
2613
|
+
case "quarter": {
|
|
2614
|
+
const R = Math.floor(e.getUTCMonth() / 3) * 3;
|
|
2615
|
+
e.setUTCMonth(R, 1), e.setUTCHours(0, 0, 0, 0);
|
|
2616
|
+
break;
|
|
2617
|
+
}
|
|
2618
|
+
case "year":
|
|
2619
|
+
e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
|
|
2620
|
+
break;
|
|
2621
|
+
}
|
|
2622
|
+
return e;
|
|
2623
|
+
}
|
|
2624
|
+
function we(T, E) {
|
|
2625
|
+
const e = new Date(T);
|
|
2626
|
+
switch (E) {
|
|
2627
|
+
case "second":
|
|
2628
|
+
e.setUTCSeconds(e.getUTCSeconds() + 1);
|
|
2629
|
+
break;
|
|
2630
|
+
case "minute":
|
|
2631
|
+
e.setUTCMinutes(e.getUTCMinutes() + 1);
|
|
2632
|
+
break;
|
|
2633
|
+
case "hour":
|
|
2634
|
+
e.setUTCHours(e.getUTCHours() + 1);
|
|
2635
|
+
break;
|
|
2636
|
+
case "day":
|
|
2637
|
+
e.setUTCDate(e.getUTCDate() + 1);
|
|
2638
|
+
break;
|
|
2639
|
+
case "week":
|
|
2640
|
+
e.setUTCDate(e.getUTCDate() + 7);
|
|
2641
|
+
break;
|
|
2642
|
+
case "month":
|
|
2643
|
+
e.setUTCMonth(e.getUTCMonth() + 1);
|
|
2644
|
+
break;
|
|
2645
|
+
case "quarter":
|
|
2646
|
+
e.setUTCMonth(e.getUTCMonth() + 3);
|
|
2647
|
+
break;
|
|
2648
|
+
case "year":
|
|
2649
|
+
e.setUTCFullYear(e.getUTCFullYear() + 1);
|
|
2650
|
+
break;
|
|
2651
|
+
}
|
|
2652
|
+
return e;
|
|
2653
|
+
}
|
|
2654
|
+
function Je(T) {
|
|
2655
|
+
if (T instanceof Date)
|
|
2656
|
+
return T.toISOString();
|
|
2657
|
+
if (typeof T == "string") {
|
|
2658
|
+
const E = new Date(T);
|
|
2659
|
+
if (!isNaN(E.getTime()))
|
|
2660
|
+
return E.toISOString();
|
|
2661
|
+
}
|
|
2662
|
+
return String(T);
|
|
2663
|
+
}
|
|
2664
|
+
function xe(T, E) {
|
|
2665
|
+
return E.length === 0 ? "__all__" : E.map((e) => String(T[e] ?? "")).join("|||");
|
|
2666
|
+
}
|
|
2667
|
+
function ve(T, E) {
|
|
2668
|
+
const { timeDimensionKey: e, granularity: R, dateRange: A, fillValue: S, measures: I, dimensions: t } = E, s = $e(A[0], A[1], R);
|
|
2669
|
+
if (s.length === 0)
|
|
2670
|
+
return T;
|
|
2671
|
+
const O = /* @__PURE__ */ new Map();
|
|
2672
|
+
for (const r of T) {
|
|
2673
|
+
const n = xe(r, t), L = Je(r[e]);
|
|
2674
|
+
O.has(n) || O.set(n, /* @__PURE__ */ new Map()), O.get(n).set(L, r);
|
|
2675
|
+
}
|
|
2676
|
+
O.size === 0 && t.length === 0 && O.set("__all__", /* @__PURE__ */ new Map());
|
|
2677
|
+
const N = [];
|
|
2678
|
+
for (const [r, n] of O) {
|
|
2679
|
+
const L = n.size > 0 ? n.values().next().value : null;
|
|
2680
|
+
for (const i of s) {
|
|
2681
|
+
const D = i.toISOString(), l = n.get(D);
|
|
2682
|
+
if (l)
|
|
2683
|
+
N.push(l);
|
|
2684
|
+
else {
|
|
2685
|
+
const P = {
|
|
2686
|
+
[e]: D
|
|
2687
|
+
};
|
|
2688
|
+
if (L)
|
|
2689
|
+
for (const U of t)
|
|
2690
|
+
P[U] = L[U];
|
|
2691
|
+
for (const U of I)
|
|
2692
|
+
P[U] = S;
|
|
2693
|
+
N.push(P);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
return N;
|
|
2698
|
+
}
|
|
2699
|
+
function Qe(T) {
|
|
2700
|
+
if (!T)
|
|
2701
|
+
return null;
|
|
2702
|
+
if (Array.isArray(T)) {
|
|
2703
|
+
if (T.length < 2)
|
|
2704
|
+
return null;
|
|
2705
|
+
const e = new Date(T[0]), R = new Date(T[1]);
|
|
2706
|
+
return isNaN(e.getTime()) || isNaN(R.getTime()) ? null : [e, R];
|
|
2707
|
+
}
|
|
2708
|
+
const E = new Date(T);
|
|
2709
|
+
return isNaN(E.getTime()) ? null : [E, E];
|
|
2710
|
+
}
|
|
2711
|
+
function Ze(T, E, e) {
|
|
2712
|
+
if (!E.timeDimensions || E.timeDimensions.length === 0)
|
|
2713
|
+
return T;
|
|
2714
|
+
const R = E.timeDimensions.filter((s) => {
|
|
2715
|
+
const O = s.fillMissingDates !== !1, N = s.granularity && s.dateRange;
|
|
2716
|
+
return O && N;
|
|
2717
|
+
});
|
|
2718
|
+
if (R.length === 0)
|
|
2719
|
+
return T;
|
|
2720
|
+
const A = E.fillMissingDatesValue === void 0 ? 0 : E.fillMissingDatesValue, S = new Set(E.timeDimensions.map((s) => s.dimension)), I = (E.dimensions || []).filter((s) => !S.has(s));
|
|
2721
|
+
let t = T;
|
|
2722
|
+
for (const s of R) {
|
|
2723
|
+
const O = Qe(s.dateRange);
|
|
2724
|
+
if (!O)
|
|
2725
|
+
continue;
|
|
2726
|
+
const N = {
|
|
2727
|
+
timeDimensionKey: s.dimension,
|
|
2728
|
+
granularity: s.granularity,
|
|
2729
|
+
dateRange: O,
|
|
2730
|
+
fillValue: A,
|
|
2731
|
+
measures: e,
|
|
2732
|
+
dimensions: I
|
|
2733
|
+
};
|
|
2734
|
+
t = ve(t, N);
|
|
2735
|
+
}
|
|
2736
|
+
return t;
|
|
2737
|
+
}
|
|
2582
2738
|
class GE {
|
|
2583
2739
|
constructor(E) {
|
|
2584
2740
|
if (this.dbExecutor = E, this.databaseAdapter = E.databaseAdapter, !this.databaseAdapter)
|
|
2585
2741
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
2586
|
-
this.queryBuilder = new
|
|
2742
|
+
this.queryBuilder = new ge(this.databaseAdapter), this.queryPlanner = new Ke();
|
|
2587
2743
|
}
|
|
2588
2744
|
queryBuilder;
|
|
2589
2745
|
queryPlanner;
|
|
@@ -2593,31 +2749,31 @@ class GE {
|
|
|
2593
2749
|
*/
|
|
2594
2750
|
async execute(E, e, R) {
|
|
2595
2751
|
try {
|
|
2596
|
-
const A =
|
|
2752
|
+
const A = Le(E, e);
|
|
2597
2753
|
if (!A.isValid)
|
|
2598
2754
|
throw new Error(`Query validation failed: ${A.errors.join(", ")}`);
|
|
2599
2755
|
const S = {
|
|
2600
2756
|
db: this.dbExecutor.db,
|
|
2601
2757
|
schema: this.dbExecutor.schema,
|
|
2602
2758
|
securityContext: R
|
|
2603
|
-
}, I = this.queryPlanner.createQueryPlan(E, e, S), t = this.buildUnifiedQuery(I, e, S), s = this.queryBuilder.collectNumericFields(E, e), O = await this.dbExecutor.execute(t, s), N = Array.isArray(O) ? O.map((
|
|
2604
|
-
const
|
|
2759
|
+
}, I = this.queryPlanner.createQueryPlan(E, e, S), t = this.buildUnifiedQuery(I, e, S), s = this.queryBuilder.collectNumericFields(E, e), O = await this.dbExecutor.execute(t, s), N = Array.isArray(O) ? O.map((i) => {
|
|
2760
|
+
const D = { ...i };
|
|
2605
2761
|
if (e.timeDimensions) {
|
|
2606
|
-
for (const
|
|
2607
|
-
if (
|
|
2608
|
-
let
|
|
2609
|
-
if (typeof
|
|
2610
|
-
const
|
|
2611
|
-
|
|
2762
|
+
for (const l of e.timeDimensions)
|
|
2763
|
+
if (l.dimension in D) {
|
|
2764
|
+
let P = D[l.dimension];
|
|
2765
|
+
if (typeof P == "string" && P.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
2766
|
+
const U = P.replace(" ", "T"), M = !U.endsWith("Z") && !U.includes("+") ? U + "Z" : U;
|
|
2767
|
+
P = new Date(M);
|
|
2612
2768
|
}
|
|
2613
|
-
|
|
2769
|
+
P = this.databaseAdapter.convertTimeDimensionResult(P), D[l.dimension] = P;
|
|
2614
2770
|
}
|
|
2615
2771
|
}
|
|
2616
|
-
return
|
|
2617
|
-
}) : [O], r = this.generateAnnotations(I, e);
|
|
2772
|
+
return D;
|
|
2773
|
+
}) : [O], r = e.measures || [], n = Ze(N, e, r), L = this.generateAnnotations(I, e);
|
|
2618
2774
|
return {
|
|
2619
|
-
data:
|
|
2620
|
-
annotation:
|
|
2775
|
+
data: n,
|
|
2776
|
+
annotation: L
|
|
2621
2777
|
};
|
|
2622
2778
|
} catch (A) {
|
|
2623
2779
|
throw new Error(`Query execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
|
|
@@ -2638,8 +2794,8 @@ class GE {
|
|
|
2638
2794
|
for (const P of E.joinKeys)
|
|
2639
2795
|
if (P.targetColumnObj) {
|
|
2640
2796
|
t[P.targetColumn] = P.targetColumnObj;
|
|
2641
|
-
for (const [
|
|
2642
|
-
M.sql === P.targetColumnObj &&
|
|
2797
|
+
for (const [U, M] of Object.entries(S.dimensions || {}))
|
|
2798
|
+
M.sql === P.targetColumnObj && U !== P.targetColumn && (t[U] = C`${P.targetColumnObj}`.as(U));
|
|
2643
2799
|
}
|
|
2644
2800
|
const s = S.name, O = /* @__PURE__ */ new Map([[s, S]]), N = this.queryBuilder.buildResolvedMeasures(
|
|
2645
2801
|
E.measures,
|
|
@@ -2647,24 +2803,24 @@ class GE {
|
|
|
2647
2803
|
R
|
|
2648
2804
|
);
|
|
2649
2805
|
for (const P of E.measures) {
|
|
2650
|
-
const [,
|
|
2806
|
+
const [, U] = P.split("."), M = N.get(P);
|
|
2651
2807
|
if (M) {
|
|
2652
2808
|
const G = M();
|
|
2653
|
-
t[
|
|
2809
|
+
t[U] = C`${G}`.as(U);
|
|
2654
2810
|
}
|
|
2655
2811
|
}
|
|
2656
2812
|
if (e.dimensions)
|
|
2657
2813
|
for (const P of e.dimensions) {
|
|
2658
|
-
const [
|
|
2659
|
-
if (
|
|
2814
|
+
const [U, M] = P.split(".");
|
|
2815
|
+
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2660
2816
|
const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R);
|
|
2661
2817
|
t[M] = C`${m}`.as(M);
|
|
2662
2818
|
}
|
|
2663
2819
|
}
|
|
2664
2820
|
if (e.timeDimensions)
|
|
2665
2821
|
for (const P of e.timeDimensions) {
|
|
2666
|
-
const [
|
|
2667
|
-
if (
|
|
2822
|
+
const [U, M] = P.dimension.split(".");
|
|
2823
|
+
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2668
2824
|
const G = S.dimensions[M], m = this.queryBuilder.buildTimeDimensionExpression(G.sql, P.granularity, R);
|
|
2669
2825
|
t[M] = C`${m}`.as(M);
|
|
2670
2826
|
}
|
|
@@ -2678,8 +2834,8 @@ class GE {
|
|
|
2678
2834
|
} : void 0, L = this.queryBuilder.buildWhereConditions(S, e, R, n), i = [];
|
|
2679
2835
|
if (e.timeDimensions)
|
|
2680
2836
|
for (const P of e.timeDimensions) {
|
|
2681
|
-
const [
|
|
2682
|
-
if (
|
|
2837
|
+
const [U, M] = P.dimension.split(".");
|
|
2838
|
+
if (U === s && S.dimensions && S.dimensions[M] && P.dateRange) {
|
|
2683
2839
|
const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R), B = this.queryBuilder.buildDateRangeCondition(m, P.dateRange);
|
|
2684
2840
|
B && i.push(B);
|
|
2685
2841
|
}
|
|
@@ -2687,11 +2843,11 @@ class GE {
|
|
|
2687
2843
|
if (e.filters) {
|
|
2688
2844
|
for (const P of e.filters)
|
|
2689
2845
|
if (!("and" in P) && !("or" in P) && "member" in P && "operator" in P) {
|
|
2690
|
-
const
|
|
2846
|
+
const U = P, [M, G] = U.member.split(".");
|
|
2691
2847
|
if (M === s && S.dimensions && S.dimensions[G]) {
|
|
2692
2848
|
const m = S.dimensions[G];
|
|
2693
|
-
if (
|
|
2694
|
-
const B = this.queryBuilder.buildMeasureExpression({ sql: m.sql, type: "number" }, R), X = this.queryBuilder.buildDateRangeCondition(B,
|
|
2849
|
+
if (U.operator === "inDateRange") {
|
|
2850
|
+
const B = this.queryBuilder.buildMeasureExpression({ sql: m.sql, type: "number" }, R), X = this.queryBuilder.buildDateRangeCondition(B, U.values);
|
|
2695
2851
|
X && i.push(X);
|
|
2696
2852
|
}
|
|
2697
2853
|
}
|
|
@@ -2702,26 +2858,26 @@ class GE {
|
|
|
2702
2858
|
const P = D.length === 1 ? D[0] : V(...D);
|
|
2703
2859
|
r = r.where(P);
|
|
2704
2860
|
}
|
|
2705
|
-
const
|
|
2861
|
+
const l = [];
|
|
2706
2862
|
for (const P of E.joinKeys)
|
|
2707
|
-
P.targetColumnObj &&
|
|
2863
|
+
P.targetColumnObj && l.push(P.targetColumnObj);
|
|
2708
2864
|
if (e.dimensions)
|
|
2709
2865
|
for (const P of e.dimensions) {
|
|
2710
|
-
const [
|
|
2711
|
-
if (
|
|
2866
|
+
const [U, M] = P.split(".");
|
|
2867
|
+
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2712
2868
|
const G = S.dimensions[M], m = w(G.sql, R);
|
|
2713
|
-
|
|
2869
|
+
l.push(m);
|
|
2714
2870
|
}
|
|
2715
2871
|
}
|
|
2716
2872
|
if (e.timeDimensions)
|
|
2717
2873
|
for (const P of e.timeDimensions) {
|
|
2718
|
-
const [
|
|
2719
|
-
if (
|
|
2874
|
+
const [U, M] = P.dimension.split(".");
|
|
2875
|
+
if (U === s && S.dimensions && S.dimensions[M]) {
|
|
2720
2876
|
const G = S.dimensions[M], m = this.queryBuilder.buildTimeDimensionExpression(G.sql, P.granularity, R);
|
|
2721
|
-
|
|
2877
|
+
l.push(m);
|
|
2722
2878
|
}
|
|
2723
2879
|
}
|
|
2724
|
-
return
|
|
2880
|
+
return l.length > 0 && (r = r.groupBy(...l)), R.db.$with(E.cteAlias).as(r);
|
|
2725
2881
|
}
|
|
2726
2882
|
// Removed unused getActualJoinTargetColumn method
|
|
2727
2883
|
/**
|
|
@@ -2745,8 +2901,8 @@ class GE {
|
|
|
2745
2901
|
const A = [], S = /* @__PURE__ */ new Map();
|
|
2746
2902
|
if (E.preAggregationCTEs && E.preAggregationCTEs.length > 0)
|
|
2747
2903
|
for (const D of E.preAggregationCTEs) {
|
|
2748
|
-
const
|
|
2749
|
-
|
|
2904
|
+
const l = this.buildPreAggregationCTE(D, e, R, E);
|
|
2905
|
+
l && (A.push(l), S.set(D.cube.name, D.cteAlias));
|
|
2750
2906
|
}
|
|
2751
2907
|
const I = E.primaryCube.sql(R), s = { ...this.queryBuilder.buildSelections(
|
|
2752
2908
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2756,12 +2912,12 @@ class GE {
|
|
|
2756
2912
|
) };
|
|
2757
2913
|
if (E.preAggregationCTEs)
|
|
2758
2914
|
for (const D of E.preAggregationCTEs) {
|
|
2759
|
-
const
|
|
2915
|
+
const l = D.cube.name;
|
|
2760
2916
|
for (const P of D.measures)
|
|
2761
2917
|
if (s[P]) {
|
|
2762
|
-
const [,
|
|
2763
|
-
if (M && M.measures && M.measures[
|
|
2764
|
-
const G = M.measures[
|
|
2918
|
+
const [, U] = P.split("."), M = this.getCubesFromPlan(E).get(l);
|
|
2919
|
+
if (M && M.measures && M.measures[U]) {
|
|
2920
|
+
const G = M.measures[U];
|
|
2765
2921
|
let m;
|
|
2766
2922
|
if (G.type === "calculated" && G.calculatedSql) {
|
|
2767
2923
|
const B = this.getCubesFromPlan(E);
|
|
@@ -2773,7 +2929,7 @@ class GE {
|
|
|
2773
2929
|
R
|
|
2774
2930
|
);
|
|
2775
2931
|
} else {
|
|
2776
|
-
const B = C`${C.identifier(D.cteAlias)}.${C.identifier(
|
|
2932
|
+
const B = C`${C.identifier(D.cteAlias)}.${C.identifier(U)}`;
|
|
2777
2933
|
switch (G.type) {
|
|
2778
2934
|
case "count":
|
|
2779
2935
|
case "countDistinct":
|
|
@@ -2800,14 +2956,14 @@ class GE {
|
|
|
2800
2956
|
}
|
|
2801
2957
|
}
|
|
2802
2958
|
for (const P in s) {
|
|
2803
|
-
const [
|
|
2804
|
-
if (
|
|
2805
|
-
const G = this.getCubesFromPlan(E).get(
|
|
2959
|
+
const [U, M] = P.split(".");
|
|
2960
|
+
if (U === l) {
|
|
2961
|
+
const G = this.getCubesFromPlan(E).get(l), m = G && G.dimensions?.[M], B = P.startsWith(l + ".");
|
|
2806
2962
|
if (m || B) {
|
|
2807
2963
|
let X = D.joinKeys.find((_E) => _E.targetColumn === M);
|
|
2808
2964
|
if (!X && G?.dimensions?.[M]) {
|
|
2809
2965
|
const _E = G.dimensions[M].sql;
|
|
2810
|
-
X = D.joinKeys.find((
|
|
2966
|
+
X = D.joinKeys.find((ie) => ie.targetColumnObj === _E);
|
|
2811
2967
|
}
|
|
2812
2968
|
X ? s[P] = C`${C.identifier(D.cteAlias)}.${C.identifier(M)}`.as(P) : B && G?.dimensions?.[M] && (s[P] = C`${C.identifier(D.cteAlias)}.${C.identifier(M)}`.as(P));
|
|
2813
2969
|
}
|
|
@@ -2834,7 +2990,7 @@ class GE {
|
|
|
2834
2990
|
}
|
|
2835
2991
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
2836
2992
|
for (const D of E.joinCubes) {
|
|
2837
|
-
const
|
|
2993
|
+
const l = S.get(D.cube.name);
|
|
2838
2994
|
if (D.junctionTable) {
|
|
2839
2995
|
const M = D.junctionTable, G = [];
|
|
2840
2996
|
if (M.securitySql) {
|
|
@@ -2860,21 +3016,21 @@ class GE {
|
|
|
2860
3016
|
} catch {
|
|
2861
3017
|
}
|
|
2862
3018
|
}
|
|
2863
|
-
let P,
|
|
2864
|
-
|
|
3019
|
+
let P, U;
|
|
3020
|
+
l ? (P = C`${C.identifier(l)}`, U = this.buildCTEJoinCondition(D, l, E)) : (P = D.cube.sql(R).from, U = D.joinCondition);
|
|
2865
3021
|
try {
|
|
2866
3022
|
switch (D.joinType || "left") {
|
|
2867
3023
|
case "left":
|
|
2868
|
-
N = N.leftJoin(P,
|
|
3024
|
+
N = N.leftJoin(P, U);
|
|
2869
3025
|
break;
|
|
2870
3026
|
case "inner":
|
|
2871
|
-
N = N.innerJoin(P,
|
|
3027
|
+
N = N.innerJoin(P, U);
|
|
2872
3028
|
break;
|
|
2873
3029
|
case "right":
|
|
2874
|
-
N = N.rightJoin(P,
|
|
3030
|
+
N = N.rightJoin(P, U);
|
|
2875
3031
|
break;
|
|
2876
3032
|
case "full":
|
|
2877
|
-
N = N.fullJoin(P,
|
|
3033
|
+
N = N.fullJoin(P, U);
|
|
2878
3034
|
break;
|
|
2879
3035
|
}
|
|
2880
3036
|
} catch {
|
|
@@ -3010,13 +3166,13 @@ class GE {
|
|
|
3010
3166
|
};
|
|
3011
3167
|
}
|
|
3012
3168
|
}
|
|
3013
|
-
const _ = (T) => T.flatMap(
|
|
3169
|
+
const _ = (T) => T.flatMap(qe), qe = (T) => IE(ke(T)).map(je), je = (T) => T.replace(/ +/g, " ").trim(), ke = (T) => ({
|
|
3014
3170
|
type: "mandatory_block",
|
|
3015
3171
|
items: ET(T, 0)[0]
|
|
3016
3172
|
}), ET = (T, E, e) => {
|
|
3017
3173
|
const R = [];
|
|
3018
3174
|
for (; T[E]; ) {
|
|
3019
|
-
const [A, S] =
|
|
3175
|
+
const [A, S] = ze(T, E);
|
|
3020
3176
|
if (R.push(A), E = S, T[E] === "|")
|
|
3021
3177
|
E++;
|
|
3022
3178
|
else if (T[E] === "}" || T[E] === "]") {
|
|
@@ -3031,44 +3187,44 @@ const _ = (T) => T.flatMap(Ke), Ke = (T) => IE(we(T)).map($e), $e = (T) => T.rep
|
|
|
3031
3187
|
throw new Error(`Unexpected "${T[E]}"`);
|
|
3032
3188
|
}
|
|
3033
3189
|
return [R, E];
|
|
3034
|
-
},
|
|
3190
|
+
}, ze = (T, E) => {
|
|
3035
3191
|
const e = [];
|
|
3036
3192
|
for (; ; ) {
|
|
3037
|
-
const [R, A] =
|
|
3193
|
+
const [R, A] = ER(T, E);
|
|
3038
3194
|
if (R)
|
|
3039
3195
|
e.push(R), E = A;
|
|
3040
3196
|
else
|
|
3041
3197
|
break;
|
|
3042
3198
|
}
|
|
3043
3199
|
return e.length === 1 ? [e[0], E] : [{ type: "concatenation", items: e }, E];
|
|
3044
|
-
},
|
|
3200
|
+
}, ER = (T, E) => {
|
|
3045
3201
|
if (T[E] === "{")
|
|
3046
|
-
return
|
|
3202
|
+
return TR(T, E + 1);
|
|
3047
3203
|
if (T[E] === "[")
|
|
3048
|
-
return
|
|
3204
|
+
return eR(T, E + 1);
|
|
3049
3205
|
{
|
|
3050
3206
|
let e = "";
|
|
3051
3207
|
for (; T[E] && /[A-Za-z0-9_ ]/.test(T[E]); )
|
|
3052
3208
|
e += T[E], E++;
|
|
3053
3209
|
return [e, E];
|
|
3054
3210
|
}
|
|
3055
|
-
},
|
|
3211
|
+
}, TR = (T, E) => {
|
|
3056
3212
|
const [e, R] = ET(T, E, "}");
|
|
3057
3213
|
return [{ type: "mandatory_block", items: e }, R];
|
|
3058
|
-
},
|
|
3214
|
+
}, eR = (T, E) => {
|
|
3059
3215
|
const [e, R] = ET(T, E, "]");
|
|
3060
3216
|
return [{ type: "optional_block", items: e }, R];
|
|
3061
3217
|
}, IE = (T) => {
|
|
3062
3218
|
if (typeof T == "string")
|
|
3063
3219
|
return [T];
|
|
3064
3220
|
if (T.type === "concatenation")
|
|
3065
|
-
return T.items.map(IE).reduce(
|
|
3221
|
+
return T.items.map(IE).reduce(RR, [""]);
|
|
3066
3222
|
if (T.type === "mandatory_block")
|
|
3067
3223
|
return T.items.flatMap(IE);
|
|
3068
3224
|
if (T.type === "optional_block")
|
|
3069
3225
|
return ["", ...T.items.flatMap(IE)];
|
|
3070
3226
|
throw new Error(`Unknown node type: ${T}`);
|
|
3071
|
-
},
|
|
3227
|
+
}, RR = (T, E) => {
|
|
3072
3228
|
const e = [];
|
|
3073
3229
|
for (const R of T)
|
|
3074
3230
|
for (const A of E)
|
|
@@ -3079,19 +3235,19 @@ var o;
|
|
|
3079
3235
|
(function(T) {
|
|
3080
3236
|
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";
|
|
3081
3237
|
})(o = o || (o = {}));
|
|
3082
|
-
const
|
|
3238
|
+
const Te = (T) => ({
|
|
3083
3239
|
type: o.EOF,
|
|
3084
3240
|
raw: "«EOF»",
|
|
3085
3241
|
text: "«EOF»",
|
|
3086
3242
|
start: T
|
|
3087
|
-
}), z =
|
|
3243
|
+
}), z = Te(1 / 0), q = (T) => (E) => E.type === T.type && E.text === T.text, x = {
|
|
3088
3244
|
ARRAY: q({ text: "ARRAY", type: o.RESERVED_DATA_TYPE }),
|
|
3089
3245
|
BY: q({ text: "BY", type: o.RESERVED_KEYWORD }),
|
|
3090
3246
|
SET: q({ text: "SET", type: o.RESERVED_CLAUSE }),
|
|
3091
3247
|
STRUCT: q({ text: "STRUCT", type: o.RESERVED_DATA_TYPE }),
|
|
3092
3248
|
WINDOW: q({ text: "WINDOW", type: o.RESERVED_CLAUSE }),
|
|
3093
3249
|
VALUES: q({ text: "VALUES", type: o.RESERVED_CLAUSE })
|
|
3094
|
-
},
|
|
3250
|
+
}, ee = (T) => T === o.RESERVED_DATA_TYPE || T === o.RESERVED_KEYWORD || T === o.RESERVED_FUNCTION_NAME || T === o.RESERVED_KEYWORD_PHRASE || T === o.RESERVED_DATA_TYPE_PHRASE || T === o.RESERVED_CLAUSE || T === o.RESERVED_SELECT || T === o.RESERVED_SET_OPERATION || T === o.RESERVED_JOIN || T === o.ARRAY_KEYWORD || T === o.CASE || T === o.END || T === o.WHEN || T === o.ELSE || T === o.THEN || T === o.LIMIT || T === o.BETWEEN || T === o.AND || T === o.OR || T === o.XOR, AR = (T) => T === o.AND || T === o.OR || T === o.XOR, SR = [
|
|
3095
3251
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
3096
3252
|
"KEYS.NEW_KEYSET",
|
|
3097
3253
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -3635,7 +3791,7 @@ const Ee = (T) => ({
|
|
|
3635
3791
|
// pivot
|
|
3636
3792
|
"PIVOT",
|
|
3637
3793
|
"UNPIVOT"
|
|
3638
|
-
],
|
|
3794
|
+
], IR = [
|
|
3639
3795
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
|
|
3640
3796
|
"ALL",
|
|
3641
3797
|
"AND",
|
|
@@ -3743,7 +3899,7 @@ const Ee = (T) => ({
|
|
|
3743
3899
|
"CASCADE",
|
|
3744
3900
|
"RESTRICT",
|
|
3745
3901
|
"DETERMINISTIC"
|
|
3746
|
-
],
|
|
3902
|
+
], NR = [
|
|
3747
3903
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types
|
|
3748
3904
|
"ARRAY",
|
|
3749
3905
|
"BOOL",
|
|
@@ -3768,7 +3924,7 @@ const Ee = (T) => ({
|
|
|
3768
3924
|
"STRUCT",
|
|
3769
3925
|
"TIME",
|
|
3770
3926
|
"TIMEZONE"
|
|
3771
|
-
],
|
|
3927
|
+
], tR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), sR = _([
|
|
3772
3928
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
3773
3929
|
"WITH [RECURSIVE]",
|
|
3774
3930
|
"FROM",
|
|
@@ -3797,7 +3953,7 @@ const Ee = (T) => ({
|
|
|
3797
3953
|
"WITH CONNECTION",
|
|
3798
3954
|
"WITH PARTITION COLUMNS",
|
|
3799
3955
|
"REMOTE WITH CONNECTION"
|
|
3800
|
-
]),
|
|
3956
|
+
]), _T = _([
|
|
3801
3957
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3802
3958
|
]), mE = _([
|
|
3803
3959
|
// - create:
|
|
@@ -3887,15 +4043,15 @@ const Ee = (T) => ({
|
|
|
3887
4043
|
"ASSERT",
|
|
3888
4044
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
3889
4045
|
"EXPORT DATA"
|
|
3890
|
-
]),
|
|
4046
|
+
]), rR = _([
|
|
3891
4047
|
"UNION {ALL | DISTINCT}",
|
|
3892
4048
|
"EXCEPT DISTINCT",
|
|
3893
4049
|
"INTERSECT DISTINCT"
|
|
3894
|
-
]),
|
|
4050
|
+
]), CR = _([
|
|
3895
4051
|
"JOIN",
|
|
3896
4052
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3897
4053
|
"{INNER | CROSS} JOIN"
|
|
3898
|
-
]),
|
|
4054
|
+
]), nR = _([
|
|
3899
4055
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
3900
4056
|
"TABLESAMPLE SYSTEM",
|
|
3901
4057
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -3906,18 +4062,18 @@ const Ee = (T) => ({
|
|
|
3906
4062
|
"{ROWS | RANGE} BETWEEN",
|
|
3907
4063
|
// comparison operator
|
|
3908
4064
|
"IS [NOT] DISTINCT FROM"
|
|
3909
|
-
]),
|
|
4065
|
+
]), LR = _([]), _R = {
|
|
3910
4066
|
name: "bigquery",
|
|
3911
4067
|
tokenizerOptions: {
|
|
3912
|
-
reservedSelect:
|
|
3913
|
-
reservedClauses: [...
|
|
3914
|
-
reservedSetOperations:
|
|
3915
|
-
reservedJoins:
|
|
3916
|
-
reservedKeywordPhrases:
|
|
3917
|
-
reservedDataTypePhrases:
|
|
3918
|
-
reservedKeywords:
|
|
3919
|
-
reservedDataTypes:
|
|
3920
|
-
reservedFunctionNames:
|
|
4068
|
+
reservedSelect: tR,
|
|
4069
|
+
reservedClauses: [...sR, ...mE, ..._T],
|
|
4070
|
+
reservedSetOperations: rR,
|
|
4071
|
+
reservedJoins: CR,
|
|
4072
|
+
reservedKeywordPhrases: nR,
|
|
4073
|
+
reservedDataTypePhrases: LR,
|
|
4074
|
+
reservedKeywords: IR,
|
|
4075
|
+
reservedDataTypes: NR,
|
|
4076
|
+
reservedFunctionNames: SR,
|
|
3921
4077
|
extraParens: ["[]"],
|
|
3922
4078
|
stringTypes: [
|
|
3923
4079
|
// The triple-quoted strings are listed first, so they get matched first.
|
|
@@ -3935,31 +4091,31 @@ const Ee = (T) => ({
|
|
|
3935
4091
|
variableTypes: [{ regex: String.raw`@@\w+` }],
|
|
3936
4092
|
lineCommentTypes: ["--", "#"],
|
|
3937
4093
|
operators: ["&", "|", "^", "~", ">>", "<<", "||", "=>"],
|
|
3938
|
-
postProcess:
|
|
4094
|
+
postProcess: iR
|
|
3939
4095
|
},
|
|
3940
4096
|
formatOptions: {
|
|
3941
|
-
onelineClauses: [...
|
|
4097
|
+
onelineClauses: [..._T, ...mE],
|
|
3942
4098
|
tabularOnelineClauses: mE
|
|
3943
4099
|
}
|
|
3944
4100
|
};
|
|
3945
|
-
function
|
|
3946
|
-
return
|
|
4101
|
+
function iR(T) {
|
|
4102
|
+
return aR(oR(T));
|
|
3947
4103
|
}
|
|
3948
|
-
function
|
|
4104
|
+
function aR(T) {
|
|
3949
4105
|
let E = z;
|
|
3950
4106
|
return T.map((e) => e.text === "OFFSET" && E.text === "[" ? (E = e, Object.assign(Object.assign({}, e), { type: o.RESERVED_FUNCTION_NAME })) : (E = e, e));
|
|
3951
4107
|
}
|
|
3952
|
-
function
|
|
4108
|
+
function oR(T) {
|
|
3953
4109
|
var E;
|
|
3954
4110
|
const e = [];
|
|
3955
4111
|
for (let R = 0; R < T.length; R++) {
|
|
3956
4112
|
const A = T[R];
|
|
3957
4113
|
if ((x.ARRAY(A) || x.STRUCT(A)) && ((E = T[R + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
3958
|
-
const S =
|
|
4114
|
+
const S = DR(T, R + 1), I = T.slice(R, S + 1);
|
|
3959
4115
|
e.push({
|
|
3960
4116
|
type: o.IDENTIFIER,
|
|
3961
|
-
raw: I.map(
|
|
3962
|
-
text: I.map(
|
|
4117
|
+
raw: I.map(iT("raw")).join(""),
|
|
4118
|
+
text: I.map(iT("text")).join(""),
|
|
3963
4119
|
start: A.start
|
|
3964
4120
|
}), R = S;
|
|
3965
4121
|
} else
|
|
@@ -3967,8 +4123,8 @@ function sR(T) {
|
|
|
3967
4123
|
}
|
|
3968
4124
|
return e;
|
|
3969
4125
|
}
|
|
3970
|
-
const
|
|
3971
|
-
function
|
|
4126
|
+
const iT = (T) => (E) => E.type === o.IDENTIFIER || E.type === o.COMMA ? E[T] + " " : E[T];
|
|
4127
|
+
function DR(T, E) {
|
|
3972
4128
|
let e = 0;
|
|
3973
4129
|
for (let R = E; R < T.length; R++) {
|
|
3974
4130
|
const A = T[R];
|
|
@@ -3977,7 +4133,7 @@ function rR(T, E) {
|
|
|
3977
4133
|
}
|
|
3978
4134
|
return T.length - 1;
|
|
3979
4135
|
}
|
|
3980
|
-
const
|
|
4136
|
+
const PR = [
|
|
3981
4137
|
// https://www.ibm.com/docs/en/db2/11.5?topic=bif-aggregate-functions
|
|
3982
4138
|
"ARRAY_AGG",
|
|
3983
4139
|
"AVG",
|
|
@@ -4297,7 +4453,7 @@ const CR = [
|
|
|
4297
4453
|
"RATIO_TO_REPORT",
|
|
4298
4454
|
// Type casting
|
|
4299
4455
|
"CAST"
|
|
4300
|
-
],
|
|
4456
|
+
], MR = [
|
|
4301
4457
|
// https://www.ibm.com/docs/en/db2/11.5?topic=sql-reserved-schema-names-reserved-words
|
|
4302
4458
|
"ACTIVATE",
|
|
4303
4459
|
"ADD",
|
|
@@ -4698,7 +4854,7 @@ const CR = [
|
|
|
4698
4854
|
"XMLNAMESPACES",
|
|
4699
4855
|
"YEAR",
|
|
4700
4856
|
"YEARS"
|
|
4701
|
-
],
|
|
4857
|
+
], UR = [
|
|
4702
4858
|
// https://www.ibm.com/docs/en/db2-for-zos/12?topic=columns-data-types
|
|
4703
4859
|
"ARRAY",
|
|
4704
4860
|
"BIGINT",
|
|
@@ -4740,7 +4896,7 @@ const CR = [
|
|
|
4740
4896
|
"VARBINARY",
|
|
4741
4897
|
"VARCHAR",
|
|
4742
4898
|
"VARGRAPHIC"
|
|
4743
|
-
],
|
|
4899
|
+
], cR = _(["SELECT [ALL | DISTINCT]"]), lR = _([
|
|
4744
4900
|
// queries
|
|
4745
4901
|
"WITH",
|
|
4746
4902
|
"FROM",
|
|
@@ -4769,9 +4925,9 @@ const CR = [
|
|
|
4769
4925
|
"WHEN [NOT] MATCHED [THEN]",
|
|
4770
4926
|
"UPDATE SET",
|
|
4771
4927
|
"INSERT"
|
|
4772
|
-
]),
|
|
4928
|
+
]), aT = _([
|
|
4773
4929
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
4774
|
-
]),
|
|
4930
|
+
]), dE = _([
|
|
4775
4931
|
// - create:
|
|
4776
4932
|
"CREATE [OR REPLACE] VIEW",
|
|
4777
4933
|
// - update:
|
|
@@ -4974,27 +5130,27 @@ const CR = [
|
|
|
4974
5130
|
"TRANSFER OWNERSHIP OF",
|
|
4975
5131
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
4976
5132
|
"WHILE"
|
|
4977
|
-
]),
|
|
5133
|
+
]), uR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), GR = _([
|
|
4978
5134
|
"JOIN",
|
|
4979
5135
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4980
5136
|
"{INNER | CROSS} JOIN"
|
|
4981
|
-
]),
|
|
5137
|
+
]), mR = _([
|
|
4982
5138
|
"ON DELETE",
|
|
4983
5139
|
"ON UPDATE",
|
|
4984
5140
|
"SET NULL",
|
|
4985
5141
|
"{ROWS | RANGE} BETWEEN"
|
|
4986
|
-
]),
|
|
5142
|
+
]), dR = _([]), HR = {
|
|
4987
5143
|
name: "db2",
|
|
4988
5144
|
tokenizerOptions: {
|
|
4989
|
-
reservedSelect:
|
|
4990
|
-
reservedClauses: [...
|
|
4991
|
-
reservedSetOperations:
|
|
4992
|
-
reservedJoins:
|
|
4993
|
-
reservedKeywordPhrases:
|
|
4994
|
-
reservedDataTypePhrases:
|
|
4995
|
-
reservedKeywords:
|
|
4996
|
-
reservedDataTypes:
|
|
4997
|
-
reservedFunctionNames:
|
|
5145
|
+
reservedSelect: cR,
|
|
5146
|
+
reservedClauses: [...lR, ...aT, ...dE],
|
|
5147
|
+
reservedSetOperations: uR,
|
|
5148
|
+
reservedJoins: GR,
|
|
5149
|
+
reservedKeywordPhrases: mR,
|
|
5150
|
+
reservedDataTypePhrases: dR,
|
|
5151
|
+
reservedKeywords: MR,
|
|
5152
|
+
reservedDataTypes: UR,
|
|
5153
|
+
reservedFunctionNames: PR,
|
|
4998
5154
|
extraParens: ["[]"],
|
|
4999
5155
|
stringTypes: [
|
|
5000
5156
|
{ quote: "''-qq", prefixes: ["G", "N", "U&"] },
|
|
@@ -5025,10 +5181,10 @@ const CR = [
|
|
|
5025
5181
|
]
|
|
5026
5182
|
},
|
|
5027
5183
|
formatOptions: {
|
|
5028
|
-
onelineClauses: [...
|
|
5029
|
-
tabularOnelineClauses:
|
|
5184
|
+
onelineClauses: [...aT, ...dE],
|
|
5185
|
+
tabularOnelineClauses: dE
|
|
5030
5186
|
}
|
|
5031
|
-
},
|
|
5187
|
+
}, BR = [
|
|
5032
5188
|
// https://www.ibm.com/docs/en/i/7.5?topic=functions-aggregate
|
|
5033
5189
|
// TODO: 'ANY', - conflicts with test for ANY predicate in 'operators.ys'!!
|
|
5034
5190
|
"ARRAY_AGG",
|
|
@@ -5362,7 +5518,7 @@ const CR = [
|
|
|
5362
5518
|
"ROW_NUMBER",
|
|
5363
5519
|
// Type casting
|
|
5364
5520
|
"CAST"
|
|
5365
|
-
],
|
|
5521
|
+
], pR = [
|
|
5366
5522
|
// https://www.ibm.com/docs/en/i/7.5?topic=words-reserved
|
|
5367
5523
|
// TODO: This list likely contains all keywords, not only the reserved ones,
|
|
5368
5524
|
// try to filter it down to just the reserved keywords.
|
|
@@ -5858,7 +6014,7 @@ const CR = [
|
|
|
5858
6014
|
"YEARS",
|
|
5859
6015
|
"YES",
|
|
5860
6016
|
"ZONE"
|
|
5861
|
-
],
|
|
6017
|
+
], FR = [
|
|
5862
6018
|
// https://www.ibm.com/docs/en/i/7.2?topic=iaodsd-odbc-data-types-how-they-correspond-db2-i-database-types
|
|
5863
6019
|
"ARRAY",
|
|
5864
6020
|
"BIGINT",
|
|
@@ -5894,7 +6050,7 @@ const CR = [
|
|
|
5894
6050
|
"VARCHAR",
|
|
5895
6051
|
"VARGRAPHIC",
|
|
5896
6052
|
"XML"
|
|
5897
|
-
],
|
|
6053
|
+
], YR = _(["SELECT [ALL | DISTINCT]"]), fR = _([
|
|
5898
6054
|
// queries
|
|
5899
6055
|
"WITH [RECURSIVE]",
|
|
5900
6056
|
"INTO",
|
|
@@ -5924,7 +6080,7 @@ const CR = [
|
|
|
5924
6080
|
"INSERT",
|
|
5925
6081
|
// Data definition - table
|
|
5926
6082
|
"FOR SYSTEM NAME"
|
|
5927
|
-
]),
|
|
6083
|
+
]), oT = _(["CREATE [OR REPLACE] TABLE"]), HE = _([
|
|
5928
6084
|
// - create:
|
|
5929
6085
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
5930
6086
|
// - update:
|
|
@@ -6020,28 +6176,28 @@ const CR = [
|
|
|
6020
6176
|
"TAG",
|
|
6021
6177
|
"TRANSFER OWNERSHIP OF",
|
|
6022
6178
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
6023
|
-
]),
|
|
6179
|
+
]), hR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), VR = _([
|
|
6024
6180
|
"JOIN",
|
|
6025
6181
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6026
6182
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
6027
6183
|
"{INNER | CROSS} JOIN"
|
|
6028
|
-
]),
|
|
6184
|
+
]), WR = _([
|
|
6029
6185
|
"ON DELETE",
|
|
6030
6186
|
"ON UPDATE",
|
|
6031
6187
|
"SET NULL",
|
|
6032
6188
|
"{ROWS | RANGE} BETWEEN"
|
|
6033
|
-
]),
|
|
6189
|
+
]), bR = _([]), XR = {
|
|
6034
6190
|
name: "db2i",
|
|
6035
6191
|
tokenizerOptions: {
|
|
6036
|
-
reservedSelect:
|
|
6037
|
-
reservedClauses: [...
|
|
6038
|
-
reservedSetOperations:
|
|
6039
|
-
reservedJoins:
|
|
6040
|
-
reservedKeywordPhrases:
|
|
6041
|
-
reservedDataTypePhrases:
|
|
6042
|
-
reservedKeywords:
|
|
6043
|
-
reservedDataTypes:
|
|
6044
|
-
reservedFunctionNames:
|
|
6192
|
+
reservedSelect: YR,
|
|
6193
|
+
reservedClauses: [...fR, ...oT, ...HE],
|
|
6194
|
+
reservedSetOperations: hR,
|
|
6195
|
+
reservedJoins: VR,
|
|
6196
|
+
reservedKeywordPhrases: WR,
|
|
6197
|
+
reservedDataTypePhrases: bR,
|
|
6198
|
+
reservedKeywords: pR,
|
|
6199
|
+
reservedDataTypes: FR,
|
|
6200
|
+
reservedFunctionNames: BR,
|
|
6045
6201
|
nestedBlockComments: !0,
|
|
6046
6202
|
extraParens: ["[]"],
|
|
6047
6203
|
stringTypes: [
|
|
@@ -6055,10 +6211,10 @@ const CR = [
|
|
|
6055
6211
|
operators: ["**", "¬=", "¬>", "¬<", "!>", "!<", "||", "=>"]
|
|
6056
6212
|
},
|
|
6057
6213
|
formatOptions: {
|
|
6058
|
-
onelineClauses: [...
|
|
6059
|
-
tabularOnelineClauses:
|
|
6214
|
+
onelineClauses: [...oT, ...HE],
|
|
6215
|
+
tabularOnelineClauses: HE
|
|
6060
6216
|
}
|
|
6061
|
-
},
|
|
6217
|
+
}, yR = [
|
|
6062
6218
|
// Functions from DuckDB (excluding those that start with an underscore):
|
|
6063
6219
|
// SELECT DISTINCT upper(function_name) AS function_name
|
|
6064
6220
|
// FROM duckdb_functions()
|
|
@@ -6721,7 +6877,7 @@ const CR = [
|
|
|
6721
6877
|
// 'NULL', we really prefer treating it as keyword
|
|
6722
6878
|
"RANK",
|
|
6723
6879
|
"ROW_NUMBER"
|
|
6724
|
-
],
|
|
6880
|
+
], gR = [
|
|
6725
6881
|
// Keywords from DuckDB:
|
|
6726
6882
|
// SELECT upper(keyword_name)
|
|
6727
6883
|
// FROM duckdb_keywords()
|
|
@@ -6803,7 +6959,7 @@ const CR = [
|
|
|
6803
6959
|
"WHERE",
|
|
6804
6960
|
"WINDOW",
|
|
6805
6961
|
"WITH"
|
|
6806
|
-
],
|
|
6962
|
+
], KR = [
|
|
6807
6963
|
// Types from DuckDB:
|
|
6808
6964
|
// SELECT DISTINCT upper(type_name)
|
|
6809
6965
|
// FROM duckdb_types()
|
|
@@ -6883,7 +7039,7 @@ const CR = [
|
|
|
6883
7039
|
"UUID",
|
|
6884
7040
|
"VARBINARY",
|
|
6885
7041
|
"VARCHAR"
|
|
6886
|
-
],
|
|
7042
|
+
], $R = _(["SELECT [ALL | DISTINCT]"]), wR = _([
|
|
6887
7043
|
// queries
|
|
6888
7044
|
"WITH [RECURSIVE]",
|
|
6889
7045
|
"FROM",
|
|
@@ -6907,7 +7063,7 @@ const CR = [
|
|
|
6907
7063
|
"SET",
|
|
6908
7064
|
// other:
|
|
6909
7065
|
"RETURNING"
|
|
6910
|
-
]),
|
|
7066
|
+
]), DT = _([
|
|
6911
7067
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
6912
7068
|
]), BE = _([
|
|
6913
7069
|
// TABLE
|
|
@@ -6987,11 +7143,11 @@ const CR = [
|
|
|
6987
7143
|
"PREPARE",
|
|
6988
7144
|
"EXECUTE",
|
|
6989
7145
|
"DEALLOCATE [PREPARE]"
|
|
6990
|
-
]),
|
|
7146
|
+
]), JR = _([
|
|
6991
7147
|
"UNION [ALL | BY NAME]",
|
|
6992
7148
|
"EXCEPT [ALL]",
|
|
6993
7149
|
"INTERSECT [ALL]"
|
|
6994
|
-
]),
|
|
7150
|
+
]), xR = _([
|
|
6995
7151
|
"JOIN",
|
|
6996
7152
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6997
7153
|
"{INNER | CROSS} JOIN",
|
|
@@ -7000,23 +7156,23 @@ const CR = [
|
|
|
7000
7156
|
"POSITIONAL JOIN",
|
|
7001
7157
|
"ANTI JOIN",
|
|
7002
7158
|
"SEMI JOIN"
|
|
7003
|
-
]),
|
|
7159
|
+
]), vR = _([
|
|
7004
7160
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
7005
7161
|
"SIMILAR TO",
|
|
7006
7162
|
"IS [NOT] DISTINCT FROM"
|
|
7007
|
-
]),
|
|
7163
|
+
]), QR = _(["TIMESTAMP WITH TIME ZONE"]), ZR = {
|
|
7008
7164
|
name: "duckdb",
|
|
7009
7165
|
tokenizerOptions: {
|
|
7010
|
-
reservedSelect:
|
|
7011
|
-
reservedClauses: [...
|
|
7012
|
-
reservedSetOperations:
|
|
7013
|
-
reservedJoins:
|
|
7014
|
-
reservedKeywordPhrases:
|
|
7015
|
-
reservedDataTypePhrases:
|
|
7166
|
+
reservedSelect: $R,
|
|
7167
|
+
reservedClauses: [...wR, ...DT, ...BE],
|
|
7168
|
+
reservedSetOperations: JR,
|
|
7169
|
+
reservedJoins: xR,
|
|
7170
|
+
reservedKeywordPhrases: vR,
|
|
7171
|
+
reservedDataTypePhrases: QR,
|
|
7016
7172
|
supportsXor: !0,
|
|
7017
|
-
reservedKeywords:
|
|
7018
|
-
reservedDataTypes:
|
|
7019
|
-
reservedFunctionNames:
|
|
7173
|
+
reservedKeywords: gR,
|
|
7174
|
+
reservedDataTypes: KR,
|
|
7175
|
+
reservedFunctionNames: yR,
|
|
7020
7176
|
nestedBlockComments: !0,
|
|
7021
7177
|
extraParens: ["[]", "{}"],
|
|
7022
7178
|
underscoresInNumbers: !0,
|
|
@@ -7077,10 +7233,10 @@ const CR = [
|
|
|
7077
7233
|
},
|
|
7078
7234
|
formatOptions: {
|
|
7079
7235
|
alwaysDenseOperators: ["::"],
|
|
7080
|
-
onelineClauses: [...
|
|
7236
|
+
onelineClauses: [...DT, ...BE],
|
|
7081
7237
|
tabularOnelineClauses: BE
|
|
7082
7238
|
}
|
|
7083
|
-
},
|
|
7239
|
+
}, qR = [
|
|
7084
7240
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
|
|
7085
7241
|
// math
|
|
7086
7242
|
"ABS",
|
|
@@ -7288,7 +7444,7 @@ const CR = [
|
|
|
7288
7444
|
"CUME_DIST",
|
|
7289
7445
|
"PERCENT_RANK",
|
|
7290
7446
|
"NTILE"
|
|
7291
|
-
],
|
|
7447
|
+
], jR = [
|
|
7292
7448
|
// https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
|
|
7293
7449
|
// Non-reserved keywords have proscribed meanings in. HiveQL, but can still be used as table or column names
|
|
7294
7450
|
"ADD",
|
|
@@ -7603,7 +7759,7 @@ const CR = [
|
|
|
7603
7759
|
"JSONFILE",
|
|
7604
7760
|
"INPUTFORMAT",
|
|
7605
7761
|
"OUTPUTFORMAT"
|
|
7606
|
-
],
|
|
7762
|
+
], kR = [
|
|
7607
7763
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
|
|
7608
7764
|
"ARRAY",
|
|
7609
7765
|
"BIGINT",
|
|
@@ -7624,7 +7780,7 @@ const CR = [
|
|
|
7624
7780
|
"STRUCT",
|
|
7625
7781
|
"TIMESTAMP",
|
|
7626
7782
|
"VARCHAR"
|
|
7627
|
-
],
|
|
7783
|
+
], zR = _(["SELECT [ALL | DISTINCT]"]), EA = _([
|
|
7628
7784
|
// queries
|
|
7629
7785
|
"WITH",
|
|
7630
7786
|
"FROM",
|
|
@@ -7658,7 +7814,7 @@ const CR = [
|
|
|
7658
7814
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
7659
7815
|
"LOAD DATA [LOCAL] INPATH",
|
|
7660
7816
|
"[OVERWRITE] INTO TABLE"
|
|
7661
|
-
]),
|
|
7817
|
+
]), PT = _([
|
|
7662
7818
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
7663
7819
|
]), pE = _([
|
|
7664
7820
|
// - create:
|
|
@@ -7685,24 +7841,24 @@ const CR = [
|
|
|
7685
7841
|
"STORED AS",
|
|
7686
7842
|
"STORED BY",
|
|
7687
7843
|
"ROW FORMAT"
|
|
7688
|
-
]),
|
|
7844
|
+
]), TA = _(["UNION [ALL | DISTINCT]"]), eA = _([
|
|
7689
7845
|
"JOIN",
|
|
7690
7846
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
7691
7847
|
"{INNER | CROSS} JOIN",
|
|
7692
7848
|
// non-standard joins
|
|
7693
7849
|
"LEFT SEMI JOIN"
|
|
7694
|
-
]),
|
|
7850
|
+
]), RA = _(["{ROWS | RANGE} BETWEEN"]), AA = _([]), SA = {
|
|
7695
7851
|
name: "hive",
|
|
7696
7852
|
tokenizerOptions: {
|
|
7697
|
-
reservedSelect:
|
|
7698
|
-
reservedClauses: [...
|
|
7699
|
-
reservedSetOperations:
|
|
7700
|
-
reservedJoins:
|
|
7701
|
-
reservedKeywordPhrases:
|
|
7702
|
-
reservedDataTypePhrases:
|
|
7703
|
-
reservedKeywords:
|
|
7704
|
-
reservedDataTypes:
|
|
7705
|
-
reservedFunctionNames:
|
|
7853
|
+
reservedSelect: zR,
|
|
7854
|
+
reservedClauses: [...EA, ...PT, ...pE],
|
|
7855
|
+
reservedSetOperations: TA,
|
|
7856
|
+
reservedJoins: eA,
|
|
7857
|
+
reservedKeywordPhrases: RA,
|
|
7858
|
+
reservedDataTypePhrases: AA,
|
|
7859
|
+
reservedKeywords: jR,
|
|
7860
|
+
reservedDataTypes: kR,
|
|
7861
|
+
reservedFunctionNames: qR,
|
|
7706
7862
|
extraParens: ["[]"],
|
|
7707
7863
|
stringTypes: ['""-bs', "''-bs"],
|
|
7708
7864
|
identTypes: ["``"],
|
|
@@ -7710,7 +7866,7 @@ const CR = [
|
|
|
7710
7866
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||"]
|
|
7711
7867
|
},
|
|
7712
7868
|
formatOptions: {
|
|
7713
|
-
onelineClauses: [...
|
|
7869
|
+
onelineClauses: [...PT, ...pE],
|
|
7714
7870
|
tabularOnelineClauses: pE
|
|
7715
7871
|
}
|
|
7716
7872
|
};
|
|
@@ -7723,7 +7879,7 @@ function LE(T) {
|
|
|
7723
7879
|
return x.VALUES(E) && A.text === "=" ? Object.assign(Object.assign({}, E), { type: o.RESERVED_FUNCTION_NAME }) : E;
|
|
7724
7880
|
});
|
|
7725
7881
|
}
|
|
7726
|
-
const
|
|
7882
|
+
const IA = [
|
|
7727
7883
|
// https://mariadb.com/kb/en/reserved-words/
|
|
7728
7884
|
"ACCESSIBLE",
|
|
7729
7885
|
"ADD",
|
|
@@ -7940,7 +8096,7 @@ const kR = [
|
|
|
7940
8096
|
"XOR",
|
|
7941
8097
|
"YEAR_MONTH",
|
|
7942
8098
|
"ZEROFILL"
|
|
7943
|
-
],
|
|
8099
|
+
], NA = [
|
|
7944
8100
|
// https://mariadb.com/kb/en/data-types/
|
|
7945
8101
|
"BIGINT",
|
|
7946
8102
|
"BINARY",
|
|
@@ -7991,7 +8147,7 @@ const kR = [
|
|
|
7991
8147
|
"YEAR"
|
|
7992
8148
|
// 'NUMBER', // ?? In oracle mode only
|
|
7993
8149
|
// 'SET' // handled as special-case in postProcess
|
|
7994
|
-
],
|
|
8150
|
+
], OA = [
|
|
7995
8151
|
// https://mariadb.com/kb/en/information-schema-sql_functions-table/
|
|
7996
8152
|
"ADDDATE",
|
|
7997
8153
|
"ADD_MONTHS",
|
|
@@ -8229,7 +8385,7 @@ const kR = [
|
|
|
8229
8385
|
// CASE expression shorthands
|
|
8230
8386
|
"COALESCE",
|
|
8231
8387
|
"NULLIF"
|
|
8232
|
-
],
|
|
8388
|
+
], tA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), sA = _([
|
|
8233
8389
|
// queries
|
|
8234
8390
|
"WITH [RECURSIVE]",
|
|
8235
8391
|
"FROM",
|
|
@@ -8251,7 +8407,7 @@ const kR = [
|
|
|
8251
8407
|
"SET",
|
|
8252
8408
|
// other
|
|
8253
8409
|
"RETURNING"
|
|
8254
|
-
]),
|
|
8410
|
+
]), MT = _([
|
|
8255
8411
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
8256
8412
|
]), FE = _([
|
|
8257
8413
|
// - create:
|
|
@@ -8460,12 +8616,12 @@ const kR = [
|
|
|
8460
8616
|
"XA RECOVER",
|
|
8461
8617
|
"XA ROLLBACK",
|
|
8462
8618
|
"XA START"
|
|
8463
|
-
]),
|
|
8619
|
+
]), rA = _([
|
|
8464
8620
|
"UNION [ALL | DISTINCT]",
|
|
8465
8621
|
"EXCEPT [ALL | DISTINCT]",
|
|
8466
8622
|
"INTERSECT [ALL | DISTINCT]",
|
|
8467
8623
|
"MINUS [ALL | DISTINCT]"
|
|
8468
|
-
]),
|
|
8624
|
+
]), CA = _([
|
|
8469
8625
|
"JOIN",
|
|
8470
8626
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8471
8627
|
"{INNER | CROSS} JOIN",
|
|
@@ -8473,24 +8629,24 @@ const kR = [
|
|
|
8473
8629
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8474
8630
|
// non-standard joins
|
|
8475
8631
|
"STRAIGHT_JOIN"
|
|
8476
|
-
]),
|
|
8632
|
+
]), nA = _([
|
|
8477
8633
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
8478
8634
|
"CHARACTER SET",
|
|
8479
8635
|
"{ROWS | RANGE} BETWEEN",
|
|
8480
8636
|
"IDENTIFIED BY"
|
|
8481
|
-
]),
|
|
8637
|
+
]), LA = _([]), _A = {
|
|
8482
8638
|
name: "mariadb",
|
|
8483
8639
|
tokenizerOptions: {
|
|
8484
|
-
reservedSelect:
|
|
8485
|
-
reservedClauses: [...
|
|
8486
|
-
reservedSetOperations:
|
|
8487
|
-
reservedJoins:
|
|
8488
|
-
reservedKeywordPhrases:
|
|
8489
|
-
reservedDataTypePhrases:
|
|
8640
|
+
reservedSelect: tA,
|
|
8641
|
+
reservedClauses: [...sA, ...MT, ...FE],
|
|
8642
|
+
reservedSetOperations: rA,
|
|
8643
|
+
reservedJoins: CA,
|
|
8644
|
+
reservedKeywordPhrases: nA,
|
|
8645
|
+
reservedDataTypePhrases: LA,
|
|
8490
8646
|
supportsXor: !0,
|
|
8491
|
-
reservedKeywords:
|
|
8492
|
-
reservedDataTypes:
|
|
8493
|
-
reservedFunctionNames:
|
|
8647
|
+
reservedKeywords: IA,
|
|
8648
|
+
reservedDataTypes: NA,
|
|
8649
|
+
reservedFunctionNames: OA,
|
|
8494
8650
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
8495
8651
|
stringTypes: [
|
|
8496
8652
|
'""-qq-bs',
|
|
@@ -8526,10 +8682,10 @@ const kR = [
|
|
|
8526
8682
|
postProcess: LE
|
|
8527
8683
|
},
|
|
8528
8684
|
formatOptions: {
|
|
8529
|
-
onelineClauses: [...
|
|
8685
|
+
onelineClauses: [...MT, ...FE],
|
|
8530
8686
|
tabularOnelineClauses: FE
|
|
8531
8687
|
}
|
|
8532
|
-
},
|
|
8688
|
+
}, iA = [
|
|
8533
8689
|
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
|
|
8534
8690
|
"ACCESSIBLE",
|
|
8535
8691
|
"ADD",
|
|
@@ -8760,7 +8916,7 @@ const kR = [
|
|
|
8760
8916
|
"YEAR_MONTH",
|
|
8761
8917
|
"ZEROFILL"
|
|
8762
8918
|
// (R)
|
|
8763
|
-
],
|
|
8919
|
+
], aA = [
|
|
8764
8920
|
// https://dev.mysql.com/doc/refman/8.0/en/data-types.html
|
|
8765
8921
|
"BIGINT",
|
|
8766
8922
|
"BINARY",
|
|
@@ -8812,7 +8968,7 @@ const kR = [
|
|
|
8812
8968
|
"VARYING",
|
|
8813
8969
|
"YEAR"
|
|
8814
8970
|
// 'SET' // handled as special-case in postProcess
|
|
8815
|
-
],
|
|
8971
|
+
], oA = [
|
|
8816
8972
|
// https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
|
|
8817
8973
|
"ABS",
|
|
8818
8974
|
"ACOS",
|
|
@@ -9235,7 +9391,7 @@ const kR = [
|
|
|
9235
9391
|
// 'XOR',
|
|
9236
9392
|
"YEAR",
|
|
9237
9393
|
"YEARWEEK"
|
|
9238
|
-
],
|
|
9394
|
+
], DA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), PA = _([
|
|
9239
9395
|
// queries
|
|
9240
9396
|
"WITH [RECURSIVE]",
|
|
9241
9397
|
"FROM",
|
|
@@ -9255,7 +9411,7 @@ const kR = [
|
|
|
9255
9411
|
"ON DUPLICATE KEY UPDATE",
|
|
9256
9412
|
// - update:
|
|
9257
9413
|
"SET"
|
|
9258
|
-
]),
|
|
9414
|
+
]), UT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), YE = _([
|
|
9259
9415
|
// - create:
|
|
9260
9416
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9261
9417
|
// - update:
|
|
@@ -9436,7 +9592,7 @@ const kR = [
|
|
|
9436
9592
|
"REPEAT",
|
|
9437
9593
|
"RETURN",
|
|
9438
9594
|
"WHILE"
|
|
9439
|
-
]),
|
|
9595
|
+
]), MA = _(["UNION [ALL | DISTINCT]"]), UA = _([
|
|
9440
9596
|
"JOIN",
|
|
9441
9597
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9442
9598
|
"{INNER | CROSS} JOIN",
|
|
@@ -9444,24 +9600,24 @@ const kR = [
|
|
|
9444
9600
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9445
9601
|
// non-standard joins
|
|
9446
9602
|
"STRAIGHT_JOIN"
|
|
9447
|
-
]),
|
|
9603
|
+
]), cA = _([
|
|
9448
9604
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9449
9605
|
"CHARACTER SET",
|
|
9450
9606
|
"{ROWS | RANGE} BETWEEN",
|
|
9451
9607
|
"IDENTIFIED BY"
|
|
9452
|
-
]),
|
|
9608
|
+
]), lA = _([]), uA = {
|
|
9453
9609
|
name: "mysql",
|
|
9454
9610
|
tokenizerOptions: {
|
|
9455
|
-
reservedSelect:
|
|
9456
|
-
reservedClauses: [...
|
|
9457
|
-
reservedSetOperations:
|
|
9458
|
-
reservedJoins:
|
|
9459
|
-
reservedKeywordPhrases:
|
|
9460
|
-
reservedDataTypePhrases:
|
|
9611
|
+
reservedSelect: DA,
|
|
9612
|
+
reservedClauses: [...PA, ...UT, ...YE],
|
|
9613
|
+
reservedSetOperations: MA,
|
|
9614
|
+
reservedJoins: UA,
|
|
9615
|
+
reservedKeywordPhrases: cA,
|
|
9616
|
+
reservedDataTypePhrases: lA,
|
|
9461
9617
|
supportsXor: !0,
|
|
9462
|
-
reservedKeywords:
|
|
9463
|
-
reservedDataTypes:
|
|
9464
|
-
reservedFunctionNames:
|
|
9618
|
+
reservedKeywords: iA,
|
|
9619
|
+
reservedDataTypes: aA,
|
|
9620
|
+
reservedFunctionNames: oA,
|
|
9465
9621
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
9466
9622
|
stringTypes: [
|
|
9467
9623
|
'""-qq-bs',
|
|
@@ -9499,10 +9655,10 @@ const kR = [
|
|
|
9499
9655
|
postProcess: LE
|
|
9500
9656
|
},
|
|
9501
9657
|
formatOptions: {
|
|
9502
|
-
onelineClauses: [...
|
|
9658
|
+
onelineClauses: [...UT, ...YE],
|
|
9503
9659
|
tabularOnelineClauses: YE
|
|
9504
9660
|
}
|
|
9505
|
-
},
|
|
9661
|
+
}, GA = [
|
|
9506
9662
|
// https://docs.pingcap.com/tidb/stable/keywords
|
|
9507
9663
|
"ADD",
|
|
9508
9664
|
"ALL",
|
|
@@ -9694,7 +9850,7 @@ const kR = [
|
|
|
9694
9850
|
"YEAR_MONTH",
|
|
9695
9851
|
"ZEROFILL"
|
|
9696
9852
|
// (R)
|
|
9697
|
-
],
|
|
9853
|
+
], mA = [
|
|
9698
9854
|
// https://docs.pingcap.com/tidb/stable/data-type-overview
|
|
9699
9855
|
"BIGINT",
|
|
9700
9856
|
"BINARY",
|
|
@@ -9741,7 +9897,7 @@ const kR = [
|
|
|
9741
9897
|
"VARYING",
|
|
9742
9898
|
"YEAR"
|
|
9743
9899
|
// 'SET' // handled as special-case in postProcess
|
|
9744
|
-
],
|
|
9900
|
+
], dA = [
|
|
9745
9901
|
// https://docs.pingcap.com/tidb/stable/sql-statement-show-builtins
|
|
9746
9902
|
// https://docs.pingcap.com/tidb/stable/functions-and-operators-overview
|
|
9747
9903
|
// + MySQL aggregate functions: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
|
|
@@ -10067,7 +10223,7 @@ const kR = [
|
|
|
10067
10223
|
// 'XOR',
|
|
10068
10224
|
"YEAR",
|
|
10069
10225
|
"YEARWEEK"
|
|
10070
|
-
],
|
|
10226
|
+
], HA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), BA = _([
|
|
10071
10227
|
// queries
|
|
10072
10228
|
"WITH [RECURSIVE]",
|
|
10073
10229
|
"FROM",
|
|
@@ -10087,7 +10243,7 @@ const kR = [
|
|
|
10087
10243
|
"ON DUPLICATE KEY UPDATE",
|
|
10088
10244
|
// - update:
|
|
10089
10245
|
"SET"
|
|
10090
|
-
]),
|
|
10246
|
+
]), cT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), fE = _([
|
|
10091
10247
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
10092
10248
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
10093
10249
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -10202,7 +10358,7 @@ const kR = [
|
|
|
10202
10358
|
"UNLOCK TABLES",
|
|
10203
10359
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
10204
10360
|
"USE"
|
|
10205
|
-
]),
|
|
10361
|
+
]), pA = _(["UNION [ALL | DISTINCT]"]), FA = _([
|
|
10206
10362
|
"JOIN",
|
|
10207
10363
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
10208
10364
|
"{INNER | CROSS} JOIN",
|
|
@@ -10210,24 +10366,24 @@ const kR = [
|
|
|
10210
10366
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
10211
10367
|
// non-standard joins
|
|
10212
10368
|
"STRAIGHT_JOIN"
|
|
10213
|
-
]),
|
|
10369
|
+
]), YA = _([
|
|
10214
10370
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10215
10371
|
"CHARACTER SET",
|
|
10216
10372
|
"{ROWS | RANGE} BETWEEN",
|
|
10217
10373
|
"IDENTIFIED BY"
|
|
10218
|
-
]),
|
|
10374
|
+
]), fA = _([]), hA = {
|
|
10219
10375
|
name: "tidb",
|
|
10220
10376
|
tokenizerOptions: {
|
|
10221
|
-
reservedSelect:
|
|
10222
|
-
reservedClauses: [...
|
|
10223
|
-
reservedSetOperations:
|
|
10224
|
-
reservedJoins:
|
|
10225
|
-
reservedKeywordPhrases:
|
|
10226
|
-
reservedDataTypePhrases:
|
|
10377
|
+
reservedSelect: HA,
|
|
10378
|
+
reservedClauses: [...BA, ...cT, ...fE],
|
|
10379
|
+
reservedSetOperations: pA,
|
|
10380
|
+
reservedJoins: FA,
|
|
10381
|
+
reservedKeywordPhrases: YA,
|
|
10382
|
+
reservedDataTypePhrases: fA,
|
|
10227
10383
|
supportsXor: !0,
|
|
10228
|
-
reservedKeywords:
|
|
10229
|
-
reservedDataTypes:
|
|
10230
|
-
reservedFunctionNames:
|
|
10384
|
+
reservedKeywords: GA,
|
|
10385
|
+
reservedDataTypes: mA,
|
|
10386
|
+
reservedFunctionNames: dA,
|
|
10231
10387
|
// TODO: support _ char set prefixes such as _utf8, _latin1, _binary, _utf8mb4, etc.
|
|
10232
10388
|
stringTypes: [
|
|
10233
10389
|
'""-qq-bs',
|
|
@@ -10265,10 +10421,10 @@ const kR = [
|
|
|
10265
10421
|
postProcess: LE
|
|
10266
10422
|
},
|
|
10267
10423
|
formatOptions: {
|
|
10268
|
-
onelineClauses: [...
|
|
10424
|
+
onelineClauses: [...cT, ...fE],
|
|
10269
10425
|
tabularOnelineClauses: fE
|
|
10270
10426
|
}
|
|
10271
|
-
},
|
|
10427
|
+
}, VA = [
|
|
10272
10428
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
|
|
10273
10429
|
"ABORT",
|
|
10274
10430
|
"ABS",
|
|
@@ -10498,7 +10654,7 @@ const kR = [
|
|
|
10498
10654
|
// not implemented in N1QL, but added here now for the sake of tests
|
|
10499
10655
|
// https://docs.couchbase.com/server/current/analytics/3_query.html#Vs_SQL-92
|
|
10500
10656
|
"CAST"
|
|
10501
|
-
],
|
|
10657
|
+
], WA = [
|
|
10502
10658
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
|
|
10503
10659
|
"ADVISE",
|
|
10504
10660
|
"ALL",
|
|
@@ -10704,7 +10860,7 @@ const kR = [
|
|
|
10704
10860
|
"WITHIN",
|
|
10705
10861
|
"WORK",
|
|
10706
10862
|
"XOR"
|
|
10707
|
-
],
|
|
10863
|
+
], bA = [
|
|
10708
10864
|
// N1QL does not support any way of declaring types for columns.
|
|
10709
10865
|
// It does not support the CREATE TABLE statement nor the CAST() expression.
|
|
10710
10866
|
//
|
|
@@ -10713,7 +10869,7 @@ const kR = [
|
|
|
10713
10869
|
// which it actually doesn't use.
|
|
10714
10870
|
//
|
|
10715
10871
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
10716
|
-
],
|
|
10872
|
+
], XA = _(["SELECT [ALL | DISTINCT]"]), yA = _([
|
|
10717
10873
|
// queries
|
|
10718
10874
|
"WITH",
|
|
10719
10875
|
"FROM",
|
|
@@ -10780,19 +10936,19 @@ const kR = [
|
|
|
10780
10936
|
"SET CURRENT SCHEMA",
|
|
10781
10937
|
"SHOW",
|
|
10782
10938
|
"USE [PRIMARY] KEYS"
|
|
10783
|
-
]),
|
|
10939
|
+
]), gA = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KA = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), $A = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), wA = _([]), JA = {
|
|
10784
10940
|
name: "n1ql",
|
|
10785
10941
|
tokenizerOptions: {
|
|
10786
|
-
reservedSelect:
|
|
10787
|
-
reservedClauses: [...
|
|
10788
|
-
reservedSetOperations:
|
|
10789
|
-
reservedJoins:
|
|
10790
|
-
reservedKeywordPhrases:
|
|
10791
|
-
reservedDataTypePhrases:
|
|
10942
|
+
reservedSelect: XA,
|
|
10943
|
+
reservedClauses: [...yA, ...lT],
|
|
10944
|
+
reservedSetOperations: gA,
|
|
10945
|
+
reservedJoins: KA,
|
|
10946
|
+
reservedKeywordPhrases: $A,
|
|
10947
|
+
reservedDataTypePhrases: wA,
|
|
10792
10948
|
supportsXor: !0,
|
|
10793
|
-
reservedKeywords:
|
|
10794
|
-
reservedDataTypes:
|
|
10795
|
-
reservedFunctionNames:
|
|
10949
|
+
reservedKeywords: WA,
|
|
10950
|
+
reservedDataTypes: bA,
|
|
10951
|
+
reservedFunctionNames: VA,
|
|
10796
10952
|
// NOTE: single quotes are actually not supported in N1QL,
|
|
10797
10953
|
// but we support them anyway as all other SQL dialects do,
|
|
10798
10954
|
// which simplifies writing tests that are shared between all dialects.
|
|
@@ -10806,7 +10962,7 @@ const kR = [
|
|
|
10806
10962
|
formatOptions: {
|
|
10807
10963
|
onelineClauses: lT
|
|
10808
10964
|
}
|
|
10809
|
-
},
|
|
10965
|
+
}, xA = [
|
|
10810
10966
|
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
|
|
10811
10967
|
// 'A',
|
|
10812
10968
|
"ADD",
|
|
@@ -11111,7 +11267,7 @@ const kR = [
|
|
|
11111
11267
|
"WRITE",
|
|
11112
11268
|
"YEAR",
|
|
11113
11269
|
"ZONE"
|
|
11114
|
-
],
|
|
11270
|
+
], vA = [
|
|
11115
11271
|
// https://www.ibm.com/docs/en/db2/10.5?topic=plsql-data-types
|
|
11116
11272
|
"ARRAY",
|
|
11117
11273
|
"BFILE_BASE",
|
|
@@ -11149,7 +11305,7 @@ const kR = [
|
|
|
11149
11305
|
"UROWID",
|
|
11150
11306
|
"VARCHAR",
|
|
11151
11307
|
"VARCHAR2"
|
|
11152
|
-
],
|
|
11308
|
+
], QA = [
|
|
11153
11309
|
// https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
|
|
11154
11310
|
// numeric
|
|
11155
11311
|
"ABS",
|
|
@@ -11414,7 +11570,7 @@ const kR = [
|
|
|
11414
11570
|
"PRESENTNNV",
|
|
11415
11571
|
"PRESENTV",
|
|
11416
11572
|
"PREVIOUS"
|
|
11417
|
-
],
|
|
11573
|
+
], ZA = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), qA = _([
|
|
11418
11574
|
// queries
|
|
11419
11575
|
"WITH",
|
|
11420
11576
|
"FROM",
|
|
@@ -11438,7 +11594,7 @@ const kR = [
|
|
|
11438
11594
|
"UPDATE SET",
|
|
11439
11595
|
// other
|
|
11440
11596
|
"RETURNING"
|
|
11441
|
-
]),
|
|
11597
|
+
]), uT = _([
|
|
11442
11598
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
11443
11599
|
]), hE = _([
|
|
11444
11600
|
// - create:
|
|
@@ -11468,7 +11624,7 @@ const kR = [
|
|
|
11468
11624
|
"EXCEPTION",
|
|
11469
11625
|
"LOOP",
|
|
11470
11626
|
"START WITH"
|
|
11471
|
-
]),
|
|
11627
|
+
]), jA = _(["UNION [ALL]", "MINUS", "INTERSECT"]), kA = _([
|
|
11472
11628
|
"JOIN",
|
|
11473
11629
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11474
11630
|
"{INNER | CROSS} JOIN",
|
|
@@ -11476,23 +11632,23 @@ const kR = [
|
|
|
11476
11632
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
11477
11633
|
// non-standard joins
|
|
11478
11634
|
"{CROSS | OUTER} APPLY"
|
|
11479
|
-
]),
|
|
11635
|
+
]), zA = _([
|
|
11480
11636
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
11481
11637
|
"ON COMMIT",
|
|
11482
11638
|
"{ROWS | RANGE} BETWEEN"
|
|
11483
|
-
]),
|
|
11639
|
+
]), ES = _([]), TS = {
|
|
11484
11640
|
name: "plsql",
|
|
11485
11641
|
tokenizerOptions: {
|
|
11486
|
-
reservedSelect:
|
|
11487
|
-
reservedClauses: [...
|
|
11488
|
-
reservedSetOperations:
|
|
11489
|
-
reservedJoins:
|
|
11490
|
-
reservedKeywordPhrases:
|
|
11491
|
-
reservedDataTypePhrases:
|
|
11642
|
+
reservedSelect: ZA,
|
|
11643
|
+
reservedClauses: [...qA, ...uT, ...hE],
|
|
11644
|
+
reservedSetOperations: jA,
|
|
11645
|
+
reservedJoins: kA,
|
|
11646
|
+
reservedKeywordPhrases: zA,
|
|
11647
|
+
reservedDataTypePhrases: ES,
|
|
11492
11648
|
supportsXor: !0,
|
|
11493
|
-
reservedKeywords:
|
|
11494
|
-
reservedDataTypes:
|
|
11495
|
-
reservedFunctionNames:
|
|
11649
|
+
reservedKeywords: xA,
|
|
11650
|
+
reservedDataTypes: vA,
|
|
11651
|
+
reservedFunctionNames: QA,
|
|
11496
11652
|
stringTypes: [
|
|
11497
11653
|
{ quote: "''-qq", prefixes: ["N"] },
|
|
11498
11654
|
{ quote: "q''", prefixes: ["N"] }
|
|
@@ -11517,19 +11673,19 @@ const kR = [
|
|
|
11517
11673
|
"@",
|
|
11518
11674
|
"||"
|
|
11519
11675
|
],
|
|
11520
|
-
postProcess:
|
|
11676
|
+
postProcess: eS
|
|
11521
11677
|
},
|
|
11522
11678
|
formatOptions: {
|
|
11523
11679
|
alwaysDenseOperators: ["@"],
|
|
11524
|
-
onelineClauses: [...
|
|
11680
|
+
onelineClauses: [...uT, ...hE],
|
|
11525
11681
|
tabularOnelineClauses: hE
|
|
11526
11682
|
}
|
|
11527
11683
|
};
|
|
11528
|
-
function
|
|
11684
|
+
function eS(T) {
|
|
11529
11685
|
let E = z;
|
|
11530
|
-
return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type: o.RESERVED_KEYWORD }) : (
|
|
11686
|
+
return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type: o.RESERVED_KEYWORD }) : (ee(e.type) && (E = e), e));
|
|
11531
11687
|
}
|
|
11532
|
-
const
|
|
11688
|
+
const RS = [
|
|
11533
11689
|
// https://www.postgresql.org/docs/14/functions.html
|
|
11534
11690
|
//
|
|
11535
11691
|
// https://www.postgresql.org/docs/14/functions-math.html
|
|
@@ -12213,7 +12369,7 @@ const ZA = [
|
|
|
12213
12369
|
"PG_MCV_LIST_ITEMS",
|
|
12214
12370
|
// cast
|
|
12215
12371
|
"CAST"
|
|
12216
|
-
],
|
|
12372
|
+
], AS = [
|
|
12217
12373
|
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
|
|
12218
12374
|
"ALL",
|
|
12219
12375
|
"ANALYSE",
|
|
@@ -12332,7 +12488,7 @@ const ZA = [
|
|
|
12332
12488
|
"WITHOUT",
|
|
12333
12489
|
"YEAR"
|
|
12334
12490
|
// requires AS
|
|
12335
|
-
],
|
|
12491
|
+
], SS = [
|
|
12336
12492
|
// https://www.postgresql.org/docs/current/datatype.html
|
|
12337
12493
|
"ARRAY",
|
|
12338
12494
|
"BIGINT",
|
|
@@ -12366,7 +12522,7 @@ const ZA = [
|
|
|
12366
12522
|
"VARCHAR",
|
|
12367
12523
|
"XML",
|
|
12368
12524
|
"ZONE"
|
|
12369
|
-
],
|
|
12525
|
+
], IS = _(["SELECT [ALL | DISTINCT]"]), NS = _([
|
|
12370
12526
|
// queries
|
|
12371
12527
|
"WITH [RECURSIVE]",
|
|
12372
12528
|
"FROM",
|
|
@@ -12389,7 +12545,7 @@ const ZA = [
|
|
|
12389
12545
|
"SET",
|
|
12390
12546
|
// other
|
|
12391
12547
|
"RETURNING"
|
|
12392
|
-
]),
|
|
12548
|
+
]), GT = _([
|
|
12393
12549
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
12394
12550
|
]), VE = _([
|
|
12395
12551
|
// - create
|
|
@@ -12469,6 +12625,7 @@ const ZA = [
|
|
|
12469
12625
|
"CHECKPOINT",
|
|
12470
12626
|
"CLOSE",
|
|
12471
12627
|
"CLUSTER",
|
|
12628
|
+
"COMMENT ON",
|
|
12472
12629
|
"COMMIT",
|
|
12473
12630
|
"COMMIT PREPARED",
|
|
12474
12631
|
"COPY",
|
|
@@ -12589,17 +12746,17 @@ const ZA = [
|
|
|
12589
12746
|
"START TRANSACTION",
|
|
12590
12747
|
"UNLISTEN",
|
|
12591
12748
|
"VACUUM"
|
|
12592
|
-
]),
|
|
12749
|
+
]), OS = _([
|
|
12593
12750
|
"UNION [ALL | DISTINCT]",
|
|
12594
12751
|
"EXCEPT [ALL | DISTINCT]",
|
|
12595
12752
|
"INTERSECT [ALL | DISTINCT]"
|
|
12596
|
-
]),
|
|
12753
|
+
]), tS = _([
|
|
12597
12754
|
"JOIN",
|
|
12598
12755
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12599
12756
|
"{INNER | CROSS} JOIN",
|
|
12600
12757
|
"NATURAL [INNER] JOIN",
|
|
12601
12758
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12602
|
-
]),
|
|
12759
|
+
]), sS = _([
|
|
12603
12760
|
"PRIMARY KEY",
|
|
12604
12761
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
12605
12762
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -12610,21 +12767,21 @@ const ZA = [
|
|
|
12610
12767
|
"IS [NOT] DISTINCT FROM",
|
|
12611
12768
|
"NULLS {FIRST | LAST}",
|
|
12612
12769
|
"WITH ORDINALITY"
|
|
12613
|
-
]),
|
|
12770
|
+
]), rS = _([
|
|
12614
12771
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
12615
12772
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
12616
|
-
]),
|
|
12773
|
+
]), CS = {
|
|
12617
12774
|
name: "postgresql",
|
|
12618
12775
|
tokenizerOptions: {
|
|
12619
|
-
reservedSelect:
|
|
12620
|
-
reservedClauses: [...
|
|
12621
|
-
reservedSetOperations:
|
|
12622
|
-
reservedJoins:
|
|
12623
|
-
reservedKeywordPhrases:
|
|
12624
|
-
reservedDataTypePhrases:
|
|
12625
|
-
reservedKeywords:
|
|
12626
|
-
reservedDataTypes:
|
|
12627
|
-
reservedFunctionNames:
|
|
12776
|
+
reservedSelect: IS,
|
|
12777
|
+
reservedClauses: [...NS, ...GT, ...VE],
|
|
12778
|
+
reservedSetOperations: OS,
|
|
12779
|
+
reservedJoins: tS,
|
|
12780
|
+
reservedKeywordPhrases: sS,
|
|
12781
|
+
reservedDataTypePhrases: rS,
|
|
12782
|
+
reservedKeywords: AS,
|
|
12783
|
+
reservedDataTypes: SS,
|
|
12784
|
+
reservedFunctionNames: RS,
|
|
12628
12785
|
nestedBlockComments: !0,
|
|
12629
12786
|
extraParens: ["[]"],
|
|
12630
12787
|
underscoresInNumbers: !0,
|
|
@@ -12736,10 +12893,10 @@ const ZA = [
|
|
|
12736
12893
|
},
|
|
12737
12894
|
formatOptions: {
|
|
12738
12895
|
alwaysDenseOperators: ["::", ":"],
|
|
12739
|
-
onelineClauses: [...
|
|
12896
|
+
onelineClauses: [...GT, ...VE],
|
|
12740
12897
|
tabularOnelineClauses: VE
|
|
12741
12898
|
}
|
|
12742
|
-
},
|
|
12899
|
+
}, nS = [
|
|
12743
12900
|
// https://docs.aws.amazon.com/redshift/latest/dg/c_Aggregate_Functions.html
|
|
12744
12901
|
"ANY_VALUE",
|
|
12745
12902
|
"APPROXIMATE PERCENTILE_DISC",
|
|
@@ -13085,7 +13242,7 @@ const ZA = [
|
|
|
13085
13242
|
"SLICE_NUM",
|
|
13086
13243
|
"USER",
|
|
13087
13244
|
"VERSION"
|
|
13088
|
-
],
|
|
13245
|
+
], LS = [
|
|
13089
13246
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_pg_keywords.html
|
|
13090
13247
|
"AES128",
|
|
13091
13248
|
"AES256",
|
|
@@ -13274,7 +13431,7 @@ const ZA = [
|
|
|
13274
13431
|
* SVL: https://docs.aws.amazon.com/redshift/latest/dg/svl_views.html
|
|
13275
13432
|
* SVV: https://docs.aws.amazon.com/redshift/latest/dg/svv_views.html
|
|
13276
13433
|
*/
|
|
13277
|
-
],
|
|
13434
|
+
], _S = [
|
|
13278
13435
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_Character_types.html#r_Character_types-text-and-bpchar-types
|
|
13279
13436
|
"ARRAY",
|
|
13280
13437
|
"BIGINT",
|
|
@@ -13295,7 +13452,7 @@ const ZA = [
|
|
|
13295
13452
|
"TEXT",
|
|
13296
13453
|
"VARBYTE",
|
|
13297
13454
|
"VARCHAR"
|
|
13298
|
-
],
|
|
13455
|
+
], iS = _(["SELECT [ALL | DISTINCT]"]), aS = _([
|
|
13299
13456
|
// queries
|
|
13300
13457
|
"WITH [RECURSIVE]",
|
|
13301
13458
|
"FROM",
|
|
@@ -13313,7 +13470,7 @@ const ZA = [
|
|
|
13313
13470
|
"VALUES",
|
|
13314
13471
|
// - update:
|
|
13315
13472
|
"SET"
|
|
13316
|
-
]),
|
|
13473
|
+
]), mT = _([
|
|
13317
13474
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
13318
13475
|
]), WE = _([
|
|
13319
13476
|
// - create:
|
|
@@ -13406,13 +13563,13 @@ const ZA = [
|
|
|
13406
13563
|
"START TRANSACTION",
|
|
13407
13564
|
"UNLOAD",
|
|
13408
13565
|
"VACUUM"
|
|
13409
|
-
]),
|
|
13566
|
+
]), oS = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), DS = _([
|
|
13410
13567
|
"JOIN",
|
|
13411
13568
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13412
13569
|
"{INNER | CROSS} JOIN",
|
|
13413
13570
|
"NATURAL [INNER] JOIN",
|
|
13414
13571
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
13415
|
-
]),
|
|
13572
|
+
]), PS = _([
|
|
13416
13573
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
13417
13574
|
"NULL AS",
|
|
13418
13575
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -13420,18 +13577,18 @@ const ZA = [
|
|
|
13420
13577
|
"HIVE METASTORE",
|
|
13421
13578
|
// in window specifications
|
|
13422
13579
|
"{ROWS | RANGE} BETWEEN"
|
|
13423
|
-
]),
|
|
13580
|
+
]), MS = _([]), US = {
|
|
13424
13581
|
name: "redshift",
|
|
13425
13582
|
tokenizerOptions: {
|
|
13426
|
-
reservedSelect:
|
|
13427
|
-
reservedClauses: [...
|
|
13428
|
-
reservedSetOperations:
|
|
13429
|
-
reservedJoins:
|
|
13430
|
-
reservedKeywordPhrases:
|
|
13431
|
-
reservedDataTypePhrases:
|
|
13432
|
-
reservedKeywords:
|
|
13433
|
-
reservedDataTypes:
|
|
13434
|
-
reservedFunctionNames:
|
|
13583
|
+
reservedSelect: iS,
|
|
13584
|
+
reservedClauses: [...aS, ...mT, ...WE],
|
|
13585
|
+
reservedSetOperations: oS,
|
|
13586
|
+
reservedJoins: DS,
|
|
13587
|
+
reservedKeywordPhrases: PS,
|
|
13588
|
+
reservedDataTypePhrases: MS,
|
|
13589
|
+
reservedKeywords: LS,
|
|
13590
|
+
reservedDataTypes: _S,
|
|
13591
|
+
reservedFunctionNames: nS,
|
|
13435
13592
|
extraParens: ["[]"],
|
|
13436
13593
|
stringTypes: ["''-qq"],
|
|
13437
13594
|
identTypes: ['""-qq'],
|
|
@@ -13455,10 +13612,10 @@ const ZA = [
|
|
|
13455
13612
|
},
|
|
13456
13613
|
formatOptions: {
|
|
13457
13614
|
alwaysDenseOperators: ["::"],
|
|
13458
|
-
onelineClauses: [...
|
|
13615
|
+
onelineClauses: [...mT, ...WE],
|
|
13459
13616
|
tabularOnelineClauses: WE
|
|
13460
13617
|
}
|
|
13461
|
-
},
|
|
13618
|
+
}, cS = [
|
|
13462
13619
|
// https://deepkb.com/CO_000013/en/kb/IMPORT-fbfa59f0-2bf1-31fe-bb7b-0f9efe9932c6/spark-sql-keywords
|
|
13463
13620
|
"ADD",
|
|
13464
13621
|
"AFTER",
|
|
@@ -13725,7 +13882,7 @@ const ZA = [
|
|
|
13725
13882
|
"UNSIGNED",
|
|
13726
13883
|
"VARIABLES",
|
|
13727
13884
|
"YEAR_MONTH"
|
|
13728
|
-
],
|
|
13885
|
+
], lS = [
|
|
13729
13886
|
// https://spark.apache.org/docs/latest/sql-ref-datatypes.html
|
|
13730
13887
|
"ARRAY",
|
|
13731
13888
|
"BIGINT",
|
|
@@ -13755,7 +13912,7 @@ const ZA = [
|
|
|
13755
13912
|
"TINYINT",
|
|
13756
13913
|
"VARCHAR"
|
|
13757
13914
|
// No varchar type in Spark, only STRING. Added for the sake of tests
|
|
13758
|
-
],
|
|
13915
|
+
], uS = [
|
|
13759
13916
|
// http://spark.apache.org/docs/latest/sql-ref-functions.html
|
|
13760
13917
|
//
|
|
13761
13918
|
// http://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#aggregate-functions
|
|
@@ -14076,7 +14233,7 @@ const ZA = [
|
|
|
14076
14233
|
// Shorthand functions to use in place of CASE expression
|
|
14077
14234
|
"COALESCE",
|
|
14078
14235
|
"NULLIF"
|
|
14079
|
-
],
|
|
14236
|
+
], GS = _(["SELECT [ALL | DISTINCT]"]), mS = _([
|
|
14080
14237
|
// queries
|
|
14081
14238
|
"WITH",
|
|
14082
14239
|
"FROM",
|
|
@@ -14101,7 +14258,7 @@ const ZA = [
|
|
|
14101
14258
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
14102
14259
|
"LOAD DATA [LOCAL] INPATH",
|
|
14103
14260
|
"[OVERWRITE] INTO TABLE"
|
|
14104
|
-
]),
|
|
14261
|
+
]), dT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), bE = _([
|
|
14105
14262
|
// - create:
|
|
14106
14263
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
14107
14264
|
// - drop table:
|
|
@@ -14157,11 +14314,11 @@ const ZA = [
|
|
|
14157
14314
|
"SHOW TBLPROPERTIES",
|
|
14158
14315
|
"SHOW VIEWS",
|
|
14159
14316
|
"UNCACHE TABLE"
|
|
14160
|
-
]),
|
|
14317
|
+
]), dS = _([
|
|
14161
14318
|
"UNION [ALL | DISTINCT]",
|
|
14162
14319
|
"EXCEPT [ALL | DISTINCT]",
|
|
14163
14320
|
"INTERSECT [ALL | DISTINCT]"
|
|
14164
|
-
]),
|
|
14321
|
+
]), HS = _([
|
|
14165
14322
|
"JOIN",
|
|
14166
14323
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14167
14324
|
"{INNER | CROSS} JOIN",
|
|
@@ -14170,24 +14327,24 @@ const ZA = [
|
|
|
14170
14327
|
// non-standard-joins
|
|
14171
14328
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
14172
14329
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
14173
|
-
]),
|
|
14330
|
+
]), BS = _([
|
|
14174
14331
|
"ON DELETE",
|
|
14175
14332
|
"ON UPDATE",
|
|
14176
14333
|
"CURRENT ROW",
|
|
14177
14334
|
"{ROWS | RANGE} BETWEEN"
|
|
14178
|
-
]),
|
|
14335
|
+
]), pS = _([]), FS = {
|
|
14179
14336
|
name: "spark",
|
|
14180
14337
|
tokenizerOptions: {
|
|
14181
|
-
reservedSelect:
|
|
14182
|
-
reservedClauses: [...
|
|
14183
|
-
reservedSetOperations:
|
|
14184
|
-
reservedJoins:
|
|
14185
|
-
reservedKeywordPhrases:
|
|
14186
|
-
reservedDataTypePhrases:
|
|
14338
|
+
reservedSelect: GS,
|
|
14339
|
+
reservedClauses: [...mS, ...dT, ...bE],
|
|
14340
|
+
reservedSetOperations: dS,
|
|
14341
|
+
reservedJoins: HS,
|
|
14342
|
+
reservedKeywordPhrases: BS,
|
|
14343
|
+
reservedDataTypePhrases: pS,
|
|
14187
14344
|
supportsXor: !0,
|
|
14188
|
-
reservedKeywords:
|
|
14189
|
-
reservedDataTypes:
|
|
14190
|
-
reservedFunctionNames:
|
|
14345
|
+
reservedKeywords: cS,
|
|
14346
|
+
reservedDataTypes: lS,
|
|
14347
|
+
reservedFunctionNames: uS,
|
|
14191
14348
|
extraParens: ["[]"],
|
|
14192
14349
|
stringTypes: [
|
|
14193
14350
|
"''-bs",
|
|
@@ -14199,20 +14356,20 @@ const ZA = [
|
|
|
14199
14356
|
identChars: { allowFirstCharNumber: !0 },
|
|
14200
14357
|
variableTypes: [{ quote: "{}", prefixes: ["$"], requirePrefix: !0 }],
|
|
14201
14358
|
operators: ["%", "~", "^", "|", "&", "<=>", "==", "!", "||", "->"],
|
|
14202
|
-
postProcess:
|
|
14359
|
+
postProcess: YS
|
|
14203
14360
|
},
|
|
14204
14361
|
formatOptions: {
|
|
14205
|
-
onelineClauses: [...
|
|
14362
|
+
onelineClauses: [...dT, ...bE],
|
|
14206
14363
|
tabularOnelineClauses: bE
|
|
14207
14364
|
}
|
|
14208
14365
|
};
|
|
14209
|
-
function
|
|
14366
|
+
function YS(T) {
|
|
14210
14367
|
return T.map((E, e) => {
|
|
14211
14368
|
const R = T[e - 1] || z, A = T[e + 1] || z;
|
|
14212
14369
|
return x.WINDOW(E) && A.type === o.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: o.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === o.RESERVED_KEYWORD && !(R.text === "COLLECTION" && A.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: o.IDENTIFIER, text: E.raw }) : E;
|
|
14213
14370
|
});
|
|
14214
14371
|
}
|
|
14215
|
-
const
|
|
14372
|
+
const fS = [
|
|
14216
14373
|
// https://www.sqlite.org/lang_corefunc.html
|
|
14217
14374
|
"ABS",
|
|
14218
14375
|
"CHANGES",
|
|
@@ -14336,7 +14493,7 @@ const GS = [
|
|
|
14336
14493
|
"JSON_TREE",
|
|
14337
14494
|
// cast
|
|
14338
14495
|
"CAST"
|
|
14339
|
-
],
|
|
14496
|
+
], hS = [
|
|
14340
14497
|
// https://www.sqlite.org/lang_keywords.html
|
|
14341
14498
|
// Note: The keywords listed on that URL are not all reserved keywords.
|
|
14342
14499
|
// We'll need to clean up this list to only include reserved keywords.
|
|
@@ -14489,7 +14646,7 @@ const GS = [
|
|
|
14489
14646
|
"WINDOW",
|
|
14490
14647
|
"WITH",
|
|
14491
14648
|
"WITHOUT"
|
|
14492
|
-
],
|
|
14649
|
+
], VS = [
|
|
14493
14650
|
// SQLite allows any word as a data type, e.g. CREATE TABLE foo (col1 madeupname(123));
|
|
14494
14651
|
// Here we just list some common ones as SQL Formatter
|
|
14495
14652
|
// is only able to detect a predefined list of data types.
|
|
@@ -14510,7 +14667,7 @@ const GS = [
|
|
|
14510
14667
|
"TEXT",
|
|
14511
14668
|
"VARCHAR",
|
|
14512
14669
|
"VARYING CHARACTER"
|
|
14513
|
-
],
|
|
14670
|
+
], WS = _(["SELECT [ALL | DISTINCT]"]), bS = _([
|
|
14514
14671
|
// queries
|
|
14515
14672
|
"WITH [RECURSIVE]",
|
|
14516
14673
|
"FROM",
|
|
@@ -14550,28 +14707,28 @@ const GS = [
|
|
|
14550
14707
|
"RENAME TO",
|
|
14551
14708
|
// - set schema
|
|
14552
14709
|
"SET SCHEMA"
|
|
14553
|
-
]),
|
|
14710
|
+
]), XS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), yS = _([
|
|
14554
14711
|
"JOIN",
|
|
14555
14712
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14556
14713
|
"{INNER | CROSS} JOIN",
|
|
14557
14714
|
"NATURAL [INNER] JOIN",
|
|
14558
14715
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14559
|
-
]),
|
|
14716
|
+
]), gS = _([
|
|
14560
14717
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14561
14718
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14562
14719
|
"DO UPDATE"
|
|
14563
|
-
]),
|
|
14720
|
+
]), KS = _([]), $S = {
|
|
14564
14721
|
name: "sqlite",
|
|
14565
14722
|
tokenizerOptions: {
|
|
14566
|
-
reservedSelect:
|
|
14567
|
-
reservedClauses: [...
|
|
14568
|
-
reservedSetOperations:
|
|
14569
|
-
reservedJoins:
|
|
14570
|
-
reservedKeywordPhrases:
|
|
14571
|
-
reservedDataTypePhrases:
|
|
14572
|
-
reservedKeywords:
|
|
14573
|
-
reservedDataTypes:
|
|
14574
|
-
reservedFunctionNames:
|
|
14723
|
+
reservedSelect: WS,
|
|
14724
|
+
reservedClauses: [...bS, ...HT, ...XE],
|
|
14725
|
+
reservedSetOperations: XS,
|
|
14726
|
+
reservedJoins: yS,
|
|
14727
|
+
reservedKeywordPhrases: gS,
|
|
14728
|
+
reservedDataTypePhrases: KS,
|
|
14729
|
+
reservedKeywords: hS,
|
|
14730
|
+
reservedDataTypes: VS,
|
|
14731
|
+
reservedFunctionNames: fS,
|
|
14575
14732
|
stringTypes: [
|
|
14576
14733
|
"''-qq",
|
|
14577
14734
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -14587,7 +14744,7 @@ const GS = [
|
|
|
14587
14744
|
onelineClauses: [...HT, ...XE],
|
|
14588
14745
|
tabularOnelineClauses: XE
|
|
14589
14746
|
}
|
|
14590
|
-
},
|
|
14747
|
+
}, wS = [
|
|
14591
14748
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_9_set_function_specification
|
|
14592
14749
|
"GROUPING",
|
|
14593
14750
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_10_window_function
|
|
@@ -14684,7 +14841,7 @@ const GS = [
|
|
|
14684
14841
|
"ASIN",
|
|
14685
14842
|
"ACOS",
|
|
14686
14843
|
"ATAN"
|
|
14687
|
-
],
|
|
14844
|
+
], JS = [
|
|
14688
14845
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#reserved-word
|
|
14689
14846
|
"ALL",
|
|
14690
14847
|
"ALLOCATE",
|
|
@@ -14882,7 +15039,7 @@ const GS = [
|
|
|
14882
15039
|
"WITHIN",
|
|
14883
15040
|
"WITHOUT",
|
|
14884
15041
|
"YEAR"
|
|
14885
|
-
],
|
|
15042
|
+
], xS = [
|
|
14886
15043
|
// https://jakewheat.github.io/sql-overview/sql-2008-foundation-grammar.html#_6_1_data_type
|
|
14887
15044
|
"ARRAY",
|
|
14888
15045
|
"BIGINT",
|
|
@@ -14922,7 +15079,7 @@ const GS = [
|
|
|
14922
15079
|
"TIMESTAMP",
|
|
14923
15080
|
"VARBINARY",
|
|
14924
15081
|
"VARCHAR"
|
|
14925
|
-
],
|
|
15082
|
+
], vS = _(["SELECT [ALL | DISTINCT]"]), QS = _([
|
|
14926
15083
|
// queries
|
|
14927
15084
|
"WITH [RECURSIVE]",
|
|
14928
15085
|
"FROM",
|
|
@@ -14941,7 +15098,7 @@ const GS = [
|
|
|
14941
15098
|
"VALUES",
|
|
14942
15099
|
// - update:
|
|
14943
15100
|
"SET"
|
|
14944
|
-
]),
|
|
15101
|
+
]), BT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), yE = _([
|
|
14945
15102
|
// - create:
|
|
14946
15103
|
"CREATE [RECURSIVE] VIEW",
|
|
14947
15104
|
// - update:
|
|
@@ -14966,31 +15123,31 @@ const GS = [
|
|
|
14966
15123
|
"TRUNCATE TABLE",
|
|
14967
15124
|
// other
|
|
14968
15125
|
"SET SCHEMA"
|
|
14969
|
-
]),
|
|
15126
|
+
]), ZS = _([
|
|
14970
15127
|
"UNION [ALL | DISTINCT]",
|
|
14971
15128
|
"EXCEPT [ALL | DISTINCT]",
|
|
14972
15129
|
"INTERSECT [ALL | DISTINCT]"
|
|
14973
|
-
]),
|
|
15130
|
+
]), qS = _([
|
|
14974
15131
|
"JOIN",
|
|
14975
15132
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14976
15133
|
"{INNER | CROSS} JOIN",
|
|
14977
15134
|
"NATURAL [INNER] JOIN",
|
|
14978
15135
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14979
|
-
]),
|
|
15136
|
+
]), jS = _([
|
|
14980
15137
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14981
15138
|
"{ROWS | RANGE} BETWEEN"
|
|
14982
|
-
]),
|
|
15139
|
+
]), kS = _([]), zS = {
|
|
14983
15140
|
name: "sql",
|
|
14984
15141
|
tokenizerOptions: {
|
|
14985
|
-
reservedSelect:
|
|
14986
|
-
reservedClauses: [...
|
|
14987
|
-
reservedSetOperations:
|
|
14988
|
-
reservedJoins:
|
|
14989
|
-
reservedKeywordPhrases:
|
|
14990
|
-
reservedDataTypePhrases:
|
|
14991
|
-
reservedKeywords:
|
|
14992
|
-
reservedDataTypes:
|
|
14993
|
-
reservedFunctionNames:
|
|
15142
|
+
reservedSelect: vS,
|
|
15143
|
+
reservedClauses: [...QS, ...BT, ...yE],
|
|
15144
|
+
reservedSetOperations: ZS,
|
|
15145
|
+
reservedJoins: qS,
|
|
15146
|
+
reservedKeywordPhrases: jS,
|
|
15147
|
+
reservedDataTypePhrases: kS,
|
|
15148
|
+
reservedKeywords: JS,
|
|
15149
|
+
reservedDataTypes: xS,
|
|
15150
|
+
reservedFunctionNames: wS,
|
|
14994
15151
|
stringTypes: [
|
|
14995
15152
|
{ quote: "''-qq-bs", prefixes: ["N", "U&"] },
|
|
14996
15153
|
{ quote: "''-raw", prefixes: ["X"], requirePrefix: !0 }
|
|
@@ -15000,10 +15157,10 @@ const GS = [
|
|
|
15000
15157
|
operators: ["||"]
|
|
15001
15158
|
},
|
|
15002
15159
|
formatOptions: {
|
|
15003
|
-
onelineClauses: [...
|
|
15160
|
+
onelineClauses: [...BT, ...yE],
|
|
15004
15161
|
tabularOnelineClauses: yE
|
|
15005
15162
|
}
|
|
15006
|
-
},
|
|
15163
|
+
}, EI = [
|
|
15007
15164
|
// https://github.com/trinodb/trino/tree/432d2897bdef99388c1a47188743a061c4ac1f34/docs/src/main/sphinx/functions
|
|
15008
15165
|
// rg '^\.\. function::' ./docs/src/main/sphinx/functions | cut -d' ' -f 3 | cut -d '(' -f 1 | sort | uniq
|
|
15009
15166
|
// rg '\* ' ./docs/src/main/sphinx/functions/list-by-topic.rst | grep '\* :func:' | cut -d'`' -f 2
|
|
@@ -15437,7 +15594,7 @@ const GS = [
|
|
|
15437
15594
|
"NEXT",
|
|
15438
15595
|
"PERMUTE",
|
|
15439
15596
|
"PREV"
|
|
15440
|
-
],
|
|
15597
|
+
], TI = [
|
|
15441
15598
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4#L858-L1128
|
|
15442
15599
|
"ABSENT",
|
|
15443
15600
|
"ADD",
|
|
@@ -15674,7 +15831,7 @@ const GS = [
|
|
|
15674
15831
|
"WRAPPER",
|
|
15675
15832
|
"WRITE",
|
|
15676
15833
|
"ZONE"
|
|
15677
|
-
],
|
|
15834
|
+
], eI = [
|
|
15678
15835
|
// https://github.com/trinodb/trino/blob/432d2897bdef99388c1a47188743a061c4ac1f34/core/trino-main/src/main/java/io/trino/metadata/TypeRegistry.java#L131-L168
|
|
15679
15836
|
// or https://trino.io/docs/current/language/types.html
|
|
15680
15837
|
"BIGINT",
|
|
@@ -15713,7 +15870,7 @@ const GS = [
|
|
|
15713
15870
|
"CODEPOINTS",
|
|
15714
15871
|
"FUNCTION",
|
|
15715
15872
|
"JSONPATH"
|
|
15716
|
-
],
|
|
15873
|
+
], RI = _(["SELECT [ALL | DISTINCT]"]), AI = _([
|
|
15717
15874
|
// queries
|
|
15718
15875
|
"WITH [RECURSIVE]",
|
|
15719
15876
|
"FROM",
|
|
@@ -15741,7 +15898,7 @@ const GS = [
|
|
|
15741
15898
|
"PATTERN",
|
|
15742
15899
|
"SUBSET",
|
|
15743
15900
|
"DEFINE"
|
|
15744
|
-
]),
|
|
15901
|
+
]), pT = _(["CREATE TABLE [IF NOT EXISTS]"]), gE = _([
|
|
15745
15902
|
// - create:
|
|
15746
15903
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
15747
15904
|
// - update:
|
|
@@ -15799,32 +15956,32 @@ const GS = [
|
|
|
15799
15956
|
"SHOW ROLE GRANTS",
|
|
15800
15957
|
"SHOW FUNCTIONS",
|
|
15801
15958
|
"SHOW SESSION"
|
|
15802
|
-
]),
|
|
15959
|
+
]), SI = _([
|
|
15803
15960
|
"UNION [ALL | DISTINCT]",
|
|
15804
15961
|
"EXCEPT [ALL | DISTINCT]",
|
|
15805
15962
|
"INTERSECT [ALL | DISTINCT]"
|
|
15806
|
-
]),
|
|
15963
|
+
]), II = _([
|
|
15807
15964
|
"JOIN",
|
|
15808
15965
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15809
15966
|
"{INNER | CROSS} JOIN",
|
|
15810
15967
|
"NATURAL [INNER] JOIN",
|
|
15811
15968
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
15812
|
-
]),
|
|
15969
|
+
]), NI = _([
|
|
15813
15970
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
15814
15971
|
// comparison operator
|
|
15815
15972
|
"IS [NOT] DISTINCT FROM"
|
|
15816
|
-
]),
|
|
15973
|
+
]), OI = _([]), tI = {
|
|
15817
15974
|
name: "trino",
|
|
15818
15975
|
tokenizerOptions: {
|
|
15819
|
-
reservedSelect:
|
|
15820
|
-
reservedClauses: [...
|
|
15821
|
-
reservedSetOperations:
|
|
15822
|
-
reservedJoins:
|
|
15823
|
-
reservedKeywordPhrases:
|
|
15824
|
-
reservedDataTypePhrases:
|
|
15825
|
-
reservedKeywords:
|
|
15826
|
-
reservedDataTypes:
|
|
15827
|
-
reservedFunctionNames:
|
|
15976
|
+
reservedSelect: RI,
|
|
15977
|
+
reservedClauses: [...AI, ...pT, ...gE],
|
|
15978
|
+
reservedSetOperations: SI,
|
|
15979
|
+
reservedJoins: II,
|
|
15980
|
+
reservedKeywordPhrases: NI,
|
|
15981
|
+
reservedDataTypePhrases: OI,
|
|
15982
|
+
reservedKeywords: TI,
|
|
15983
|
+
reservedDataTypes: eI,
|
|
15984
|
+
reservedFunctionNames: EI,
|
|
15828
15985
|
// Trino also supports {- ... -} parenthesis.
|
|
15829
15986
|
// The formatting of these currently works out as a result of { and -
|
|
15830
15987
|
// not getting a space added in-between.
|
|
@@ -15853,10 +16010,10 @@ const GS = [
|
|
|
15853
16010
|
]
|
|
15854
16011
|
},
|
|
15855
16012
|
formatOptions: {
|
|
15856
|
-
onelineClauses: [...
|
|
16013
|
+
onelineClauses: [...pT, ...gE],
|
|
15857
16014
|
tabularOnelineClauses: gE
|
|
15858
16015
|
}
|
|
15859
|
-
},
|
|
16016
|
+
}, sI = [
|
|
15860
16017
|
// https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
|
|
15861
16018
|
// aggregate
|
|
15862
16019
|
"APPROX_COUNT_DISTINCT",
|
|
@@ -16161,7 +16318,7 @@ const GS = [
|
|
|
16161
16318
|
// Shorthand functions to use in place of CASE expression
|
|
16162
16319
|
"COALESCE",
|
|
16163
16320
|
"NULLIF"
|
|
16164
|
-
],
|
|
16321
|
+
], rI = [
|
|
16165
16322
|
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15
|
|
16166
16323
|
// standard
|
|
16167
16324
|
"ADD",
|
|
@@ -16342,7 +16499,7 @@ const GS = [
|
|
|
16342
16499
|
"WRITETEXT",
|
|
16343
16500
|
// https://learn.microsoft.com/en-us/sql/t-sql/queries/output-clause-transact-sql?view=sql-server-ver16#action
|
|
16344
16501
|
"$ACTION"
|
|
16345
|
-
],
|
|
16502
|
+
], CI = [
|
|
16346
16503
|
// https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15
|
|
16347
16504
|
"BINARY",
|
|
16348
16505
|
"BIT",
|
|
@@ -16369,7 +16526,7 @@ const GS = [
|
|
|
16369
16526
|
"TIMESTAMP",
|
|
16370
16527
|
"VARBINARY",
|
|
16371
16528
|
"VARCHAR"
|
|
16372
|
-
],
|
|
16529
|
+
], nI = _(["SELECT [ALL | DISTINCT]"]), LI = _([
|
|
16373
16530
|
// queries
|
|
16374
16531
|
"WITH",
|
|
16375
16532
|
"INTO",
|
|
@@ -16394,7 +16551,7 @@ const GS = [
|
|
|
16394
16551
|
"MERGE [INTO]",
|
|
16395
16552
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
16396
16553
|
"UPDATE SET"
|
|
16397
|
-
]),
|
|
16554
|
+
]), FT = _(["CREATE TABLE"]), KE = _([
|
|
16398
16555
|
// - create:
|
|
16399
16556
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
16400
16557
|
// - update:
|
|
@@ -16574,27 +16731,27 @@ const GS = [
|
|
|
16574
16731
|
"XACT_ABORT",
|
|
16575
16732
|
"XML INDEX",
|
|
16576
16733
|
"XML SCHEMA COLLECTION"
|
|
16577
|
-
]),
|
|
16734
|
+
]), _I = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), iI = _([
|
|
16578
16735
|
"JOIN",
|
|
16579
16736
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16580
16737
|
"{INNER | CROSS} JOIN",
|
|
16581
16738
|
// non-standard joins
|
|
16582
16739
|
"{CROSS | OUTER} APPLY"
|
|
16583
|
-
]),
|
|
16740
|
+
]), aI = _([
|
|
16584
16741
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
16585
16742
|
"{ROWS | RANGE} BETWEEN"
|
|
16586
|
-
]),
|
|
16743
|
+
]), oI = _([]), DI = {
|
|
16587
16744
|
name: "transactsql",
|
|
16588
16745
|
tokenizerOptions: {
|
|
16589
|
-
reservedSelect:
|
|
16590
|
-
reservedClauses: [...
|
|
16591
|
-
reservedSetOperations:
|
|
16592
|
-
reservedJoins:
|
|
16593
|
-
reservedKeywordPhrases:
|
|
16594
|
-
reservedDataTypePhrases:
|
|
16595
|
-
reservedKeywords:
|
|
16596
|
-
reservedDataTypes:
|
|
16597
|
-
reservedFunctionNames:
|
|
16746
|
+
reservedSelect: nI,
|
|
16747
|
+
reservedClauses: [...LI, ...FT, ...KE],
|
|
16748
|
+
reservedSetOperations: _I,
|
|
16749
|
+
reservedJoins: iI,
|
|
16750
|
+
reservedKeywordPhrases: aI,
|
|
16751
|
+
reservedDataTypePhrases: oI,
|
|
16752
|
+
reservedKeywords: rI,
|
|
16753
|
+
reservedDataTypes: CI,
|
|
16754
|
+
reservedFunctionNames: sI,
|
|
16598
16755
|
nestedBlockComments: !0,
|
|
16599
16756
|
stringTypes: [{ quote: "''-qq", prefixes: ["N"] }, "{}"],
|
|
16600
16757
|
identTypes: ['""-qq', "[]"],
|
|
@@ -16624,10 +16781,10 @@ const GS = [
|
|
|
16624
16781
|
},
|
|
16625
16782
|
formatOptions: {
|
|
16626
16783
|
alwaysDenseOperators: ["::"],
|
|
16627
|
-
onelineClauses: [...
|
|
16784
|
+
onelineClauses: [...FT, ...KE],
|
|
16628
16785
|
tabularOnelineClauses: KE
|
|
16629
16786
|
}
|
|
16630
|
-
},
|
|
16787
|
+
}, PI = [
|
|
16631
16788
|
// List of all keywords taken from:
|
|
16632
16789
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/restricted-keywords/list-of-restricted-keywords.html
|
|
16633
16790
|
// Then filtered down to reserved keywords by running
|
|
@@ -16840,7 +16997,7 @@ const GS = [
|
|
|
16840
16997
|
"XOR",
|
|
16841
16998
|
"YEAR_MONTH",
|
|
16842
16999
|
"ZEROFILL"
|
|
16843
|
-
],
|
|
17000
|
+
], MI = [
|
|
16844
17001
|
// https://docs.singlestore.com/cloud/reference/sql-reference/data-types/
|
|
16845
17002
|
"BIGINT",
|
|
16846
17003
|
"BINARY",
|
|
@@ -16889,7 +17046,7 @@ const GS = [
|
|
|
16889
17046
|
"VARCHAR",
|
|
16890
17047
|
"VARCHARACTER",
|
|
16891
17048
|
"YEAR"
|
|
16892
|
-
],
|
|
17049
|
+
], UI = [
|
|
16893
17050
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/vector-functions/vector-functions.html
|
|
16894
17051
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/window-functions/window-functions.html
|
|
16895
17052
|
// https://docs.singlestore.com/managed-service/en/reference/sql-reference/string-functions/string-functions.html
|
|
@@ -17169,7 +17326,7 @@ const GS = [
|
|
|
17169
17326
|
"WEEKDAY",
|
|
17170
17327
|
"WEEKOFYEAR",
|
|
17171
17328
|
"YEAR"
|
|
17172
|
-
],
|
|
17329
|
+
], cI = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lI = _([
|
|
17173
17330
|
// queries
|
|
17174
17331
|
"WITH",
|
|
17175
17332
|
"FROM",
|
|
@@ -17191,7 +17348,7 @@ const GS = [
|
|
|
17191
17348
|
// Data definition
|
|
17192
17349
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
17193
17350
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
17194
|
-
]),
|
|
17351
|
+
]), YT = _([
|
|
17195
17352
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
17196
17353
|
]), $E = _([
|
|
17197
17354
|
// - create:
|
|
@@ -17370,36 +17527,36 @@ const GS = [
|
|
|
17370
17527
|
"REPEAT",
|
|
17371
17528
|
"RETURN",
|
|
17372
17529
|
"WHILE"
|
|
17373
|
-
]),
|
|
17530
|
+
]), uI = _([
|
|
17374
17531
|
"UNION [ALL | DISTINCT]",
|
|
17375
17532
|
"EXCEPT",
|
|
17376
17533
|
"INTERSECT",
|
|
17377
17534
|
"MINUS"
|
|
17378
|
-
]),
|
|
17535
|
+
]), GI = _([
|
|
17379
17536
|
"JOIN",
|
|
17380
17537
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17381
17538
|
"{INNER | CROSS} JOIN",
|
|
17382
17539
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
17383
17540
|
// non-standard joins
|
|
17384
17541
|
"STRAIGHT_JOIN"
|
|
17385
|
-
]),
|
|
17542
|
+
]), mI = _([
|
|
17386
17543
|
"ON DELETE",
|
|
17387
17544
|
"ON UPDATE",
|
|
17388
17545
|
"CHARACTER SET",
|
|
17389
17546
|
"{ROWS | RANGE} BETWEEN",
|
|
17390
17547
|
"IDENTIFIED BY"
|
|
17391
|
-
]),
|
|
17548
|
+
]), dI = _([]), HI = {
|
|
17392
17549
|
name: "singlestoredb",
|
|
17393
17550
|
tokenizerOptions: {
|
|
17394
|
-
reservedSelect:
|
|
17395
|
-
reservedClauses: [...
|
|
17396
|
-
reservedSetOperations:
|
|
17397
|
-
reservedJoins:
|
|
17398
|
-
reservedKeywordPhrases:
|
|
17399
|
-
reservedDataTypePhrases:
|
|
17400
|
-
reservedKeywords:
|
|
17401
|
-
reservedDataTypes:
|
|
17402
|
-
reservedFunctionNames:
|
|
17551
|
+
reservedSelect: cI,
|
|
17552
|
+
reservedClauses: [...lI, ...YT, ...$E],
|
|
17553
|
+
reservedSetOperations: uI,
|
|
17554
|
+
reservedJoins: GI,
|
|
17555
|
+
reservedKeywordPhrases: mI,
|
|
17556
|
+
reservedDataTypePhrases: dI,
|
|
17557
|
+
reservedKeywords: PI,
|
|
17558
|
+
reservedDataTypes: MI,
|
|
17559
|
+
reservedFunctionNames: UI,
|
|
17403
17560
|
// TODO: support _binary"some string" prefix
|
|
17404
17561
|
stringTypes: [
|
|
17405
17562
|
'""-qq-bs',
|
|
@@ -17436,10 +17593,10 @@ const GS = [
|
|
|
17436
17593
|
},
|
|
17437
17594
|
formatOptions: {
|
|
17438
17595
|
alwaysDenseOperators: ["::", "::$", "::%"],
|
|
17439
|
-
onelineClauses: [...
|
|
17596
|
+
onelineClauses: [...YT, ...$E],
|
|
17440
17597
|
tabularOnelineClauses: $E
|
|
17441
17598
|
}
|
|
17442
|
-
},
|
|
17599
|
+
}, BI = [
|
|
17443
17600
|
// https://docs.snowflake.com/en/sql-reference-functions.html
|
|
17444
17601
|
//
|
|
17445
17602
|
// https://docs.snowflake.com/en/sql-reference/functions-all.html
|
|
@@ -18047,7 +18204,7 @@ const GS = [
|
|
|
18047
18204
|
"QUARTER",
|
|
18048
18205
|
"ZEROIFNULL",
|
|
18049
18206
|
"ZIPF"
|
|
18050
|
-
],
|
|
18207
|
+
], pI = [
|
|
18051
18208
|
// https://docs.snowflake.com/en/sql-reference/reserved-keywords.html
|
|
18052
18209
|
//
|
|
18053
18210
|
// run in console on this page: $x('//tbody/tr/*[1]/p/text()').map(x => x.nodeValue)
|
|
@@ -18144,7 +18301,7 @@ const GS = [
|
|
|
18144
18301
|
"WITH",
|
|
18145
18302
|
// These are definitely keywords, but haven't found a definite list in the docs
|
|
18146
18303
|
"COMMENT"
|
|
18147
|
-
],
|
|
18304
|
+
], FI = [
|
|
18148
18305
|
"NUMBER",
|
|
18149
18306
|
"DECIMAL",
|
|
18150
18307
|
"NUMERIC",
|
|
@@ -18181,7 +18338,7 @@ const GS = [
|
|
|
18181
18338
|
"ARRAY",
|
|
18182
18339
|
"GEOGRAPHY",
|
|
18183
18340
|
"GEOMETRY"
|
|
18184
|
-
],
|
|
18341
|
+
], YI = _(["SELECT [ALL | DISTINCT]"]), fI = _([
|
|
18185
18342
|
// queries
|
|
18186
18343
|
"WITH [RECURSIVE]",
|
|
18187
18344
|
"FROM",
|
|
@@ -18209,7 +18366,7 @@ const GS = [
|
|
|
18209
18366
|
"WHEN MATCHED [AND]",
|
|
18210
18367
|
"THEN {UPDATE SET | DELETE}",
|
|
18211
18368
|
"WHEN NOT MATCHED THEN INSERT"
|
|
18212
|
-
]),
|
|
18369
|
+
]), fT = _([
|
|
18213
18370
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
18214
18371
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
18215
18372
|
]), wE = _([
|
|
@@ -18453,25 +18610,25 @@ const GS = [
|
|
|
18453
18610
|
"USE SCHEMA",
|
|
18454
18611
|
"USE SECONDARY ROLES",
|
|
18455
18612
|
"USE WAREHOUSE"
|
|
18456
|
-
]),
|
|
18613
|
+
]), hI = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), VI = _([
|
|
18457
18614
|
"[INNER] JOIN",
|
|
18458
18615
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
18459
18616
|
"{CROSS | NATURAL} JOIN"
|
|
18460
|
-
]),
|
|
18617
|
+
]), WI = _([
|
|
18461
18618
|
"{ROWS | RANGE} BETWEEN",
|
|
18462
18619
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
18463
|
-
]),
|
|
18620
|
+
]), bI = _([]), XI = {
|
|
18464
18621
|
name: "snowflake",
|
|
18465
18622
|
tokenizerOptions: {
|
|
18466
|
-
reservedSelect:
|
|
18467
|
-
reservedClauses: [...
|
|
18468
|
-
reservedSetOperations:
|
|
18469
|
-
reservedJoins:
|
|
18470
|
-
reservedKeywordPhrases:
|
|
18471
|
-
reservedDataTypePhrases:
|
|
18472
|
-
reservedKeywords:
|
|
18473
|
-
reservedDataTypes:
|
|
18474
|
-
reservedFunctionNames:
|
|
18623
|
+
reservedSelect: YI,
|
|
18624
|
+
reservedClauses: [...fI, ...fT, ...wE],
|
|
18625
|
+
reservedSetOperations: hI,
|
|
18626
|
+
reservedJoins: VI,
|
|
18627
|
+
reservedKeywordPhrases: WI,
|
|
18628
|
+
reservedDataTypePhrases: bI,
|
|
18629
|
+
reservedKeywords: pI,
|
|
18630
|
+
reservedDataTypes: FI,
|
|
18631
|
+
reservedFunctionNames: BI,
|
|
18475
18632
|
stringTypes: ["$$", "''-qq-bs"],
|
|
18476
18633
|
identTypes: ['""-qq'],
|
|
18477
18634
|
variableTypes: [
|
|
@@ -18501,46 +18658,46 @@ const GS = [
|
|
|
18501
18658
|
},
|
|
18502
18659
|
formatOptions: {
|
|
18503
18660
|
alwaysDenseOperators: ["::"],
|
|
18504
|
-
onelineClauses: [...
|
|
18661
|
+
onelineClauses: [...fT, ...wE],
|
|
18505
18662
|
tabularOnelineClauses: wE
|
|
18506
18663
|
}
|
|
18507
|
-
},
|
|
18664
|
+
}, yI = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
18508
18665
|
__proto__: null,
|
|
18509
|
-
bigquery:
|
|
18510
|
-
db2:
|
|
18511
|
-
db2i:
|
|
18512
|
-
duckdb:
|
|
18513
|
-
hive:
|
|
18514
|
-
mariadb:
|
|
18515
|
-
mysql:
|
|
18516
|
-
n1ql:
|
|
18517
|
-
plsql:
|
|
18518
|
-
postgresql:
|
|
18519
|
-
redshift:
|
|
18520
|
-
singlestoredb:
|
|
18521
|
-
snowflake:
|
|
18522
|
-
spark:
|
|
18523
|
-
sql:
|
|
18524
|
-
sqlite:
|
|
18525
|
-
tidb:
|
|
18526
|
-
transactsql:
|
|
18527
|
-
trino:
|
|
18528
|
-
}, Symbol.toStringTag, { value: "Module" })), eE = (T) => T[T.length - 1],
|
|
18666
|
+
bigquery: _R,
|
|
18667
|
+
db2: HR,
|
|
18668
|
+
db2i: XR,
|
|
18669
|
+
duckdb: ZR,
|
|
18670
|
+
hive: SA,
|
|
18671
|
+
mariadb: _A,
|
|
18672
|
+
mysql: uA,
|
|
18673
|
+
n1ql: JA,
|
|
18674
|
+
plsql: TS,
|
|
18675
|
+
postgresql: CS,
|
|
18676
|
+
redshift: US,
|
|
18677
|
+
singlestoredb: HI,
|
|
18678
|
+
snowflake: XI,
|
|
18679
|
+
spark: FS,
|
|
18680
|
+
sql: zS,
|
|
18681
|
+
sqlite: $S,
|
|
18682
|
+
tidb: hA,
|
|
18683
|
+
transactsql: DI,
|
|
18684
|
+
trino: tI
|
|
18685
|
+
}, Symbol.toStringTag, { value: "Module" })), eE = (T) => T[T.length - 1], Re = (T) => T.sort((E, e) => e.length - E.length || E.localeCompare(e)), NE = (T) => T.replace(/\s+/gu, " "), JE = (T) => /\n/.test(T), y = (T) => T.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), hT = /\s+/uy, v = (T) => new RegExp(`(?:${T})`, "uy"), gI = (T) => T.split("").map((E) => / /gu.test(E) ? "\\s+" : `[${E.toUpperCase()}${E.toLowerCase()}]`).join(""), KI = (T) => T + "(?:-" + T + ")*", $I = ({ prefixes: T, requirePrefix: E }) => `(?:${T.map(gI).join("|")}${E ? "" : "|"})`, wI = (T) => new RegExp(`(?:${T.map(y).join("|")}).*?(?=\r
|
|
18529
18686
|
|\r|
|
|
18530
|
-
|$)`, "uy"),
|
|
18687
|
+
|$)`, "uy"), VT = (T, E = []) => {
|
|
18531
18688
|
const e = T === "open" ? 0 : 1, R = ["()", ...E].map((A) => A[e]);
|
|
18532
18689
|
return v(R.map(y).join("|"));
|
|
18533
|
-
},
|
|
18690
|
+
}, WT = (T) => v(`${Re(T).map(y).join("|")}`), JI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", K = (T, E = {}) => {
|
|
18534
18691
|
if (T.length === 0)
|
|
18535
18692
|
return /^\b$/u;
|
|
18536
|
-
const e =
|
|
18693
|
+
const e = JI(E), R = Re(T).map(y).join("|").replace(/ /gu, "\\s+");
|
|
18537
18694
|
return new RegExp(`(?:${R})${e}\\b`, "iuy");
|
|
18538
18695
|
}, xE = (T, E) => {
|
|
18539
18696
|
if (!T.length)
|
|
18540
18697
|
return;
|
|
18541
18698
|
const e = T.map(y).join("|");
|
|
18542
18699
|
return v(`(?:${e})(?:${E})`);
|
|
18543
|
-
},
|
|
18700
|
+
}, xI = () => {
|
|
18544
18701
|
const T = {
|
|
18545
18702
|
"<": ">",
|
|
18546
18703
|
"[": "]",
|
|
@@ -18548,7 +18705,7 @@ const GS = [
|
|
|
18548
18705
|
"{": "}"
|
|
18549
18706
|
}, E = "{left}(?:(?!{right}').)*?{right}", e = Object.entries(T).map(([I, t]) => E.replace(/{left}/g, y(I)).replace(/{right}/g, y(t))), R = y(Object.keys(T).join(""));
|
|
18550
18707
|
return `[Qq]'(?:${String.raw`(?<tag>[^\s${R}])(?:(?!\k<tag>').)*?\k<tag>`}|${e.join("|")})'`;
|
|
18551
|
-
},
|
|
18708
|
+
}, bT = {
|
|
18552
18709
|
// - backtick quoted (using `` to escape)
|
|
18553
18710
|
"``": "(?:`[^`]*`)+",
|
|
18554
18711
|
// - Transact-SQL square bracket quoted (using ]] to escape)
|
|
@@ -18572,16 +18729,16 @@ const GS = [
|
|
|
18572
18729
|
// Hive and Spark variables: ${name}
|
|
18573
18730
|
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
18574
18731
|
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
18575
|
-
"q''":
|
|
18576
|
-
},
|
|
18732
|
+
"q''": xI()
|
|
18733
|
+
}, Ae = (T) => typeof T == "string" ? bT[T] : "regex" in T ? T.regex : $I(T) + bT[T.quote], vI = (T) => v(T.map((E) => "regex" in E ? E.regex : Ae(E)).join("|")), Se = (T) => T.map(Ae).join("|"), XT = (T) => v(Se(T)), QI = (T = {}) => v(Ie(T)), Ie = ({ first: T, rest: E, dashes: e, allowFirstCharNumber: R } = {}) => {
|
|
18577
18734
|
const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I = y(T ?? ""), t = y(E ?? ""), s = R ? `[${A}${S}${I}][${A}${S}${t}]*` : `[${A}${I}][${A}${S}${t}]*`;
|
|
18578
|
-
return e ?
|
|
18735
|
+
return e ? KI(s) : s;
|
|
18579
18736
|
};
|
|
18580
|
-
function
|
|
18737
|
+
function Ne(T, E) {
|
|
18581
18738
|
const e = T.slice(0, E).split(/\n/);
|
|
18582
18739
|
return { line: e.length, col: e[e.length - 1].length + 1 };
|
|
18583
18740
|
}
|
|
18584
|
-
class
|
|
18741
|
+
class ZI {
|
|
18585
18742
|
constructor(E, e) {
|
|
18586
18743
|
this.rules = E, this.dialectName = e, this.input = "", this.index = 0;
|
|
18587
18744
|
}
|
|
@@ -18607,7 +18764,7 @@ class gI {
|
|
|
18607
18764
|
return e;
|
|
18608
18765
|
}
|
|
18609
18766
|
createParseError() {
|
|
18610
|
-
const E = this.input.slice(this.index, this.index + 10), { line: e, col: R } =
|
|
18767
|
+
const E = this.input.slice(this.index, this.index + 10), { line: e, col: R } = Ne(this.input, this.index);
|
|
18611
18768
|
return new Error(`Parse error: Unexpected "${E}" at line ${e} column ${R}.
|
|
18612
18769
|
${this.dialectInfo()}`);
|
|
18613
18770
|
}
|
|
@@ -18616,8 +18773,8 @@ ${this.dialectInfo()}`);
|
|
|
18616
18773
|
If possible, please select a more specific dialect (like sqlite, postgresql, etc).` : `SQL dialect used: "${this.dialectName}".`;
|
|
18617
18774
|
}
|
|
18618
18775
|
getWhitespace() {
|
|
18619
|
-
|
|
18620
|
-
const E =
|
|
18776
|
+
hT.lastIndex = this.index;
|
|
18777
|
+
const E = hT.exec(this.input);
|
|
18621
18778
|
if (E)
|
|
18622
18779
|
return this.index += E[0].length, E[0];
|
|
18623
18780
|
}
|
|
@@ -18643,23 +18800,23 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
|
|
|
18643
18800
|
}
|
|
18644
18801
|
}
|
|
18645
18802
|
}
|
|
18646
|
-
const
|
|
18647
|
-
class
|
|
18803
|
+
const yT = /\/\*/uy, qI = /[\s\S]/uy, jI = /\*\//uy;
|
|
18804
|
+
class kI {
|
|
18648
18805
|
constructor() {
|
|
18649
18806
|
this.lastIndex = 0;
|
|
18650
18807
|
}
|
|
18651
18808
|
exec(E) {
|
|
18652
18809
|
let e = "", R, A = 0;
|
|
18653
|
-
if (R = this.matchSection(
|
|
18810
|
+
if (R = this.matchSection(yT, E))
|
|
18654
18811
|
e += R, A++;
|
|
18655
18812
|
else
|
|
18656
18813
|
return null;
|
|
18657
18814
|
for (; A > 0; )
|
|
18658
|
-
if (R = this.matchSection(
|
|
18815
|
+
if (R = this.matchSection(yT, E))
|
|
18659
18816
|
e += R, A++;
|
|
18660
|
-
else if (R = this.matchSection(
|
|
18817
|
+
else if (R = this.matchSection(jI, E))
|
|
18661
18818
|
e += R, A--;
|
|
18662
|
-
else if (R = this.matchSection(
|
|
18819
|
+
else if (R = this.matchSection(qI, E))
|
|
18663
18820
|
e += R;
|
|
18664
18821
|
else
|
|
18665
18822
|
return null;
|
|
@@ -18671,7 +18828,7 @@ class wI {
|
|
|
18671
18828
|
return R && (this.lastIndex += R[0].length), R ? R[0] : null;
|
|
18672
18829
|
}
|
|
18673
18830
|
}
|
|
18674
|
-
class
|
|
18831
|
+
class zI {
|
|
18675
18832
|
constructor(E, e) {
|
|
18676
18833
|
this.cfg = E, this.dialectName = e, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
|
|
18677
18834
|
}
|
|
@@ -18680,7 +18837,7 @@ class JI {
|
|
|
18680
18837
|
...this.rulesBeforeParams,
|
|
18681
18838
|
...this.buildParamRules(this.cfg, e),
|
|
18682
18839
|
...this.rulesAfterParams
|
|
18683
|
-
], A = new
|
|
18840
|
+
], A = new ZI(R, this.dialectName).tokenize(E);
|
|
18684
18841
|
return this.cfg.postProcess ? this.cfg.postProcess(A) : A;
|
|
18685
18842
|
}
|
|
18686
18843
|
// These rules can be cached as they only depend on
|
|
@@ -18694,15 +18851,15 @@ class JI {
|
|
|
18694
18851
|
},
|
|
18695
18852
|
{
|
|
18696
18853
|
type: o.BLOCK_COMMENT,
|
|
18697
|
-
regex: E.nestedBlockComments ? new
|
|
18854
|
+
regex: E.nestedBlockComments ? new kI() : /(\/\*[^]*?\*\/)/uy
|
|
18698
18855
|
},
|
|
18699
18856
|
{
|
|
18700
18857
|
type: o.LINE_COMMENT,
|
|
18701
|
-
regex:
|
|
18858
|
+
regex: wI((e = E.lineCommentTypes) !== null && e !== void 0 ? e : ["--"])
|
|
18702
18859
|
},
|
|
18703
18860
|
{
|
|
18704
18861
|
type: o.QUOTED_IDENTIFIER,
|
|
18705
|
-
regex:
|
|
18862
|
+
regex: XT(E.identTypes)
|
|
18706
18863
|
},
|
|
18707
18864
|
{
|
|
18708
18865
|
type: o.NUMBER,
|
|
@@ -18820,26 +18977,26 @@ class JI {
|
|
|
18820
18977
|
return this.validRules([
|
|
18821
18978
|
{
|
|
18822
18979
|
type: o.VARIABLE,
|
|
18823
|
-
regex: E.variableTypes ?
|
|
18980
|
+
regex: E.variableTypes ? vI(E.variableTypes) : void 0
|
|
18824
18981
|
},
|
|
18825
|
-
{ type: o.STRING, regex:
|
|
18982
|
+
{ type: o.STRING, regex: XT(E.stringTypes) },
|
|
18826
18983
|
{
|
|
18827
18984
|
type: o.IDENTIFIER,
|
|
18828
|
-
regex:
|
|
18985
|
+
regex: QI(E.identChars)
|
|
18829
18986
|
},
|
|
18830
18987
|
{ type: o.DELIMITER, regex: /[;]/uy },
|
|
18831
18988
|
{ type: o.COMMA, regex: /[,]/y },
|
|
18832
18989
|
{
|
|
18833
18990
|
type: o.OPEN_PAREN,
|
|
18834
|
-
regex:
|
|
18991
|
+
regex: VT("open", E.extraParens)
|
|
18835
18992
|
},
|
|
18836
18993
|
{
|
|
18837
18994
|
type: o.CLOSE_PAREN,
|
|
18838
|
-
regex:
|
|
18995
|
+
regex: VT("close", E.extraParens)
|
|
18839
18996
|
},
|
|
18840
18997
|
{
|
|
18841
18998
|
type: o.OPERATOR,
|
|
18842
|
-
regex:
|
|
18999
|
+
regex: WT([
|
|
18843
19000
|
// standard operators
|
|
18844
19001
|
"+",
|
|
18845
19002
|
"-",
|
|
@@ -18857,7 +19014,7 @@ class JI {
|
|
|
18857
19014
|
{ type: o.ASTERISK, regex: /[*]/uy },
|
|
18858
19015
|
{
|
|
18859
19016
|
type: o.PROPERTY_ACCESS_OPERATOR,
|
|
18860
|
-
regex:
|
|
19017
|
+
regex: WT([".", ...(R = E.propertyAccessOperators) !== null && R !== void 0 ? R : []])
|
|
18861
19018
|
}
|
|
18862
19019
|
]);
|
|
18863
19020
|
}
|
|
@@ -18875,12 +19032,12 @@ class JI {
|
|
|
18875
19032
|
return this.validRules([
|
|
18876
19033
|
{
|
|
18877
19034
|
type: o.NAMED_PARAMETER,
|
|
18878
|
-
regex: xE(s.named,
|
|
19035
|
+
regex: xE(s.named, Ie(E.paramChars || E.identChars)),
|
|
18879
19036
|
key: (O) => O.slice(1)
|
|
18880
19037
|
},
|
|
18881
19038
|
{
|
|
18882
19039
|
type: o.QUOTED_PARAMETER,
|
|
18883
|
-
regex: xE(s.quoted,
|
|
19040
|
+
regex: xE(s.quoted, Se(E.identTypes)),
|
|
18884
19041
|
key: (O) => (({ tokenKey: N, quoteChar: r }) => N.replace(new RegExp(y("\\" + r), "gu"), r))({
|
|
18885
19042
|
tokenKey: O.slice(2, -1),
|
|
18886
19043
|
quoteChar: O.slice(-1)
|
|
@@ -18910,13 +19067,13 @@ class JI {
|
|
|
18910
19067
|
return E.filter((e) => !!e.regex);
|
|
18911
19068
|
}
|
|
18912
19069
|
}
|
|
18913
|
-
const p = (T) => NE(T.toUpperCase()),
|
|
18914
|
-
let E =
|
|
18915
|
-
return E || (E =
|
|
18916
|
-
},
|
|
18917
|
-
tokenizer: new
|
|
18918
|
-
formatOptions:
|
|
18919
|
-
}),
|
|
19070
|
+
const p = (T) => NE(T.toUpperCase()), gT = /* @__PURE__ */ new Map(), EN = (T) => {
|
|
19071
|
+
let E = gT.get(T);
|
|
19072
|
+
return E || (E = TN(T), gT.set(T, E)), E;
|
|
19073
|
+
}, TN = (T) => ({
|
|
19074
|
+
tokenizer: new zI(T.tokenizerOptions, T.name),
|
|
19075
|
+
formatOptions: eN(T.formatOptions)
|
|
19076
|
+
}), eN = (T) => {
|
|
18920
19077
|
var E;
|
|
18921
19078
|
return {
|
|
18922
19079
|
alwaysDenseOperators: T.alwaysDenseOperators || [],
|
|
@@ -18924,13 +19081,13 @@ const p = (T) => NE(T.toUpperCase()), yT = /* @__PURE__ */ new Map(), xI = (T) =
|
|
|
18924
19081
|
tabularOnelineClauses: Object.fromEntries(((E = T.tabularOnelineClauses) !== null && E !== void 0 ? E : T.onelineClauses).map((e) => [e, !0]))
|
|
18925
19082
|
};
|
|
18926
19083
|
};
|
|
18927
|
-
function
|
|
19084
|
+
function RN(T) {
|
|
18928
19085
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight" ? " ".repeat(10) : T.useTabs ? " " : " ".repeat(T.tabWidth);
|
|
18929
19086
|
}
|
|
18930
19087
|
function j(T) {
|
|
18931
19088
|
return T.indentStyle === "tabularLeft" || T.indentStyle === "tabularRight";
|
|
18932
19089
|
}
|
|
18933
|
-
class
|
|
19090
|
+
class AN {
|
|
18934
19091
|
constructor(E) {
|
|
18935
19092
|
this.params = E, this.index = 0;
|
|
18936
19093
|
}
|
|
@@ -18953,15 +19110,15 @@ class qI {
|
|
|
18953
19110
|
this.index = E;
|
|
18954
19111
|
}
|
|
18955
19112
|
}
|
|
18956
|
-
function
|
|
19113
|
+
function SN(T) {
|
|
18957
19114
|
return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
|
|
18958
19115
|
}
|
|
18959
|
-
var OE = { exports: {} },
|
|
18960
|
-
function
|
|
18961
|
-
return
|
|
19116
|
+
var OE = { exports: {} }, IN = OE.exports, KT;
|
|
19117
|
+
function NN() {
|
|
19118
|
+
return KT || (KT = 1, (function(T) {
|
|
18962
19119
|
(function(E, e) {
|
|
18963
19120
|
T.exports ? T.exports = e() : E.nearley = e();
|
|
18964
|
-
})(
|
|
19121
|
+
})(IN, function() {
|
|
18965
19122
|
function E(O, N, r) {
|
|
18966
19123
|
return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = r, this;
|
|
18967
19124
|
}
|
|
@@ -18994,29 +19151,29 @@ function zI() {
|
|
|
18994
19151
|
var i = N[L];
|
|
18995
19152
|
if (i.isComplete) {
|
|
18996
19153
|
if (i.finish(), i.data !== I.fail) {
|
|
18997
|
-
for (var D = i.wantedBy,
|
|
18998
|
-
var P = D[
|
|
19154
|
+
for (var D = i.wantedBy, l = D.length; l--; ) {
|
|
19155
|
+
var P = D[l];
|
|
18999
19156
|
this.complete(P, i);
|
|
19000
19157
|
}
|
|
19001
19158
|
if (i.reference === this.index) {
|
|
19002
|
-
var
|
|
19003
|
-
(this.completed[
|
|
19159
|
+
var U = i.rule.name;
|
|
19160
|
+
(this.completed[U] = this.completed[U] || []).push(i);
|
|
19004
19161
|
}
|
|
19005
19162
|
}
|
|
19006
19163
|
} else {
|
|
19007
|
-
var
|
|
19008
|
-
if (typeof
|
|
19164
|
+
var U = i.rule.symbols[i.dot];
|
|
19165
|
+
if (typeof U != "string") {
|
|
19009
19166
|
this.scannable.push(i);
|
|
19010
19167
|
continue;
|
|
19011
19168
|
}
|
|
19012
|
-
if (r[
|
|
19013
|
-
if (r[
|
|
19014
|
-
for (var M = n[
|
|
19015
|
-
var G = M[
|
|
19169
|
+
if (r[U]) {
|
|
19170
|
+
if (r[U].push(i), n.hasOwnProperty(U))
|
|
19171
|
+
for (var M = n[U], l = 0; l < M.length; l++) {
|
|
19172
|
+
var G = M[l];
|
|
19016
19173
|
this.complete(i, G);
|
|
19017
19174
|
}
|
|
19018
19175
|
} else
|
|
19019
|
-
r[
|
|
19176
|
+
r[U] = [i], this.predict(U);
|
|
19020
19177
|
}
|
|
19021
19178
|
}
|
|
19022
19179
|
}, R.prototype.predict = function(O) {
|
|
@@ -19072,17 +19229,17 @@ function zI() {
|
|
|
19072
19229
|
var i = this.index - this.lastLineBreak, D = String(this.line).length;
|
|
19073
19230
|
return N += " at line " + this.line + " col " + i + `:
|
|
19074
19231
|
|
|
19075
|
-
`, N += n.map(function(P,
|
|
19076
|
-
return
|
|
19232
|
+
`, N += n.map(function(P, U) {
|
|
19233
|
+
return l(this.line - n.length + U + 1, D) + " " + P;
|
|
19077
19234
|
}, this).join(`
|
|
19078
19235
|
`), N += `
|
|
19079
|
-
` +
|
|
19236
|
+
` + l("", D + i) + `^
|
|
19080
19237
|
`, N;
|
|
19081
19238
|
} else
|
|
19082
19239
|
return N + " at index " + (this.index - 1);
|
|
19083
|
-
function
|
|
19240
|
+
function l(P, U) {
|
|
19084
19241
|
var M = String(P);
|
|
19085
|
-
return Array(
|
|
19242
|
+
return Array(U - M.length + 1).join(" ") + M;
|
|
19086
19243
|
}
|
|
19087
19244
|
};
|
|
19088
19245
|
function I(O, N, r) {
|
|
@@ -19117,9 +19274,9 @@ function zI() {
|
|
|
19117
19274
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
19118
19275
|
var i = this.current + 1, D = new R(this.grammar, i);
|
|
19119
19276
|
this.table.push(D);
|
|
19120
|
-
for (var
|
|
19121
|
-
var G =
|
|
19122
|
-
if (m.test ? m.test(P) : m.type ? m.type === r.type : m.literal ===
|
|
19277
|
+
for (var l = r.text !== void 0 ? r.text : r.value, P = N.constructor === S ? r.value : r, U = L.scannable, M = U.length; M--; ) {
|
|
19278
|
+
var G = U[M], m = G.rule.symbols[G.dot];
|
|
19279
|
+
if (m.test ? m.test(P) : m.type ? m.type === r.type : m.literal === l) {
|
|
19123
19280
|
var B = G.nextState({ data: P, token: r, isToken: !0, reference: i - 1 });
|
|
19124
19281
|
D.states.push(B);
|
|
19125
19282
|
}
|
|
@@ -19140,8 +19297,8 @@ function zI() {
|
|
|
19140
19297
|
}, I.prototype.reportErrorCommon = function(O, N) {
|
|
19141
19298
|
var r = [];
|
|
19142
19299
|
r.push(O);
|
|
19143
|
-
var n = this.table.length - 2, L = this.table[n], i = L.states.filter(function(
|
|
19144
|
-
var P =
|
|
19300
|
+
var n = this.table.length - 2, L = this.table[n], i = L.states.filter(function(l) {
|
|
19301
|
+
var P = l.rule.symbols[l.dot];
|
|
19145
19302
|
return P && typeof P != "string";
|
|
19146
19303
|
});
|
|
19147
19304
|
if (i.length === 0)
|
|
@@ -19150,12 +19307,12 @@ function zI() {
|
|
|
19150
19307
|
else {
|
|
19151
19308
|
r.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
19152
19309
|
`);
|
|
19153
|
-
var D = i.map(function(
|
|
19154
|
-
return this.buildFirstStateStack(
|
|
19310
|
+
var D = i.map(function(l) {
|
|
19311
|
+
return this.buildFirstStateStack(l, []) || [l];
|
|
19155
19312
|
}, this);
|
|
19156
|
-
D.forEach(function(
|
|
19157
|
-
var P =
|
|
19158
|
-
r.push("A " + M + " based on:"), this.displayStateStack(
|
|
19313
|
+
D.forEach(function(l) {
|
|
19314
|
+
var P = l[0], U = P.rule.symbols[P.dot], M = this.getSymbolDisplay(U);
|
|
19315
|
+
r.push("A " + M + " based on:"), this.displayStateStack(l, r);
|
|
19159
19316
|
}, this);
|
|
19160
19317
|
}
|
|
19161
19318
|
return r.push(""), r.join(`
|
|
@@ -19232,14 +19389,14 @@ function zI() {
|
|
|
19232
19389
|
});
|
|
19233
19390
|
})(OE)), OE.exports;
|
|
19234
19391
|
}
|
|
19235
|
-
var
|
|
19236
|
-
const
|
|
19237
|
-
function
|
|
19238
|
-
return T.map(
|
|
19392
|
+
var ON = NN();
|
|
19393
|
+
const tN = /* @__PURE__ */ SN(ON);
|
|
19394
|
+
function sN(T) {
|
|
19395
|
+
return T.map(rN).map(CN).map(nN).map(LN).map(_N);
|
|
19239
19396
|
}
|
|
19240
|
-
const
|
|
19241
|
-
if (
|
|
19242
|
-
const R =
|
|
19397
|
+
const rN = (T, E, e) => {
|
|
19398
|
+
if (ee(T.type)) {
|
|
19399
|
+
const R = iN(e, E);
|
|
19243
19400
|
if (R && R.type === o.PROPERTY_ACCESS_OPERATOR)
|
|
19244
19401
|
return Object.assign(Object.assign({}, T), { type: o.IDENTIFIER, text: T.raw });
|
|
19245
19402
|
const A = EE(e, E);
|
|
@@ -19247,41 +19404,41 @@ const RN = (T, E, e) => {
|
|
|
19247
19404
|
return Object.assign(Object.assign({}, T), { type: o.IDENTIFIER, text: T.raw });
|
|
19248
19405
|
}
|
|
19249
19406
|
return T;
|
|
19250
|
-
},
|
|
19407
|
+
}, CN = (T, E, e) => {
|
|
19251
19408
|
if (T.type === o.RESERVED_FUNCTION_NAME) {
|
|
19252
19409
|
const R = EE(e, E);
|
|
19253
|
-
if (!R || !
|
|
19410
|
+
if (!R || !Oe(R))
|
|
19254
19411
|
return Object.assign(Object.assign({}, T), { type: o.IDENTIFIER, text: T.raw });
|
|
19255
19412
|
}
|
|
19256
19413
|
return T;
|
|
19257
|
-
},
|
|
19414
|
+
}, nN = (T, E, e) => {
|
|
19258
19415
|
if (T.type === o.RESERVED_DATA_TYPE) {
|
|
19259
19416
|
const R = EE(e, E);
|
|
19260
|
-
if (R &&
|
|
19417
|
+
if (R && Oe(R))
|
|
19261
19418
|
return Object.assign(Object.assign({}, T), { type: o.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
19262
19419
|
}
|
|
19263
19420
|
return T;
|
|
19264
|
-
},
|
|
19421
|
+
}, LN = (T, E, e) => {
|
|
19265
19422
|
if (T.type === o.IDENTIFIER) {
|
|
19266
19423
|
const R = EE(e, E);
|
|
19267
|
-
if (R &&
|
|
19424
|
+
if (R && te(R))
|
|
19268
19425
|
return Object.assign(Object.assign({}, T), { type: o.ARRAY_IDENTIFIER });
|
|
19269
19426
|
}
|
|
19270
19427
|
return T;
|
|
19271
|
-
},
|
|
19428
|
+
}, _N = (T, E, e) => {
|
|
19272
19429
|
if (T.type === o.RESERVED_DATA_TYPE) {
|
|
19273
19430
|
const R = EE(e, E);
|
|
19274
|
-
if (R &&
|
|
19431
|
+
if (R && te(R))
|
|
19275
19432
|
return Object.assign(Object.assign({}, T), { type: o.ARRAY_KEYWORD });
|
|
19276
19433
|
}
|
|
19277
19434
|
return T;
|
|
19278
|
-
},
|
|
19435
|
+
}, iN = (T, E) => EE(T, E, -1), EE = (T, E, e = 1) => {
|
|
19279
19436
|
let R = 1;
|
|
19280
|
-
for (; T[E + R * e] &&
|
|
19437
|
+
for (; T[E + R * e] && aN(T[E + R * e]); )
|
|
19281
19438
|
R++;
|
|
19282
19439
|
return T[E + R * e];
|
|
19283
|
-
},
|
|
19284
|
-
class
|
|
19440
|
+
}, Oe = (T) => T.type === o.OPEN_PAREN && T.text === "(", te = (T) => T.type === o.OPEN_PAREN && T.text === "[", aN = (T) => T.type === o.BLOCK_COMMENT || T.type === o.LINE_COMMENT;
|
|
19441
|
+
class se {
|
|
19285
19442
|
constructor(E) {
|
|
19286
19443
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
19287
19444
|
}
|
|
@@ -19294,30 +19451,30 @@ class te {
|
|
|
19294
19451
|
save() {
|
|
19295
19452
|
}
|
|
19296
19453
|
formatError(E) {
|
|
19297
|
-
const { line: e, col: R } =
|
|
19454
|
+
const { line: e, col: R } = Ne(this.input, E.start);
|
|
19298
19455
|
return `Parse error at token: ${E.text} at line ${e} column ${R}`;
|
|
19299
19456
|
}
|
|
19300
19457
|
has(E) {
|
|
19301
19458
|
return E in o;
|
|
19302
19459
|
}
|
|
19303
19460
|
}
|
|
19304
|
-
var
|
|
19461
|
+
var c;
|
|
19305
19462
|
(function(T) {
|
|
19306
19463
|
T.statement = "statement", T.clause = "clause", T.set_operation = "set_operation", T.function_call = "function_call", T.parameterized_data_type = "parameterized_data_type", T.array_subscript = "array_subscript", T.property_access = "property_access", T.parenthesis = "parenthesis", T.between_predicate = "between_predicate", T.case_expression = "case_expression", T.case_when = "case_when", T.case_else = "case_else", T.limit_clause = "limit_clause", T.all_columns_asterisk = "all_columns_asterisk", T.literal = "literal", T.identifier = "identifier", T.keyword = "keyword", T.data_type = "data_type", T.parameter = "parameter", T.operator = "operator", T.comma = "comma", T.line_comment = "line_comment", T.block_comment = "block_comment", T.disable_comment = "disable_comment";
|
|
19307
|
-
})(
|
|
19464
|
+
})(c = c || (c = {}));
|
|
19308
19465
|
function vE(T) {
|
|
19309
19466
|
return T[0];
|
|
19310
19467
|
}
|
|
19311
|
-
const u = new
|
|
19312
|
-
type:
|
|
19468
|
+
const u = new se((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
19469
|
+
type: c.keyword,
|
|
19313
19470
|
tokenType: T.type,
|
|
19314
19471
|
text: T.text,
|
|
19315
19472
|
raw: T.raw
|
|
19316
|
-
}),
|
|
19317
|
-
type:
|
|
19473
|
+
}), $T = (T) => ({
|
|
19474
|
+
type: c.data_type,
|
|
19318
19475
|
text: T.text,
|
|
19319
19476
|
raw: T.raw
|
|
19320
|
-
}), Y = (T, { leading: E, trailing: e }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), e?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: e })), T),
|
|
19477
|
+
}), Y = (T, { leading: E, trailing: e }) => (E?.length && (T = Object.assign(Object.assign({}, T), { leadingComments: E })), e?.length && (T = Object.assign(Object.assign({}, T), { trailingComments: e })), T), oN = (T, { leading: E, trailing: e }) => {
|
|
19321
19478
|
if (E?.length) {
|
|
19322
19479
|
const [R, ...A] = T;
|
|
19323
19480
|
T = [Y(R, { leading: E }), ...A];
|
|
@@ -19327,7 +19484,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19327
19484
|
T = [...R, Y(A, { trailing: e })];
|
|
19328
19485
|
}
|
|
19329
19486
|
return T;
|
|
19330
|
-
},
|
|
19487
|
+
}, DN = {
|
|
19331
19488
|
Lexer: u,
|
|
19332
19489
|
ParserRules: [
|
|
19333
19490
|
{ name: "main$ebnf$1", symbols: [] },
|
|
@@ -19346,7 +19503,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19346
19503
|
name: "statement",
|
|
19347
19504
|
symbols: ["expressions_or_clauses", "statement$subexpression$1"],
|
|
19348
19505
|
postprocess: ([T, [E]]) => ({
|
|
19349
|
-
type:
|
|
19506
|
+
type: c.statement,
|
|
19350
19507
|
children: T,
|
|
19351
19508
|
hasSemicolon: E.type === o.DELIMITER
|
|
19352
19509
|
})
|
|
@@ -19377,14 +19534,14 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19377
19534
|
if (R) {
|
|
19378
19535
|
const [A, S] = R;
|
|
19379
19536
|
return {
|
|
19380
|
-
type:
|
|
19537
|
+
type: c.limit_clause,
|
|
19381
19538
|
limitKw: Y(F(T), { trailing: E }),
|
|
19382
19539
|
offset: e,
|
|
19383
19540
|
count: S
|
|
19384
19541
|
};
|
|
19385
19542
|
} else
|
|
19386
19543
|
return {
|
|
19387
|
-
type:
|
|
19544
|
+
type: c.limit_clause,
|
|
19388
19545
|
limitKw: Y(F(T), { trailing: E }),
|
|
19389
19546
|
count: e
|
|
19390
19547
|
};
|
|
@@ -19400,7 +19557,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19400
19557
|
name: "select_clause",
|
|
19401
19558
|
symbols: [u.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
|
|
19402
19559
|
postprocess: ([T, [E, e]]) => ({
|
|
19403
|
-
type:
|
|
19560
|
+
type: c.clause,
|
|
19404
19561
|
nameKw: F(T),
|
|
19405
19562
|
children: [E, ...e]
|
|
19406
19563
|
})
|
|
@@ -19409,7 +19566,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19409
19566
|
name: "select_clause",
|
|
19410
19567
|
symbols: [u.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
|
|
19411
19568
|
postprocess: ([T]) => ({
|
|
19412
|
-
type:
|
|
19569
|
+
type: c.clause,
|
|
19413
19570
|
nameKw: F(T),
|
|
19414
19571
|
children: []
|
|
19415
19572
|
})
|
|
@@ -19417,7 +19574,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19417
19574
|
{
|
|
19418
19575
|
name: "all_columns_asterisk",
|
|
19419
19576
|
symbols: [u.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK],
|
|
19420
|
-
postprocess: () => ({ type:
|
|
19577
|
+
postprocess: () => ({ type: c.all_columns_asterisk })
|
|
19421
19578
|
},
|
|
19422
19579
|
{ name: "other_clause$ebnf$1", symbols: [] },
|
|
19423
19580
|
{ name: "other_clause$ebnf$1", symbols: ["other_clause$ebnf$1", "free_form_sql"], postprocess: (T) => T[0].concat([T[1]]) },
|
|
@@ -19425,7 +19582,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19425
19582
|
name: "other_clause",
|
|
19426
19583
|
symbols: [u.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
|
|
19427
19584
|
postprocess: ([T, E]) => ({
|
|
19428
|
-
type:
|
|
19585
|
+
type: c.clause,
|
|
19429
19586
|
nameKw: F(T),
|
|
19430
19587
|
children: E
|
|
19431
19588
|
})
|
|
@@ -19436,7 +19593,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19436
19593
|
name: "set_operation",
|
|
19437
19594
|
symbols: [u.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
|
|
19438
19595
|
postprocess: ([T, E]) => ({
|
|
19439
|
-
type:
|
|
19596
|
+
type: c.set_operation,
|
|
19440
19597
|
nameKw: F(T),
|
|
19441
19598
|
children: E
|
|
19442
19599
|
})
|
|
@@ -19509,8 +19666,8 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19509
19666
|
name: "array_subscript",
|
|
19510
19667
|
symbols: [u.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
|
|
19511
19668
|
postprocess: ([T, E, e]) => ({
|
|
19512
|
-
type:
|
|
19513
|
-
array: Y({ type:
|
|
19669
|
+
type: c.array_subscript,
|
|
19670
|
+
array: Y({ type: c.identifier, quoted: !1, text: T.text }, { trailing: E }),
|
|
19514
19671
|
parenthesis: e
|
|
19515
19672
|
})
|
|
19516
19673
|
},
|
|
@@ -19518,7 +19675,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19518
19675
|
name: "array_subscript",
|
|
19519
19676
|
symbols: [u.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
|
|
19520
19677
|
postprocess: ([T, E, e]) => ({
|
|
19521
|
-
type:
|
|
19678
|
+
type: c.array_subscript,
|
|
19522
19679
|
array: Y(F(T), { trailing: E }),
|
|
19523
19680
|
parenthesis: e
|
|
19524
19681
|
})
|
|
@@ -19527,7 +19684,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19527
19684
|
name: "function_call",
|
|
19528
19685
|
symbols: [u.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
|
|
19529
19686
|
postprocess: ([T, E, e]) => ({
|
|
19530
|
-
type:
|
|
19687
|
+
type: c.function_call,
|
|
19531
19688
|
nameKw: Y(F(T), { trailing: E }),
|
|
19532
19689
|
parenthesis: e
|
|
19533
19690
|
})
|
|
@@ -19536,7 +19693,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19536
19693
|
name: "parenthesis",
|
|
19537
19694
|
symbols: [{ literal: "(" }, "expressions_or_clauses", { literal: ")" }],
|
|
19538
19695
|
postprocess: ([T, E, e]) => ({
|
|
19539
|
-
type:
|
|
19696
|
+
type: c.parenthesis,
|
|
19540
19697
|
children: E,
|
|
19541
19698
|
openParen: "(",
|
|
19542
19699
|
closeParen: ")"
|
|
@@ -19548,7 +19705,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19548
19705
|
name: "curly_braces",
|
|
19549
19706
|
symbols: [{ literal: "{" }, "curly_braces$ebnf$1", { literal: "}" }],
|
|
19550
19707
|
postprocess: ([T, E, e]) => ({
|
|
19551
|
-
type:
|
|
19708
|
+
type: c.parenthesis,
|
|
19552
19709
|
children: E,
|
|
19553
19710
|
openParen: "{",
|
|
19554
19711
|
closeParen: "}"
|
|
@@ -19560,7 +19717,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19560
19717
|
name: "square_brackets",
|
|
19561
19718
|
symbols: [{ literal: "[" }, "square_brackets$ebnf$1", { literal: "]" }],
|
|
19562
19719
|
postprocess: ([T, E, e]) => ({
|
|
19563
|
-
type:
|
|
19720
|
+
type: c.parenthesis,
|
|
19564
19721
|
children: E,
|
|
19565
19722
|
openParen: "[",
|
|
19566
19723
|
closeParen: "]"
|
|
@@ -19579,7 +19736,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19579
19736
|
// but we currently can't do that because of another hack that requires
|
|
19580
19737
|
// %ARRAY_IDENTIFIER on the left side of <array_subscript>.
|
|
19581
19738
|
([T, E, e, R, [A]]) => ({
|
|
19582
|
-
type:
|
|
19739
|
+
type: c.property_access,
|
|
19583
19740
|
object: Y(T, { trailing: E }),
|
|
19584
19741
|
operator: e.text,
|
|
19585
19742
|
property: Y(A, { leading: R })
|
|
@@ -19590,9 +19747,9 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19590
19747
|
name: "between_predicate",
|
|
19591
19748
|
symbols: [u.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", u.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
|
|
19592
19749
|
postprocess: ([T, E, e, R, A, S, I]) => ({
|
|
19593
|
-
type:
|
|
19750
|
+
type: c.between_predicate,
|
|
19594
19751
|
betweenKw: F(T),
|
|
19595
|
-
expr1:
|
|
19752
|
+
expr1: oN(e, { leading: E, trailing: R }),
|
|
19596
19753
|
andKw: F(A),
|
|
19597
19754
|
expr2: [Y(I, { leading: S })]
|
|
19598
19755
|
})
|
|
@@ -19605,7 +19762,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19605
19762
|
name: "case_expression",
|
|
19606
19763
|
symbols: [u.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", u.has("END") ? { type: "END" } : END],
|
|
19607
19764
|
postprocess: ([T, E, e, R, A]) => ({
|
|
19608
|
-
type:
|
|
19765
|
+
type: c.case_expression,
|
|
19609
19766
|
caseKw: Y(F(T), { trailing: E }),
|
|
19610
19767
|
endKw: F(A),
|
|
19611
19768
|
expr: e || [],
|
|
@@ -19616,7 +19773,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19616
19773
|
name: "case_clause",
|
|
19617
19774
|
symbols: [u.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", u.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
|
|
19618
19775
|
postprocess: ([T, E, e, R, A, S]) => ({
|
|
19619
|
-
type:
|
|
19776
|
+
type: c.case_when,
|
|
19620
19777
|
whenKw: Y(F(T), { trailing: E }),
|
|
19621
19778
|
thenKw: Y(F(R), { trailing: A }),
|
|
19622
19779
|
condition: e,
|
|
@@ -19627,30 +19784,30 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19627
19784
|
name: "case_clause",
|
|
19628
19785
|
symbols: [u.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
|
|
19629
19786
|
postprocess: ([T, E, e]) => ({
|
|
19630
|
-
type:
|
|
19787
|
+
type: c.case_else,
|
|
19631
19788
|
elseKw: Y(F(T), { trailing: E }),
|
|
19632
19789
|
result: e
|
|
19633
19790
|
})
|
|
19634
19791
|
},
|
|
19635
19792
|
{ name: "comma$subexpression$1", symbols: [u.has("COMMA") ? { type: "COMMA" } : COMMA] },
|
|
19636
|
-
{ name: "comma", symbols: ["comma$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19793
|
+
{ name: "comma", symbols: ["comma$subexpression$1"], postprocess: ([[T]]) => ({ type: c.comma }) },
|
|
19637
19794
|
{ name: "asterisk$subexpression$1", symbols: [u.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK] },
|
|
19638
|
-
{ name: "asterisk", symbols: ["asterisk$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19795
|
+
{ name: "asterisk", symbols: ["asterisk$subexpression$1"], postprocess: ([[T]]) => ({ type: c.operator, text: T.text }) },
|
|
19639
19796
|
{ name: "operator$subexpression$1", symbols: [u.has("OPERATOR") ? { type: "OPERATOR" } : OPERATOR] },
|
|
19640
|
-
{ name: "operator", symbols: ["operator$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19797
|
+
{ name: "operator", symbols: ["operator$subexpression$1"], postprocess: ([[T]]) => ({ type: c.operator, text: T.text }) },
|
|
19641
19798
|
{ name: "identifier$subexpression$1", symbols: [u.has("IDENTIFIER") ? { type: "IDENTIFIER" } : IDENTIFIER] },
|
|
19642
19799
|
{ name: "identifier$subexpression$1", symbols: [u.has("QUOTED_IDENTIFIER") ? { type: "QUOTED_IDENTIFIER" } : QUOTED_IDENTIFIER] },
|
|
19643
19800
|
{ name: "identifier$subexpression$1", symbols: [u.has("VARIABLE") ? { type: "VARIABLE" } : VARIABLE] },
|
|
19644
|
-
{ name: "identifier", symbols: ["identifier$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19801
|
+
{ name: "identifier", symbols: ["identifier$subexpression$1"], postprocess: ([[T]]) => ({ type: c.identifier, quoted: T.type !== "IDENTIFIER", text: T.text }) },
|
|
19645
19802
|
{ name: "parameter$subexpression$1", symbols: [u.has("NAMED_PARAMETER") ? { type: "NAMED_PARAMETER" } : NAMED_PARAMETER] },
|
|
19646
19803
|
{ name: "parameter$subexpression$1", symbols: [u.has("QUOTED_PARAMETER") ? { type: "QUOTED_PARAMETER" } : QUOTED_PARAMETER] },
|
|
19647
19804
|
{ name: "parameter$subexpression$1", symbols: [u.has("NUMBERED_PARAMETER") ? { type: "NUMBERED_PARAMETER" } : NUMBERED_PARAMETER] },
|
|
19648
19805
|
{ name: "parameter$subexpression$1", symbols: [u.has("POSITIONAL_PARAMETER") ? { type: "POSITIONAL_PARAMETER" } : POSITIONAL_PARAMETER] },
|
|
19649
19806
|
{ name: "parameter$subexpression$1", symbols: [u.has("CUSTOM_PARAMETER") ? { type: "CUSTOM_PARAMETER" } : CUSTOM_PARAMETER] },
|
|
19650
|
-
{ name: "parameter", symbols: ["parameter$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19807
|
+
{ name: "parameter", symbols: ["parameter$subexpression$1"], postprocess: ([[T]]) => ({ type: c.parameter, key: T.key, text: T.text }) },
|
|
19651
19808
|
{ name: "literal$subexpression$1", symbols: [u.has("NUMBER") ? { type: "NUMBER" } : NUMBER] },
|
|
19652
19809
|
{ name: "literal$subexpression$1", symbols: [u.has("STRING") ? { type: "STRING" } : STRING] },
|
|
19653
|
-
{ name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[T]]) => ({ type:
|
|
19810
|
+
{ name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[T]]) => ({ type: c.literal, text: T.text }) },
|
|
19654
19811
|
{ name: "keyword$subexpression$1", symbols: [u.has("RESERVED_KEYWORD") ? { type: "RESERVED_KEYWORD" } : RESERVED_KEYWORD] },
|
|
19655
19812
|
{ name: "keyword$subexpression$1", symbols: [u.has("RESERVED_KEYWORD_PHRASE") ? { type: "RESERVED_KEYWORD_PHRASE" } : RESERVED_KEYWORD_PHRASE] },
|
|
19656
19813
|
{ name: "keyword$subexpression$1", symbols: [u.has("RESERVED_JOIN") ? { type: "RESERVED_JOIN" } : RESERVED_JOIN] },
|
|
@@ -19664,14 +19821,14 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19664
19821
|
{
|
|
19665
19822
|
name: "data_type",
|
|
19666
19823
|
symbols: ["data_type$subexpression$1"],
|
|
19667
|
-
postprocess: ([[T]]) =>
|
|
19824
|
+
postprocess: ([[T]]) => $T(T)
|
|
19668
19825
|
},
|
|
19669
19826
|
{
|
|
19670
19827
|
name: "data_type",
|
|
19671
19828
|
symbols: [u.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
19672
19829
|
postprocess: ([T, E, e]) => ({
|
|
19673
|
-
type:
|
|
19674
|
-
dataType: Y(
|
|
19830
|
+
type: c.parameterized_data_type,
|
|
19831
|
+
dataType: Y($T(T), { trailing: E }),
|
|
19675
19832
|
parenthesis: e
|
|
19676
19833
|
})
|
|
19677
19834
|
},
|
|
@@ -19699,7 +19856,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19699
19856
|
name: "comment",
|
|
19700
19857
|
symbols: [u.has("LINE_COMMENT") ? { type: "LINE_COMMENT" } : LINE_COMMENT],
|
|
19701
19858
|
postprocess: ([T]) => ({
|
|
19702
|
-
type:
|
|
19859
|
+
type: c.line_comment,
|
|
19703
19860
|
text: T.text,
|
|
19704
19861
|
precedingWhitespace: T.precedingWhitespace
|
|
19705
19862
|
})
|
|
@@ -19708,7 +19865,7 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19708
19865
|
name: "comment",
|
|
19709
19866
|
symbols: [u.has("BLOCK_COMMENT") ? { type: "BLOCK_COMMENT" } : BLOCK_COMMENT],
|
|
19710
19867
|
postprocess: ([T]) => ({
|
|
19711
|
-
type:
|
|
19868
|
+
type: c.block_comment,
|
|
19712
19869
|
text: T.text,
|
|
19713
19870
|
precedingWhitespace: T.precedingWhitespace
|
|
19714
19871
|
})
|
|
@@ -19717,20 +19874,20 @@ const u = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
|
|
|
19717
19874
|
name: "comment",
|
|
19718
19875
|
symbols: [u.has("DISABLE_COMMENT") ? { type: "DISABLE_COMMENT" } : DISABLE_COMMENT],
|
|
19719
19876
|
postprocess: ([T]) => ({
|
|
19720
|
-
type:
|
|
19877
|
+
type: c.disable_comment,
|
|
19721
19878
|
text: T.text,
|
|
19722
19879
|
precedingWhitespace: T.precedingWhitespace
|
|
19723
19880
|
})
|
|
19724
19881
|
}
|
|
19725
19882
|
],
|
|
19726
19883
|
ParserStart: "main"
|
|
19727
|
-
}, { Parser:
|
|
19728
|
-
function
|
|
19884
|
+
}, { Parser: PN, Grammar: MN } = tN;
|
|
19885
|
+
function UN(T) {
|
|
19729
19886
|
let E = {};
|
|
19730
|
-
const e = new
|
|
19731
|
-
...
|
|
19732
|
-
|
|
19733
|
-
]), R = new
|
|
19887
|
+
const e = new se((A) => [
|
|
19888
|
+
...sN(T.tokenize(A, E)),
|
|
19889
|
+
Te(A.length)
|
|
19890
|
+
]), R = new PN(MN.fromCompiled(DN), { lexer: e });
|
|
19734
19891
|
return {
|
|
19735
19892
|
parse: (A, S) => {
|
|
19736
19893
|
E = S;
|
|
@@ -19746,7 +19903,7 @@ var a;
|
|
|
19746
19903
|
(function(T) {
|
|
19747
19904
|
T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
19748
19905
|
})(a = a || (a = {}));
|
|
19749
|
-
class
|
|
19906
|
+
class re {
|
|
19750
19907
|
constructor(E) {
|
|
19751
19908
|
this.indentation = E, this.items = [];
|
|
19752
19909
|
}
|
|
@@ -19782,11 +19939,11 @@ class se {
|
|
|
19782
19939
|
}
|
|
19783
19940
|
}
|
|
19784
19941
|
trimHorizontalWhitespace() {
|
|
19785
|
-
for (;
|
|
19942
|
+
for (; cN(eE(this.items)); )
|
|
19786
19943
|
this.items.pop();
|
|
19787
19944
|
}
|
|
19788
19945
|
trimWhitespace() {
|
|
19789
|
-
for (;
|
|
19946
|
+
for (; lN(eE(this.items)); )
|
|
19790
19947
|
this.items.pop();
|
|
19791
19948
|
}
|
|
19792
19949
|
addNewline(E) {
|
|
@@ -19833,18 +19990,18 @@ class se {
|
|
|
19833
19990
|
}
|
|
19834
19991
|
}
|
|
19835
19992
|
}
|
|
19836
|
-
const
|
|
19837
|
-
function
|
|
19993
|
+
const cN = (T) => T === a.SPACE || T === a.SINGLE_INDENT, lN = (T) => T === a.SPACE || T === a.SINGLE_INDENT || T === a.NEWLINE;
|
|
19994
|
+
function wT(T, E) {
|
|
19838
19995
|
if (E === "standard")
|
|
19839
19996
|
return T;
|
|
19840
19997
|
let e = [];
|
|
19841
19998
|
return T.length >= 10 && T.includes(" ") && ([T, ...e] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...e].join(" ");
|
|
19842
19999
|
}
|
|
19843
|
-
function
|
|
19844
|
-
return
|
|
20000
|
+
function JT(T) {
|
|
20001
|
+
return AR(T) || T === o.RESERVED_CLAUSE || T === o.RESERVED_SELECT || T === o.RESERVED_SET_OPERATION || T === o.RESERVED_JOIN || T === o.LIMIT;
|
|
19845
20002
|
}
|
|
19846
|
-
const QE = "top-level",
|
|
19847
|
-
class
|
|
20003
|
+
const QE = "top-level", uN = "block-level";
|
|
20004
|
+
class Ce {
|
|
19848
20005
|
/**
|
|
19849
20006
|
* @param {string} indent A string to indent with
|
|
19850
20007
|
*/
|
|
@@ -19873,7 +20030,7 @@ class re {
|
|
|
19873
20030
|
* Increases indentation by one block-level indent.
|
|
19874
20031
|
*/
|
|
19875
20032
|
increaseBlockLevel() {
|
|
19876
|
-
this.indentTypes.push(
|
|
20033
|
+
this.indentTypes.push(uN);
|
|
19877
20034
|
}
|
|
19878
20035
|
/**
|
|
19879
20036
|
* Decreases indentation by one top-level indent.
|
|
@@ -19892,9 +20049,9 @@ class re {
|
|
|
19892
20049
|
;
|
|
19893
20050
|
}
|
|
19894
20051
|
}
|
|
19895
|
-
class
|
|
20052
|
+
class GN extends re {
|
|
19896
20053
|
constructor(E) {
|
|
19897
|
-
super(new
|
|
20054
|
+
super(new Ce("")), this.expressionWidth = E, this.length = 0, this.trailingSpace = !1;
|
|
19898
20055
|
}
|
|
19899
20056
|
add(...E) {
|
|
19900
20057
|
if (E.forEach((e) => this.addToLength(e)), this.length > this.expressionWidth)
|
|
@@ -19927,51 +20084,51 @@ class nE {
|
|
|
19927
20084
|
}
|
|
19928
20085
|
formatNodeWithoutComments(E) {
|
|
19929
20086
|
switch (E.type) {
|
|
19930
|
-
case
|
|
20087
|
+
case c.function_call:
|
|
19931
20088
|
return this.formatFunctionCall(E);
|
|
19932
|
-
case
|
|
20089
|
+
case c.parameterized_data_type:
|
|
19933
20090
|
return this.formatParameterizedDataType(E);
|
|
19934
|
-
case
|
|
20091
|
+
case c.array_subscript:
|
|
19935
20092
|
return this.formatArraySubscript(E);
|
|
19936
|
-
case
|
|
20093
|
+
case c.property_access:
|
|
19937
20094
|
return this.formatPropertyAccess(E);
|
|
19938
|
-
case
|
|
20095
|
+
case c.parenthesis:
|
|
19939
20096
|
return this.formatParenthesis(E);
|
|
19940
|
-
case
|
|
20097
|
+
case c.between_predicate:
|
|
19941
20098
|
return this.formatBetweenPredicate(E);
|
|
19942
|
-
case
|
|
20099
|
+
case c.case_expression:
|
|
19943
20100
|
return this.formatCaseExpression(E);
|
|
19944
|
-
case
|
|
20101
|
+
case c.case_when:
|
|
19945
20102
|
return this.formatCaseWhen(E);
|
|
19946
|
-
case
|
|
20103
|
+
case c.case_else:
|
|
19947
20104
|
return this.formatCaseElse(E);
|
|
19948
|
-
case
|
|
20105
|
+
case c.clause:
|
|
19949
20106
|
return this.formatClause(E);
|
|
19950
|
-
case
|
|
20107
|
+
case c.set_operation:
|
|
19951
20108
|
return this.formatSetOperation(E);
|
|
19952
|
-
case
|
|
20109
|
+
case c.limit_clause:
|
|
19953
20110
|
return this.formatLimitClause(E);
|
|
19954
|
-
case
|
|
20111
|
+
case c.all_columns_asterisk:
|
|
19955
20112
|
return this.formatAllColumnsAsterisk(E);
|
|
19956
|
-
case
|
|
20113
|
+
case c.literal:
|
|
19957
20114
|
return this.formatLiteral(E);
|
|
19958
|
-
case
|
|
20115
|
+
case c.identifier:
|
|
19959
20116
|
return this.formatIdentifier(E);
|
|
19960
|
-
case
|
|
20117
|
+
case c.parameter:
|
|
19961
20118
|
return this.formatParameter(E);
|
|
19962
|
-
case
|
|
20119
|
+
case c.operator:
|
|
19963
20120
|
return this.formatOperator(E);
|
|
19964
|
-
case
|
|
20121
|
+
case c.comma:
|
|
19965
20122
|
return this.formatComma(E);
|
|
19966
|
-
case
|
|
20123
|
+
case c.line_comment:
|
|
19967
20124
|
return this.formatLineComment(E);
|
|
19968
|
-
case
|
|
20125
|
+
case c.block_comment:
|
|
19969
20126
|
return this.formatBlockComment(E);
|
|
19970
|
-
case
|
|
20127
|
+
case c.disable_comment:
|
|
19971
20128
|
return this.formatBlockComment(E);
|
|
19972
|
-
case
|
|
20129
|
+
case c.data_type:
|
|
19973
20130
|
return this.formatDataType(E);
|
|
19974
|
-
case
|
|
20131
|
+
case c.keyword:
|
|
19975
20132
|
return this.formatKeywordNode(E);
|
|
19976
20133
|
}
|
|
19977
20134
|
}
|
|
@@ -19988,10 +20145,10 @@ class nE {
|
|
|
19988
20145
|
formatArraySubscript(E) {
|
|
19989
20146
|
let e;
|
|
19990
20147
|
switch (E.array.type) {
|
|
19991
|
-
case
|
|
20148
|
+
case c.data_type:
|
|
19992
20149
|
e = this.showDataType(E.array);
|
|
19993
20150
|
break;
|
|
19994
|
-
case
|
|
20151
|
+
case c.keyword:
|
|
19995
20152
|
e = this.showKw(E.array);
|
|
19996
20153
|
break;
|
|
19997
20154
|
default:
|
|
@@ -20067,14 +20224,14 @@ class nE {
|
|
|
20067
20224
|
}
|
|
20068
20225
|
formatComments(E) {
|
|
20069
20226
|
E && E.forEach((e) => {
|
|
20070
|
-
e.type ===
|
|
20227
|
+
e.type === c.line_comment ? this.formatLineComment(e) : this.formatBlockComment(e);
|
|
20071
20228
|
});
|
|
20072
20229
|
}
|
|
20073
20230
|
formatLineComment(E) {
|
|
20074
20231
|
JE(E.precedingWhitespace || "") ? this.layout.add(a.NEWLINE, a.INDENT, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(a.NO_NEWLINE, a.SPACE, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.add(E.text, a.MANDATORY_NEWLINE, a.INDENT);
|
|
20075
20232
|
}
|
|
20076
20233
|
formatBlockComment(E) {
|
|
20077
|
-
E.type ===
|
|
20234
|
+
E.type === c.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((e) => {
|
|
20078
20235
|
this.layout.add(a.NEWLINE, a.INDENT, e);
|
|
20079
20236
|
}), this.layout.add(a.NEWLINE, a.INDENT)) : this.layout.add(E.text, a.SPACE);
|
|
20080
20237
|
}
|
|
@@ -20136,7 +20293,7 @@ class nE {
|
|
|
20136
20293
|
cfg: this.cfg,
|
|
20137
20294
|
dialectCfg: this.dialectCfg,
|
|
20138
20295
|
params: this.params,
|
|
20139
|
-
layout: new
|
|
20296
|
+
layout: new GN(this.cfg.expressionWidth),
|
|
20140
20297
|
inline: !0
|
|
20141
20298
|
}).format(E);
|
|
20142
20299
|
} catch (R) {
|
|
@@ -20172,7 +20329,7 @@ class nE {
|
|
|
20172
20329
|
this.layout.add(this.showDataType(E), a.SPACE);
|
|
20173
20330
|
}
|
|
20174
20331
|
showKw(E) {
|
|
20175
|
-
return
|
|
20332
|
+
return JT(E.tokenType) ? wT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
|
|
20176
20333
|
}
|
|
20177
20334
|
// Like showKw(), but skips tabular formatting
|
|
20178
20335
|
showNonTabularKw(E) {
|
|
@@ -20186,7 +20343,7 @@ class nE {
|
|
|
20186
20343
|
}
|
|
20187
20344
|
}
|
|
20188
20345
|
showFunctionKw(E) {
|
|
20189
|
-
return
|
|
20346
|
+
return JT(E.tokenType) ? wT(this.showNonTabularFunctionKw(E), this.cfg.indentStyle) : this.showNonTabularFunctionKw(E);
|
|
20190
20347
|
}
|
|
20191
20348
|
// Like showFunctionKw(), but skips tabular formatting
|
|
20192
20349
|
showNonTabularFunctionKw(E) {
|
|
@@ -20222,9 +20379,9 @@ class nE {
|
|
|
20222
20379
|
}
|
|
20223
20380
|
}
|
|
20224
20381
|
}
|
|
20225
|
-
class
|
|
20382
|
+
class mN {
|
|
20226
20383
|
constructor(E, e) {
|
|
20227
|
-
this.dialect = E, this.cfg = e, this.params = new
|
|
20384
|
+
this.dialect = E, this.cfg = e, this.params = new AN(this.cfg.params);
|
|
20228
20385
|
}
|
|
20229
20386
|
/**
|
|
20230
20387
|
* Formats an SQL query.
|
|
@@ -20236,7 +20393,7 @@ class DN {
|
|
|
20236
20393
|
return this.formatAst(e).trimEnd();
|
|
20237
20394
|
}
|
|
20238
20395
|
parse(E) {
|
|
20239
|
-
return
|
|
20396
|
+
return UN(this.dialect.tokenizer).parse(E, this.cfg.paramTypes || {});
|
|
20240
20397
|
}
|
|
20241
20398
|
formatAst(E) {
|
|
20242
20399
|
return E.map((e) => this.formatStatement(e)).join(`
|
|
@@ -20247,14 +20404,14 @@ class DN {
|
|
|
20247
20404
|
cfg: this.cfg,
|
|
20248
20405
|
dialectCfg: this.dialect.formatOptions,
|
|
20249
20406
|
params: this.params,
|
|
20250
|
-
layout: new
|
|
20407
|
+
layout: new re(new Ce(RN(this.cfg)))
|
|
20251
20408
|
}).format(E.children);
|
|
20252
20409
|
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? e.add(a.NEWLINE, ";") : e.add(a.NO_NEWLINE, ";")), e.toString();
|
|
20253
20410
|
}
|
|
20254
20411
|
}
|
|
20255
20412
|
class tE extends Error {
|
|
20256
20413
|
}
|
|
20257
|
-
function
|
|
20414
|
+
function dN(T) {
|
|
20258
20415
|
const E = [
|
|
20259
20416
|
"multilineLists",
|
|
20260
20417
|
"newlineBeforeOpenParen",
|
|
@@ -20268,17 +20425,17 @@ function PN(T) {
|
|
|
20268
20425
|
throw new tE(`${e} config is no more supported.`);
|
|
20269
20426
|
if (T.expressionWidth <= 0)
|
|
20270
20427
|
throw new tE(`expressionWidth config must be positive number. Received ${T.expressionWidth} instead.`);
|
|
20271
|
-
if (T.params && !
|
|
20428
|
+
if (T.params && !HN(T.params) && console.warn('WARNING: All "params" option values should be strings.'), T.paramTypes && !BN(T.paramTypes))
|
|
20272
20429
|
throw new tE("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
20273
20430
|
return T;
|
|
20274
20431
|
}
|
|
20275
|
-
function
|
|
20432
|
+
function HN(T) {
|
|
20276
20433
|
return (T instanceof Array ? T : Object.values(T)).every((e) => typeof e == "string");
|
|
20277
20434
|
}
|
|
20278
|
-
function
|
|
20435
|
+
function BN(T) {
|
|
20279
20436
|
return T.custom && Array.isArray(T.custom) ? T.custom.every((E) => E.regex !== "") : !0;
|
|
20280
20437
|
}
|
|
20281
|
-
var
|
|
20438
|
+
var pN = function(T, E) {
|
|
20282
20439
|
var e = {};
|
|
20283
20440
|
for (var R in T) Object.prototype.hasOwnProperty.call(T, R) && E.indexOf(R) < 0 && (e[R] = T[R]);
|
|
20284
20441
|
if (T != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -20286,7 +20443,7 @@ var lN = function(T, E) {
|
|
|
20286
20443
|
E.indexOf(R[A]) < 0 && Object.prototype.propertyIsEnumerable.call(T, R[A]) && (e[R[A]] = T[R[A]]);
|
|
20287
20444
|
return e;
|
|
20288
20445
|
};
|
|
20289
|
-
const
|
|
20446
|
+
const ne = {
|
|
20290
20447
|
bigquery: "bigquery",
|
|
20291
20448
|
db2: "db2",
|
|
20292
20449
|
db2i: "db2i",
|
|
@@ -20307,7 +20464,7 @@ const Ce = {
|
|
|
20307
20464
|
tsql: "transactsql",
|
|
20308
20465
|
singlestoredb: "singlestoredb",
|
|
20309
20466
|
snowflake: "snowflake"
|
|
20310
|
-
},
|
|
20467
|
+
}, FN = Object.keys(ne), YN = {
|
|
20311
20468
|
tabWidth: 2,
|
|
20312
20469
|
useTabs: !1,
|
|
20313
20470
|
keywordCase: "preserve",
|
|
@@ -20320,27 +20477,27 @@ const Ce = {
|
|
|
20320
20477
|
linesBetweenQueries: 1,
|
|
20321
20478
|
denseOperators: !1,
|
|
20322
20479
|
newlineBeforeSemicolon: !1
|
|
20323
|
-
},
|
|
20324
|
-
if (typeof E.language == "string" && !
|
|
20480
|
+
}, fN = (T, E = {}) => {
|
|
20481
|
+
if (typeof E.language == "string" && !FN.includes(E.language))
|
|
20325
20482
|
throw new tE(`Unsupported SQL dialect: ${E.language}`);
|
|
20326
|
-
const e =
|
|
20327
|
-
return
|
|
20328
|
-
},
|
|
20329
|
-
var { dialect: e } = E, R =
|
|
20483
|
+
const e = ne[E.language || "sql"];
|
|
20484
|
+
return hN(T, Object.assign(Object.assign({}, E), { dialect: yI[e] }));
|
|
20485
|
+
}, hN = (T, E) => {
|
|
20486
|
+
var { dialect: e } = E, R = pN(E, ["dialect"]);
|
|
20330
20487
|
if (typeof T != "string")
|
|
20331
20488
|
throw new Error("Invalid query argument. Expected string, instead got " + typeof T);
|
|
20332
|
-
const A =
|
|
20333
|
-
return new
|
|
20489
|
+
const A = dN(Object.assign(Object.assign({}, YN), R));
|
|
20490
|
+
return new mN(EN(e), A).format(T);
|
|
20334
20491
|
};
|
|
20335
|
-
function
|
|
20492
|
+
function VN(T) {
|
|
20336
20493
|
let E = 0;
|
|
20337
20494
|
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";
|
|
20338
20495
|
}
|
|
20339
|
-
function
|
|
20496
|
+
function WN() {
|
|
20340
20497
|
const T = Date.now(), E = Math.random().toString(36).substring(2, 9);
|
|
20341
20498
|
return `${T}-${E}`;
|
|
20342
20499
|
}
|
|
20343
|
-
function
|
|
20500
|
+
function bN(T) {
|
|
20344
20501
|
const E = T.dimensions || [], e = T.timeDimensions || [], R = T.measures || [];
|
|
20345
20502
|
return {
|
|
20346
20503
|
sortedDimensions: E,
|
|
@@ -20365,7 +20522,7 @@ function BN(T) {
|
|
|
20365
20522
|
hasMultiStage: !1
|
|
20366
20523
|
};
|
|
20367
20524
|
}
|
|
20368
|
-
function
|
|
20525
|
+
function XN(T) {
|
|
20369
20526
|
if (T.hasExecutor()) {
|
|
20370
20527
|
const E = T.databaseExecutor;
|
|
20371
20528
|
if (E?.engineType)
|
|
@@ -20373,7 +20530,7 @@ function pN(T) {
|
|
|
20373
20530
|
}
|
|
20374
20531
|
return "postgres";
|
|
20375
20532
|
}
|
|
20376
|
-
async function
|
|
20533
|
+
async function KN(T, E, e) {
|
|
20377
20534
|
const R = e.validateQuery(T);
|
|
20378
20535
|
if (!R.isValid)
|
|
20379
20536
|
throw new Error(`Query validation failed: ${R.errors.join(", ")}`);
|
|
@@ -20426,15 +20583,15 @@ async function fN(T, E, e) {
|
|
|
20426
20583
|
sql: [I.sql],
|
|
20427
20584
|
params: I.params || []
|
|
20428
20585
|
},
|
|
20429
|
-
complexity:
|
|
20586
|
+
complexity: VN(T),
|
|
20430
20587
|
valid: !0,
|
|
20431
20588
|
cubesUsed: Array.from(A),
|
|
20432
20589
|
joinType: S ? "multi_cube_join" : "single_cube",
|
|
20433
20590
|
query: T
|
|
20434
20591
|
};
|
|
20435
20592
|
}
|
|
20436
|
-
function
|
|
20437
|
-
const R =
|
|
20593
|
+
function yN(T, E, e) {
|
|
20594
|
+
const R = XN(e), A = WN(), S = (/* @__PURE__ */ new Date()).toISOString(), I = bN(T);
|
|
20438
20595
|
return {
|
|
20439
20596
|
queryType: "regularQuery",
|
|
20440
20597
|
results: [{
|
|
@@ -20458,9 +20615,9 @@ function FN(T, E, e) {
|
|
|
20458
20615
|
slowQuery: !1
|
|
20459
20616
|
};
|
|
20460
20617
|
}
|
|
20461
|
-
function
|
|
20618
|
+
function xT(T, E) {
|
|
20462
20619
|
try {
|
|
20463
|
-
return
|
|
20620
|
+
return fN(T, {
|
|
20464
20621
|
language: {
|
|
20465
20622
|
postgres: "postgresql",
|
|
20466
20623
|
mysql: "mysql",
|
|
@@ -20476,29 +20633,29 @@ function JT(T, E) {
|
|
|
20476
20633
|
return console.warn("SQL formatting failed:", e), T;
|
|
20477
20634
|
}
|
|
20478
20635
|
}
|
|
20479
|
-
function
|
|
20636
|
+
function $N(T, E) {
|
|
20480
20637
|
return {
|
|
20481
20638
|
sql: E.sql,
|
|
20482
20639
|
params: E.params || [],
|
|
20483
20640
|
query: T
|
|
20484
20641
|
};
|
|
20485
20642
|
}
|
|
20486
|
-
function
|
|
20643
|
+
function wN(T) {
|
|
20487
20644
|
return {
|
|
20488
20645
|
cubes: T
|
|
20489
20646
|
};
|
|
20490
20647
|
}
|
|
20491
|
-
function
|
|
20648
|
+
function JN(T, E = 500) {
|
|
20492
20649
|
return {
|
|
20493
20650
|
error: T instanceof Error ? T.message : T,
|
|
20494
20651
|
status: E
|
|
20495
20652
|
};
|
|
20496
20653
|
}
|
|
20497
|
-
async function
|
|
20654
|
+
async function xN(T, E, e) {
|
|
20498
20655
|
return { results: (await Promise.allSettled(
|
|
20499
20656
|
T.map(async (S) => {
|
|
20500
20657
|
const I = await e.executeMultiCubeQuery(S, E);
|
|
20501
|
-
return
|
|
20658
|
+
return yN(S, I, e);
|
|
20502
20659
|
})
|
|
20503
20660
|
)).map((S, I) => S.status === "fulfilled" ? {
|
|
20504
20661
|
success: !0,
|
|
@@ -20510,7 +20667,7 @@ async function bN(T, E, e) {
|
|
|
20510
20667
|
// Include the query that failed for debugging
|
|
20511
20668
|
}) };
|
|
20512
20669
|
}
|
|
20513
|
-
class
|
|
20670
|
+
class gN {
|
|
20514
20671
|
cubes = /* @__PURE__ */ new Map();
|
|
20515
20672
|
dbExecutor;
|
|
20516
20673
|
metadataCache;
|
|
@@ -20569,7 +20726,7 @@ class YN {
|
|
|
20569
20726
|
);
|
|
20570
20727
|
continue;
|
|
20571
20728
|
}
|
|
20572
|
-
const S =
|
|
20729
|
+
const S = ye(A.calculatedSql);
|
|
20573
20730
|
if (!S.isValid) {
|
|
20574
20731
|
e.push(
|
|
20575
20732
|
`Invalid calculatedSql syntax in '${E.name}.${R}': ${S.errors.join(", ")}`
|
|
@@ -20734,7 +20891,7 @@ ${e.join(`
|
|
|
20734
20891
|
throw new Error("Database executor not configured");
|
|
20735
20892
|
const I = await new GE(this.dbExecutor).generateSQL(A, e, R), t = this.dbExecutor.getEngineType();
|
|
20736
20893
|
return {
|
|
20737
|
-
sql:
|
|
20894
|
+
sql: xT(I.sql, t),
|
|
20738
20895
|
params: I.params
|
|
20739
20896
|
};
|
|
20740
20897
|
}
|
|
@@ -20746,7 +20903,7 @@ ${e.join(`
|
|
|
20746
20903
|
throw new Error("Database executor not configured");
|
|
20747
20904
|
const A = await new GE(this.dbExecutor).generateMultiCubeSQL(this.cubes, E, e), S = this.dbExecutor.getEngineType();
|
|
20748
20905
|
return {
|
|
20749
|
-
sql:
|
|
20906
|
+
sql: xT(A.sql, S),
|
|
20750
20907
|
params: A.params
|
|
20751
20908
|
};
|
|
20752
20909
|
}
|
|
@@ -20787,10 +20944,10 @@ ${e.join(`
|
|
|
20787
20944
|
* Ensures all referenced cubes and fields exist
|
|
20788
20945
|
*/
|
|
20789
20946
|
validateQuery(E) {
|
|
20790
|
-
return
|
|
20947
|
+
return Le(this.cubes, E);
|
|
20791
20948
|
}
|
|
20792
20949
|
}
|
|
20793
|
-
function
|
|
20950
|
+
function Le(T, E) {
|
|
20794
20951
|
const e = [], R = /* @__PURE__ */ new Set();
|
|
20795
20952
|
if (E.measures)
|
|
20796
20953
|
for (const A of E.measures) {
|
|
@@ -20839,17 +20996,17 @@ function ne(T, E) {
|
|
|
20839
20996
|
}
|
|
20840
20997
|
if (E.filters)
|
|
20841
20998
|
for (const A of E.filters)
|
|
20842
|
-
|
|
20999
|
+
_e(A, T, e, R);
|
|
20843
21000
|
return R.size === 0 && e.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
20844
21001
|
isValid: e.length === 0,
|
|
20845
21002
|
errors: e
|
|
20846
21003
|
};
|
|
20847
21004
|
}
|
|
20848
|
-
function
|
|
21005
|
+
function _e(T, E, e, R) {
|
|
20849
21006
|
if ("and" in T || "or" in T) {
|
|
20850
21007
|
const t = T.and || T.or || [];
|
|
20851
21008
|
for (const s of t)
|
|
20852
|
-
|
|
21009
|
+
_e(s, E, e, R);
|
|
20853
21010
|
return;
|
|
20854
21011
|
}
|
|
20855
21012
|
if (!("member" in T)) {
|
|
@@ -20869,13 +21026,13 @@ function Le(T, E, e, R) {
|
|
|
20869
21026
|
}
|
|
20870
21027
|
!I.dimensions[S] && !I.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
|
|
20871
21028
|
}
|
|
20872
|
-
new
|
|
21029
|
+
new gN();
|
|
20873
21030
|
export {
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
21031
|
+
gN as S,
|
|
21032
|
+
wN as a,
|
|
21033
|
+
$N as b,
|
|
21034
|
+
KN as c,
|
|
21035
|
+
JN as d,
|
|
21036
|
+
yN as f,
|
|
21037
|
+
xN as h
|
|
20881
21038
|
};
|