drizzle-cube 0.1.41 → 0.1.42
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-CkjmApqo.js → compiler-B57cLx38.js} +1148 -1118
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/client/chunks/{components-DnCh4Y4N.js → components-DzCsplX7.js} +5752 -5618
- package/dist/client/chunks/components-DzCsplX7.js.map +1 -0
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/types.d.ts +2 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +854 -824
- package/package.json +1 -1
- package/dist/client/chunks/components-DnCh4Y4N.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sql as
|
|
1
|
+
import { sql as n, eq as x, and as p, StringChunk as xT, count as SE, sum as f, max as q, min as j, countDistinct as vT, SQL as QT, or as IE, isNotNull as yE, ne as KE, isNull as $E, notInArray as gE, inArray as OE, lt as NE, gt as tE, gte as $, lte as g, desc as ZT, asc as wE } from "drizzle-orm";
|
|
2
2
|
class fE {
|
|
3
3
|
/**
|
|
4
4
|
* Default implementation returns template unchanged
|
|
@@ -36,21 +36,21 @@ class qT extends fE {
|
|
|
36
36
|
buildTimeDimension(E, T) {
|
|
37
37
|
switch (E) {
|
|
38
38
|
case "year":
|
|
39
|
-
return
|
|
39
|
+
return n`DATE_TRUNC('year', ${T}::timestamp)`;
|
|
40
40
|
case "quarter":
|
|
41
|
-
return
|
|
41
|
+
return n`DATE_TRUNC('quarter', ${T}::timestamp)`;
|
|
42
42
|
case "month":
|
|
43
|
-
return
|
|
43
|
+
return n`DATE_TRUNC('month', ${T}::timestamp)`;
|
|
44
44
|
case "week":
|
|
45
|
-
return
|
|
45
|
+
return n`DATE_TRUNC('week', ${T}::timestamp)`;
|
|
46
46
|
case "day":
|
|
47
|
-
return
|
|
47
|
+
return n`DATE_TRUNC('day', ${T}::timestamp)::timestamp`;
|
|
48
48
|
case "hour":
|
|
49
|
-
return
|
|
49
|
+
return n`DATE_TRUNC('hour', ${T}::timestamp)`;
|
|
50
50
|
case "minute":
|
|
51
|
-
return
|
|
51
|
+
return n`DATE_TRUNC('minute', ${T}::timestamp)`;
|
|
52
52
|
case "second":
|
|
53
|
-
return
|
|
53
|
+
return n`DATE_TRUNC('second', ${T}::timestamp)`;
|
|
54
54
|
default:
|
|
55
55
|
return T;
|
|
56
56
|
}
|
|
@@ -62,23 +62,23 @@ class qT extends fE {
|
|
|
62
62
|
buildStringCondition(E, T, A) {
|
|
63
63
|
switch (T) {
|
|
64
64
|
case "contains":
|
|
65
|
-
return
|
|
65
|
+
return n`${E} ILIKE ${`%${A}%`}`;
|
|
66
66
|
case "notContains":
|
|
67
|
-
return
|
|
67
|
+
return n`${E} NOT ILIKE ${`%${A}%`}`;
|
|
68
68
|
case "startsWith":
|
|
69
|
-
return
|
|
69
|
+
return n`${E} ILIKE ${`${A}%`}`;
|
|
70
70
|
case "endsWith":
|
|
71
|
-
return
|
|
71
|
+
return n`${E} ILIKE ${`%${A}`}`;
|
|
72
72
|
case "like":
|
|
73
|
-
return
|
|
73
|
+
return n`${E} LIKE ${A}`;
|
|
74
74
|
case "notLike":
|
|
75
|
-
return
|
|
75
|
+
return n`${E} NOT LIKE ${A}`;
|
|
76
76
|
case "ilike":
|
|
77
|
-
return
|
|
77
|
+
return n`${E} ILIKE ${A}`;
|
|
78
78
|
case "regex":
|
|
79
|
-
return
|
|
79
|
+
return n`${E} ~* ${A}`;
|
|
80
80
|
case "notRegex":
|
|
81
|
-
return
|
|
81
|
+
return n`${E} !~* ${A}`;
|
|
82
82
|
default:
|
|
83
83
|
throw new Error(`Unsupported string operator: ${T}`);
|
|
84
84
|
}
|
|
@@ -90,11 +90,11 @@ class qT extends fE {
|
|
|
90
90
|
castToType(E, T) {
|
|
91
91
|
switch (T) {
|
|
92
92
|
case "timestamp":
|
|
93
|
-
return
|
|
93
|
+
return n`${E}::timestamp`;
|
|
94
94
|
case "decimal":
|
|
95
|
-
return
|
|
95
|
+
return n`${E}::decimal`;
|
|
96
96
|
case "integer":
|
|
97
|
-
return
|
|
97
|
+
return n`${E}::integer`;
|
|
98
98
|
default:
|
|
99
99
|
throw new Error(`Unsupported cast type: ${T}`);
|
|
100
100
|
}
|
|
@@ -105,21 +105,21 @@ class qT extends fE {
|
|
|
105
105
|
* Extracted from multi-cube-builder.ts:284
|
|
106
106
|
*/
|
|
107
107
|
buildAvg(E) {
|
|
108
|
-
return
|
|
108
|
+
return n`COALESCE(AVG(${E}), 0)`;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* Build PostgreSQL CASE WHEN conditional expression
|
|
112
112
|
*/
|
|
113
113
|
buildCaseWhen(E, T) {
|
|
114
|
-
const A = E.map((e) =>
|
|
115
|
-
return T !== void 0 ?
|
|
114
|
+
const A = E.map((e) => n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
|
|
115
|
+
return T !== void 0 ? n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Build PostgreSQL boolean literal
|
|
119
119
|
* PostgreSQL uses TRUE/FALSE keywords
|
|
120
120
|
*/
|
|
121
121
|
buildBooleanLiteral(E) {
|
|
122
|
-
return E ?
|
|
122
|
+
return E ? n`TRUE` : n`FALSE`;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Convert filter values - PostgreSQL uses native types
|
|
@@ -172,12 +172,12 @@ class HT extends fE {
|
|
|
172
172
|
};
|
|
173
173
|
switch (E) {
|
|
174
174
|
case "quarter":
|
|
175
|
-
return
|
|
175
|
+
return n`DATE_ADD(MAKEDATE(YEAR(${T}), 1), INTERVAL (QUARTER(${T}) - 1) * 3 MONTH)`;
|
|
176
176
|
case "week":
|
|
177
|
-
return
|
|
177
|
+
return n`DATE_SUB(${T}, INTERVAL WEEKDAY(${T}) DAY)`;
|
|
178
178
|
default:
|
|
179
179
|
const e = A[E];
|
|
180
|
-
return e ?
|
|
180
|
+
return e ? n`STR_TO_DATE(DATE_FORMAT(${T}, ${e}), '%Y-%m-%d %H:%i:%s')` : T;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
@@ -188,23 +188,23 @@ class HT extends fE {
|
|
|
188
188
|
buildStringCondition(E, T, A) {
|
|
189
189
|
switch (T) {
|
|
190
190
|
case "contains":
|
|
191
|
-
return
|
|
191
|
+
return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
|
|
192
192
|
case "notContains":
|
|
193
|
-
return
|
|
193
|
+
return n`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
|
|
194
194
|
case "startsWith":
|
|
195
|
-
return
|
|
195
|
+
return n`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
|
|
196
196
|
case "endsWith":
|
|
197
|
-
return
|
|
197
|
+
return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
|
|
198
198
|
case "like":
|
|
199
|
-
return
|
|
199
|
+
return n`${E} LIKE ${A}`;
|
|
200
200
|
case "notLike":
|
|
201
|
-
return
|
|
201
|
+
return n`${E} NOT LIKE ${A}`;
|
|
202
202
|
case "ilike":
|
|
203
|
-
return
|
|
203
|
+
return n`LOWER(${E}) LIKE ${A.toLowerCase()}`;
|
|
204
204
|
case "regex":
|
|
205
|
-
return
|
|
205
|
+
return n`${E} REGEXP ${A}`;
|
|
206
206
|
case "notRegex":
|
|
207
|
-
return
|
|
207
|
+
return n`${E} NOT REGEXP ${A}`;
|
|
208
208
|
default:
|
|
209
209
|
throw new Error(`Unsupported string operator: ${T}`);
|
|
210
210
|
}
|
|
@@ -216,11 +216,11 @@ class HT extends fE {
|
|
|
216
216
|
castToType(E, T) {
|
|
217
217
|
switch (T) {
|
|
218
218
|
case "timestamp":
|
|
219
|
-
return
|
|
219
|
+
return n`CAST(${E} AS DATETIME)`;
|
|
220
220
|
case "decimal":
|
|
221
|
-
return
|
|
221
|
+
return n`CAST(${E} AS DECIMAL(10,2))`;
|
|
222
222
|
case "integer":
|
|
223
|
-
return
|
|
223
|
+
return n`CAST(${E} AS SIGNED INTEGER)`;
|
|
224
224
|
default:
|
|
225
225
|
throw new Error(`Unsupported cast type: ${T}`);
|
|
226
226
|
}
|
|
@@ -230,21 +230,21 @@ class HT extends fE {
|
|
|
230
230
|
* MySQL AVG returns NULL for empty sets, using IFNULL for consistency
|
|
231
231
|
*/
|
|
232
232
|
buildAvg(E) {
|
|
233
|
-
return
|
|
233
|
+
return n`IFNULL(AVG(${E}), 0)`;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Build MySQL CASE WHEN conditional expression
|
|
237
237
|
*/
|
|
238
238
|
buildCaseWhen(E, T) {
|
|
239
|
-
const A = E.map((e) =>
|
|
240
|
-
return T !== void 0 ?
|
|
239
|
+
const A = E.map((e) => n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
|
|
240
|
+
return T !== void 0 ? n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* Build MySQL boolean literal
|
|
244
244
|
* MySQL uses TRUE/FALSE keywords (equivalent to 1/0)
|
|
245
245
|
*/
|
|
246
246
|
buildBooleanLiteral(E) {
|
|
247
|
-
return E ?
|
|
247
|
+
return E ? n`TRUE` : n`FALSE`;
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
250
|
* Convert filter values - MySQL uses native types
|
|
@@ -287,28 +287,28 @@ class jT extends fE {
|
|
|
287
287
|
buildTimeDimension(E, T) {
|
|
288
288
|
switch (E) {
|
|
289
289
|
case "year":
|
|
290
|
-
return
|
|
290
|
+
return n`datetime(${T}, 'unixepoch', 'start of year')`;
|
|
291
291
|
case "quarter":
|
|
292
|
-
const A =
|
|
293
|
-
return
|
|
292
|
+
const A = n`datetime(${T}, 'unixepoch')`;
|
|
293
|
+
return n`datetime(${A}, 'start of year',
|
|
294
294
|
'+' || (((CAST(strftime('%m', ${A}) AS INTEGER) - 1) / 3) * 3) || ' months')`;
|
|
295
295
|
case "month":
|
|
296
|
-
return
|
|
296
|
+
return n`datetime(${T}, 'unixepoch', 'start of month')`;
|
|
297
297
|
case "week":
|
|
298
|
-
return
|
|
298
|
+
return n`date(datetime(${T}, 'unixepoch'), 'weekday 1', '-6 days')`;
|
|
299
299
|
case "day":
|
|
300
|
-
return
|
|
300
|
+
return n`datetime(${T}, 'unixepoch', 'start of day')`;
|
|
301
301
|
case "hour":
|
|
302
|
-
const e =
|
|
303
|
-
return
|
|
302
|
+
const e = n`datetime(${T}, 'unixepoch')`;
|
|
303
|
+
return n`datetime(strftime('%Y-%m-%d %H:00:00', ${e}))`;
|
|
304
304
|
case "minute":
|
|
305
|
-
const S =
|
|
306
|
-
return
|
|
305
|
+
const S = n`datetime(${T}, 'unixepoch')`;
|
|
306
|
+
return n`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
|
|
307
307
|
case "second":
|
|
308
|
-
const I =
|
|
309
|
-
return
|
|
308
|
+
const I = n`datetime(${T}, 'unixepoch')`;
|
|
309
|
+
return n`datetime(strftime('%Y-%m-%d %H:%M:%S', ${I}))`;
|
|
310
310
|
default:
|
|
311
|
-
return
|
|
311
|
+
return n`datetime(${T}, 'unixepoch')`;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
@@ -318,23 +318,23 @@ class jT extends fE {
|
|
|
318
318
|
buildStringCondition(E, T, A) {
|
|
319
319
|
switch (T) {
|
|
320
320
|
case "contains":
|
|
321
|
-
return
|
|
321
|
+
return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}%`}`;
|
|
322
322
|
case "notContains":
|
|
323
|
-
return
|
|
323
|
+
return n`LOWER(${E}) NOT LIKE ${`%${A.toLowerCase()}%`}`;
|
|
324
324
|
case "startsWith":
|
|
325
|
-
return
|
|
325
|
+
return n`LOWER(${E}) LIKE ${`${A.toLowerCase()}%`}`;
|
|
326
326
|
case "endsWith":
|
|
327
|
-
return
|
|
327
|
+
return n`LOWER(${E}) LIKE ${`%${A.toLowerCase()}`}`;
|
|
328
328
|
case "like":
|
|
329
|
-
return
|
|
329
|
+
return n`${E} LIKE ${A}`;
|
|
330
330
|
case "notLike":
|
|
331
|
-
return
|
|
331
|
+
return n`${E} NOT LIKE ${A}`;
|
|
332
332
|
case "ilike":
|
|
333
|
-
return
|
|
333
|
+
return n`LOWER(${E}) LIKE ${A.toLowerCase()}`;
|
|
334
334
|
case "regex":
|
|
335
|
-
return
|
|
335
|
+
return n`${E} GLOB ${A}`;
|
|
336
336
|
case "notRegex":
|
|
337
|
-
return
|
|
337
|
+
return n`${E} NOT GLOB ${A}`;
|
|
338
338
|
default:
|
|
339
339
|
throw new Error(`Unsupported string operator: ${T}`);
|
|
340
340
|
}
|
|
@@ -346,11 +346,11 @@ class jT extends fE {
|
|
|
346
346
|
castToType(E, T) {
|
|
347
347
|
switch (T) {
|
|
348
348
|
case "timestamp":
|
|
349
|
-
return
|
|
349
|
+
return n`datetime(${E} / 1000, 'unixepoch')`;
|
|
350
350
|
case "decimal":
|
|
351
|
-
return
|
|
351
|
+
return n`CAST(${E} AS REAL)`;
|
|
352
352
|
case "integer":
|
|
353
|
-
return
|
|
353
|
+
return n`CAST(${E} AS INTEGER)`;
|
|
354
354
|
default:
|
|
355
355
|
throw new Error(`Unsupported cast type: ${T}`);
|
|
356
356
|
}
|
|
@@ -360,21 +360,21 @@ class jT extends fE {
|
|
|
360
360
|
* SQLite AVG returns NULL for empty sets, using IFNULL for consistency
|
|
361
361
|
*/
|
|
362
362
|
buildAvg(E) {
|
|
363
|
-
return
|
|
363
|
+
return n`IFNULL(AVG(${E}), 0)`;
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
366
|
* Build SQLite CASE WHEN conditional expression
|
|
367
367
|
*/
|
|
368
368
|
buildCaseWhen(E, T) {
|
|
369
|
-
const A = E.map((e) => e.then && typeof e.then == "object" && (e.then.queryChunks || e.then._ || e.then.sql) ?
|
|
370
|
-
return T !== void 0 ? T && typeof T == "object" && (T.queryChunks || T._ || T.sql) ?
|
|
369
|
+
const A = E.map((e) => e.then && typeof e.then == "object" && (e.then.queryChunks || e.then._ || e.then.sql) ? n`WHEN ${e.when} THEN ${n.raw("(")}${e.then}${n.raw(")")}` : n`WHEN ${e.when} THEN ${e.then}`).reduce((e, S) => n`${e} ${S}`);
|
|
370
|
+
return T !== void 0 ? T && typeof T == "object" && (T.queryChunks || T._ || T.sql) ? n`CASE ${A} ELSE ${n.raw("(")}${T}${n.raw(")")} END` : n`CASE ${A} ELSE ${T} END` : n`CASE ${A} END`;
|
|
371
371
|
}
|
|
372
372
|
/**
|
|
373
373
|
* Build SQLite boolean literal
|
|
374
374
|
* SQLite uses 1/0 for true/false
|
|
375
375
|
*/
|
|
376
376
|
buildBooleanLiteral(E) {
|
|
377
|
-
return E ?
|
|
377
|
+
return E ? n`1` : n`0`;
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Preprocess calculated measure templates for SQLite-specific handling
|
|
@@ -657,7 +657,7 @@ function dT(R, E) {
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
function SR(R) {
|
|
660
|
-
return R && typeof R == "object" ?
|
|
660
|
+
return R && typeof R == "object" ? n`${n`${R}`}` : R;
|
|
661
661
|
}
|
|
662
662
|
function X(R, E) {
|
|
663
663
|
const T = typeof R == "function" ? R(E) : R;
|
|
@@ -680,30 +680,30 @@ function IR(R, E) {
|
|
|
680
680
|
if (R.relationship !== "belongsToMany" || !R.through)
|
|
681
681
|
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
682
682
|
const { table: T, sourceKey: A, targetKey: e, securitySql: S } = R.through, I = [];
|
|
683
|
-
for (const
|
|
684
|
-
const s =
|
|
685
|
-
I.push(s(
|
|
683
|
+
for (const N of A) {
|
|
684
|
+
const s = N.as || x;
|
|
685
|
+
I.push(s(N.source, N.target));
|
|
686
686
|
}
|
|
687
687
|
const t = [];
|
|
688
|
-
for (const
|
|
689
|
-
const s =
|
|
690
|
-
t.push(s(
|
|
688
|
+
for (const N of e) {
|
|
689
|
+
const s = N.as || x;
|
|
690
|
+
t.push(s(N.source, N.target));
|
|
691
691
|
}
|
|
692
692
|
let C;
|
|
693
693
|
if (S) {
|
|
694
|
-
const
|
|
695
|
-
C = Array.isArray(
|
|
694
|
+
const N = S(E);
|
|
695
|
+
C = Array.isArray(N) ? N : [N];
|
|
696
696
|
}
|
|
697
|
-
const
|
|
697
|
+
const O = dT("belongsToMany", R.sqlJoinType);
|
|
698
698
|
return {
|
|
699
699
|
junctionJoins: [
|
|
700
700
|
{
|
|
701
|
-
joinType:
|
|
701
|
+
joinType: O,
|
|
702
702
|
table: T,
|
|
703
703
|
condition: p(...I)
|
|
704
704
|
},
|
|
705
705
|
{
|
|
706
|
-
joinType:
|
|
706
|
+
joinType: O,
|
|
707
707
|
table: T,
|
|
708
708
|
// This will be replaced with target cube table in query planner
|
|
709
709
|
condition: p(...t)
|
|
@@ -755,8 +755,8 @@ class b {
|
|
|
755
755
|
if (A.type === "calculated" && A.calculatedSql) {
|
|
756
756
|
const e = `${E.name}.${T}`, S = this.extractDependencies(A.calculatedSql), I = /* @__PURE__ */ new Set();
|
|
757
757
|
for (const t of S) {
|
|
758
|
-
const
|
|
759
|
-
I.add(
|
|
758
|
+
const O = `${t.cubeName || E.name}.${t.fieldName}`;
|
|
759
|
+
I.add(O);
|
|
760
760
|
}
|
|
761
761
|
this.dependencyGraph.set(e, {
|
|
762
762
|
id: e,
|
|
@@ -935,35 +935,35 @@ class b {
|
|
|
935
935
|
function NR(R, E) {
|
|
936
936
|
const { cube: T, allCubes: A, resolvedMeasures: e } = E, S = WE(R), I = /* @__PURE__ */ new Map();
|
|
937
937
|
for (const s of S) {
|
|
938
|
-
const { originalRef:
|
|
938
|
+
const { originalRef: r, cubeName: L, fieldName: i } = s, o = L || T.name;
|
|
939
939
|
if (!A.get(o))
|
|
940
940
|
throw new Error(
|
|
941
|
-
`Cannot substitute {${
|
|
941
|
+
`Cannot substitute {${r}}: cube '${o}' not found`
|
|
942
942
|
);
|
|
943
|
-
const P = `${o}.${
|
|
943
|
+
const P = `${o}.${i}`, c = e.get(P);
|
|
944
944
|
if (!c)
|
|
945
945
|
throw new Error(
|
|
946
|
-
`Cannot substitute {${
|
|
946
|
+
`Cannot substitute {${r}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
947
947
|
);
|
|
948
|
-
const M = c(), u =
|
|
949
|
-
I.set(
|
|
948
|
+
const M = c(), u = n`${M}`;
|
|
949
|
+
I.set(r, u);
|
|
950
950
|
}
|
|
951
951
|
const t = [], C = [];
|
|
952
|
-
let
|
|
952
|
+
let O = 0;
|
|
953
953
|
for (const s of S) {
|
|
954
|
-
const
|
|
955
|
-
if (
|
|
956
|
-
t.push(R.substring(
|
|
957
|
-
const
|
|
958
|
-
|
|
954
|
+
const r = `{${s.originalRef}}`, L = R.indexOf(r, O);
|
|
955
|
+
if (L >= 0) {
|
|
956
|
+
t.push(R.substring(O, L));
|
|
957
|
+
const i = I.get(s.originalRef);
|
|
958
|
+
i && C.push(i), O = L + r.length;
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
|
-
if (t.push(R.substring(
|
|
962
|
-
return
|
|
963
|
-
const
|
|
961
|
+
if (t.push(R.substring(O)), C.length === 0)
|
|
962
|
+
return n.raw(R);
|
|
963
|
+
const N = [];
|
|
964
964
|
for (let s = 0; s < t.length; s++)
|
|
965
|
-
t[s] &&
|
|
966
|
-
return
|
|
965
|
+
t[s] && N.push(new xT(t[s])), s < C.length && N.push(C[s]);
|
|
966
|
+
return n.join(N, n.raw(""));
|
|
967
967
|
}
|
|
968
968
|
function WE(R) {
|
|
969
969
|
const E = /\{([^}]+)\}/g, T = R.matchAll(E), A = [];
|
|
@@ -1034,44 +1034,44 @@ class sR {
|
|
|
1034
1034
|
* @returns Map of measure names to SQL builder functions
|
|
1035
1035
|
*/
|
|
1036
1036
|
buildResolvedMeasures(E, T, A, e) {
|
|
1037
|
-
const S = /* @__PURE__ */ new Map(), I = [], t = [], C = new Set(E),
|
|
1038
|
-
for (const
|
|
1039
|
-
|
|
1040
|
-
for (const
|
|
1041
|
-
const [s,
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
b.isCalculatedMeasure(
|
|
1037
|
+
const S = /* @__PURE__ */ new Map(), I = [], t = [], C = new Set(E), O = new b(T);
|
|
1038
|
+
for (const N of T.values())
|
|
1039
|
+
O.buildGraph(N);
|
|
1040
|
+
for (const N of E) {
|
|
1041
|
+
const [s, r] = N.split("."), L = T.get(s);
|
|
1042
|
+
if (L && L.measures && L.measures[r]) {
|
|
1043
|
+
const i = L.measures[r];
|
|
1044
|
+
b.isCalculatedMeasure(i) ? (t.push(N), sE(i.calculatedSql, s).forEach((P) => C.add(P)), O.getAllDependencies(N).forEach((P) => {
|
|
1045
1045
|
const [c, M] = P.split("."), u = T.get(c);
|
|
1046
1046
|
if (u && u.measures[M]) {
|
|
1047
1047
|
const H = u.measures[M];
|
|
1048
1048
|
b.isCalculatedMeasure(H) && sE(H.calculatedSql, c).forEach((Y) => C.add(Y));
|
|
1049
1049
|
}
|
|
1050
|
-
})) : I.push(
|
|
1050
|
+
})) : I.push(N);
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
for (const
|
|
1054
|
-
const [s,
|
|
1055
|
-
if (
|
|
1056
|
-
const
|
|
1057
|
-
b.isCalculatedMeasure(
|
|
1053
|
+
for (const N of C) {
|
|
1054
|
+
const [s, r] = N.split("."), L = T.get(s);
|
|
1055
|
+
if (L && L.measures && L.measures[r]) {
|
|
1056
|
+
const i = L.measures[r];
|
|
1057
|
+
b.isCalculatedMeasure(i) ? t.includes(N) || t.push(N) : I.includes(N) || I.push(N);
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
|
-
for (const
|
|
1061
|
-
const [s,
|
|
1060
|
+
for (const N of I) {
|
|
1061
|
+
const [s, r] = N.split("."), L = T.get(s), i = L.measures[r];
|
|
1062
1062
|
if (e) {
|
|
1063
|
-
const o = e(
|
|
1064
|
-
S.set(
|
|
1063
|
+
const o = e(N, i, L);
|
|
1064
|
+
S.set(N, () => o);
|
|
1065
1065
|
} else
|
|
1066
|
-
S.set(
|
|
1066
|
+
S.set(N, () => this.buildMeasureExpression(i, A));
|
|
1067
1067
|
}
|
|
1068
1068
|
if (t.length > 0) {
|
|
1069
|
-
const
|
|
1070
|
-
for (const s of
|
|
1071
|
-
const [
|
|
1069
|
+
const N = O.topologicalSort(t);
|
|
1070
|
+
for (const s of N) {
|
|
1071
|
+
const [r, L] = s.split("."), i = T.get(r), o = i.measures[L];
|
|
1072
1072
|
S.set(s, () => this.buildCalculatedMeasure(
|
|
1073
1073
|
o,
|
|
1074
|
-
|
|
1074
|
+
i,
|
|
1075
1075
|
T,
|
|
1076
1076
|
S,
|
|
1077
1077
|
A
|
|
@@ -1089,10 +1089,10 @@ class sR {
|
|
|
1089
1089
|
const e = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1090
1090
|
if (T.dimensions)
|
|
1091
1091
|
for (const I of T.dimensions) {
|
|
1092
|
-
const [t, C] = I.split("."),
|
|
1093
|
-
if (
|
|
1094
|
-
const
|
|
1095
|
-
e[I] =
|
|
1092
|
+
const [t, C] = I.split("."), O = S.get(t);
|
|
1093
|
+
if (O && O.dimensions && O.dimensions[C]) {
|
|
1094
|
+
const N = O.dimensions[C], s = X(N.sql, A);
|
|
1095
|
+
e[I] = n`${s}`.as(I);
|
|
1096
1096
|
}
|
|
1097
1097
|
}
|
|
1098
1098
|
if (T.measures) {
|
|
@@ -1104,21 +1104,21 @@ class sR {
|
|
|
1104
1104
|
for (const t of T.measures) {
|
|
1105
1105
|
const C = I.get(t);
|
|
1106
1106
|
if (C) {
|
|
1107
|
-
const
|
|
1108
|
-
e[t] =
|
|
1107
|
+
const O = C();
|
|
1108
|
+
e[t] = n`${O}`.as(t);
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
1112
|
if (T.timeDimensions)
|
|
1113
1113
|
for (const I of T.timeDimensions) {
|
|
1114
|
-
const [t, C] = I.dimension.split("."),
|
|
1115
|
-
if (
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1114
|
+
const [t, C] = I.dimension.split("."), O = S.get(t);
|
|
1115
|
+
if (O && O.dimensions && O.dimensions[C]) {
|
|
1116
|
+
const N = O.dimensions[C], s = this.buildTimeDimensionExpression(
|
|
1117
|
+
N.sql,
|
|
1118
1118
|
I.granularity,
|
|
1119
1119
|
A
|
|
1120
1120
|
);
|
|
1121
|
-
e[I.dimension] =
|
|
1121
|
+
e[I.dimension] = n`${s}`.as(I.dimension);
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
1124
|
return Object.keys(e).length === 0 && (e.count = SE()), e;
|
|
@@ -1160,34 +1160,34 @@ class sR {
|
|
|
1160
1160
|
);
|
|
1161
1161
|
const I = /* @__PURE__ */ new Map(), t = sE(E.calculatedSql, T.name);
|
|
1162
1162
|
for (const C of t) {
|
|
1163
|
-
const [
|
|
1164
|
-
if (s && s.measures[
|
|
1165
|
-
const
|
|
1163
|
+
const [O, N] = C.split("."), s = e.get(O);
|
|
1164
|
+
if (s && s.measures[N]) {
|
|
1165
|
+
const r = s.measures[N];
|
|
1166
1166
|
if (A.measures.includes(C)) {
|
|
1167
|
-
const
|
|
1168
|
-
let
|
|
1169
|
-
switch (
|
|
1167
|
+
const L = n`${n.identifier(A.cteAlias)}.${n.identifier(N)}`;
|
|
1168
|
+
let i;
|
|
1169
|
+
switch (r.type) {
|
|
1170
1170
|
case "count":
|
|
1171
1171
|
case "countDistinct":
|
|
1172
1172
|
case "sum":
|
|
1173
|
-
|
|
1173
|
+
i = f(L);
|
|
1174
1174
|
break;
|
|
1175
1175
|
case "avg":
|
|
1176
|
-
|
|
1176
|
+
i = this.databaseAdapter.buildAvg(L);
|
|
1177
1177
|
break;
|
|
1178
1178
|
case "min":
|
|
1179
|
-
|
|
1179
|
+
i = j(L);
|
|
1180
1180
|
break;
|
|
1181
1181
|
case "max":
|
|
1182
|
-
|
|
1182
|
+
i = q(L);
|
|
1183
1183
|
break;
|
|
1184
1184
|
case "number":
|
|
1185
|
-
|
|
1185
|
+
i = f(L);
|
|
1186
1186
|
break;
|
|
1187
1187
|
default:
|
|
1188
|
-
|
|
1188
|
+
i = f(L);
|
|
1189
1189
|
}
|
|
1190
|
-
I.set(C, () =>
|
|
1190
|
+
I.set(C, () => i);
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
1193
|
}
|
|
@@ -1207,13 +1207,13 @@ class sR {
|
|
|
1207
1207
|
const I = S.preAggregationCTEs.find((t) => t.cube.name === E);
|
|
1208
1208
|
if (I && I.measures.includes(`${E}.${T}`))
|
|
1209
1209
|
if (A.type === "calculated" && A.calculatedSql) {
|
|
1210
|
-
const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((
|
|
1210
|
+
const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((O) => O.cube.name === E)?.cube;
|
|
1211
1211
|
if (!t)
|
|
1212
1212
|
throw new Error(`Cube ${E} not found in query plan`);
|
|
1213
1213
|
const C = /* @__PURE__ */ new Map([[S.primaryCube.name, S.primaryCube]]);
|
|
1214
1214
|
if (S.joinCubes)
|
|
1215
|
-
for (const
|
|
1216
|
-
C.set(
|
|
1215
|
+
for (const O of S.joinCubes)
|
|
1216
|
+
C.set(O.cube.name, O.cube);
|
|
1217
1217
|
return this.buildCTECalculatedMeasure(
|
|
1218
1218
|
A,
|
|
1219
1219
|
t,
|
|
@@ -1222,7 +1222,7 @@ class sR {
|
|
|
1222
1222
|
e
|
|
1223
1223
|
);
|
|
1224
1224
|
} else {
|
|
1225
|
-
const t =
|
|
1225
|
+
const t = n`${n.identifier(I.cteAlias)}.${n.identifier(T)}`;
|
|
1226
1226
|
switch (A.type) {
|
|
1227
1227
|
case "count":
|
|
1228
1228
|
case "countDistinct":
|
|
@@ -1260,7 +1260,7 @@ class sR {
|
|
|
1260
1260
|
if (E.filters && E.filters.length > 0) {
|
|
1261
1261
|
const e = E.filters.map((S) => {
|
|
1262
1262
|
const I = S(T);
|
|
1263
|
-
return I ?
|
|
1263
|
+
return I ? n`(${I})` : void 0;
|
|
1264
1264
|
}).filter(Boolean);
|
|
1265
1265
|
if (e.length > 0) {
|
|
1266
1266
|
const S = e.length === 1 ? e[0] : p(...e);
|
|
@@ -1293,7 +1293,7 @@ class sR {
|
|
|
1293
1293
|
*/
|
|
1294
1294
|
buildTimeDimensionExpression(E, T, A) {
|
|
1295
1295
|
const e = X(E, A);
|
|
1296
|
-
return T ? this.databaseAdapter.buildTimeDimension(T, e) : e instanceof QT ? e :
|
|
1296
|
+
return T ? this.databaseAdapter.buildTimeDimension(T, e) : e instanceof QT ? e : n`${e}`;
|
|
1297
1297
|
}
|
|
1298
1298
|
/**
|
|
1299
1299
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -1308,12 +1308,12 @@ class sR {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
if (T.timeDimensions)
|
|
1310
1310
|
for (const t of T.timeDimensions) {
|
|
1311
|
-
const [C,
|
|
1312
|
-
if (
|
|
1311
|
+
const [C, O] = t.dimension.split("."), N = I.get(C);
|
|
1312
|
+
if (N && N.dimensions[O] && t.dateRange) {
|
|
1313
1313
|
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((o) => o.cube.name === C))
|
|
1314
1314
|
continue;
|
|
1315
|
-
const s =
|
|
1316
|
-
|
|
1315
|
+
const s = N.dimensions[O], r = X(s.sql, A), L = this.buildDateRangeCondition(r, t.dateRange);
|
|
1316
|
+
L && S.push(L);
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
1319
|
return S;
|
|
@@ -1337,31 +1337,43 @@ class sR {
|
|
|
1337
1337
|
*/
|
|
1338
1338
|
processFilter(E, T, A, e, S) {
|
|
1339
1339
|
if ("and" in E || "or" in E) {
|
|
1340
|
-
const
|
|
1341
|
-
if (
|
|
1342
|
-
const
|
|
1343
|
-
return
|
|
1340
|
+
const L = E;
|
|
1341
|
+
if (L.and) {
|
|
1342
|
+
const i = L.and.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
|
|
1343
|
+
return i.length > 0 ? p(...i) : null;
|
|
1344
1344
|
}
|
|
1345
|
-
if (
|
|
1346
|
-
const
|
|
1347
|
-
return
|
|
1345
|
+
if (L.or) {
|
|
1346
|
+
const i = L.or.map((o) => this.processFilter(o, T, A, e, S)).filter((o) => o !== null);
|
|
1347
|
+
return i.length > 0 ? IE(...i) : null;
|
|
1348
1348
|
}
|
|
1349
1349
|
}
|
|
1350
|
-
const I = E, [t, C] = I.member.split("."),
|
|
1351
|
-
if (!
|
|
1352
|
-
const
|
|
1353
|
-
if (!
|
|
1354
|
-
if (e === "where" &&
|
|
1350
|
+
const I = E, [t, C] = I.member.split("."), O = T.get(t);
|
|
1351
|
+
if (!O) return null;
|
|
1352
|
+
const N = O.dimensions[C], s = O.measures[C], r = N || s;
|
|
1353
|
+
if (!r) return null;
|
|
1354
|
+
if (e === "where" && N) {
|
|
1355
1355
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
|
|
1356
1356
|
return null;
|
|
1357
|
-
const
|
|
1358
|
-
return this.buildFilterCondition(
|
|
1357
|
+
const L = X(N.sql, A);
|
|
1358
|
+
return this.buildFilterCondition(
|
|
1359
|
+
L,
|
|
1360
|
+
I.operator,
|
|
1361
|
+
I.values,
|
|
1362
|
+
r,
|
|
1363
|
+
I.dateRange
|
|
1364
|
+
);
|
|
1359
1365
|
} else {
|
|
1360
1366
|
if (e === "where" && s)
|
|
1361
1367
|
return null;
|
|
1362
1368
|
if (e === "having" && s) {
|
|
1363
|
-
const
|
|
1364
|
-
return this.buildFilterCondition(
|
|
1369
|
+
const L = this.buildHavingMeasureExpression(t, C, s, A, S);
|
|
1370
|
+
return this.buildFilterCondition(
|
|
1371
|
+
L,
|
|
1372
|
+
I.operator,
|
|
1373
|
+
I.values,
|
|
1374
|
+
r,
|
|
1375
|
+
I.dateRange
|
|
1376
|
+
);
|
|
1365
1377
|
}
|
|
1366
1378
|
}
|
|
1367
1379
|
return null;
|
|
@@ -1369,97 +1381,108 @@ class sR {
|
|
|
1369
1381
|
/**
|
|
1370
1382
|
* Build filter condition using Drizzle operators
|
|
1371
1383
|
*/
|
|
1372
|
-
buildFilterCondition(E, T, A, e) {
|
|
1384
|
+
buildFilterCondition(E, T, A, e, S) {
|
|
1385
|
+
if (S !== void 0) {
|
|
1386
|
+
if (T !== "inDateRange")
|
|
1387
|
+
throw new Error(
|
|
1388
|
+
`dateRange can only be used with 'inDateRange' operator, but got '${T}'. Use explicit date values in the 'values' array for other date operators.`
|
|
1389
|
+
);
|
|
1390
|
+
if (e && e.type !== "time")
|
|
1391
|
+
throw new Error(
|
|
1392
|
+
`dateRange can only be used on time dimensions, but field '${e.name || "unknown"}' has type '${e.type}'`
|
|
1393
|
+
);
|
|
1394
|
+
return this.buildDateRangeCondition(E, S);
|
|
1395
|
+
}
|
|
1373
1396
|
if (!A || A.length === 0)
|
|
1374
1397
|
return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
1375
|
-
const
|
|
1376
|
-
if (
|
|
1398
|
+
const I = A.filter((C) => !(C == null || C === "" || typeof C == "string" && C.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
|
|
1399
|
+
if (I.length === 0 && !["set", "notSet"].includes(T))
|
|
1377
1400
|
return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
1378
|
-
const
|
|
1401
|
+
const t = I[0];
|
|
1379
1402
|
switch (T) {
|
|
1380
1403
|
case "equals":
|
|
1381
|
-
if (
|
|
1404
|
+
if (I.length > 1) {
|
|
1382
1405
|
if (e?.type === "time") {
|
|
1383
|
-
const
|
|
1384
|
-
return OE(E,
|
|
1406
|
+
const C = I.map((O) => this.normalizeDate(O) || O);
|
|
1407
|
+
return OE(E, C);
|
|
1385
1408
|
}
|
|
1386
|
-
return OE(E,
|
|
1387
|
-
} else if (
|
|
1388
|
-
const
|
|
1389
|
-
return x(E,
|
|
1409
|
+
return OE(E, I);
|
|
1410
|
+
} else if (I.length === 1) {
|
|
1411
|
+
const C = e?.type === "time" && this.normalizeDate(t) || t;
|
|
1412
|
+
return x(E, C);
|
|
1390
1413
|
}
|
|
1391
1414
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
1392
1415
|
case "notEquals":
|
|
1393
|
-
return
|
|
1416
|
+
return I.length > 1 ? gE(E, I) : I.length === 1 ? KE(E, t) : null;
|
|
1394
1417
|
case "contains":
|
|
1395
|
-
return this.databaseAdapter.buildStringCondition(E, "contains",
|
|
1418
|
+
return this.databaseAdapter.buildStringCondition(E, "contains", t);
|
|
1396
1419
|
case "notContains":
|
|
1397
|
-
return this.databaseAdapter.buildStringCondition(E, "notContains",
|
|
1420
|
+
return this.databaseAdapter.buildStringCondition(E, "notContains", t);
|
|
1398
1421
|
case "startsWith":
|
|
1399
|
-
return this.databaseAdapter.buildStringCondition(E, "startsWith",
|
|
1422
|
+
return this.databaseAdapter.buildStringCondition(E, "startsWith", t);
|
|
1400
1423
|
case "endsWith":
|
|
1401
|
-
return this.databaseAdapter.buildStringCondition(E, "endsWith",
|
|
1424
|
+
return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
|
|
1402
1425
|
case "gt":
|
|
1403
|
-
return tE(E,
|
|
1426
|
+
return tE(E, t);
|
|
1404
1427
|
case "gte":
|
|
1405
|
-
return $(E,
|
|
1428
|
+
return $(E, t);
|
|
1406
1429
|
case "lt":
|
|
1407
|
-
return NE(E,
|
|
1430
|
+
return NE(E, t);
|
|
1408
1431
|
case "lte":
|
|
1409
|
-
return g(E,
|
|
1432
|
+
return g(E, t);
|
|
1410
1433
|
case "set":
|
|
1411
1434
|
return yE(E);
|
|
1412
1435
|
case "notSet":
|
|
1413
1436
|
return $E(E);
|
|
1414
1437
|
case "inDateRange":
|
|
1415
|
-
if (
|
|
1416
|
-
const
|
|
1417
|
-
let
|
|
1418
|
-
if (
|
|
1438
|
+
if (I.length >= 2) {
|
|
1439
|
+
const C = this.normalizeDate(I[0]);
|
|
1440
|
+
let O = this.normalizeDate(I[1]);
|
|
1441
|
+
if (C && O) {
|
|
1419
1442
|
const N = A[1];
|
|
1420
1443
|
if (typeof N == "string" && /^\d{4}-\d{2}-\d{2}$/.test(N.trim())) {
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1444
|
+
const s = typeof O == "number" ? new Date(O * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(O), r = new Date(s);
|
|
1445
|
+
r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? O = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : O = r.toISOString();
|
|
1423
1446
|
}
|
|
1424
1447
|
return p(
|
|
1425
|
-
$(E,
|
|
1426
|
-
g(E,
|
|
1448
|
+
$(E, C),
|
|
1449
|
+
g(E, O)
|
|
1427
1450
|
);
|
|
1428
1451
|
}
|
|
1429
1452
|
}
|
|
1430
1453
|
return null;
|
|
1431
1454
|
case "beforeDate": {
|
|
1432
|
-
const
|
|
1433
|
-
return
|
|
1455
|
+
const C = this.normalizeDate(t);
|
|
1456
|
+
return C ? NE(E, C) : null;
|
|
1434
1457
|
}
|
|
1435
1458
|
case "afterDate": {
|
|
1436
|
-
const
|
|
1437
|
-
return
|
|
1459
|
+
const C = this.normalizeDate(t);
|
|
1460
|
+
return C ? tE(E, C) : null;
|
|
1438
1461
|
}
|
|
1439
1462
|
case "between":
|
|
1440
|
-
return
|
|
1441
|
-
$(E,
|
|
1442
|
-
g(E,
|
|
1463
|
+
return I.length >= 2 ? p(
|
|
1464
|
+
$(E, I[0]),
|
|
1465
|
+
g(E, I[1])
|
|
1443
1466
|
) : null;
|
|
1444
1467
|
case "notBetween":
|
|
1445
|
-
return
|
|
1446
|
-
NE(E,
|
|
1447
|
-
tE(E,
|
|
1468
|
+
return I.length >= 2 ? IE(
|
|
1469
|
+
NE(E, I[0]),
|
|
1470
|
+
tE(E, I[1])
|
|
1448
1471
|
) : null;
|
|
1449
1472
|
case "in":
|
|
1450
|
-
return
|
|
1473
|
+
return I.length > 0 ? OE(E, I) : null;
|
|
1451
1474
|
case "notIn":
|
|
1452
|
-
return
|
|
1475
|
+
return I.length > 0 ? gE(E, I) : null;
|
|
1453
1476
|
case "like":
|
|
1454
|
-
return this.databaseAdapter.buildStringCondition(E, "like",
|
|
1477
|
+
return this.databaseAdapter.buildStringCondition(E, "like", t);
|
|
1455
1478
|
case "notLike":
|
|
1456
|
-
return this.databaseAdapter.buildStringCondition(E, "notLike",
|
|
1479
|
+
return this.databaseAdapter.buildStringCondition(E, "notLike", t);
|
|
1457
1480
|
case "ilike":
|
|
1458
|
-
return this.databaseAdapter.buildStringCondition(E, "ilike",
|
|
1481
|
+
return this.databaseAdapter.buildStringCondition(E, "ilike", t);
|
|
1459
1482
|
case "regex":
|
|
1460
|
-
return this.databaseAdapter.buildStringCondition(E, "regex",
|
|
1483
|
+
return this.databaseAdapter.buildStringCondition(E, "regex", t);
|
|
1461
1484
|
case "notRegex":
|
|
1462
|
-
return this.databaseAdapter.buildStringCondition(E, "notRegex",
|
|
1485
|
+
return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
|
|
1463
1486
|
case "isEmpty":
|
|
1464
1487
|
return IE(
|
|
1465
1488
|
$E(E),
|
|
@@ -1495,9 +1518,9 @@ class sR {
|
|
|
1495
1518
|
if (typeof T == "string") {
|
|
1496
1519
|
const A = this.parseRelativeDateRange(T);
|
|
1497
1520
|
if (A) {
|
|
1498
|
-
let
|
|
1499
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (
|
|
1500
|
-
$(E,
|
|
1521
|
+
let N, s;
|
|
1522
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (N = Math.floor(A.start.getTime() / 1e3), s = Math.floor(A.end.getTime() / 1e3)) : (N = A.start.getTime(), s = A.end.getTime()) : (N = A.start.toISOString(), s = A.end.toISOString()), p(
|
|
1523
|
+
$(E, N),
|
|
1501
1524
|
g(E, s)
|
|
1502
1525
|
);
|
|
1503
1526
|
}
|
|
@@ -1507,10 +1530,10 @@ class sR {
|
|
|
1507
1530
|
I.setUTCHours(0, 0, 0, 0);
|
|
1508
1531
|
const t = new Date(S);
|
|
1509
1532
|
t.setUTCHours(23, 59, 59, 999);
|
|
1510
|
-
let C,
|
|
1511
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3),
|
|
1533
|
+
let C, O;
|
|
1534
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(I.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (C = I.getTime(), O = t.getTime()) : (C = I.toISOString(), O = t.toISOString()), p(
|
|
1512
1535
|
$(E, C),
|
|
1513
|
-
g(E,
|
|
1536
|
+
g(E, O)
|
|
1514
1537
|
);
|
|
1515
1538
|
}
|
|
1516
1539
|
return null;
|
|
@@ -1522,73 +1545,80 @@ class sR {
|
|
|
1522
1545
|
parseRelativeDateRange(E) {
|
|
1523
1546
|
const T = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = T.getUTCFullYear(), S = T.getUTCMonth(), I = T.getUTCDate(), t = T.getUTCDay();
|
|
1524
1547
|
if (A === "today") {
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1527
|
-
const
|
|
1528
|
-
return
|
|
1548
|
+
const r = new Date(T);
|
|
1549
|
+
r.setUTCHours(0, 0, 0, 0);
|
|
1550
|
+
const L = new Date(T);
|
|
1551
|
+
return L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
|
|
1529
1552
|
}
|
|
1530
1553
|
if (A === "yesterday") {
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1533
|
-
const
|
|
1534
|
-
return
|
|
1554
|
+
const r = new Date(T);
|
|
1555
|
+
r.setUTCDate(I - 1), r.setUTCHours(0, 0, 0, 0);
|
|
1556
|
+
const L = new Date(T);
|
|
1557
|
+
return L.setUTCDate(I - 1), L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
|
|
1535
1558
|
}
|
|
1536
1559
|
if (A === "this week") {
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
const
|
|
1540
|
-
return
|
|
1560
|
+
const r = t === 0 ? -6 : 1 - t, L = new Date(T);
|
|
1561
|
+
L.setUTCDate(I + r), L.setUTCHours(0, 0, 0, 0);
|
|
1562
|
+
const i = new Date(L);
|
|
1563
|
+
return i.setUTCDate(L.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
|
|
1541
1564
|
}
|
|
1542
1565
|
if (A === "this month") {
|
|
1543
|
-
const
|
|
1544
|
-
return { start:
|
|
1566
|
+
const r = new Date(Date.UTC(e, S, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S + 1, 0, 23, 59, 59, 999));
|
|
1567
|
+
return { start: r, end: L };
|
|
1545
1568
|
}
|
|
1546
1569
|
if (A === "this quarter") {
|
|
1547
|
-
const
|
|
1548
|
-
return { start:
|
|
1570
|
+
const r = Math.floor(S / 3), L = new Date(Date.UTC(e, r * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(e, r * 3 + 3, 0, 23, 59, 59, 999));
|
|
1571
|
+
return { start: L, end: i };
|
|
1549
1572
|
}
|
|
1550
1573
|
if (A === "this year") {
|
|
1551
|
-
const
|
|
1552
|
-
return { start:
|
|
1574
|
+
const r = new Date(Date.UTC(e, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, 11, 31, 23, 59, 59, 999));
|
|
1575
|
+
return { start: r, end: L };
|
|
1553
1576
|
}
|
|
1554
1577
|
const C = A.match(/^last\s+(\d+)\s+days?$/);
|
|
1555
1578
|
if (C) {
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
const
|
|
1559
|
-
return
|
|
1579
|
+
const r = parseInt(C[1], 10), L = new Date(T);
|
|
1580
|
+
L.setUTCDate(I - r + 1), L.setUTCHours(0, 0, 0, 0);
|
|
1581
|
+
const i = new Date(T);
|
|
1582
|
+
return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
|
|
1583
|
+
}
|
|
1584
|
+
const O = A.match(/^last\s+(\d+)\s+weeks?$/);
|
|
1585
|
+
if (O) {
|
|
1586
|
+
const L = parseInt(O[1], 10) * 7, i = new Date(T);
|
|
1587
|
+
i.setUTCDate(I - L + 1), i.setUTCHours(0, 0, 0, 0);
|
|
1588
|
+
const o = new Date(T);
|
|
1589
|
+
return o.setUTCHours(23, 59, 59, 999), { start: i, end: o };
|
|
1560
1590
|
}
|
|
1561
1591
|
if (A === "last week") {
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1565
|
-
return
|
|
1592
|
+
const r = t === 0 ? -13 : -6 - t, L = new Date(T);
|
|
1593
|
+
L.setUTCDate(I + r), L.setUTCHours(0, 0, 0, 0);
|
|
1594
|
+
const i = new Date(L);
|
|
1595
|
+
return i.setUTCDate(L.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
|
|
1566
1596
|
}
|
|
1567
1597
|
if (A === "last month") {
|
|
1568
|
-
const
|
|
1569
|
-
return { start:
|
|
1598
|
+
const r = new Date(Date.UTC(e, S - 1, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e, S, 0, 23, 59, 59, 999));
|
|
1599
|
+
return { start: r, end: L };
|
|
1570
1600
|
}
|
|
1571
1601
|
if (A === "last quarter") {
|
|
1572
|
-
const
|
|
1573
|
-
return { start:
|
|
1602
|
+
const r = Math.floor(S / 3), L = r === 0 ? 3 : r - 1, i = r === 0 ? e - 1 : e, o = new Date(Date.UTC(i, L * 3, 1, 0, 0, 0, 0)), l = new Date(Date.UTC(i, L * 3 + 3, 0, 23, 59, 59, 999));
|
|
1603
|
+
return { start: o, end: l };
|
|
1574
1604
|
}
|
|
1575
1605
|
if (A === "last year") {
|
|
1576
|
-
const
|
|
1577
|
-
return { start:
|
|
1606
|
+
const r = new Date(Date.UTC(e - 1, 0, 1, 0, 0, 0, 0)), L = new Date(Date.UTC(e - 1, 11, 31, 23, 59, 59, 999));
|
|
1607
|
+
return { start: r, end: L };
|
|
1578
1608
|
}
|
|
1579
1609
|
if (A === "last 12 months") {
|
|
1580
|
-
const
|
|
1581
|
-
return
|
|
1610
|
+
const r = new Date(Date.UTC(e, S - 11, 1, 0, 0, 0, 0)), L = new Date(T);
|
|
1611
|
+
return L.setUTCHours(23, 59, 59, 999), { start: r, end: L };
|
|
1582
1612
|
}
|
|
1583
1613
|
const N = A.match(/^last\s+(\d+)\s+months?$/);
|
|
1584
1614
|
if (N) {
|
|
1585
|
-
const
|
|
1586
|
-
return
|
|
1615
|
+
const r = parseInt(N[1], 10), L = new Date(Date.UTC(e, S - r + 1, 1, 0, 0, 0, 0)), i = new Date(T);
|
|
1616
|
+
return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
|
|
1587
1617
|
}
|
|
1588
|
-
const
|
|
1589
|
-
if (
|
|
1590
|
-
const
|
|
1591
|
-
return
|
|
1618
|
+
const s = A.match(/^last\s+(\d+)\s+years?$/);
|
|
1619
|
+
if (s) {
|
|
1620
|
+
const r = parseInt(s[1], 10), L = new Date(Date.UTC(e - r, 0, 1, 0, 0, 0, 0)), i = new Date(T);
|
|
1621
|
+
return i.setUTCHours(23, 59, 59, 999), { start: L, end: i };
|
|
1592
1622
|
}
|
|
1593
1623
|
return null;
|
|
1594
1624
|
}
|
|
@@ -1627,45 +1657,45 @@ class sR {
|
|
|
1627
1657
|
const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1628
1658
|
if (T.dimensions)
|
|
1629
1659
|
for (const C of T.dimensions) {
|
|
1630
|
-
const [
|
|
1631
|
-
if (s && s.dimensions && s.dimensions[
|
|
1632
|
-
if (e?.preAggregationCTEs?.some((
|
|
1633
|
-
const
|
|
1634
|
-
if (
|
|
1635
|
-
S.push(
|
|
1660
|
+
const [O, N] = C.split("."), s = t.get(O);
|
|
1661
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1662
|
+
if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
|
|
1663
|
+
const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
|
|
1664
|
+
if (i && i.sourceColumnObj)
|
|
1665
|
+
S.push(i.sourceColumnObj);
|
|
1636
1666
|
else {
|
|
1637
|
-
const o =
|
|
1667
|
+
const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
|
|
1638
1668
|
S.push(o);
|
|
1639
1669
|
}
|
|
1640
1670
|
} else {
|
|
1641
|
-
const
|
|
1642
|
-
S.push(
|
|
1671
|
+
const L = s.dimensions[N], i = X(L.sql, A);
|
|
1672
|
+
S.push(i);
|
|
1643
1673
|
}
|
|
1644
1674
|
}
|
|
1645
1675
|
if (T.timeDimensions)
|
|
1646
1676
|
for (const C of T.timeDimensions) {
|
|
1647
|
-
const [
|
|
1648
|
-
if (s && s.dimensions && s.dimensions[
|
|
1649
|
-
if (e?.preAggregationCTEs?.some((
|
|
1650
|
-
const
|
|
1651
|
-
if (
|
|
1677
|
+
const [O, N] = C.dimension.split("."), s = t.get(O);
|
|
1678
|
+
if (s && s.dimensions && s.dimensions[N])
|
|
1679
|
+
if (e?.preAggregationCTEs?.some((L) => L.cube.name === O)) {
|
|
1680
|
+
const L = e.preAggregationCTEs.find((o) => o.cube.name === O), i = L.joinKeys.find((o) => o.targetColumn === N);
|
|
1681
|
+
if (i && i.sourceColumnObj) {
|
|
1652
1682
|
const o = this.buildTimeDimensionExpression(
|
|
1653
|
-
|
|
1683
|
+
i.sourceColumnObj,
|
|
1654
1684
|
C.granularity,
|
|
1655
1685
|
A
|
|
1656
1686
|
);
|
|
1657
1687
|
S.push(o);
|
|
1658
1688
|
} else {
|
|
1659
|
-
const o =
|
|
1689
|
+
const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
|
|
1660
1690
|
S.push(o);
|
|
1661
1691
|
}
|
|
1662
1692
|
} else {
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1693
|
+
const L = s.dimensions[N], i = this.buildTimeDimensionExpression(
|
|
1694
|
+
L.sql,
|
|
1665
1695
|
C.granularity,
|
|
1666
1696
|
A
|
|
1667
1697
|
);
|
|
1668
|
-
S.push(
|
|
1698
|
+
S.push(i);
|
|
1669
1699
|
}
|
|
1670
1700
|
}
|
|
1671
1701
|
return S;
|
|
@@ -1683,7 +1713,7 @@ class sR {
|
|
|
1683
1713
|
for (const [S, I] of Object.entries(E.order)) {
|
|
1684
1714
|
if (!e.includes(S))
|
|
1685
1715
|
throw new Error(`Cannot order by '${S}': field is not selected in the query`);
|
|
1686
|
-
const t = I === "desc" ? ZT(
|
|
1716
|
+
const t = I === "desc" ? ZT(n.identifier(S)) : wE(n.identifier(S));
|
|
1687
1717
|
A.push(t);
|
|
1688
1718
|
}
|
|
1689
1719
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
@@ -1691,7 +1721,7 @@ class sR {
|
|
|
1691
1721
|
(t, C) => t.dimension.localeCompare(C.dimension)
|
|
1692
1722
|
);
|
|
1693
1723
|
for (const t of I)
|
|
1694
|
-
S.has(t.dimension) || A.push(wE(
|
|
1724
|
+
S.has(t.dimension) || A.push(wE(n.identifier(t.dimension)));
|
|
1695
1725
|
}
|
|
1696
1726
|
return A;
|
|
1697
1727
|
}
|
|
@@ -1705,8 +1735,8 @@ class sR {
|
|
|
1705
1735
|
for (const S of T.dimensions) {
|
|
1706
1736
|
const [I, t] = S.split("."), C = e.get(I);
|
|
1707
1737
|
if (C) {
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1738
|
+
const O = C.dimensions[t];
|
|
1739
|
+
O && O.type === "number" && A.push(S);
|
|
1710
1740
|
}
|
|
1711
1741
|
}
|
|
1712
1742
|
return A;
|
|
@@ -1821,7 +1851,7 @@ class CR {
|
|
|
1821
1851
|
groupByFields: []
|
|
1822
1852
|
// Will be built by QueryBuilder
|
|
1823
1853
|
};
|
|
1824
|
-
const C = this.buildJoinPlan(E, t, S, A),
|
|
1854
|
+
const C = this.buildJoinPlan(E, t, S, A), O = this.planPreAggregationCTEs(E, t, C, T);
|
|
1825
1855
|
return {
|
|
1826
1856
|
primaryCube: t,
|
|
1827
1857
|
joinCubes: C,
|
|
@@ -1831,7 +1861,7 @@ class CR {
|
|
|
1831
1861
|
// Will be built by QueryBuilder
|
|
1832
1862
|
groupByFields: [],
|
|
1833
1863
|
// Will be built by QueryBuilder
|
|
1834
|
-
preAggregationCTEs:
|
|
1864
|
+
preAggregationCTEs: O
|
|
1835
1865
|
};
|
|
1836
1866
|
}
|
|
1837
1867
|
/**
|
|
@@ -1885,48 +1915,48 @@ class CR {
|
|
|
1885
1915
|
for (const C of t) {
|
|
1886
1916
|
if (I.has(C))
|
|
1887
1917
|
continue;
|
|
1888
|
-
const
|
|
1889
|
-
if (!
|
|
1918
|
+
const O = this.findJoinPath(E, T.name, C, I);
|
|
1919
|
+
if (!O || O.length === 0)
|
|
1890
1920
|
throw new Error(`No join path found from '${T.name}' to '${C}'`);
|
|
1891
|
-
for (const { toCube:
|
|
1892
|
-
if (I.has(
|
|
1921
|
+
for (const { toCube: N, joinDef: s } of O) {
|
|
1922
|
+
if (I.has(N))
|
|
1893
1923
|
continue;
|
|
1894
|
-
const
|
|
1895
|
-
if (!
|
|
1896
|
-
throw new Error(`Cube '${
|
|
1924
|
+
const r = E.get(N);
|
|
1925
|
+
if (!r)
|
|
1926
|
+
throw new Error(`Cube '${N}' not found`);
|
|
1897
1927
|
if (s.relationship === "belongsToMany" && s.through) {
|
|
1898
|
-
const
|
|
1928
|
+
const L = IR(s, e.securityContext);
|
|
1899
1929
|
S.push({
|
|
1900
|
-
cube:
|
|
1901
|
-
alias: `${
|
|
1902
|
-
joinType:
|
|
1930
|
+
cube: r,
|
|
1931
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1932
|
+
joinType: L.junctionJoins[1].joinType,
|
|
1903
1933
|
// Use the target join type
|
|
1904
|
-
joinCondition:
|
|
1934
|
+
joinCondition: L.junctionJoins[1].condition,
|
|
1905
1935
|
// Target join condition
|
|
1906
1936
|
junctionTable: {
|
|
1907
1937
|
table: s.through.table,
|
|
1908
|
-
alias: `junction_${
|
|
1909
|
-
joinType:
|
|
1910
|
-
joinCondition:
|
|
1938
|
+
alias: `junction_${N.toLowerCase()}`,
|
|
1939
|
+
joinType: L.junctionJoins[0].joinType,
|
|
1940
|
+
joinCondition: L.junctionJoins[0].condition,
|
|
1911
1941
|
securitySql: s.through.securitySql
|
|
1912
1942
|
}
|
|
1913
1943
|
});
|
|
1914
1944
|
} else {
|
|
1915
|
-
const
|
|
1945
|
+
const L = this.buildJoinCondition(
|
|
1916
1946
|
s,
|
|
1917
1947
|
null,
|
|
1918
1948
|
// No source alias needed - use the actual column
|
|
1919
1949
|
null
|
|
1920
1950
|
// No target alias needed - use the actual column
|
|
1921
|
-
),
|
|
1951
|
+
), i = dT(s.relationship, s.sqlJoinType);
|
|
1922
1952
|
S.push({
|
|
1923
|
-
cube:
|
|
1924
|
-
alias: `${
|
|
1925
|
-
joinType:
|
|
1926
|
-
joinCondition:
|
|
1953
|
+
cube: r,
|
|
1954
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1955
|
+
joinType: i,
|
|
1956
|
+
joinCondition: L
|
|
1927
1957
|
});
|
|
1928
1958
|
}
|
|
1929
|
-
I.add(
|
|
1959
|
+
I.add(N);
|
|
1930
1960
|
}
|
|
1931
1961
|
}
|
|
1932
1962
|
return S;
|
|
@@ -1937,7 +1967,7 @@ class CR {
|
|
|
1937
1967
|
buildJoinCondition(E, T, A) {
|
|
1938
1968
|
const e = [];
|
|
1939
1969
|
for (const S of E.on) {
|
|
1940
|
-
const I = T ?
|
|
1970
|
+
const I = T ? n`${n.identifier(T)}.${n.identifier(S.source.name)}` : S.source, t = A ? n`${n.identifier(A)}.${n.identifier(S.target.name)}` : S.target, C = S.as || x;
|
|
1941
1971
|
e.push(C(I, t));
|
|
1942
1972
|
}
|
|
1943
1973
|
return p(...e);
|
|
@@ -1953,20 +1983,20 @@ class CR {
|
|
|
1953
1983
|
{ cube: T, path: [] }
|
|
1954
1984
|
], I = /* @__PURE__ */ new Set([T, ...e]);
|
|
1955
1985
|
for (; S.length > 0; ) {
|
|
1956
|
-
const { cube: t, path: C } = S.shift(),
|
|
1957
|
-
if (
|
|
1958
|
-
for (const [,
|
|
1959
|
-
const
|
|
1960
|
-
if (I.has(
|
|
1986
|
+
const { cube: t, path: C } = S.shift(), O = E.get(t);
|
|
1987
|
+
if (O?.joins)
|
|
1988
|
+
for (const [, N] of Object.entries(O.joins)) {
|
|
1989
|
+
const r = QE(N.targetCube).name;
|
|
1990
|
+
if (I.has(r))
|
|
1961
1991
|
continue;
|
|
1962
|
-
const
|
|
1992
|
+
const L = [...C, {
|
|
1963
1993
|
fromCube: t,
|
|
1964
|
-
toCube:
|
|
1965
|
-
joinDef:
|
|
1994
|
+
toCube: r,
|
|
1995
|
+
joinDef: N
|
|
1966
1996
|
}];
|
|
1967
|
-
if (
|
|
1968
|
-
return
|
|
1969
|
-
I.add(
|
|
1997
|
+
if (r === A)
|
|
1998
|
+
return L;
|
|
1999
|
+
I.add(r), S.push({ cube: r, path: L });
|
|
1970
2000
|
}
|
|
1971
2001
|
}
|
|
1972
2002
|
return null;
|
|
@@ -1985,24 +2015,24 @@ class CR {
|
|
|
1985
2015
|
if (!t)
|
|
1986
2016
|
continue;
|
|
1987
2017
|
const C = e.measures ? e.measures.filter(
|
|
1988
|
-
(
|
|
1989
|
-
) : [],
|
|
1990
|
-
if (
|
|
2018
|
+
(L) => L.startsWith(I.cube.name + ".")
|
|
2019
|
+
) : [], O = this.extractMeasuresFromFilters(e, I.cube.name), N = [.../* @__PURE__ */ new Set([...C, ...O])];
|
|
2020
|
+
if (N.length === 0)
|
|
1991
2021
|
continue;
|
|
1992
2022
|
const s = this.expandCalculatedMeasureDependencies(
|
|
1993
2023
|
I.cube,
|
|
1994
|
-
|
|
1995
|
-
),
|
|
1996
|
-
sourceColumn:
|
|
1997
|
-
targetColumn:
|
|
1998
|
-
sourceColumnObj:
|
|
1999
|
-
targetColumnObj:
|
|
2024
|
+
N
|
|
2025
|
+
), r = t.on.map((L) => ({
|
|
2026
|
+
sourceColumn: L.source.name,
|
|
2027
|
+
targetColumn: L.target.name,
|
|
2028
|
+
sourceColumnObj: L.source,
|
|
2029
|
+
targetColumnObj: L.target
|
|
2000
2030
|
}));
|
|
2001
2031
|
S.push({
|
|
2002
2032
|
cube: I.cube,
|
|
2003
2033
|
alias: I.alias,
|
|
2004
2034
|
cteAlias: `${I.cube.name.toLowerCase()}_agg`,
|
|
2005
|
-
joinKeys:
|
|
2035
|
+
joinKeys: r,
|
|
2006
2036
|
measures: s
|
|
2007
2037
|
});
|
|
2008
2038
|
}
|
|
@@ -2024,8 +2054,8 @@ class CR {
|
|
|
2024
2054
|
const t = E.measures[I];
|
|
2025
2055
|
if (t.type === "calculated" && t.calculatedSql) {
|
|
2026
2056
|
const C = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
|
|
2027
|
-
for (const
|
|
2028
|
-
A.has(
|
|
2057
|
+
for (const O of C)
|
|
2058
|
+
A.has(O) || e.push(O);
|
|
2029
2059
|
}
|
|
2030
2060
|
}
|
|
2031
2061
|
return Array.from(A);
|
|
@@ -2074,23 +2104,23 @@ class CE {
|
|
|
2074
2104
|
db: this.dbExecutor.db,
|
|
2075
2105
|
schema: this.dbExecutor.schema,
|
|
2076
2106
|
securityContext: A
|
|
2077
|
-
}, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), C = this.queryBuilder.collectNumericFields(E, T),
|
|
2078
|
-
const
|
|
2107
|
+
}, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), C = this.queryBuilder.collectNumericFields(E, T), O = await this.dbExecutor.execute(t, C), N = Array.isArray(O) ? O.map((r) => {
|
|
2108
|
+
const L = { ...r };
|
|
2079
2109
|
if (T.timeDimensions) {
|
|
2080
|
-
for (const
|
|
2081
|
-
if (
|
|
2082
|
-
let o =
|
|
2110
|
+
for (const i of T.timeDimensions)
|
|
2111
|
+
if (i.dimension in L) {
|
|
2112
|
+
let o = L[i.dimension];
|
|
2083
2113
|
if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
2084
2114
|
const l = o.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
|
|
2085
2115
|
o = new Date(P);
|
|
2086
2116
|
}
|
|
2087
|
-
o = this.databaseAdapter.convertTimeDimensionResult(o),
|
|
2117
|
+
o = this.databaseAdapter.convertTimeDimensionResult(o), L[i.dimension] = o;
|
|
2088
2118
|
}
|
|
2089
2119
|
}
|
|
2090
|
-
return
|
|
2091
|
-
}) : [
|
|
2120
|
+
return L;
|
|
2121
|
+
}) : [O], s = this.generateAnnotations(I, T);
|
|
2092
2122
|
return {
|
|
2093
|
-
data:
|
|
2123
|
+
data: N,
|
|
2094
2124
|
annotation: s
|
|
2095
2125
|
};
|
|
2096
2126
|
} catch (e) {
|
|
@@ -2113,18 +2143,18 @@ class CE {
|
|
|
2113
2143
|
if (P.targetColumnObj) {
|
|
2114
2144
|
t[P.targetColumn] = P.targetColumnObj;
|
|
2115
2145
|
for (const [c, M] of Object.entries(S.dimensions || {}))
|
|
2116
|
-
M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] =
|
|
2146
|
+
M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] = n`${P.targetColumnObj}`.as(c));
|
|
2117
2147
|
}
|
|
2118
|
-
const C = S.name,
|
|
2148
|
+
const C = S.name, O = /* @__PURE__ */ new Map([[C, S]]), N = this.queryBuilder.buildResolvedMeasures(
|
|
2119
2149
|
E.measures,
|
|
2120
|
-
|
|
2150
|
+
O,
|
|
2121
2151
|
A
|
|
2122
2152
|
);
|
|
2123
2153
|
for (const P of E.measures) {
|
|
2124
|
-
const [, c] = P.split("."), M =
|
|
2154
|
+
const [, c] = P.split("."), M = N.get(P);
|
|
2125
2155
|
if (M) {
|
|
2126
2156
|
const u = M();
|
|
2127
|
-
t[c] =
|
|
2157
|
+
t[c] = n`${u}`.as(c);
|
|
2128
2158
|
}
|
|
2129
2159
|
}
|
|
2130
2160
|
if (T.dimensions)
|
|
@@ -2132,7 +2162,7 @@ class CE {
|
|
|
2132
2162
|
const [c, M] = P.split(".");
|
|
2133
2163
|
if (c === C && S.dimensions && S.dimensions[M]) {
|
|
2134
2164
|
const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A);
|
|
2135
|
-
t[M] =
|
|
2165
|
+
t[M] = n`${H}`.as(M);
|
|
2136
2166
|
}
|
|
2137
2167
|
}
|
|
2138
2168
|
if (T.timeDimensions)
|
|
@@ -2140,22 +2170,22 @@ class CE {
|
|
|
2140
2170
|
const [c, M] = P.dimension.split(".");
|
|
2141
2171
|
if (c === C && S.dimensions && S.dimensions[M]) {
|
|
2142
2172
|
const u = S.dimensions[M], H = this.queryBuilder.buildTimeDimensionExpression(u.sql, P.granularity, A);
|
|
2143
|
-
t[M] =
|
|
2173
|
+
t[M] = n`${H}`.as(M);
|
|
2144
2174
|
}
|
|
2145
2175
|
}
|
|
2146
2176
|
if (Object.keys(t).length === 0)
|
|
2147
2177
|
return null;
|
|
2148
2178
|
let s = A.db.select(t).from(I.from);
|
|
2149
|
-
const
|
|
2179
|
+
const r = e ? {
|
|
2150
2180
|
...e,
|
|
2151
2181
|
preAggregationCTEs: e.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
|
|
2152
|
-
} : void 0,
|
|
2182
|
+
} : void 0, L = this.queryBuilder.buildWhereConditions(S, T, A, r), i = [];
|
|
2153
2183
|
if (T.timeDimensions)
|
|
2154
2184
|
for (const P of T.timeDimensions) {
|
|
2155
2185
|
const [c, M] = P.dimension.split(".");
|
|
2156
2186
|
if (c === C && S.dimensions && S.dimensions[M] && P.dateRange) {
|
|
2157
2187
|
const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(H, P.dateRange);
|
|
2158
|
-
B &&
|
|
2188
|
+
B && i.push(B);
|
|
2159
2189
|
}
|
|
2160
2190
|
}
|
|
2161
2191
|
if (T.filters) {
|
|
@@ -2166,13 +2196,13 @@ class CE {
|
|
|
2166
2196
|
const H = S.dimensions[u];
|
|
2167
2197
|
if (c.operator === "inDateRange") {
|
|
2168
2198
|
const B = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), Y = this.queryBuilder.buildDateRangeCondition(B, c.values);
|
|
2169
|
-
Y &&
|
|
2199
|
+
Y && i.push(Y);
|
|
2170
2200
|
}
|
|
2171
2201
|
}
|
|
2172
2202
|
}
|
|
2173
2203
|
}
|
|
2174
2204
|
const o = [];
|
|
2175
|
-
if (I.where && o.push(I.where), o.push(...
|
|
2205
|
+
if (I.where && o.push(I.where), o.push(...L, ...i), o.length > 0) {
|
|
2176
2206
|
const P = o.length === 1 ? o[0] : p(...o);
|
|
2177
2207
|
s = s.where(P);
|
|
2178
2208
|
}
|
|
@@ -2207,7 +2237,7 @@ class CE {
|
|
|
2207
2237
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
2208
2238
|
const S = [];
|
|
2209
2239
|
for (const I of e.joinKeys) {
|
|
2210
|
-
const t = I.sourceColumnObj ||
|
|
2240
|
+
const t = I.sourceColumnObj || n.identifier(I.sourceColumn), C = n`${n.identifier(T)}.${n.identifier(I.targetColumn)}`;
|
|
2211
2241
|
S.push(x(t, C));
|
|
2212
2242
|
}
|
|
2213
2243
|
return S.length === 1 ? S[0] : p(...S);
|
|
@@ -2247,7 +2277,7 @@ class CE {
|
|
|
2247
2277
|
A
|
|
2248
2278
|
);
|
|
2249
2279
|
} else {
|
|
2250
|
-
const B =
|
|
2280
|
+
const B = n`${n.identifier(o.cteAlias)}.${n.identifier(c)}`;
|
|
2251
2281
|
switch (u.type) {
|
|
2252
2282
|
case "count":
|
|
2253
2283
|
case "countDistinct":
|
|
@@ -2270,7 +2300,7 @@ class CE {
|
|
|
2270
2300
|
H = f(B);
|
|
2271
2301
|
}
|
|
2272
2302
|
}
|
|
2273
|
-
C[P] =
|
|
2303
|
+
C[P] = n`${H}`.as(P);
|
|
2274
2304
|
}
|
|
2275
2305
|
}
|
|
2276
2306
|
for (const P in C) {
|
|
@@ -2283,27 +2313,27 @@ class CE {
|
|
|
2283
2313
|
const eE = u.dimensions[M].sql;
|
|
2284
2314
|
Y = o.joinKeys.find((JT) => JT.targetColumnObj === eE);
|
|
2285
2315
|
}
|
|
2286
|
-
Y ? C[P] =
|
|
2316
|
+
Y ? C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P) : B && u?.dimensions?.[M] && (C[P] = n`${n.identifier(o.cteAlias)}.${n.identifier(M)}`.as(P));
|
|
2287
2317
|
}
|
|
2288
2318
|
}
|
|
2289
2319
|
}
|
|
2290
2320
|
}
|
|
2291
|
-
const
|
|
2292
|
-
let
|
|
2293
|
-
if (e.length > 0 && (
|
|
2321
|
+
const O = [];
|
|
2322
|
+
let N = A.db.select(C).from(I.from);
|
|
2323
|
+
if (e.length > 0 && (N = A.db.with(...e).select(C).from(I.from)), I.joins)
|
|
2294
2324
|
for (const o of I.joins)
|
|
2295
2325
|
switch (o.type || "left") {
|
|
2296
2326
|
case "left":
|
|
2297
|
-
|
|
2327
|
+
N = N.leftJoin(o.table, o.on);
|
|
2298
2328
|
break;
|
|
2299
2329
|
case "inner":
|
|
2300
|
-
|
|
2330
|
+
N = N.innerJoin(o.table, o.on);
|
|
2301
2331
|
break;
|
|
2302
2332
|
case "right":
|
|
2303
|
-
|
|
2333
|
+
N = N.rightJoin(o.table, o.on);
|
|
2304
2334
|
break;
|
|
2305
2335
|
case "full":
|
|
2306
|
-
|
|
2336
|
+
N = N.fullJoin(o.table, o.on);
|
|
2307
2337
|
break;
|
|
2308
2338
|
}
|
|
2309
2339
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
@@ -2318,48 +2348,48 @@ class CE {
|
|
|
2318
2348
|
try {
|
|
2319
2349
|
switch (M.joinType || "left") {
|
|
2320
2350
|
case "left":
|
|
2321
|
-
|
|
2351
|
+
N = N.leftJoin(M.table, M.joinCondition);
|
|
2322
2352
|
break;
|
|
2323
2353
|
case "inner":
|
|
2324
|
-
|
|
2354
|
+
N = N.innerJoin(M.table, M.joinCondition);
|
|
2325
2355
|
break;
|
|
2326
2356
|
case "right":
|
|
2327
|
-
|
|
2357
|
+
N = N.rightJoin(M.table, M.joinCondition);
|
|
2328
2358
|
break;
|
|
2329
2359
|
case "full":
|
|
2330
|
-
|
|
2360
|
+
N = N.fullJoin(M.table, M.joinCondition);
|
|
2331
2361
|
break;
|
|
2332
2362
|
}
|
|
2333
|
-
u.length > 0 &&
|
|
2363
|
+
u.length > 0 && O.push(...u);
|
|
2334
2364
|
} catch {
|
|
2335
2365
|
}
|
|
2336
2366
|
}
|
|
2337
2367
|
let P, c;
|
|
2338
|
-
l ? (P =
|
|
2368
|
+
l ? (P = n`${n.identifier(l)}`, c = this.buildCTEJoinCondition(o, l, E)) : (P = o.cube.sql(A).from, c = o.joinCondition);
|
|
2339
2369
|
try {
|
|
2340
2370
|
switch (o.joinType || "left") {
|
|
2341
2371
|
case "left":
|
|
2342
|
-
|
|
2372
|
+
N = N.leftJoin(P, c);
|
|
2343
2373
|
break;
|
|
2344
2374
|
case "inner":
|
|
2345
|
-
|
|
2375
|
+
N = N.innerJoin(P, c);
|
|
2346
2376
|
break;
|
|
2347
2377
|
case "right":
|
|
2348
|
-
|
|
2378
|
+
N = N.rightJoin(P, c);
|
|
2349
2379
|
break;
|
|
2350
2380
|
case "full":
|
|
2351
|
-
|
|
2381
|
+
N = N.fullJoin(P, c);
|
|
2352
2382
|
break;
|
|
2353
2383
|
}
|
|
2354
2384
|
} catch {
|
|
2355
2385
|
}
|
|
2356
2386
|
}
|
|
2357
|
-
if (I.where &&
|
|
2387
|
+
if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
|
|
2358
2388
|
for (const o of E.joinCubes) {
|
|
2359
2389
|
if (S.get(o.cube.name))
|
|
2360
2390
|
continue;
|
|
2361
2391
|
const P = o.cube.sql(A);
|
|
2362
|
-
P.where &&
|
|
2392
|
+
P.where && O.push(P.where);
|
|
2363
2393
|
}
|
|
2364
2394
|
const s = this.queryBuilder.buildWhereConditions(
|
|
2365
2395
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2369,11 +2399,11 @@ class CE {
|
|
|
2369
2399
|
E
|
|
2370
2400
|
// Pass the queryPlan to handle CTE scenarios
|
|
2371
2401
|
);
|
|
2372
|
-
if (s.length > 0 &&
|
|
2373
|
-
const o =
|
|
2374
|
-
|
|
2402
|
+
if (s.length > 0 && O.push(...s), O.length > 0) {
|
|
2403
|
+
const o = O.length === 1 ? O[0] : p(...O);
|
|
2404
|
+
N = N.where(o);
|
|
2375
2405
|
}
|
|
2376
|
-
const
|
|
2406
|
+
const r = this.queryBuilder.buildGroupByFields(
|
|
2377
2407
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
2378
2408
|
// Single cube
|
|
2379
2409
|
T,
|
|
@@ -2381,8 +2411,8 @@ class CE {
|
|
|
2381
2411
|
E
|
|
2382
2412
|
// Pass the queryPlan to handle CTE scenarios
|
|
2383
2413
|
);
|
|
2384
|
-
|
|
2385
|
-
const
|
|
2414
|
+
r.length > 0 && (N = N.groupBy(...r));
|
|
2415
|
+
const L = this.queryBuilder.buildHavingConditions(
|
|
2386
2416
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
2387
2417
|
// Single cube
|
|
2388
2418
|
T,
|
|
@@ -2390,12 +2420,12 @@ class CE {
|
|
|
2390
2420
|
E
|
|
2391
2421
|
// Pass the queryPlan to handle CTE scenarios
|
|
2392
2422
|
);
|
|
2393
|
-
if (
|
|
2394
|
-
const o =
|
|
2395
|
-
|
|
2423
|
+
if (L.length > 0) {
|
|
2424
|
+
const o = L.length === 1 ? L[0] : p(...L);
|
|
2425
|
+
N = N.having(o);
|
|
2396
2426
|
}
|
|
2397
|
-
const
|
|
2398
|
-
return
|
|
2427
|
+
const i = this.queryBuilder.buildOrderBy(T);
|
|
2428
|
+
return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, T), N;
|
|
2399
2429
|
}
|
|
2400
2430
|
/**
|
|
2401
2431
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -2441,36 +2471,36 @@ class CE {
|
|
|
2441
2471
|
const A = {}, e = {}, S = {}, I = [E.primaryCube];
|
|
2442
2472
|
if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), T.measures)
|
|
2443
2473
|
for (const t of T.measures) {
|
|
2444
|
-
const [C,
|
|
2445
|
-
if (
|
|
2446
|
-
const s =
|
|
2474
|
+
const [C, O] = t.split("."), N = I.find((s) => s.name === C);
|
|
2475
|
+
if (N && N.measures[O]) {
|
|
2476
|
+
const s = N.measures[O];
|
|
2447
2477
|
A[t] = {
|
|
2448
|
-
title: s.title ||
|
|
2449
|
-
shortTitle: s.title ||
|
|
2478
|
+
title: s.title || O,
|
|
2479
|
+
shortTitle: s.title || O,
|
|
2450
2480
|
type: s.type
|
|
2451
2481
|
};
|
|
2452
2482
|
}
|
|
2453
2483
|
}
|
|
2454
2484
|
if (T.dimensions)
|
|
2455
2485
|
for (const t of T.dimensions) {
|
|
2456
|
-
const [C,
|
|
2457
|
-
if (
|
|
2458
|
-
const s =
|
|
2486
|
+
const [C, O] = t.split("."), N = I.find((s) => s.name === C);
|
|
2487
|
+
if (N && N.dimensions[O]) {
|
|
2488
|
+
const s = N.dimensions[O];
|
|
2459
2489
|
e[t] = {
|
|
2460
|
-
title: s.title ||
|
|
2461
|
-
shortTitle: s.title ||
|
|
2490
|
+
title: s.title || O,
|
|
2491
|
+
shortTitle: s.title || O,
|
|
2462
2492
|
type: s.type
|
|
2463
2493
|
};
|
|
2464
2494
|
}
|
|
2465
2495
|
}
|
|
2466
2496
|
if (T.timeDimensions)
|
|
2467
2497
|
for (const t of T.timeDimensions) {
|
|
2468
|
-
const [C,
|
|
2469
|
-
if (
|
|
2470
|
-
const s =
|
|
2498
|
+
const [C, O] = t.dimension.split("."), N = I.find((s) => s.name === C);
|
|
2499
|
+
if (N && N.dimensions && N.dimensions[O]) {
|
|
2500
|
+
const s = N.dimensions[O];
|
|
2471
2501
|
S[t.dimension] = {
|
|
2472
|
-
title: s.title ||
|
|
2473
|
-
shortTitle: s.title ||
|
|
2502
|
+
title: s.title || O,
|
|
2503
|
+
shortTitle: s.title || O,
|
|
2474
2504
|
type: s.type,
|
|
2475
2505
|
granularity: t.granularity
|
|
2476
2506
|
};
|
|
@@ -2484,7 +2514,7 @@ class CE {
|
|
|
2484
2514
|
};
|
|
2485
2515
|
}
|
|
2486
2516
|
}
|
|
2487
|
-
const
|
|
2517
|
+
const _ = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.replace(/ +/g, " ").trim(), rR = (R) => ({
|
|
2488
2518
|
type: "mandatory_block",
|
|
2489
2519
|
items: XE(R, 0)[0]
|
|
2490
2520
|
}), XE = (R, E, T) => {
|
|
@@ -2549,23 +2579,23 @@ const L = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.repl
|
|
|
2549
2579
|
T.push(A + e);
|
|
2550
2580
|
return T;
|
|
2551
2581
|
};
|
|
2552
|
-
var
|
|
2582
|
+
var D;
|
|
2553
2583
|
(function(R) {
|
|
2554
2584
|
R.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", R.IDENTIFIER = "IDENTIFIER", R.STRING = "STRING", R.VARIABLE = "VARIABLE", R.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", R.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", R.RESERVED_KEYWORD = "RESERVED_KEYWORD", R.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", R.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", R.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", R.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", R.RESERVED_CLAUSE = "RESERVED_CLAUSE", R.RESERVED_SELECT = "RESERVED_SELECT", R.RESERVED_JOIN = "RESERVED_JOIN", R.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", R.ARRAY_KEYWORD = "ARRAY_KEYWORD", R.CASE = "CASE", R.END = "END", R.WHEN = "WHEN", R.ELSE = "ELSE", R.THEN = "THEN", R.LIMIT = "LIMIT", R.BETWEEN = "BETWEEN", R.AND = "AND", R.OR = "OR", R.XOR = "XOR", R.OPERATOR = "OPERATOR", R.COMMA = "COMMA", R.ASTERISK = "ASTERISK", R.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", R.OPEN_PAREN = "OPEN_PAREN", R.CLOSE_PAREN = "CLOSE_PAREN", R.LINE_COMMENT = "LINE_COMMENT", R.BLOCK_COMMENT = "BLOCK_COMMENT", R.DISABLE_COMMENT = "DISABLE_COMMENT", R.NUMBER = "NUMBER", R.NAMED_PARAMETER = "NAMED_PARAMETER", R.QUOTED_PARAMETER = "QUOTED_PARAMETER", R.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", R.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", R.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", R.DELIMITER = "DELIMITER", R.EOF = "EOF";
|
|
2555
|
-
})(
|
|
2585
|
+
})(D = D || (D = {}));
|
|
2556
2586
|
const FT = (R) => ({
|
|
2557
|
-
type:
|
|
2587
|
+
type: D.EOF,
|
|
2558
2588
|
raw: "«EOF»",
|
|
2559
2589
|
text: "«EOF»",
|
|
2560
2590
|
start: R
|
|
2561
2591
|
}), v = FT(1 / 0), w = (R) => (E) => E.type === R.type && E.text === R.text, y = {
|
|
2562
|
-
ARRAY: w({ text: "ARRAY", type:
|
|
2563
|
-
BY: w({ text: "BY", type:
|
|
2564
|
-
SET: w({ text: "SET", type:
|
|
2565
|
-
STRUCT: w({ text: "STRUCT", type:
|
|
2566
|
-
WINDOW: w({ text: "WINDOW", type:
|
|
2567
|
-
VALUES: w({ text: "VALUES", type:
|
|
2568
|
-
}, mT = (R) => R ===
|
|
2592
|
+
ARRAY: w({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
|
|
2593
|
+
BY: w({ text: "BY", type: D.RESERVED_KEYWORD }),
|
|
2594
|
+
SET: w({ text: "SET", type: D.RESERVED_CLAUSE }),
|
|
2595
|
+
STRUCT: w({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
|
|
2596
|
+
WINDOW: w({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
|
|
2597
|
+
VALUES: w({ text: "VALUES", type: D.RESERVED_CLAUSE })
|
|
2598
|
+
}, mT = (R) => R === D.RESERVED_DATA_TYPE || R === D.RESERVED_KEYWORD || R === D.RESERVED_FUNCTION_NAME || R === D.RESERVED_KEYWORD_PHRASE || R === D.RESERVED_DATA_TYPE_PHRASE || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.ARRAY_KEYWORD || R === D.CASE || R === D.END || R === D.WHEN || R === D.ELSE || R === D.THEN || R === D.LIMIT || R === D.BETWEEN || R === D.AND || R === D.OR || R === D.XOR, PR = (R) => R === D.AND || R === D.OR || R === D.XOR, MR = [
|
|
2569
2599
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
2570
2600
|
"KEYS.NEW_KEYSET",
|
|
2571
2601
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -3242,7 +3272,7 @@ const FT = (R) => ({
|
|
|
3242
3272
|
"STRUCT",
|
|
3243
3273
|
"TIME",
|
|
3244
3274
|
"TIMEZONE"
|
|
3245
|
-
], GR =
|
|
3275
|
+
], GR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = _([
|
|
3246
3276
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
3247
3277
|
"WITH [RECURSIVE]",
|
|
3248
3278
|
"FROM",
|
|
@@ -3271,9 +3301,9 @@ const FT = (R) => ({
|
|
|
3271
3301
|
"WITH CONNECTION",
|
|
3272
3302
|
"WITH PARTITION COLUMNS",
|
|
3273
3303
|
"REMOTE WITH CONNECTION"
|
|
3274
|
-
]), ZE =
|
|
3304
|
+
]), ZE = _([
|
|
3275
3305
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3276
|
-
]), LE =
|
|
3306
|
+
]), LE = _([
|
|
3277
3307
|
// - create:
|
|
3278
3308
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
3279
3309
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -3361,15 +3391,15 @@ const FT = (R) => ({
|
|
|
3361
3391
|
"ASSERT",
|
|
3362
3392
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
3363
3393
|
"EXPORT DATA"
|
|
3364
|
-
]), uR =
|
|
3394
|
+
]), uR = _([
|
|
3365
3395
|
"UNION {ALL | DISTINCT}",
|
|
3366
3396
|
"EXCEPT DISTINCT",
|
|
3367
3397
|
"INTERSECT DISTINCT"
|
|
3368
|
-
]), HR =
|
|
3398
|
+
]), HR = _([
|
|
3369
3399
|
"JOIN",
|
|
3370
3400
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3371
3401
|
"{INNER | CROSS} JOIN"
|
|
3372
|
-
]), BR =
|
|
3402
|
+
]), BR = _([
|
|
3373
3403
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
3374
3404
|
"TABLESAMPLE SYSTEM",
|
|
3375
3405
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -3380,7 +3410,7 @@ const FT = (R) => ({
|
|
|
3380
3410
|
"{ROWS | RANGE} BETWEEN",
|
|
3381
3411
|
// comparison operator
|
|
3382
3412
|
"IS [NOT] DISTINCT FROM"
|
|
3383
|
-
]), dR =
|
|
3413
|
+
]), dR = _([]), FR = {
|
|
3384
3414
|
name: "bigquery",
|
|
3385
3415
|
tokenizerOptions: {
|
|
3386
3416
|
reservedSelect: GR,
|
|
@@ -3421,7 +3451,7 @@ function mR(R) {
|
|
|
3421
3451
|
}
|
|
3422
3452
|
function pR(R) {
|
|
3423
3453
|
let E = v;
|
|
3424
|
-
return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type:
|
|
3454
|
+
return R.map((T) => T.text === "OFFSET" && E.text === "[" ? (E = T, Object.assign(Object.assign({}, T), { type: D.RESERVED_FUNCTION_NAME })) : (E = T, T));
|
|
3425
3455
|
}
|
|
3426
3456
|
function YR(R) {
|
|
3427
3457
|
var E;
|
|
@@ -3431,7 +3461,7 @@ function YR(R) {
|
|
|
3431
3461
|
if ((y.ARRAY(e) || y.STRUCT(e)) && ((E = R[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
3432
3462
|
const S = hR(R, A + 1), I = R.slice(A, S + 1);
|
|
3433
3463
|
T.push({
|
|
3434
|
-
type:
|
|
3464
|
+
type: D.IDENTIFIER,
|
|
3435
3465
|
raw: I.map(qE("raw")).join(""),
|
|
3436
3466
|
text: I.map(qE("text")).join(""),
|
|
3437
3467
|
start: e.start
|
|
@@ -3441,7 +3471,7 @@ function YR(R) {
|
|
|
3441
3471
|
}
|
|
3442
3472
|
return T;
|
|
3443
3473
|
}
|
|
3444
|
-
const qE = (R) => (E) => E.type ===
|
|
3474
|
+
const qE = (R) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[R] + " " : E[R];
|
|
3445
3475
|
function hR(R, E) {
|
|
3446
3476
|
let T = 0;
|
|
3447
3477
|
for (let A = E; A < R.length; A++) {
|
|
@@ -4214,7 +4244,7 @@ const fR = [
|
|
|
4214
4244
|
"VARBINARY",
|
|
4215
4245
|
"VARCHAR",
|
|
4216
4246
|
"VARGRAPHIC"
|
|
4217
|
-
], XR =
|
|
4247
|
+
], XR = _(["SELECT [ALL | DISTINCT]"]), bR = _([
|
|
4218
4248
|
// queries
|
|
4219
4249
|
"WITH",
|
|
4220
4250
|
"FROM",
|
|
@@ -4243,9 +4273,9 @@ const fR = [
|
|
|
4243
4273
|
"WHEN [NOT] MATCHED [THEN]",
|
|
4244
4274
|
"UPDATE SET",
|
|
4245
4275
|
"INSERT"
|
|
4246
|
-
]), jE =
|
|
4276
|
+
]), jE = _([
|
|
4247
4277
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
4248
|
-
]), _E =
|
|
4278
|
+
]), _E = _([
|
|
4249
4279
|
// - create:
|
|
4250
4280
|
"CREATE [OR REPLACE] VIEW",
|
|
4251
4281
|
// - update:
|
|
@@ -4448,16 +4478,16 @@ const fR = [
|
|
|
4448
4478
|
"TRANSFER OWNERSHIP OF",
|
|
4449
4479
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
4450
4480
|
"WHILE"
|
|
4451
|
-
]), yR =
|
|
4481
|
+
]), yR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = _([
|
|
4452
4482
|
"JOIN",
|
|
4453
4483
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4454
4484
|
"{INNER | CROSS} JOIN"
|
|
4455
|
-
]), $R =
|
|
4485
|
+
]), $R = _([
|
|
4456
4486
|
"ON DELETE",
|
|
4457
4487
|
"ON UPDATE",
|
|
4458
4488
|
"SET NULL",
|
|
4459
4489
|
"{ROWS | RANGE} BETWEEN"
|
|
4460
|
-
]), gR =
|
|
4490
|
+
]), gR = _([]), wR = {
|
|
4461
4491
|
name: "db2",
|
|
4462
4492
|
tokenizerOptions: {
|
|
4463
4493
|
reservedSelect: XR,
|
|
@@ -5368,7 +5398,7 @@ const fR = [
|
|
|
5368
5398
|
"VARCHAR",
|
|
5369
5399
|
"VARGRAPHIC",
|
|
5370
5400
|
"XML"
|
|
5371
|
-
], QR =
|
|
5401
|
+
], QR = _(["SELECT [ALL | DISTINCT]"]), ZR = _([
|
|
5372
5402
|
// queries
|
|
5373
5403
|
"WITH [RECURSIVE]",
|
|
5374
5404
|
"INTO",
|
|
@@ -5398,7 +5428,7 @@ const fR = [
|
|
|
5398
5428
|
"INSERT",
|
|
5399
5429
|
// Data definition - table
|
|
5400
5430
|
"FOR SYSTEM NAME"
|
|
5401
|
-
]), kE =
|
|
5431
|
+
]), kE = _(["CREATE [OR REPLACE] TABLE"]), rE = _([
|
|
5402
5432
|
// - create:
|
|
5403
5433
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
5404
5434
|
// - update:
|
|
@@ -5494,17 +5524,17 @@ const fR = [
|
|
|
5494
5524
|
"TAG",
|
|
5495
5525
|
"TRANSFER OWNERSHIP OF",
|
|
5496
5526
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
5497
|
-
]), qR =
|
|
5527
|
+
]), qR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = _([
|
|
5498
5528
|
"JOIN",
|
|
5499
5529
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5500
5530
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
5501
5531
|
"{INNER | CROSS} JOIN"
|
|
5502
|
-
]), kR =
|
|
5532
|
+
]), kR = _([
|
|
5503
5533
|
"ON DELETE",
|
|
5504
5534
|
"ON UPDATE",
|
|
5505
5535
|
"SET NULL",
|
|
5506
5536
|
"{ROWS | RANGE} BETWEEN"
|
|
5507
|
-
]), zR =
|
|
5537
|
+
]), zR = _([]), EA = {
|
|
5508
5538
|
name: "db2i",
|
|
5509
5539
|
tokenizerOptions: {
|
|
5510
5540
|
reservedSelect: QR,
|
|
@@ -6357,7 +6387,7 @@ const fR = [
|
|
|
6357
6387
|
"UUID",
|
|
6358
6388
|
"VARBINARY",
|
|
6359
6389
|
"VARCHAR"
|
|
6360
|
-
], eA =
|
|
6390
|
+
], eA = _(["SELECT [ALL | DISTINCT]"]), SA = _([
|
|
6361
6391
|
// queries
|
|
6362
6392
|
"WITH [RECURSIVE]",
|
|
6363
6393
|
"FROM",
|
|
@@ -6381,9 +6411,9 @@ const fR = [
|
|
|
6381
6411
|
"SET",
|
|
6382
6412
|
// other:
|
|
6383
6413
|
"RETURNING"
|
|
6384
|
-
]), zE =
|
|
6414
|
+
]), zE = _([
|
|
6385
6415
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
6386
|
-
]), nE =
|
|
6416
|
+
]), nE = _([
|
|
6387
6417
|
// TABLE
|
|
6388
6418
|
// - update:
|
|
6389
6419
|
"UPDATE",
|
|
@@ -6461,11 +6491,11 @@ const fR = [
|
|
|
6461
6491
|
"PREPARE",
|
|
6462
6492
|
"EXECUTE",
|
|
6463
6493
|
"DEALLOCATE [PREPARE]"
|
|
6464
|
-
]), IA =
|
|
6494
|
+
]), IA = _([
|
|
6465
6495
|
"UNION [ALL | BY NAME]",
|
|
6466
6496
|
"EXCEPT [ALL]",
|
|
6467
6497
|
"INTERSECT [ALL]"
|
|
6468
|
-
]), OA =
|
|
6498
|
+
]), OA = _([
|
|
6469
6499
|
"JOIN",
|
|
6470
6500
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6471
6501
|
"{INNER | CROSS} JOIN",
|
|
@@ -6474,11 +6504,11 @@ const fR = [
|
|
|
6474
6504
|
"POSITIONAL JOIN",
|
|
6475
6505
|
"ANTI JOIN",
|
|
6476
6506
|
"SEMI JOIN"
|
|
6477
|
-
]), NA =
|
|
6507
|
+
]), NA = _([
|
|
6478
6508
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
6479
6509
|
"SIMILAR TO",
|
|
6480
6510
|
"IS [NOT] DISTINCT FROM"
|
|
6481
|
-
]), tA =
|
|
6511
|
+
]), tA = _(["TIMESTAMP WITH TIME ZONE"]), sA = {
|
|
6482
6512
|
name: "duckdb",
|
|
6483
6513
|
tokenizerOptions: {
|
|
6484
6514
|
reservedSelect: eA,
|
|
@@ -7098,7 +7128,7 @@ const fR = [
|
|
|
7098
7128
|
"STRUCT",
|
|
7099
7129
|
"TIMESTAMP",
|
|
7100
7130
|
"VARCHAR"
|
|
7101
|
-
], rA =
|
|
7131
|
+
], rA = _(["SELECT [ALL | DISTINCT]"]), nA = _([
|
|
7102
7132
|
// queries
|
|
7103
7133
|
"WITH",
|
|
7104
7134
|
"FROM",
|
|
@@ -7132,9 +7162,9 @@ const fR = [
|
|
|
7132
7162
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
7133
7163
|
"LOAD DATA [LOCAL] INPATH",
|
|
7134
7164
|
"[OVERWRITE] INTO TABLE"
|
|
7135
|
-
]), ET =
|
|
7165
|
+
]), ET = _([
|
|
7136
7166
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
7137
|
-
]), iE =
|
|
7167
|
+
]), iE = _([
|
|
7138
7168
|
// - create:
|
|
7139
7169
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
7140
7170
|
// - update:
|
|
@@ -7159,13 +7189,13 @@ const fR = [
|
|
|
7159
7189
|
"STORED AS",
|
|
7160
7190
|
"STORED BY",
|
|
7161
7191
|
"ROW FORMAT"
|
|
7162
|
-
]), iA =
|
|
7192
|
+
]), iA = _(["UNION [ALL | DISTINCT]"]), aA = _([
|
|
7163
7193
|
"JOIN",
|
|
7164
7194
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
7165
7195
|
"{INNER | CROSS} JOIN",
|
|
7166
7196
|
// non-standard joins
|
|
7167
7197
|
"LEFT SEMI JOIN"
|
|
7168
|
-
]), oA =
|
|
7198
|
+
]), oA = _(["{ROWS | RANGE} BETWEEN"]), DA = _([]), PA = {
|
|
7169
7199
|
name: "hive",
|
|
7170
7200
|
tokenizerOptions: {
|
|
7171
7201
|
reservedSelect: rA,
|
|
@@ -7192,9 +7222,9 @@ function AE(R) {
|
|
|
7192
7222
|
return R.map((E, T) => {
|
|
7193
7223
|
const A = R[T + 1] || v;
|
|
7194
7224
|
if (y.SET(E) && A.text === "(")
|
|
7195
|
-
return Object.assign(Object.assign({}, E), { type:
|
|
7225
|
+
return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
|
|
7196
7226
|
const e = R[T - 1] || v;
|
|
7197
|
-
return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type:
|
|
7227
|
+
return y.VALUES(E) && e.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
|
|
7198
7228
|
});
|
|
7199
7229
|
}
|
|
7200
7230
|
const MA = [
|
|
@@ -7703,7 +7733,7 @@ const MA = [
|
|
|
7703
7733
|
// CASE expression shorthands
|
|
7704
7734
|
"COALESCE",
|
|
7705
7735
|
"NULLIF"
|
|
7706
|
-
], GA =
|
|
7736
|
+
], GA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = _([
|
|
7707
7737
|
// queries
|
|
7708
7738
|
"WITH [RECURSIVE]",
|
|
7709
7739
|
"FROM",
|
|
@@ -7725,9 +7755,9 @@ const MA = [
|
|
|
7725
7755
|
"SET",
|
|
7726
7756
|
// other
|
|
7727
7757
|
"RETURNING"
|
|
7728
|
-
]), TT =
|
|
7758
|
+
]), TT = _([
|
|
7729
7759
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
7730
|
-
]), aE =
|
|
7760
|
+
]), aE = _([
|
|
7731
7761
|
// - create:
|
|
7732
7762
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
7733
7763
|
// - update:
|
|
@@ -7934,12 +7964,12 @@ const MA = [
|
|
|
7934
7964
|
"XA RECOVER",
|
|
7935
7965
|
"XA ROLLBACK",
|
|
7936
7966
|
"XA START"
|
|
7937
|
-
]), uA =
|
|
7967
|
+
]), uA = _([
|
|
7938
7968
|
"UNION [ALL | DISTINCT]",
|
|
7939
7969
|
"EXCEPT [ALL | DISTINCT]",
|
|
7940
7970
|
"INTERSECT [ALL | DISTINCT]",
|
|
7941
7971
|
"MINUS [ALL | DISTINCT]"
|
|
7942
|
-
]), HA =
|
|
7972
|
+
]), HA = _([
|
|
7943
7973
|
"JOIN",
|
|
7944
7974
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
7945
7975
|
"{INNER | CROSS} JOIN",
|
|
@@ -7947,12 +7977,12 @@ const MA = [
|
|
|
7947
7977
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7948
7978
|
// non-standard joins
|
|
7949
7979
|
"STRAIGHT_JOIN"
|
|
7950
|
-
]), BA =
|
|
7980
|
+
]), BA = _([
|
|
7951
7981
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7952
7982
|
"CHARACTER SET",
|
|
7953
7983
|
"{ROWS | RANGE} BETWEEN",
|
|
7954
7984
|
"IDENTIFIED BY"
|
|
7955
|
-
]), dA =
|
|
7985
|
+
]), dA = _([]), FA = {
|
|
7956
7986
|
name: "mariadb",
|
|
7957
7987
|
tokenizerOptions: {
|
|
7958
7988
|
reservedSelect: GA,
|
|
@@ -8709,7 +8739,7 @@ const MA = [
|
|
|
8709
8739
|
// 'XOR',
|
|
8710
8740
|
"YEAR",
|
|
8711
8741
|
"YEARWEEK"
|
|
8712
|
-
], hA =
|
|
8742
|
+
], hA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = _([
|
|
8713
8743
|
// queries
|
|
8714
8744
|
"WITH [RECURSIVE]",
|
|
8715
8745
|
"FROM",
|
|
@@ -8729,7 +8759,7 @@ const MA = [
|
|
|
8729
8759
|
"ON DUPLICATE KEY UPDATE",
|
|
8730
8760
|
// - update:
|
|
8731
8761
|
"SET"
|
|
8732
|
-
]), RT =
|
|
8762
|
+
]), RT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = _([
|
|
8733
8763
|
// - create:
|
|
8734
8764
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8735
8765
|
// - update:
|
|
@@ -8910,7 +8940,7 @@ const MA = [
|
|
|
8910
8940
|
"REPEAT",
|
|
8911
8941
|
"RETURN",
|
|
8912
8942
|
"WHILE"
|
|
8913
|
-
]), VA =
|
|
8943
|
+
]), VA = _(["UNION [ALL | DISTINCT]"]), WA = _([
|
|
8914
8944
|
"JOIN",
|
|
8915
8945
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8916
8946
|
"{INNER | CROSS} JOIN",
|
|
@@ -8918,12 +8948,12 @@ const MA = [
|
|
|
8918
8948
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8919
8949
|
// non-standard joins
|
|
8920
8950
|
"STRAIGHT_JOIN"
|
|
8921
|
-
]), XA =
|
|
8951
|
+
]), XA = _([
|
|
8922
8952
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8923
8953
|
"CHARACTER SET",
|
|
8924
8954
|
"{ROWS | RANGE} BETWEEN",
|
|
8925
8955
|
"IDENTIFIED BY"
|
|
8926
|
-
]), bA =
|
|
8956
|
+
]), bA = _([]), yA = {
|
|
8927
8957
|
name: "mysql",
|
|
8928
8958
|
tokenizerOptions: {
|
|
8929
8959
|
reservedSelect: hA,
|
|
@@ -9541,7 +9571,7 @@ const MA = [
|
|
|
9541
9571
|
// 'XOR',
|
|
9542
9572
|
"YEAR",
|
|
9543
9573
|
"YEARWEEK"
|
|
9544
|
-
], wA =
|
|
9574
|
+
], wA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = _([
|
|
9545
9575
|
// queries
|
|
9546
9576
|
"WITH [RECURSIVE]",
|
|
9547
9577
|
"FROM",
|
|
@@ -9561,7 +9591,7 @@ const MA = [
|
|
|
9561
9591
|
"ON DUPLICATE KEY UPDATE",
|
|
9562
9592
|
// - update:
|
|
9563
9593
|
"SET"
|
|
9564
|
-
]), AT =
|
|
9594
|
+
]), AT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = _([
|
|
9565
9595
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
9566
9596
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9567
9597
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -9676,7 +9706,7 @@ const MA = [
|
|
|
9676
9706
|
"UNLOCK TABLES",
|
|
9677
9707
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
9678
9708
|
"USE"
|
|
9679
|
-
]), xA =
|
|
9709
|
+
]), xA = _(["UNION [ALL | DISTINCT]"]), vA = _([
|
|
9680
9710
|
"JOIN",
|
|
9681
9711
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9682
9712
|
"{INNER | CROSS} JOIN",
|
|
@@ -9684,12 +9714,12 @@ const MA = [
|
|
|
9684
9714
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9685
9715
|
// non-standard joins
|
|
9686
9716
|
"STRAIGHT_JOIN"
|
|
9687
|
-
]), QA =
|
|
9717
|
+
]), QA = _([
|
|
9688
9718
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9689
9719
|
"CHARACTER SET",
|
|
9690
9720
|
"{ROWS | RANGE} BETWEEN",
|
|
9691
9721
|
"IDENTIFIED BY"
|
|
9692
|
-
]), ZA =
|
|
9722
|
+
]), ZA = _([]), qA = {
|
|
9693
9723
|
name: "tidb",
|
|
9694
9724
|
tokenizerOptions: {
|
|
9695
9725
|
reservedSelect: wA,
|
|
@@ -10187,7 +10217,7 @@ const MA = [
|
|
|
10187
10217
|
// which it actually doesn't use.
|
|
10188
10218
|
//
|
|
10189
10219
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
10190
|
-
], Ee =
|
|
10220
|
+
], Ee = _(["SELECT [ALL | DISTINCT]"]), Te = _([
|
|
10191
10221
|
// queries
|
|
10192
10222
|
"WITH",
|
|
10193
10223
|
"FROM",
|
|
@@ -10214,7 +10244,7 @@ const MA = [
|
|
|
10214
10244
|
"NEST",
|
|
10215
10245
|
"UNNEST",
|
|
10216
10246
|
"RETURNING"
|
|
10217
|
-
]), eT =
|
|
10247
|
+
]), eT = _([
|
|
10218
10248
|
// - update:
|
|
10219
10249
|
"UPDATE",
|
|
10220
10250
|
// - delete:
|
|
@@ -10254,7 +10284,7 @@ const MA = [
|
|
|
10254
10284
|
"SET CURRENT SCHEMA",
|
|
10255
10285
|
"SHOW",
|
|
10256
10286
|
"USE [PRIMARY] KEYS"
|
|
10257
|
-
]), Re =
|
|
10287
|
+
]), Re = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ae = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ee = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), Se = _([]), Ie = {
|
|
10258
10288
|
name: "n1ql",
|
|
10259
10289
|
tokenizerOptions: {
|
|
10260
10290
|
reservedSelect: Ee,
|
|
@@ -10888,7 +10918,7 @@ const MA = [
|
|
|
10888
10918
|
"PRESENTNNV",
|
|
10889
10919
|
"PRESENTV",
|
|
10890
10920
|
"PREVIOUS"
|
|
10891
|
-
], se =
|
|
10921
|
+
], se = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = _([
|
|
10892
10922
|
// queries
|
|
10893
10923
|
"WITH",
|
|
10894
10924
|
"FROM",
|
|
@@ -10912,9 +10942,9 @@ const MA = [
|
|
|
10912
10942
|
"UPDATE SET",
|
|
10913
10943
|
// other
|
|
10914
10944
|
"RETURNING"
|
|
10915
|
-
]), ST =
|
|
10945
|
+
]), ST = _([
|
|
10916
10946
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
10917
|
-
]), PE =
|
|
10947
|
+
]), PE = _([
|
|
10918
10948
|
// - create:
|
|
10919
10949
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
10920
10950
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -10942,7 +10972,7 @@ const MA = [
|
|
|
10942
10972
|
"EXCEPTION",
|
|
10943
10973
|
"LOOP",
|
|
10944
10974
|
"START WITH"
|
|
10945
|
-
]), Le =
|
|
10975
|
+
]), Le = _(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = _([
|
|
10946
10976
|
"JOIN",
|
|
10947
10977
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10948
10978
|
"{INNER | CROSS} JOIN",
|
|
@@ -10950,11 +10980,11 @@ const MA = [
|
|
|
10950
10980
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10951
10981
|
// non-standard joins
|
|
10952
10982
|
"{CROSS | OUTER} APPLY"
|
|
10953
|
-
]), re =
|
|
10983
|
+
]), re = _([
|
|
10954
10984
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10955
10985
|
"ON COMMIT",
|
|
10956
10986
|
"{ROWS | RANGE} BETWEEN"
|
|
10957
|
-
]), ne =
|
|
10987
|
+
]), ne = _([]), ie = {
|
|
10958
10988
|
name: "plsql",
|
|
10959
10989
|
tokenizerOptions: {
|
|
10960
10990
|
reservedSelect: se,
|
|
@@ -11001,7 +11031,7 @@ const MA = [
|
|
|
11001
11031
|
};
|
|
11002
11032
|
function ae(R) {
|
|
11003
11033
|
let E = v;
|
|
11004
|
-
return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type:
|
|
11034
|
+
return R.map((T) => y.SET(T) && y.BY(E) ? Object.assign(Object.assign({}, T), { type: D.RESERVED_KEYWORD }) : (mT(T.type) && (E = T), T));
|
|
11005
11035
|
}
|
|
11006
11036
|
const oe = [
|
|
11007
11037
|
// https://www.postgresql.org/docs/14/functions.html
|
|
@@ -11840,7 +11870,7 @@ const oe = [
|
|
|
11840
11870
|
"VARCHAR",
|
|
11841
11871
|
"XML",
|
|
11842
11872
|
"ZONE"
|
|
11843
|
-
], Me =
|
|
11873
|
+
], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
|
|
11844
11874
|
// queries
|
|
11845
11875
|
"WITH [RECURSIVE]",
|
|
11846
11876
|
"FROM",
|
|
@@ -11863,9 +11893,9 @@ const oe = [
|
|
|
11863
11893
|
"SET",
|
|
11864
11894
|
// other
|
|
11865
11895
|
"RETURNING"
|
|
11866
|
-
]), IT =
|
|
11896
|
+
]), IT = _([
|
|
11867
11897
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
11868
|
-
]), ME =
|
|
11898
|
+
]), ME = _([
|
|
11869
11899
|
// - create
|
|
11870
11900
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
11871
11901
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -12063,17 +12093,17 @@ const oe = [
|
|
|
12063
12093
|
"START TRANSACTION",
|
|
12064
12094
|
"UNLISTEN",
|
|
12065
12095
|
"VACUUM"
|
|
12066
|
-
]), ce =
|
|
12096
|
+
]), ce = _([
|
|
12067
12097
|
"UNION [ALL | DISTINCT]",
|
|
12068
12098
|
"EXCEPT [ALL | DISTINCT]",
|
|
12069
12099
|
"INTERSECT [ALL | DISTINCT]"
|
|
12070
|
-
]), Ge =
|
|
12100
|
+
]), Ge = _([
|
|
12071
12101
|
"JOIN",
|
|
12072
12102
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12073
12103
|
"{INNER | CROSS} JOIN",
|
|
12074
12104
|
"NATURAL [INNER] JOIN",
|
|
12075
12105
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12076
|
-
]), le =
|
|
12106
|
+
]), le = _([
|
|
12077
12107
|
"PRIMARY KEY",
|
|
12078
12108
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
12079
12109
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -12084,7 +12114,7 @@ const oe = [
|
|
|
12084
12114
|
"IS [NOT] DISTINCT FROM",
|
|
12085
12115
|
"NULLS {FIRST | LAST}",
|
|
12086
12116
|
"WITH ORDINALITY"
|
|
12087
|
-
]), ue =
|
|
12117
|
+
]), ue = _([
|
|
12088
12118
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
12089
12119
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
12090
12120
|
]), He = {
|
|
@@ -12769,7 +12799,7 @@ const oe = [
|
|
|
12769
12799
|
"TEXT",
|
|
12770
12800
|
"VARBYTE",
|
|
12771
12801
|
"VARCHAR"
|
|
12772
|
-
], me =
|
|
12802
|
+
], me = _(["SELECT [ALL | DISTINCT]"]), pe = _([
|
|
12773
12803
|
// queries
|
|
12774
12804
|
"WITH [RECURSIVE]",
|
|
12775
12805
|
"FROM",
|
|
@@ -12787,9 +12817,9 @@ const oe = [
|
|
|
12787
12817
|
"VALUES",
|
|
12788
12818
|
// - update:
|
|
12789
12819
|
"SET"
|
|
12790
|
-
]), OT =
|
|
12820
|
+
]), OT = _([
|
|
12791
12821
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
12792
|
-
]), UE =
|
|
12822
|
+
]), UE = _([
|
|
12793
12823
|
// - create:
|
|
12794
12824
|
"CREATE [OR REPLACE | MATERIALIZED] VIEW",
|
|
12795
12825
|
// - update:
|
|
@@ -12880,13 +12910,13 @@ const oe = [
|
|
|
12880
12910
|
"START TRANSACTION",
|
|
12881
12911
|
"UNLOAD",
|
|
12882
12912
|
"VACUUM"
|
|
12883
|
-
]), Ye =
|
|
12913
|
+
]), Ye = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = _([
|
|
12884
12914
|
"JOIN",
|
|
12885
12915
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12886
12916
|
"{INNER | CROSS} JOIN",
|
|
12887
12917
|
"NATURAL [INNER] JOIN",
|
|
12888
12918
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12889
|
-
]), fe =
|
|
12919
|
+
]), fe = _([
|
|
12890
12920
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12891
12921
|
"NULL AS",
|
|
12892
12922
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12894,7 +12924,7 @@ const oe = [
|
|
|
12894
12924
|
"HIVE METASTORE",
|
|
12895
12925
|
// in window specifications
|
|
12896
12926
|
"{ROWS | RANGE} BETWEEN"
|
|
12897
|
-
]), Ve =
|
|
12927
|
+
]), Ve = _([]), We = {
|
|
12898
12928
|
name: "redshift",
|
|
12899
12929
|
tokenizerOptions: {
|
|
12900
12930
|
reservedSelect: me,
|
|
@@ -13550,7 +13580,7 @@ const oe = [
|
|
|
13550
13580
|
// Shorthand functions to use in place of CASE expression
|
|
13551
13581
|
"COALESCE",
|
|
13552
13582
|
"NULLIF"
|
|
13553
|
-
], Ke =
|
|
13583
|
+
], Ke = _(["SELECT [ALL | DISTINCT]"]), $e = _([
|
|
13554
13584
|
// queries
|
|
13555
13585
|
"WITH",
|
|
13556
13586
|
"FROM",
|
|
@@ -13575,7 +13605,7 @@ const oe = [
|
|
|
13575
13605
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
13576
13606
|
"LOAD DATA [LOCAL] INPATH",
|
|
13577
13607
|
"[OVERWRITE] INTO TABLE"
|
|
13578
|
-
]), NT =
|
|
13608
|
+
]), NT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = _([
|
|
13579
13609
|
// - create:
|
|
13580
13610
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
13581
13611
|
// - drop table:
|
|
@@ -13631,11 +13661,11 @@ const oe = [
|
|
|
13631
13661
|
"SHOW TBLPROPERTIES",
|
|
13632
13662
|
"SHOW VIEWS",
|
|
13633
13663
|
"UNCACHE TABLE"
|
|
13634
|
-
]), ge =
|
|
13664
|
+
]), ge = _([
|
|
13635
13665
|
"UNION [ALL | DISTINCT]",
|
|
13636
13666
|
"EXCEPT [ALL | DISTINCT]",
|
|
13637
13667
|
"INTERSECT [ALL | DISTINCT]"
|
|
13638
|
-
]), we =
|
|
13668
|
+
]), we = _([
|
|
13639
13669
|
"JOIN",
|
|
13640
13670
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13641
13671
|
"{INNER | CROSS} JOIN",
|
|
@@ -13644,12 +13674,12 @@ const oe = [
|
|
|
13644
13674
|
// non-standard-joins
|
|
13645
13675
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
13646
13676
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
13647
|
-
]), Je =
|
|
13677
|
+
]), Je = _([
|
|
13648
13678
|
"ON DELETE",
|
|
13649
13679
|
"ON UPDATE",
|
|
13650
13680
|
"CURRENT ROW",
|
|
13651
13681
|
"{ROWS | RANGE} BETWEEN"
|
|
13652
|
-
]), xe =
|
|
13682
|
+
]), xe = _([]), ve = {
|
|
13653
13683
|
name: "spark",
|
|
13654
13684
|
tokenizerOptions: {
|
|
13655
13685
|
reservedSelect: Ke,
|
|
@@ -13683,7 +13713,7 @@ const oe = [
|
|
|
13683
13713
|
function Qe(R) {
|
|
13684
13714
|
return R.map((E, T) => {
|
|
13685
13715
|
const A = R[T - 1] || v, e = R[T + 1] || v;
|
|
13686
|
-
return y.WINDOW(E) && e.type ===
|
|
13716
|
+
return y.WINDOW(E) && e.type === D.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === D.RESERVED_KEYWORD && !(A.text === "COLLECTION" && e.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
|
|
13687
13717
|
});
|
|
13688
13718
|
}
|
|
13689
13719
|
const Ze = [
|
|
@@ -13984,7 +14014,7 @@ const Ze = [
|
|
|
13984
14014
|
"TEXT",
|
|
13985
14015
|
"VARCHAR",
|
|
13986
14016
|
"VARYING CHARACTER"
|
|
13987
|
-
], ke =
|
|
14017
|
+
], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
|
|
13988
14018
|
// queries
|
|
13989
14019
|
"WITH [RECURSIVE]",
|
|
13990
14020
|
"FROM",
|
|
@@ -14005,7 +14035,7 @@ const Ze = [
|
|
|
14005
14035
|
"SET",
|
|
14006
14036
|
// other:
|
|
14007
14037
|
"RETURNING"
|
|
14008
|
-
]), tT =
|
|
14038
|
+
]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = _([
|
|
14009
14039
|
// - create:
|
|
14010
14040
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
14011
14041
|
// - update:
|
|
@@ -14024,17 +14054,17 @@ const Ze = [
|
|
|
14024
14054
|
"RENAME TO",
|
|
14025
14055
|
// - set schema
|
|
14026
14056
|
"SET SCHEMA"
|
|
14027
|
-
]), ES =
|
|
14057
|
+
]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = _([
|
|
14028
14058
|
"JOIN",
|
|
14029
14059
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14030
14060
|
"{INNER | CROSS} JOIN",
|
|
14031
14061
|
"NATURAL [INNER] JOIN",
|
|
14032
14062
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14033
|
-
]), RS =
|
|
14063
|
+
]), RS = _([
|
|
14034
14064
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14035
14065
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14036
14066
|
"DO UPDATE"
|
|
14037
|
-
]), AS =
|
|
14067
|
+
]), AS = _([]), eS = {
|
|
14038
14068
|
name: "sqlite",
|
|
14039
14069
|
tokenizerOptions: {
|
|
14040
14070
|
reservedSelect: ke,
|
|
@@ -14396,7 +14426,7 @@ const Ze = [
|
|
|
14396
14426
|
"TIMESTAMP",
|
|
14397
14427
|
"VARBINARY",
|
|
14398
14428
|
"VARCHAR"
|
|
14399
|
-
], NS =
|
|
14429
|
+
], NS = _(["SELECT [ALL | DISTINCT]"]), tS = _([
|
|
14400
14430
|
// queries
|
|
14401
14431
|
"WITH [RECURSIVE]",
|
|
14402
14432
|
"FROM",
|
|
@@ -14415,7 +14445,7 @@ const Ze = [
|
|
|
14415
14445
|
"VALUES",
|
|
14416
14446
|
// - update:
|
|
14417
14447
|
"SET"
|
|
14418
|
-
]), sT =
|
|
14448
|
+
]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = _([
|
|
14419
14449
|
// - create:
|
|
14420
14450
|
"CREATE [RECURSIVE] VIEW",
|
|
14421
14451
|
// - update:
|
|
@@ -14440,20 +14470,20 @@ const Ze = [
|
|
|
14440
14470
|
"TRUNCATE TABLE",
|
|
14441
14471
|
// other
|
|
14442
14472
|
"SET SCHEMA"
|
|
14443
|
-
]), sS =
|
|
14473
|
+
]), sS = _([
|
|
14444
14474
|
"UNION [ALL | DISTINCT]",
|
|
14445
14475
|
"EXCEPT [ALL | DISTINCT]",
|
|
14446
14476
|
"INTERSECT [ALL | DISTINCT]"
|
|
14447
|
-
]), CS =
|
|
14477
|
+
]), CS = _([
|
|
14448
14478
|
"JOIN",
|
|
14449
14479
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14450
14480
|
"{INNER | CROSS} JOIN",
|
|
14451
14481
|
"NATURAL [INNER] JOIN",
|
|
14452
14482
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14453
|
-
]), LS =
|
|
14483
|
+
]), LS = _([
|
|
14454
14484
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14455
14485
|
"{ROWS | RANGE} BETWEEN"
|
|
14456
|
-
]), _S =
|
|
14486
|
+
]), _S = _([]), rS = {
|
|
14457
14487
|
name: "sql",
|
|
14458
14488
|
tokenizerOptions: {
|
|
14459
14489
|
reservedSelect: NS,
|
|
@@ -15187,7 +15217,7 @@ const Ze = [
|
|
|
15187
15217
|
"CODEPOINTS",
|
|
15188
15218
|
"FUNCTION",
|
|
15189
15219
|
"JSONPATH"
|
|
15190
|
-
], oS =
|
|
15220
|
+
], oS = _(["SELECT [ALL | DISTINCT]"]), DS = _([
|
|
15191
15221
|
// queries
|
|
15192
15222
|
"WITH [RECURSIVE]",
|
|
15193
15223
|
"FROM",
|
|
@@ -15215,7 +15245,7 @@ const Ze = [
|
|
|
15215
15245
|
"PATTERN",
|
|
15216
15246
|
"SUBSET",
|
|
15217
15247
|
"DEFINE"
|
|
15218
|
-
]), CT =
|
|
15248
|
+
]), CT = _(["CREATE TABLE [IF NOT EXISTS]"]), uE = _([
|
|
15219
15249
|
// - create:
|
|
15220
15250
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
15221
15251
|
// - update:
|
|
@@ -15273,21 +15303,21 @@ const Ze = [
|
|
|
15273
15303
|
"SHOW ROLE GRANTS",
|
|
15274
15304
|
"SHOW FUNCTIONS",
|
|
15275
15305
|
"SHOW SESSION"
|
|
15276
|
-
]), PS =
|
|
15306
|
+
]), PS = _([
|
|
15277
15307
|
"UNION [ALL | DISTINCT]",
|
|
15278
15308
|
"EXCEPT [ALL | DISTINCT]",
|
|
15279
15309
|
"INTERSECT [ALL | DISTINCT]"
|
|
15280
|
-
]), MS =
|
|
15310
|
+
]), MS = _([
|
|
15281
15311
|
"JOIN",
|
|
15282
15312
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15283
15313
|
"{INNER | CROSS} JOIN",
|
|
15284
15314
|
"NATURAL [INNER] JOIN",
|
|
15285
15315
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
15286
|
-
]), US =
|
|
15316
|
+
]), US = _([
|
|
15287
15317
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
15288
15318
|
// comparison operator
|
|
15289
15319
|
"IS [NOT] DISTINCT FROM"
|
|
15290
|
-
]), cS =
|
|
15320
|
+
]), cS = _([]), GS = {
|
|
15291
15321
|
name: "trino",
|
|
15292
15322
|
tokenizerOptions: {
|
|
15293
15323
|
reservedSelect: oS,
|
|
@@ -15843,7 +15873,7 @@ const Ze = [
|
|
|
15843
15873
|
"TIMESTAMP",
|
|
15844
15874
|
"VARBINARY",
|
|
15845
15875
|
"VARCHAR"
|
|
15846
|
-
], BS =
|
|
15876
|
+
], BS = _(["SELECT [ALL | DISTINCT]"]), dS = _([
|
|
15847
15877
|
// queries
|
|
15848
15878
|
"WITH",
|
|
15849
15879
|
"INTO",
|
|
@@ -15868,7 +15898,7 @@ const Ze = [
|
|
|
15868
15898
|
"MERGE [INTO]",
|
|
15869
15899
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
15870
15900
|
"UPDATE SET"
|
|
15871
|
-
]), LT =
|
|
15901
|
+
]), LT = _(["CREATE TABLE"]), HE = _([
|
|
15872
15902
|
// - create:
|
|
15873
15903
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
15874
15904
|
// - update:
|
|
@@ -16048,16 +16078,16 @@ const Ze = [
|
|
|
16048
16078
|
"XACT_ABORT",
|
|
16049
16079
|
"XML INDEX",
|
|
16050
16080
|
"XML SCHEMA COLLECTION"
|
|
16051
|
-
]), FS =
|
|
16081
|
+
]), FS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = _([
|
|
16052
16082
|
"JOIN",
|
|
16053
16083
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16054
16084
|
"{INNER | CROSS} JOIN",
|
|
16055
16085
|
// non-standard joins
|
|
16056
16086
|
"{CROSS | OUTER} APPLY"
|
|
16057
|
-
]), pS =
|
|
16087
|
+
]), pS = _([
|
|
16058
16088
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
16059
16089
|
"{ROWS | RANGE} BETWEEN"
|
|
16060
|
-
]), YS =
|
|
16090
|
+
]), YS = _([]), hS = {
|
|
16061
16091
|
name: "transactsql",
|
|
16062
16092
|
tokenizerOptions: {
|
|
16063
16093
|
reservedSelect: BS,
|
|
@@ -16643,7 +16673,7 @@ const Ze = [
|
|
|
16643
16673
|
"WEEKDAY",
|
|
16644
16674
|
"WEEKOFYEAR",
|
|
16645
16675
|
"YEAR"
|
|
16646
|
-
], XS =
|
|
16676
|
+
], XS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = _([
|
|
16647
16677
|
// queries
|
|
16648
16678
|
"WITH",
|
|
16649
16679
|
"FROM",
|
|
@@ -16665,9 +16695,9 @@ const Ze = [
|
|
|
16665
16695
|
// Data definition
|
|
16666
16696
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
16667
16697
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
16668
|
-
]), _T =
|
|
16698
|
+
]), _T = _([
|
|
16669
16699
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
16670
|
-
]), BE =
|
|
16700
|
+
]), BE = _([
|
|
16671
16701
|
// - create:
|
|
16672
16702
|
"CREATE VIEW",
|
|
16673
16703
|
// - update:
|
|
@@ -16844,25 +16874,25 @@ const Ze = [
|
|
|
16844
16874
|
"REPEAT",
|
|
16845
16875
|
"RETURN",
|
|
16846
16876
|
"WHILE"
|
|
16847
|
-
]), yS =
|
|
16877
|
+
]), yS = _([
|
|
16848
16878
|
"UNION [ALL | DISTINCT]",
|
|
16849
16879
|
"EXCEPT",
|
|
16850
16880
|
"INTERSECT",
|
|
16851
16881
|
"MINUS"
|
|
16852
|
-
]), KS =
|
|
16882
|
+
]), KS = _([
|
|
16853
16883
|
"JOIN",
|
|
16854
16884
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16855
16885
|
"{INNER | CROSS} JOIN",
|
|
16856
16886
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
16857
16887
|
// non-standard joins
|
|
16858
16888
|
"STRAIGHT_JOIN"
|
|
16859
|
-
]), $S =
|
|
16889
|
+
]), $S = _([
|
|
16860
16890
|
"ON DELETE",
|
|
16861
16891
|
"ON UPDATE",
|
|
16862
16892
|
"CHARACTER SET",
|
|
16863
16893
|
"{ROWS | RANGE} BETWEEN",
|
|
16864
16894
|
"IDENTIFIED BY"
|
|
16865
|
-
]), gS =
|
|
16895
|
+
]), gS = _([]), wS = {
|
|
16866
16896
|
name: "singlestoredb",
|
|
16867
16897
|
tokenizerOptions: {
|
|
16868
16898
|
reservedSelect: XS,
|
|
@@ -17655,7 +17685,7 @@ const Ze = [
|
|
|
17655
17685
|
"ARRAY",
|
|
17656
17686
|
"GEOGRAPHY",
|
|
17657
17687
|
"GEOMETRY"
|
|
17658
|
-
], QS =
|
|
17688
|
+
], QS = _(["SELECT [ALL | DISTINCT]"]), ZS = _([
|
|
17659
17689
|
// queries
|
|
17660
17690
|
"WITH [RECURSIVE]",
|
|
17661
17691
|
"FROM",
|
|
@@ -17683,10 +17713,10 @@ const Ze = [
|
|
|
17683
17713
|
"WHEN MATCHED [AND]",
|
|
17684
17714
|
"THEN {UPDATE SET | DELETE}",
|
|
17685
17715
|
"WHEN NOT MATCHED THEN INSERT"
|
|
17686
|
-
]), rT =
|
|
17716
|
+
]), rT = _([
|
|
17687
17717
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
17688
17718
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
17689
|
-
]), dE =
|
|
17719
|
+
]), dE = _([
|
|
17690
17720
|
// - create:
|
|
17691
17721
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
17692
17722
|
// - update:
|
|
@@ -17927,14 +17957,14 @@ const Ze = [
|
|
|
17927
17957
|
"USE SCHEMA",
|
|
17928
17958
|
"USE SECONDARY ROLES",
|
|
17929
17959
|
"USE WAREHOUSE"
|
|
17930
|
-
]), qS =
|
|
17960
|
+
]), qS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = _([
|
|
17931
17961
|
"[INNER] JOIN",
|
|
17932
17962
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17933
17963
|
"{CROSS | NATURAL} JOIN"
|
|
17934
|
-
]), kS =
|
|
17964
|
+
]), kS = _([
|
|
17935
17965
|
"{ROWS | RANGE} BETWEEN",
|
|
17936
17966
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17937
|
-
]), zS =
|
|
17967
|
+
]), zS = _([]), EI = {
|
|
17938
17968
|
name: "snowflake",
|
|
17939
17969
|
tokenizerOptions: {
|
|
17940
17970
|
reservedSelect: QS,
|
|
@@ -18163,125 +18193,125 @@ class rI {
|
|
|
18163
18193
|
var T, A, e;
|
|
18164
18194
|
return this.validRules([
|
|
18165
18195
|
{
|
|
18166
|
-
type:
|
|
18196
|
+
type: D.DISABLE_COMMENT,
|
|
18167
18197
|
regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
|
|
18168
18198
|
},
|
|
18169
18199
|
{
|
|
18170
|
-
type:
|
|
18200
|
+
type: D.BLOCK_COMMENT,
|
|
18171
18201
|
regex: E.nestedBlockComments ? new _I() : /(\/\*[^]*?\*\/)/uy
|
|
18172
18202
|
},
|
|
18173
18203
|
{
|
|
18174
|
-
type:
|
|
18204
|
+
type: D.LINE_COMMENT,
|
|
18175
18205
|
regex: SI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
|
|
18176
18206
|
},
|
|
18177
18207
|
{
|
|
18178
|
-
type:
|
|
18208
|
+
type: D.QUOTED_IDENTIFIER,
|
|
18179
18209
|
regex: DT(E.identTypes)
|
|
18180
18210
|
},
|
|
18181
18211
|
{
|
|
18182
|
-
type:
|
|
18212
|
+
type: D.NUMBER,
|
|
18183
18213
|
regex: E.underscoresInNumbers ? /(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy : /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
|
|
18184
18214
|
},
|
|
18185
18215
|
// RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
|
|
18186
18216
|
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
18187
18217
|
{
|
|
18188
|
-
type:
|
|
18218
|
+
type: D.RESERVED_KEYWORD_PHRASE,
|
|
18189
18219
|
regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
18190
18220
|
text: d
|
|
18191
18221
|
},
|
|
18192
18222
|
{
|
|
18193
|
-
type:
|
|
18223
|
+
type: D.RESERVED_DATA_TYPE_PHRASE,
|
|
18194
18224
|
regex: V((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
|
|
18195
18225
|
text: d
|
|
18196
18226
|
},
|
|
18197
18227
|
{
|
|
18198
|
-
type:
|
|
18228
|
+
type: D.CASE,
|
|
18199
18229
|
regex: /CASE\b/iuy,
|
|
18200
18230
|
text: d
|
|
18201
18231
|
},
|
|
18202
18232
|
{
|
|
18203
|
-
type:
|
|
18233
|
+
type: D.END,
|
|
18204
18234
|
regex: /END\b/iuy,
|
|
18205
18235
|
text: d
|
|
18206
18236
|
},
|
|
18207
18237
|
{
|
|
18208
|
-
type:
|
|
18238
|
+
type: D.BETWEEN,
|
|
18209
18239
|
regex: /BETWEEN\b/iuy,
|
|
18210
18240
|
text: d
|
|
18211
18241
|
},
|
|
18212
18242
|
{
|
|
18213
|
-
type:
|
|
18243
|
+
type: D.LIMIT,
|
|
18214
18244
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
18215
18245
|
text: d
|
|
18216
18246
|
},
|
|
18217
18247
|
{
|
|
18218
|
-
type:
|
|
18248
|
+
type: D.RESERVED_CLAUSE,
|
|
18219
18249
|
regex: V(E.reservedClauses, E.identChars),
|
|
18220
18250
|
text: d
|
|
18221
18251
|
},
|
|
18222
18252
|
{
|
|
18223
|
-
type:
|
|
18253
|
+
type: D.RESERVED_SELECT,
|
|
18224
18254
|
regex: V(E.reservedSelect, E.identChars),
|
|
18225
18255
|
text: d
|
|
18226
18256
|
},
|
|
18227
18257
|
{
|
|
18228
|
-
type:
|
|
18258
|
+
type: D.RESERVED_SET_OPERATION,
|
|
18229
18259
|
regex: V(E.reservedSetOperations, E.identChars),
|
|
18230
18260
|
text: d
|
|
18231
18261
|
},
|
|
18232
18262
|
{
|
|
18233
|
-
type:
|
|
18263
|
+
type: D.WHEN,
|
|
18234
18264
|
regex: /WHEN\b/iuy,
|
|
18235
18265
|
text: d
|
|
18236
18266
|
},
|
|
18237
18267
|
{
|
|
18238
|
-
type:
|
|
18268
|
+
type: D.ELSE,
|
|
18239
18269
|
regex: /ELSE\b/iuy,
|
|
18240
18270
|
text: d
|
|
18241
18271
|
},
|
|
18242
18272
|
{
|
|
18243
|
-
type:
|
|
18273
|
+
type: D.THEN,
|
|
18244
18274
|
regex: /THEN\b/iuy,
|
|
18245
18275
|
text: d
|
|
18246
18276
|
},
|
|
18247
18277
|
{
|
|
18248
|
-
type:
|
|
18278
|
+
type: D.RESERVED_JOIN,
|
|
18249
18279
|
regex: V(E.reservedJoins, E.identChars),
|
|
18250
18280
|
text: d
|
|
18251
18281
|
},
|
|
18252
18282
|
{
|
|
18253
|
-
type:
|
|
18283
|
+
type: D.AND,
|
|
18254
18284
|
regex: /AND\b/iuy,
|
|
18255
18285
|
text: d
|
|
18256
18286
|
},
|
|
18257
18287
|
{
|
|
18258
|
-
type:
|
|
18288
|
+
type: D.OR,
|
|
18259
18289
|
regex: /OR\b/iuy,
|
|
18260
18290
|
text: d
|
|
18261
18291
|
},
|
|
18262
18292
|
{
|
|
18263
|
-
type:
|
|
18293
|
+
type: D.XOR,
|
|
18264
18294
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
18265
18295
|
text: d
|
|
18266
18296
|
},
|
|
18267
18297
|
...E.operatorKeyword ? [
|
|
18268
18298
|
{
|
|
18269
|
-
type:
|
|
18299
|
+
type: D.OPERATOR,
|
|
18270
18300
|
regex: /OPERATOR *\([^)]+\)/iuy
|
|
18271
18301
|
}
|
|
18272
18302
|
] : [],
|
|
18273
18303
|
{
|
|
18274
|
-
type:
|
|
18304
|
+
type: D.RESERVED_FUNCTION_NAME,
|
|
18275
18305
|
regex: V(E.reservedFunctionNames, E.identChars),
|
|
18276
18306
|
text: d
|
|
18277
18307
|
},
|
|
18278
18308
|
{
|
|
18279
|
-
type:
|
|
18309
|
+
type: D.RESERVED_DATA_TYPE,
|
|
18280
18310
|
regex: V(E.reservedDataTypes, E.identChars),
|
|
18281
18311
|
text: d
|
|
18282
18312
|
},
|
|
18283
18313
|
{
|
|
18284
|
-
type:
|
|
18314
|
+
type: D.RESERVED_KEYWORD,
|
|
18285
18315
|
regex: V(E.reservedKeywords, E.identChars),
|
|
18286
18316
|
text: d
|
|
18287
18317
|
}
|
|
@@ -18293,26 +18323,26 @@ class rI {
|
|
|
18293
18323
|
var T, A;
|
|
18294
18324
|
return this.validRules([
|
|
18295
18325
|
{
|
|
18296
|
-
type:
|
|
18326
|
+
type: D.VARIABLE,
|
|
18297
18327
|
regex: E.variableTypes ? NI(E.variableTypes) : void 0
|
|
18298
18328
|
},
|
|
18299
|
-
{ type:
|
|
18329
|
+
{ type: D.STRING, regex: DT(E.stringTypes) },
|
|
18300
18330
|
{
|
|
18301
|
-
type:
|
|
18331
|
+
type: D.IDENTIFIER,
|
|
18302
18332
|
regex: tI(E.identChars)
|
|
18303
18333
|
},
|
|
18304
|
-
{ type:
|
|
18305
|
-
{ type:
|
|
18334
|
+
{ type: D.DELIMITER, regex: /[;]/uy },
|
|
18335
|
+
{ type: D.COMMA, regex: /[,]/y },
|
|
18306
18336
|
{
|
|
18307
|
-
type:
|
|
18337
|
+
type: D.OPEN_PAREN,
|
|
18308
18338
|
regex: iT("open", E.extraParens)
|
|
18309
18339
|
},
|
|
18310
18340
|
{
|
|
18311
|
-
type:
|
|
18341
|
+
type: D.CLOSE_PAREN,
|
|
18312
18342
|
regex: iT("close", E.extraParens)
|
|
18313
18343
|
},
|
|
18314
18344
|
{
|
|
18315
|
-
type:
|
|
18345
|
+
type: D.OPERATOR,
|
|
18316
18346
|
regex: aT([
|
|
18317
18347
|
// standard operators
|
|
18318
18348
|
"+",
|
|
@@ -18328,9 +18358,9 @@ class rI {
|
|
|
18328
18358
|
...(T = E.operators) !== null && T !== void 0 ? T : []
|
|
18329
18359
|
])
|
|
18330
18360
|
},
|
|
18331
|
-
{ type:
|
|
18361
|
+
{ type: D.ASTERISK, regex: /[*]/uy },
|
|
18332
18362
|
{
|
|
18333
|
-
type:
|
|
18363
|
+
type: D.PROPERTY_ACCESS_OPERATOR,
|
|
18334
18364
|
regex: aT([".", ...(A = E.propertyAccessOperators) !== null && A !== void 0 ? A : []])
|
|
18335
18365
|
}
|
|
18336
18366
|
]);
|
|
@@ -18348,33 +18378,33 @@ class rI {
|
|
|
18348
18378
|
};
|
|
18349
18379
|
return this.validRules([
|
|
18350
18380
|
{
|
|
18351
|
-
type:
|
|
18381
|
+
type: D.NAMED_PARAMETER,
|
|
18352
18382
|
regex: mE(C.named, fT(E.paramChars || E.identChars)),
|
|
18353
|
-
key: (
|
|
18383
|
+
key: (O) => O.slice(1)
|
|
18354
18384
|
},
|
|
18355
18385
|
{
|
|
18356
|
-
type:
|
|
18386
|
+
type: D.QUOTED_PARAMETER,
|
|
18357
18387
|
regex: mE(C.quoted, hT(E.identTypes)),
|
|
18358
|
-
key: (
|
|
18359
|
-
tokenKey:
|
|
18360
|
-
quoteChar:
|
|
18388
|
+
key: (O) => (({ tokenKey: N, quoteChar: s }) => N.replace(new RegExp(h("\\" + s), "gu"), s))({
|
|
18389
|
+
tokenKey: O.slice(2, -1),
|
|
18390
|
+
quoteChar: O.slice(-1)
|
|
18361
18391
|
})
|
|
18362
18392
|
},
|
|
18363
18393
|
{
|
|
18364
|
-
type:
|
|
18394
|
+
type: D.NUMBERED_PARAMETER,
|
|
18365
18395
|
regex: mE(C.numbered, "[0-9]+"),
|
|
18366
|
-
key: (
|
|
18396
|
+
key: (O) => O.slice(1)
|
|
18367
18397
|
},
|
|
18368
18398
|
{
|
|
18369
|
-
type:
|
|
18399
|
+
type: D.POSITIONAL_PARAMETER,
|
|
18370
18400
|
regex: C.positional ? /[?]/y : void 0
|
|
18371
18401
|
},
|
|
18372
|
-
...C.custom.map((
|
|
18373
|
-
var
|
|
18402
|
+
...C.custom.map((O) => {
|
|
18403
|
+
var N;
|
|
18374
18404
|
return {
|
|
18375
|
-
type:
|
|
18376
|
-
regex: K(
|
|
18377
|
-
key: (
|
|
18405
|
+
type: D.CUSTOM_PARAMETER,
|
|
18406
|
+
regex: K(O.regex),
|
|
18407
|
+
key: (N = O.key) !== null && N !== void 0 ? N : ((s) => s)
|
|
18378
18408
|
};
|
|
18379
18409
|
})
|
|
18380
18410
|
]);
|
|
@@ -18436,195 +18466,195 @@ function UI() {
|
|
|
18436
18466
|
(function(E, T) {
|
|
18437
18467
|
R.exports ? R.exports = T() : E.nearley = T();
|
|
18438
18468
|
})(MI, function() {
|
|
18439
|
-
function E(
|
|
18440
|
-
return this.id = ++E.highestId, this.name =
|
|
18469
|
+
function E(O, N, s) {
|
|
18470
|
+
return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = s, this;
|
|
18441
18471
|
}
|
|
18442
|
-
E.highestId = 0, E.prototype.toString = function(
|
|
18443
|
-
var
|
|
18444
|
-
return this.name + " → " +
|
|
18472
|
+
E.highestId = 0, E.prototype.toString = function(O) {
|
|
18473
|
+
var N = typeof O > "u" ? this.symbols.map(C).join(" ") : this.symbols.slice(0, O).map(C).join(" ") + " ● " + this.symbols.slice(O).map(C).join(" ");
|
|
18474
|
+
return this.name + " → " + N;
|
|
18445
18475
|
};
|
|
18446
|
-
function T(
|
|
18447
|
-
this.rule =
|
|
18476
|
+
function T(O, N, s, r) {
|
|
18477
|
+
this.rule = O, this.dot = N, this.reference = s, this.data = [], this.wantedBy = r, this.isComplete = this.dot === O.symbols.length;
|
|
18448
18478
|
}
|
|
18449
18479
|
T.prototype.toString = function() {
|
|
18450
18480
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
18451
|
-
}, T.prototype.nextState = function(
|
|
18452
|
-
var
|
|
18453
|
-
return
|
|
18481
|
+
}, T.prototype.nextState = function(O) {
|
|
18482
|
+
var N = new T(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
18483
|
+
return N.left = this, N.right = O, N.isComplete && (N.data = N.build(), N.right = void 0), N;
|
|
18454
18484
|
}, T.prototype.build = function() {
|
|
18455
|
-
var
|
|
18485
|
+
var O = [], N = this;
|
|
18456
18486
|
do
|
|
18457
|
-
|
|
18458
|
-
while (
|
|
18459
|
-
return
|
|
18487
|
+
O.push(N.right.data), N = N.left;
|
|
18488
|
+
while (N.left);
|
|
18489
|
+
return O.reverse(), O;
|
|
18460
18490
|
}, T.prototype.finish = function() {
|
|
18461
18491
|
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
|
|
18462
18492
|
};
|
|
18463
|
-
function A(
|
|
18464
|
-
this.grammar =
|
|
18493
|
+
function A(O, N) {
|
|
18494
|
+
this.grammar = O, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
18465
18495
|
}
|
|
18466
|
-
A.prototype.process = function(
|
|
18467
|
-
for (var
|
|
18468
|
-
var
|
|
18469
|
-
if (
|
|
18470
|
-
if (
|
|
18471
|
-
for (var o =
|
|
18496
|
+
A.prototype.process = function(O) {
|
|
18497
|
+
for (var N = this.states, s = this.wants, r = this.completed, L = 0; L < N.length; L++) {
|
|
18498
|
+
var i = N[L];
|
|
18499
|
+
if (i.isComplete) {
|
|
18500
|
+
if (i.finish(), i.data !== I.fail) {
|
|
18501
|
+
for (var o = i.wantedBy, l = o.length; l--; ) {
|
|
18472
18502
|
var P = o[l];
|
|
18473
|
-
this.complete(P,
|
|
18503
|
+
this.complete(P, i);
|
|
18474
18504
|
}
|
|
18475
|
-
if (
|
|
18476
|
-
var c =
|
|
18477
|
-
(this.completed[c] = this.completed[c] || []).push(
|
|
18505
|
+
if (i.reference === this.index) {
|
|
18506
|
+
var c = i.rule.name;
|
|
18507
|
+
(this.completed[c] = this.completed[c] || []).push(i);
|
|
18478
18508
|
}
|
|
18479
18509
|
}
|
|
18480
18510
|
} else {
|
|
18481
|
-
var c =
|
|
18511
|
+
var c = i.rule.symbols[i.dot];
|
|
18482
18512
|
if (typeof c != "string") {
|
|
18483
|
-
this.scannable.push(
|
|
18513
|
+
this.scannable.push(i);
|
|
18484
18514
|
continue;
|
|
18485
18515
|
}
|
|
18486
18516
|
if (s[c]) {
|
|
18487
|
-
if (s[c].push(
|
|
18488
|
-
for (var M =
|
|
18517
|
+
if (s[c].push(i), r.hasOwnProperty(c))
|
|
18518
|
+
for (var M = r[c], l = 0; l < M.length; l++) {
|
|
18489
18519
|
var u = M[l];
|
|
18490
|
-
this.complete(
|
|
18520
|
+
this.complete(i, u);
|
|
18491
18521
|
}
|
|
18492
18522
|
} else
|
|
18493
|
-
s[c] = [
|
|
18523
|
+
s[c] = [i], this.predict(c);
|
|
18494
18524
|
}
|
|
18495
18525
|
}
|
|
18496
|
-
}, A.prototype.predict = function(
|
|
18497
|
-
for (var
|
|
18498
|
-
var
|
|
18499
|
-
this.states.push(
|
|
18526
|
+
}, A.prototype.predict = function(O) {
|
|
18527
|
+
for (var N = this.grammar.byName[O] || [], s = 0; s < N.length; s++) {
|
|
18528
|
+
var r = N[s], L = this.wants[O], i = new T(r, 0, this.index, L);
|
|
18529
|
+
this.states.push(i);
|
|
18500
18530
|
}
|
|
18501
|
-
}, A.prototype.complete = function(
|
|
18502
|
-
var s =
|
|
18531
|
+
}, A.prototype.complete = function(O, N) {
|
|
18532
|
+
var s = O.nextState(N);
|
|
18503
18533
|
this.states.push(s);
|
|
18504
18534
|
};
|
|
18505
|
-
function e(
|
|
18506
|
-
this.rules =
|
|
18535
|
+
function e(O, N) {
|
|
18536
|
+
this.rules = O, this.start = N || this.rules[0].name;
|
|
18507
18537
|
var s = this.byName = {};
|
|
18508
|
-
this.rules.forEach(function(
|
|
18509
|
-
s.hasOwnProperty(
|
|
18538
|
+
this.rules.forEach(function(r) {
|
|
18539
|
+
s.hasOwnProperty(r.name) || (s[r.name] = []), s[r.name].push(r);
|
|
18510
18540
|
});
|
|
18511
18541
|
}
|
|
18512
|
-
e.fromCompiled = function(
|
|
18513
|
-
var s =
|
|
18514
|
-
|
|
18515
|
-
var
|
|
18516
|
-
return new E(
|
|
18517
|
-
}),
|
|
18518
|
-
return
|
|
18542
|
+
e.fromCompiled = function(r, N) {
|
|
18543
|
+
var s = r.Lexer;
|
|
18544
|
+
r.ParserStart && (N = r.ParserStart, r = r.ParserRules);
|
|
18545
|
+
var r = r.map(function(i) {
|
|
18546
|
+
return new E(i.name, i.symbols, i.postprocess);
|
|
18547
|
+
}), L = new e(r, N);
|
|
18548
|
+
return L.lexer = s, L;
|
|
18519
18549
|
};
|
|
18520
18550
|
function S() {
|
|
18521
18551
|
this.reset("");
|
|
18522
18552
|
}
|
|
18523
|
-
S.prototype.reset = function(
|
|
18524
|
-
this.buffer =
|
|
18553
|
+
S.prototype.reset = function(O, N) {
|
|
18554
|
+
this.buffer = O, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
|
|
18525
18555
|
}, S.prototype.next = function() {
|
|
18526
18556
|
if (this.index < this.buffer.length) {
|
|
18527
|
-
var
|
|
18528
|
-
return
|
|
18529
|
-
` && (this.line += 1, this.lastLineBreak = this.index), { value:
|
|
18557
|
+
var O = this.buffer[this.index++];
|
|
18558
|
+
return O === `
|
|
18559
|
+
` && (this.line += 1, this.lastLineBreak = this.index), { value: O };
|
|
18530
18560
|
}
|
|
18531
18561
|
}, S.prototype.save = function() {
|
|
18532
18562
|
return {
|
|
18533
18563
|
line: this.line,
|
|
18534
18564
|
col: this.index - this.lastLineBreak
|
|
18535
18565
|
};
|
|
18536
|
-
}, S.prototype.formatError = function(
|
|
18566
|
+
}, S.prototype.formatError = function(O, N) {
|
|
18537
18567
|
var s = this.buffer;
|
|
18538
18568
|
if (typeof s == "string") {
|
|
18539
|
-
var
|
|
18569
|
+
var r = s.split(`
|
|
18540
18570
|
`).slice(
|
|
18541
18571
|
Math.max(0, this.line - 5),
|
|
18542
18572
|
this.line
|
|
18543
|
-
),
|
|
18573
|
+
), L = s.indexOf(`
|
|
18544
18574
|
`, this.index);
|
|
18545
|
-
|
|
18546
|
-
var
|
|
18547
|
-
return
|
|
18575
|
+
L === -1 && (L = s.length);
|
|
18576
|
+
var i = this.index - this.lastLineBreak, o = String(this.line).length;
|
|
18577
|
+
return N += " at line " + this.line + " col " + i + `:
|
|
18548
18578
|
|
|
18549
|
-
`,
|
|
18550
|
-
return l(this.line -
|
|
18579
|
+
`, N += r.map(function(P, c) {
|
|
18580
|
+
return l(this.line - r.length + c + 1, o) + " " + P;
|
|
18551
18581
|
}, this).join(`
|
|
18552
|
-
`),
|
|
18553
|
-
` + l("", o +
|
|
18554
|
-
`,
|
|
18582
|
+
`), N += `
|
|
18583
|
+
` + l("", o + i) + `^
|
|
18584
|
+
`, N;
|
|
18555
18585
|
} else
|
|
18556
|
-
return
|
|
18586
|
+
return N + " at index " + (this.index - 1);
|
|
18557
18587
|
function l(P, c) {
|
|
18558
18588
|
var M = String(P);
|
|
18559
18589
|
return Array(c - M.length + 1).join(" ") + M;
|
|
18560
18590
|
}
|
|
18561
18591
|
};
|
|
18562
|
-
function I(
|
|
18563
|
-
if (
|
|
18564
|
-
var
|
|
18592
|
+
function I(O, N, s) {
|
|
18593
|
+
if (O instanceof e)
|
|
18594
|
+
var r = O, s = N;
|
|
18565
18595
|
else
|
|
18566
|
-
var
|
|
18567
|
-
this.grammar =
|
|
18596
|
+
var r = e.fromCompiled(O, N);
|
|
18597
|
+
this.grammar = r, this.options = {
|
|
18568
18598
|
keepHistory: !1,
|
|
18569
|
-
lexer:
|
|
18599
|
+
lexer: r.lexer || new S()
|
|
18570
18600
|
};
|
|
18571
|
-
for (var
|
|
18572
|
-
this.options[
|
|
18601
|
+
for (var L in s || {})
|
|
18602
|
+
this.options[L] = s[L];
|
|
18573
18603
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
18574
|
-
var
|
|
18575
|
-
this.table = [
|
|
18604
|
+
var i = new A(r, 0);
|
|
18605
|
+
this.table = [i], i.wants[r.start] = [], i.predict(r.start), i.process(), this.current = 0;
|
|
18576
18606
|
}
|
|
18577
|
-
I.fail = {}, I.prototype.feed = function(
|
|
18578
|
-
var
|
|
18579
|
-
|
|
18607
|
+
I.fail = {}, I.prototype.feed = function(O) {
|
|
18608
|
+
var N = this.lexer;
|
|
18609
|
+
N.reset(O, this.lexerState);
|
|
18580
18610
|
for (var s; ; ) {
|
|
18581
18611
|
try {
|
|
18582
|
-
if (s =
|
|
18612
|
+
if (s = N.next(), !s)
|
|
18583
18613
|
break;
|
|
18584
18614
|
} catch (Y) {
|
|
18585
18615
|
var o = new A(this.grammar, this.current + 1);
|
|
18586
18616
|
this.table.push(o);
|
|
18587
|
-
var
|
|
18588
|
-
throw
|
|
18617
|
+
var r = new Error(this.reportLexerError(Y));
|
|
18618
|
+
throw r.offset = this.current, r.token = Y.token, r;
|
|
18589
18619
|
}
|
|
18590
|
-
var
|
|
18620
|
+
var L = this.table[this.current];
|
|
18591
18621
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
18592
|
-
var
|
|
18622
|
+
var i = this.current + 1, o = new A(this.grammar, i);
|
|
18593
18623
|
this.table.push(o);
|
|
18594
|
-
for (var l = s.text !== void 0 ? s.text : s.value, P =
|
|
18624
|
+
for (var l = s.text !== void 0 ? s.text : s.value, P = N.constructor === S ? s.value : s, c = L.scannable, M = c.length; M--; ) {
|
|
18595
18625
|
var u = c[M], H = u.rule.symbols[u.dot];
|
|
18596
18626
|
if (H.test ? H.test(P) : H.type ? H.type === s.type : H.literal === l) {
|
|
18597
|
-
var B = u.nextState({ data: P, token: s, isToken: !0, reference:
|
|
18627
|
+
var B = u.nextState({ data: P, token: s, isToken: !0, reference: i - 1 });
|
|
18598
18628
|
o.states.push(B);
|
|
18599
18629
|
}
|
|
18600
18630
|
}
|
|
18601
18631
|
if (o.process(), o.states.length === 0) {
|
|
18602
|
-
var
|
|
18603
|
-
throw
|
|
18632
|
+
var r = new Error(this.reportError(s));
|
|
18633
|
+
throw r.offset = this.current, r.token = s, r;
|
|
18604
18634
|
}
|
|
18605
|
-
this.options.keepHistory && (
|
|
18635
|
+
this.options.keepHistory && (L.lexerState = N.save()), this.current++;
|
|
18606
18636
|
}
|
|
18607
|
-
return
|
|
18608
|
-
}, I.prototype.reportLexerError = function(
|
|
18609
|
-
var
|
|
18610
|
-
return
|
|
18611
|
-
}, I.prototype.reportError = function(
|
|
18612
|
-
var
|
|
18613
|
-
return this.reportErrorCommon(s,
|
|
18614
|
-
}, I.prototype.reportErrorCommon = function(
|
|
18637
|
+
return L && (this.lexerState = N.save()), this.results = this.finish(), this;
|
|
18638
|
+
}, I.prototype.reportLexerError = function(O) {
|
|
18639
|
+
var N, s, r = O.token;
|
|
18640
|
+
return r ? (N = "input " + JSON.stringify(r.text[0]) + " (lexer error)", s = this.lexer.formatError(r, "Syntax error")) : (N = "input (lexer error)", s = O.message), this.reportErrorCommon(s, N);
|
|
18641
|
+
}, I.prototype.reportError = function(O) {
|
|
18642
|
+
var N = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), s = this.lexer.formatError(O, "Syntax error");
|
|
18643
|
+
return this.reportErrorCommon(s, N);
|
|
18644
|
+
}, I.prototype.reportErrorCommon = function(O, N) {
|
|
18615
18645
|
var s = [];
|
|
18616
|
-
s.push(
|
|
18617
|
-
var
|
|
18646
|
+
s.push(O);
|
|
18647
|
+
var r = this.table.length - 2, L = this.table[r], i = L.states.filter(function(l) {
|
|
18618
18648
|
var P = l.rule.symbols[l.dot];
|
|
18619
18649
|
return P && typeof P != "string";
|
|
18620
18650
|
});
|
|
18621
|
-
if (
|
|
18622
|
-
s.push("Unexpected " +
|
|
18623
|
-
`), this.displayStateStack(
|
|
18651
|
+
if (i.length === 0)
|
|
18652
|
+
s.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
|
|
18653
|
+
`), this.displayStateStack(L.states, s);
|
|
18624
18654
|
else {
|
|
18625
|
-
s.push("Unexpected " +
|
|
18655
|
+
s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
18626
18656
|
`);
|
|
18627
|
-
var o =
|
|
18657
|
+
var o = i.map(function(l) {
|
|
18628
18658
|
return this.buildFirstStateStack(l, []) || [l];
|
|
18629
18659
|
}, this);
|
|
18630
18660
|
o.forEach(function(l) {
|
|
@@ -18634,68 +18664,68 @@ function UI() {
|
|
|
18634
18664
|
}
|
|
18635
18665
|
return s.push(""), s.join(`
|
|
18636
18666
|
`);
|
|
18637
|
-
}, I.prototype.displayStateStack = function(
|
|
18638
|
-
for (var s,
|
|
18639
|
-
var
|
|
18640
|
-
o === s ?
|
|
18667
|
+
}, I.prototype.displayStateStack = function(O, N) {
|
|
18668
|
+
for (var s, r = 0, L = 0; L < O.length; L++) {
|
|
18669
|
+
var i = O[L], o = i.rule.toString(i.dot);
|
|
18670
|
+
o === s ? r++ : (r > 0 && N.push(" ^ " + r + " more lines identical to this"), r = 0, N.push(" " + o)), s = o;
|
|
18641
18671
|
}
|
|
18642
|
-
}, I.prototype.getSymbolDisplay = function(
|
|
18643
|
-
return t(
|
|
18644
|
-
}, I.prototype.buildFirstStateStack = function(
|
|
18645
|
-
if (
|
|
18672
|
+
}, I.prototype.getSymbolDisplay = function(O) {
|
|
18673
|
+
return t(O);
|
|
18674
|
+
}, I.prototype.buildFirstStateStack = function(O, N) {
|
|
18675
|
+
if (N.indexOf(O) !== -1)
|
|
18646
18676
|
return null;
|
|
18647
|
-
if (
|
|
18648
|
-
return [
|
|
18649
|
-
var s =
|
|
18650
|
-
return
|
|
18677
|
+
if (O.wantedBy.length === 0)
|
|
18678
|
+
return [O];
|
|
18679
|
+
var s = O.wantedBy[0], r = [O].concat(N), L = this.buildFirstStateStack(s, r);
|
|
18680
|
+
return L === null ? null : [O].concat(L);
|
|
18651
18681
|
}, I.prototype.save = function() {
|
|
18652
|
-
var
|
|
18653
|
-
return
|
|
18654
|
-
}, I.prototype.restore = function(
|
|
18655
|
-
var
|
|
18656
|
-
this.current =
|
|
18657
|
-
}, I.prototype.rewind = function(
|
|
18682
|
+
var O = this.table[this.current];
|
|
18683
|
+
return O.lexerState = this.lexerState, O;
|
|
18684
|
+
}, I.prototype.restore = function(O) {
|
|
18685
|
+
var N = O.index;
|
|
18686
|
+
this.current = N, this.table[N] = O, this.table.splice(N + 1), this.lexerState = O.lexerState, this.results = this.finish();
|
|
18687
|
+
}, I.prototype.rewind = function(O) {
|
|
18658
18688
|
if (!this.options.keepHistory)
|
|
18659
18689
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
18660
|
-
this.restore(this.table[
|
|
18690
|
+
this.restore(this.table[O]);
|
|
18661
18691
|
}, I.prototype.finish = function() {
|
|
18662
|
-
var
|
|
18663
|
-
return s.states.forEach(function(
|
|
18664
|
-
|
|
18665
|
-
}),
|
|
18666
|
-
return
|
|
18692
|
+
var O = [], N = this.grammar.start, s = this.table[this.table.length - 1];
|
|
18693
|
+
return s.states.forEach(function(r) {
|
|
18694
|
+
r.rule.name === N && r.dot === r.rule.symbols.length && r.reference === 0 && r.data !== I.fail && O.push(r);
|
|
18695
|
+
}), O.map(function(r) {
|
|
18696
|
+
return r.data;
|
|
18667
18697
|
});
|
|
18668
18698
|
};
|
|
18669
|
-
function t(
|
|
18670
|
-
var
|
|
18671
|
-
if (
|
|
18672
|
-
return
|
|
18673
|
-
if (
|
|
18674
|
-
if (
|
|
18675
|
-
return JSON.stringify(
|
|
18676
|
-
if (
|
|
18677
|
-
return "character matching " +
|
|
18678
|
-
if (
|
|
18679
|
-
return
|
|
18680
|
-
if (
|
|
18681
|
-
return "token matching " + String(
|
|
18682
|
-
throw new Error("Unknown symbol type: " +
|
|
18699
|
+
function t(O) {
|
|
18700
|
+
var N = typeof O;
|
|
18701
|
+
if (N === "string")
|
|
18702
|
+
return O;
|
|
18703
|
+
if (N === "object") {
|
|
18704
|
+
if (O.literal)
|
|
18705
|
+
return JSON.stringify(O.literal);
|
|
18706
|
+
if (O instanceof RegExp)
|
|
18707
|
+
return "character matching " + O;
|
|
18708
|
+
if (O.type)
|
|
18709
|
+
return O.type + " token";
|
|
18710
|
+
if (O.test)
|
|
18711
|
+
return "token matching " + String(O.test);
|
|
18712
|
+
throw new Error("Unknown symbol type: " + O);
|
|
18683
18713
|
}
|
|
18684
18714
|
}
|
|
18685
|
-
function C(
|
|
18686
|
-
var
|
|
18687
|
-
if (
|
|
18688
|
-
return
|
|
18689
|
-
if (
|
|
18690
|
-
if (
|
|
18691
|
-
return JSON.stringify(
|
|
18692
|
-
if (
|
|
18693
|
-
return
|
|
18694
|
-
if (
|
|
18695
|
-
return "%" +
|
|
18696
|
-
if (
|
|
18697
|
-
return "<" + String(
|
|
18698
|
-
throw new Error("Unknown symbol type: " +
|
|
18715
|
+
function C(O) {
|
|
18716
|
+
var N = typeof O;
|
|
18717
|
+
if (N === "string")
|
|
18718
|
+
return O;
|
|
18719
|
+
if (N === "object") {
|
|
18720
|
+
if (O.literal)
|
|
18721
|
+
return JSON.stringify(O.literal);
|
|
18722
|
+
if (O instanceof RegExp)
|
|
18723
|
+
return O.toString();
|
|
18724
|
+
if (O.type)
|
|
18725
|
+
return "%" + O.type;
|
|
18726
|
+
if (O.test)
|
|
18727
|
+
return "<" + String(O.test) + ">";
|
|
18728
|
+
throw new Error("Unknown symbol type: " + O);
|
|
18699
18729
|
}
|
|
18700
18730
|
}
|
|
18701
18731
|
return {
|
|
@@ -18714,39 +18744,39 @@ function lI(R) {
|
|
|
18714
18744
|
const uI = (R, E, T) => {
|
|
18715
18745
|
if (mT(R.type)) {
|
|
18716
18746
|
const A = mI(T, E);
|
|
18717
|
-
if (A && A.type ===
|
|
18718
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18747
|
+
if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
|
|
18748
|
+
return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
|
|
18719
18749
|
const e = Q(T, E);
|
|
18720
|
-
if (e && e.type ===
|
|
18721
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18750
|
+
if (e && e.type === D.PROPERTY_ACCESS_OPERATOR)
|
|
18751
|
+
return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
|
|
18722
18752
|
}
|
|
18723
18753
|
return R;
|
|
18724
18754
|
}, HI = (R, E, T) => {
|
|
18725
|
-
if (R.type ===
|
|
18755
|
+
if (R.type === D.RESERVED_FUNCTION_NAME) {
|
|
18726
18756
|
const A = Q(T, E);
|
|
18727
18757
|
if (!A || !WT(A))
|
|
18728
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18758
|
+
return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
|
|
18729
18759
|
}
|
|
18730
18760
|
return R;
|
|
18731
18761
|
}, BI = (R, E, T) => {
|
|
18732
|
-
if (R.type ===
|
|
18762
|
+
if (R.type === D.RESERVED_DATA_TYPE) {
|
|
18733
18763
|
const A = Q(T, E);
|
|
18734
18764
|
if (A && WT(A))
|
|
18735
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18765
|
+
return Object.assign(Object.assign({}, R), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
18736
18766
|
}
|
|
18737
18767
|
return R;
|
|
18738
18768
|
}, dI = (R, E, T) => {
|
|
18739
|
-
if (R.type ===
|
|
18769
|
+
if (R.type === D.IDENTIFIER) {
|
|
18740
18770
|
const A = Q(T, E);
|
|
18741
18771
|
if (A && XT(A))
|
|
18742
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18772
|
+
return Object.assign(Object.assign({}, R), { type: D.ARRAY_IDENTIFIER });
|
|
18743
18773
|
}
|
|
18744
18774
|
return R;
|
|
18745
18775
|
}, FI = (R, E, T) => {
|
|
18746
|
-
if (R.type ===
|
|
18776
|
+
if (R.type === D.RESERVED_DATA_TYPE) {
|
|
18747
18777
|
const A = Q(T, E);
|
|
18748
18778
|
if (A && XT(A))
|
|
18749
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18779
|
+
return Object.assign(Object.assign({}, R), { type: D.ARRAY_KEYWORD });
|
|
18750
18780
|
}
|
|
18751
18781
|
return R;
|
|
18752
18782
|
}, mI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
|
|
@@ -18754,7 +18784,7 @@ const uI = (R, E, T) => {
|
|
|
18754
18784
|
for (; R[E + A * T] && pI(R[E + A * T]); )
|
|
18755
18785
|
A++;
|
|
18756
18786
|
return R[E + A * T];
|
|
18757
|
-
}, WT = (R) => R.type ===
|
|
18787
|
+
}, WT = (R) => R.type === D.OPEN_PAREN && R.text === "(", XT = (R) => R.type === D.OPEN_PAREN && R.text === "[", pI = (R) => R.type === D.BLOCK_COMMENT || R.type === D.LINE_COMMENT;
|
|
18758
18788
|
class bT {
|
|
18759
18789
|
constructor(E) {
|
|
18760
18790
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
@@ -18772,7 +18802,7 @@ class bT {
|
|
|
18772
18802
|
return `Parse error at token: ${E.text} at line ${T} column ${A}`;
|
|
18773
18803
|
}
|
|
18774
18804
|
has(E) {
|
|
18775
|
-
return E in
|
|
18805
|
+
return E in D;
|
|
18776
18806
|
}
|
|
18777
18807
|
}
|
|
18778
18808
|
var U;
|
|
@@ -18822,7 +18852,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
|
|
|
18822
18852
|
postprocess: ([R, [E]]) => ({
|
|
18823
18853
|
type: U.statement,
|
|
18824
18854
|
children: R,
|
|
18825
|
-
hasSemicolon: E.type ===
|
|
18855
|
+
hasSemicolon: E.type === D.DELIMITER
|
|
18826
18856
|
})
|
|
18827
18857
|
},
|
|
18828
18858
|
{ name: "expressions_or_clauses$ebnf$1", symbols: [] },
|
|
@@ -19216,10 +19246,10 @@ ${JSON.stringify(I, void 0, 2)}`);
|
|
|
19216
19246
|
}
|
|
19217
19247
|
};
|
|
19218
19248
|
}
|
|
19219
|
-
var
|
|
19249
|
+
var a;
|
|
19220
19250
|
(function(R) {
|
|
19221
19251
|
R[R.SPACE = 0] = "SPACE", R[R.NO_SPACE = 1] = "NO_SPACE", R[R.NO_NEWLINE = 2] = "NO_NEWLINE", R[R.NEWLINE = 3] = "NEWLINE", R[R.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", R[R.INDENT = 5] = "INDENT", R[R.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
19222
|
-
})(
|
|
19252
|
+
})(a = a || (a = {}));
|
|
19223
19253
|
class yT {
|
|
19224
19254
|
constructor(E) {
|
|
19225
19255
|
this.indentation = E, this.items = [];
|
|
@@ -19230,26 +19260,26 @@ class yT {
|
|
|
19230
19260
|
add(...E) {
|
|
19231
19261
|
for (const T of E)
|
|
19232
19262
|
switch (T) {
|
|
19233
|
-
case
|
|
19234
|
-
this.items.push(
|
|
19263
|
+
case a.SPACE:
|
|
19264
|
+
this.items.push(a.SPACE);
|
|
19235
19265
|
break;
|
|
19236
|
-
case
|
|
19266
|
+
case a.NO_SPACE:
|
|
19237
19267
|
this.trimHorizontalWhitespace();
|
|
19238
19268
|
break;
|
|
19239
|
-
case
|
|
19269
|
+
case a.NO_NEWLINE:
|
|
19240
19270
|
this.trimWhitespace();
|
|
19241
19271
|
break;
|
|
19242
|
-
case
|
|
19243
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
19272
|
+
case a.NEWLINE:
|
|
19273
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
|
|
19244
19274
|
break;
|
|
19245
|
-
case
|
|
19246
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
19275
|
+
case a.MANDATORY_NEWLINE:
|
|
19276
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
|
|
19247
19277
|
break;
|
|
19248
|
-
case
|
|
19278
|
+
case a.INDENT:
|
|
19249
19279
|
this.addIndentation();
|
|
19250
19280
|
break;
|
|
19251
|
-
case
|
|
19252
|
-
this.items.push(
|
|
19281
|
+
case a.SINGLE_INDENT:
|
|
19282
|
+
this.items.push(a.SINGLE_INDENT);
|
|
19253
19283
|
break;
|
|
19254
19284
|
default:
|
|
19255
19285
|
this.items.push(T);
|
|
@@ -19266,10 +19296,10 @@ class yT {
|
|
|
19266
19296
|
addNewline(E) {
|
|
19267
19297
|
if (this.items.length > 0)
|
|
19268
19298
|
switch (Z(this.items)) {
|
|
19269
|
-
case
|
|
19299
|
+
case a.NEWLINE:
|
|
19270
19300
|
this.items.pop(), this.items.push(E);
|
|
19271
19301
|
break;
|
|
19272
|
-
case
|
|
19302
|
+
case a.MANDATORY_NEWLINE:
|
|
19273
19303
|
break;
|
|
19274
19304
|
default:
|
|
19275
19305
|
this.items.push(E);
|
|
@@ -19278,7 +19308,7 @@ class yT {
|
|
|
19278
19308
|
}
|
|
19279
19309
|
addIndentation() {
|
|
19280
19310
|
for (let E = 0; E < this.indentation.getLevel(); E++)
|
|
19281
|
-
this.items.push(
|
|
19311
|
+
this.items.push(a.SINGLE_INDENT);
|
|
19282
19312
|
}
|
|
19283
19313
|
/**
|
|
19284
19314
|
* Returns the final SQL string.
|
|
@@ -19294,20 +19324,20 @@ class yT {
|
|
|
19294
19324
|
}
|
|
19295
19325
|
itemToString(E) {
|
|
19296
19326
|
switch (E) {
|
|
19297
|
-
case
|
|
19327
|
+
case a.SPACE:
|
|
19298
19328
|
return " ";
|
|
19299
|
-
case
|
|
19300
|
-
case
|
|
19329
|
+
case a.NEWLINE:
|
|
19330
|
+
case a.MANDATORY_NEWLINE:
|
|
19301
19331
|
return `
|
|
19302
19332
|
`;
|
|
19303
|
-
case
|
|
19333
|
+
case a.SINGLE_INDENT:
|
|
19304
19334
|
return this.indentation.getSingleIndent();
|
|
19305
19335
|
default:
|
|
19306
19336
|
return E;
|
|
19307
19337
|
}
|
|
19308
19338
|
}
|
|
19309
19339
|
}
|
|
19310
|
-
const XI = (R) => R ===
|
|
19340
|
+
const XI = (R) => R === a.SPACE || R === a.SINGLE_INDENT, bI = (R) => R === a.SPACE || R === a.SINGLE_INDENT || R === a.NEWLINE;
|
|
19311
19341
|
function GT(R, E) {
|
|
19312
19342
|
if (E === "standard")
|
|
19313
19343
|
return R;
|
|
@@ -19315,7 +19345,7 @@ function GT(R, E) {
|
|
|
19315
19345
|
return R.length >= 10 && R.includes(" ") && ([R, ...T] = R.split(" ")), E === "tabularLeft" ? R = R.padEnd(9, " ") : R = R.padStart(9, " "), R + ["", ...T].join(" ");
|
|
19316
19346
|
}
|
|
19317
19347
|
function lT(R) {
|
|
19318
|
-
return PR(R) || R ===
|
|
19348
|
+
return PR(R) || R === D.RESERVED_CLAUSE || R === D.RESERVED_SELECT || R === D.RESERVED_SET_OPERATION || R === D.RESERVED_JOIN || R === D.LIMIT;
|
|
19319
19349
|
}
|
|
19320
19350
|
const YE = "top-level", yI = "block-level";
|
|
19321
19351
|
class KT {
|
|
@@ -19379,9 +19409,9 @@ class KI extends yT {
|
|
|
19379
19409
|
if (typeof E == "string")
|
|
19380
19410
|
this.length += E.length, this.trailingSpace = !1;
|
|
19381
19411
|
else {
|
|
19382
|
-
if (E ===
|
|
19412
|
+
if (E === a.MANDATORY_NEWLINE || E === a.NEWLINE)
|
|
19383
19413
|
throw new hE();
|
|
19384
|
-
E ===
|
|
19414
|
+
E === a.INDENT || E === a.SINGLE_INDENT || E === a.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === a.NO_NEWLINE || E === a.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
|
|
19385
19415
|
}
|
|
19386
19416
|
}
|
|
19387
19417
|
}
|
|
@@ -19477,23 +19507,23 @@ class RE {
|
|
|
19477
19507
|
}), this.formatNode(E.parenthesis);
|
|
19478
19508
|
}
|
|
19479
19509
|
formatPropertyAccess(E) {
|
|
19480
|
-
this.formatNode(E.object), this.layout.add(
|
|
19510
|
+
this.formatNode(E.object), this.layout.add(a.NO_SPACE, E.operator), this.formatNode(E.property);
|
|
19481
19511
|
}
|
|
19482
19512
|
formatParenthesis(E) {
|
|
19483
19513
|
const T = this.formatInlineExpression(E.children);
|
|
19484
|
-
T ? (this.layout.add(E.openParen), this.layout.add(...T.getLayoutItems()), this.layout.add(
|
|
19514
|
+
T ? (this.layout.add(E.openParen), this.layout.add(...T.getLayoutItems()), this.layout.add(a.NO_SPACE, E.closeParen, a.SPACE)) : (this.layout.add(E.openParen, a.NEWLINE), J(this.cfg) ? (this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(a.NEWLINE, a.INDENT, E.closeParen, a.SPACE));
|
|
19485
19515
|
}
|
|
19486
19516
|
formatBetweenPredicate(E) {
|
|
19487
|
-
this.layout.add(this.showKw(E.betweenKw),
|
|
19517
|
+
this.layout.add(this.showKw(E.betweenKw), a.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(a.NO_SPACE, a.SPACE, this.showNonTabularKw(E.andKw), a.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(a.SPACE);
|
|
19488
19518
|
}
|
|
19489
19519
|
formatCaseExpression(E) {
|
|
19490
|
-
this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(
|
|
19520
|
+
this.formatNode(E.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(E.expr), this.layout = this.formatSubExpression(E.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.endKw);
|
|
19491
19521
|
}
|
|
19492
19522
|
formatCaseWhen(E) {
|
|
19493
|
-
this.layout.add(
|
|
19523
|
+
this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
|
|
19494
19524
|
}
|
|
19495
19525
|
formatCaseElse(E) {
|
|
19496
|
-
this.layout.add(
|
|
19526
|
+
this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
|
|
19497
19527
|
}
|
|
19498
19528
|
formatClause(E) {
|
|
19499
19529
|
this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : J(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
|
|
@@ -19502,39 +19532,39 @@ class RE {
|
|
|
19502
19532
|
return J(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
|
|
19503
19533
|
}
|
|
19504
19534
|
formatClauseInIndentedStyle(E) {
|
|
19505
|
-
this.layout.add(
|
|
19535
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
|
|
19506
19536
|
}
|
|
19507
19537
|
formatClauseInOnelineStyle(E) {
|
|
19508
|
-
this.layout.add(
|
|
19538
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout = this.formatSubExpression(E.children);
|
|
19509
19539
|
}
|
|
19510
19540
|
formatClauseInTabularStyle(E) {
|
|
19511
|
-
this.layout.add(
|
|
19541
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
|
|
19512
19542
|
}
|
|
19513
19543
|
formatSetOperation(E) {
|
|
19514
|
-
this.layout.add(
|
|
19544
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children);
|
|
19515
19545
|
}
|
|
19516
19546
|
formatLimitClause(E) {
|
|
19517
19547
|
this.withComments(E.limitKw, () => {
|
|
19518
|
-
this.layout.add(
|
|
19519
|
-
}), this.layout.indentation.increaseTopLevel(), J(this.cfg) ? this.layout.add(
|
|
19548
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.limitKw));
|
|
19549
|
+
}), this.layout.indentation.increaseTopLevel(), J(this.cfg) ? this.layout.add(a.SPACE) : this.layout.add(a.NEWLINE, a.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(a.NO_SPACE, ",", a.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
|
|
19520
19550
|
}
|
|
19521
19551
|
formatAllColumnsAsterisk(E) {
|
|
19522
|
-
this.layout.add("*",
|
|
19552
|
+
this.layout.add("*", a.SPACE);
|
|
19523
19553
|
}
|
|
19524
19554
|
formatLiteral(E) {
|
|
19525
|
-
this.layout.add(E.text,
|
|
19555
|
+
this.layout.add(E.text, a.SPACE);
|
|
19526
19556
|
}
|
|
19527
19557
|
formatIdentifier(E) {
|
|
19528
|
-
this.layout.add(this.showIdentifier(E),
|
|
19558
|
+
this.layout.add(this.showIdentifier(E), a.SPACE);
|
|
19529
19559
|
}
|
|
19530
19560
|
formatParameter(E) {
|
|
19531
|
-
this.layout.add(this.params.get(E),
|
|
19561
|
+
this.layout.add(this.params.get(E), a.SPACE);
|
|
19532
19562
|
}
|
|
19533
19563
|
formatOperator({ text: E }) {
|
|
19534
|
-
this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(
|
|
19564
|
+
this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(a.NO_SPACE, E) : E === ":" ? this.layout.add(a.NO_SPACE, E, a.SPACE) : this.layout.add(E, a.SPACE);
|
|
19535
19565
|
}
|
|
19536
19566
|
formatComma(E) {
|
|
19537
|
-
this.inline ? this.layout.add(
|
|
19567
|
+
this.inline ? this.layout.add(a.NO_SPACE, ",", a.SPACE) : this.layout.add(a.NO_SPACE, ",", a.NEWLINE, a.INDENT);
|
|
19538
19568
|
}
|
|
19539
19569
|
withComments(E, T) {
|
|
19540
19570
|
this.formatComments(E.leadingComments), T(), this.formatComments(E.trailingComments);
|
|
@@ -19545,12 +19575,12 @@ class RE {
|
|
|
19545
19575
|
});
|
|
19546
19576
|
}
|
|
19547
19577
|
formatLineComment(E) {
|
|
19548
|
-
FE(E.precedingWhitespace || "") ? this.layout.add(
|
|
19578
|
+
FE(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);
|
|
19549
19579
|
}
|
|
19550
19580
|
formatBlockComment(E) {
|
|
19551
19581
|
E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((T) => {
|
|
19552
|
-
this.layout.add(
|
|
19553
|
-
}), this.layout.add(
|
|
19582
|
+
this.layout.add(a.NEWLINE, a.INDENT, T);
|
|
19583
|
+
}), this.layout.add(a.NEWLINE, a.INDENT)) : this.layout.add(E.text, a.SPACE);
|
|
19554
19584
|
}
|
|
19555
19585
|
isMultilineBlockComment(E) {
|
|
19556
19586
|
return FE(E.text) || FE(E.precedingWhitespace || "");
|
|
@@ -19623,27 +19653,27 @@ class RE {
|
|
|
19623
19653
|
}
|
|
19624
19654
|
formatKeywordNode(E) {
|
|
19625
19655
|
switch (E.tokenType) {
|
|
19626
|
-
case
|
|
19656
|
+
case D.RESERVED_JOIN:
|
|
19627
19657
|
return this.formatJoin(E);
|
|
19628
|
-
case
|
|
19629
|
-
case
|
|
19630
|
-
case
|
|
19658
|
+
case D.AND:
|
|
19659
|
+
case D.OR:
|
|
19660
|
+
case D.XOR:
|
|
19631
19661
|
return this.formatLogicalOperator(E);
|
|
19632
19662
|
default:
|
|
19633
19663
|
return this.formatKeyword(E);
|
|
19634
19664
|
}
|
|
19635
19665
|
}
|
|
19636
19666
|
formatJoin(E) {
|
|
19637
|
-
J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(
|
|
19667
|
+
J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE);
|
|
19638
19668
|
}
|
|
19639
19669
|
formatKeyword(E) {
|
|
19640
|
-
this.layout.add(this.showKw(E),
|
|
19670
|
+
this.layout.add(this.showKw(E), a.SPACE);
|
|
19641
19671
|
}
|
|
19642
19672
|
formatLogicalOperator(E) {
|
|
19643
|
-
this.cfg.logicalOperatorNewline === "before" ? J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(
|
|
19673
|
+
this.cfg.logicalOperatorNewline === "before" ? J(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE) : this.layout.add(this.showKw(E), a.NEWLINE, a.INDENT);
|
|
19644
19674
|
}
|
|
19645
19675
|
formatDataType(E) {
|
|
19646
|
-
this.layout.add(this.showDataType(E),
|
|
19676
|
+
this.layout.add(this.showDataType(E), a.SPACE);
|
|
19647
19677
|
}
|
|
19648
19678
|
showKw(E) {
|
|
19649
19679
|
return lT(E.tokenType) ? GT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
|
|
@@ -19723,7 +19753,7 @@ class $I {
|
|
|
19723
19753
|
params: this.params,
|
|
19724
19754
|
layout: new yT(new KT(oI(this.cfg)))
|
|
19725
19755
|
}).format(E.children);
|
|
19726
|
-
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(
|
|
19756
|
+
return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? T.add(a.NEWLINE, ";") : T.add(a.NO_NEWLINE, ";")), T.toString();
|
|
19727
19757
|
}
|
|
19728
19758
|
}
|
|
19729
19759
|
class TE extends Error {
|
|
@@ -19990,27 +20020,27 @@ ${T.join(`
|
|
|
19990
20020
|
generateCubeMetadata(E) {
|
|
19991
20021
|
const T = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(T.length), S = new Array(A.length);
|
|
19992
20022
|
for (let t = 0; t < T.length; t++) {
|
|
19993
|
-
const C = T[t],
|
|
20023
|
+
const C = T[t], O = E.measures[C];
|
|
19994
20024
|
e[t] = {
|
|
19995
20025
|
name: `${E.name}.${C}`,
|
|
19996
|
-
title:
|
|
19997
|
-
shortTitle:
|
|
19998
|
-
type:
|
|
20026
|
+
title: O.title || C,
|
|
20027
|
+
shortTitle: O.title || C,
|
|
20028
|
+
type: O.type,
|
|
19999
20029
|
format: void 0,
|
|
20000
20030
|
// Measure doesn't have format field
|
|
20001
|
-
description:
|
|
20031
|
+
description: O.description
|
|
20002
20032
|
};
|
|
20003
20033
|
}
|
|
20004
20034
|
for (let t = 0; t < A.length; t++) {
|
|
20005
|
-
const C = A[t],
|
|
20035
|
+
const C = A[t], O = E.dimensions[C];
|
|
20006
20036
|
S[t] = {
|
|
20007
20037
|
name: `${E.name}.${C}`,
|
|
20008
|
-
title:
|
|
20009
|
-
shortTitle:
|
|
20010
|
-
type:
|
|
20038
|
+
title: O.title || C,
|
|
20039
|
+
shortTitle: O.title || C,
|
|
20040
|
+
type: O.type,
|
|
20011
20041
|
format: void 0,
|
|
20012
20042
|
// Dimension doesn't have format field
|
|
20013
|
-
description:
|
|
20043
|
+
description: O.description
|
|
20014
20044
|
};
|
|
20015
20045
|
}
|
|
20016
20046
|
const I = [];
|
|
@@ -20020,9 +20050,9 @@ ${T.join(`
|
|
|
20020
20050
|
I.push({
|
|
20021
20051
|
targetCube: C.name,
|
|
20022
20052
|
relationship: t.relationship,
|
|
20023
|
-
joinFields: t.on.map((
|
|
20024
|
-
sourceField: this.getColumnName(
|
|
20025
|
-
targetField: this.getColumnName(
|
|
20053
|
+
joinFields: t.on.map((O) => ({
|
|
20054
|
+
sourceField: this.getColumnName(O.source),
|
|
20055
|
+
targetField: this.getColumnName(O.target)
|
|
20026
20056
|
}))
|
|
20027
20057
|
});
|
|
20028
20058
|
}
|