drizzle-cube 0.1.40 → 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-BNrqoxJZ.js → compiler-B57cLx38.js} +1152 -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-D6NT6kRL.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 +6 -2
- package/dist/server/index.js +858 -824
- package/package.json +1 -1
- package/dist/client/chunks/components-D6NT6kRL.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":
|
|
@@ -1252,11 +1252,15 @@ class sR {
|
|
|
1252
1252
|
throw new Error(
|
|
1253
1253
|
`Cannot build calculated measure '${E.name}' directly. Use buildCalculatedMeasure instead.`
|
|
1254
1254
|
);
|
|
1255
|
+
if (!E.sql)
|
|
1256
|
+
throw new Error(
|
|
1257
|
+
`Measure '${E.name}' of type '${E.type}' is missing required 'sql' property. Only calculated measures can omit 'sql'.`
|
|
1258
|
+
);
|
|
1255
1259
|
let A = X(E.sql, T);
|
|
1256
1260
|
if (E.filters && E.filters.length > 0) {
|
|
1257
1261
|
const e = E.filters.map((S) => {
|
|
1258
1262
|
const I = S(T);
|
|
1259
|
-
return I ?
|
|
1263
|
+
return I ? n`(${I})` : void 0;
|
|
1260
1264
|
}).filter(Boolean);
|
|
1261
1265
|
if (e.length > 0) {
|
|
1262
1266
|
const S = e.length === 1 ? e[0] : p(...e);
|
|
@@ -1289,7 +1293,7 @@ class sR {
|
|
|
1289
1293
|
*/
|
|
1290
1294
|
buildTimeDimensionExpression(E, T, A) {
|
|
1291
1295
|
const e = X(E, A);
|
|
1292
|
-
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}`;
|
|
1293
1297
|
}
|
|
1294
1298
|
/**
|
|
1295
1299
|
* Build WHERE conditions from semantic query filters (dimensions only)
|
|
@@ -1304,12 +1308,12 @@ class sR {
|
|
|
1304
1308
|
}
|
|
1305
1309
|
if (T.timeDimensions)
|
|
1306
1310
|
for (const t of T.timeDimensions) {
|
|
1307
|
-
const [C,
|
|
1308
|
-
if (
|
|
1311
|
+
const [C, O] = t.dimension.split("."), N = I.get(C);
|
|
1312
|
+
if (N && N.dimensions[O] && t.dateRange) {
|
|
1309
1313
|
if (e?.preAggregationCTEs && e.preAggregationCTEs.some((o) => o.cube.name === C))
|
|
1310
1314
|
continue;
|
|
1311
|
-
const s =
|
|
1312
|
-
|
|
1315
|
+
const s = N.dimensions[O], r = X(s.sql, A), L = this.buildDateRangeCondition(r, t.dateRange);
|
|
1316
|
+
L && S.push(L);
|
|
1313
1317
|
}
|
|
1314
1318
|
}
|
|
1315
1319
|
return S;
|
|
@@ -1333,31 +1337,43 @@ class sR {
|
|
|
1333
1337
|
*/
|
|
1334
1338
|
processFilter(E, T, A, e, S) {
|
|
1335
1339
|
if ("and" in E || "or" in E) {
|
|
1336
|
-
const
|
|
1337
|
-
if (
|
|
1338
|
-
const
|
|
1339
|
-
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;
|
|
1340
1344
|
}
|
|
1341
|
-
if (
|
|
1342
|
-
const
|
|
1343
|
-
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;
|
|
1344
1348
|
}
|
|
1345
1349
|
}
|
|
1346
|
-
const I = E, [t, C] = I.member.split("."),
|
|
1347
|
-
if (!
|
|
1348
|
-
const
|
|
1349
|
-
if (!
|
|
1350
|
-
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) {
|
|
1351
1355
|
if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
|
|
1352
1356
|
return null;
|
|
1353
|
-
const
|
|
1354
|
-
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
|
+
);
|
|
1355
1365
|
} else {
|
|
1356
1366
|
if (e === "where" && s)
|
|
1357
1367
|
return null;
|
|
1358
1368
|
if (e === "having" && s) {
|
|
1359
|
-
const
|
|
1360
|
-
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
|
+
);
|
|
1361
1377
|
}
|
|
1362
1378
|
}
|
|
1363
1379
|
return null;
|
|
@@ -1365,97 +1381,108 @@ class sR {
|
|
|
1365
1381
|
/**
|
|
1366
1382
|
* Build filter condition using Drizzle operators
|
|
1367
1383
|
*/
|
|
1368
|
-
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
|
+
}
|
|
1369
1396
|
if (!A || A.length === 0)
|
|
1370
1397
|
return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
1371
|
-
const
|
|
1372
|
-
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))
|
|
1373
1400
|
return T === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
|
|
1374
|
-
const
|
|
1401
|
+
const t = I[0];
|
|
1375
1402
|
switch (T) {
|
|
1376
1403
|
case "equals":
|
|
1377
|
-
if (
|
|
1404
|
+
if (I.length > 1) {
|
|
1378
1405
|
if (e?.type === "time") {
|
|
1379
|
-
const
|
|
1380
|
-
return OE(E,
|
|
1406
|
+
const C = I.map((O) => this.normalizeDate(O) || O);
|
|
1407
|
+
return OE(E, C);
|
|
1381
1408
|
}
|
|
1382
|
-
return OE(E,
|
|
1383
|
-
} else if (
|
|
1384
|
-
const
|
|
1385
|
-
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);
|
|
1386
1413
|
}
|
|
1387
1414
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
1388
1415
|
case "notEquals":
|
|
1389
|
-
return
|
|
1416
|
+
return I.length > 1 ? gE(E, I) : I.length === 1 ? KE(E, t) : null;
|
|
1390
1417
|
case "contains":
|
|
1391
|
-
return this.databaseAdapter.buildStringCondition(E, "contains",
|
|
1418
|
+
return this.databaseAdapter.buildStringCondition(E, "contains", t);
|
|
1392
1419
|
case "notContains":
|
|
1393
|
-
return this.databaseAdapter.buildStringCondition(E, "notContains",
|
|
1420
|
+
return this.databaseAdapter.buildStringCondition(E, "notContains", t);
|
|
1394
1421
|
case "startsWith":
|
|
1395
|
-
return this.databaseAdapter.buildStringCondition(E, "startsWith",
|
|
1422
|
+
return this.databaseAdapter.buildStringCondition(E, "startsWith", t);
|
|
1396
1423
|
case "endsWith":
|
|
1397
|
-
return this.databaseAdapter.buildStringCondition(E, "endsWith",
|
|
1424
|
+
return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
|
|
1398
1425
|
case "gt":
|
|
1399
|
-
return tE(E,
|
|
1426
|
+
return tE(E, t);
|
|
1400
1427
|
case "gte":
|
|
1401
|
-
return $(E,
|
|
1428
|
+
return $(E, t);
|
|
1402
1429
|
case "lt":
|
|
1403
|
-
return NE(E,
|
|
1430
|
+
return NE(E, t);
|
|
1404
1431
|
case "lte":
|
|
1405
|
-
return g(E,
|
|
1432
|
+
return g(E, t);
|
|
1406
1433
|
case "set":
|
|
1407
1434
|
return yE(E);
|
|
1408
1435
|
case "notSet":
|
|
1409
1436
|
return $E(E);
|
|
1410
1437
|
case "inDateRange":
|
|
1411
|
-
if (
|
|
1412
|
-
const
|
|
1413
|
-
let
|
|
1414
|
-
if (
|
|
1438
|
+
if (I.length >= 2) {
|
|
1439
|
+
const C = this.normalizeDate(I[0]);
|
|
1440
|
+
let O = this.normalizeDate(I[1]);
|
|
1441
|
+
if (C && O) {
|
|
1415
1442
|
const N = A[1];
|
|
1416
1443
|
if (typeof N == "string" && /^\d{4}-\d{2}-\d{2}$/.test(N.trim())) {
|
|
1417
|
-
const
|
|
1418
|
-
|
|
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();
|
|
1419
1446
|
}
|
|
1420
1447
|
return p(
|
|
1421
|
-
$(E,
|
|
1422
|
-
g(E,
|
|
1448
|
+
$(E, C),
|
|
1449
|
+
g(E, O)
|
|
1423
1450
|
);
|
|
1424
1451
|
}
|
|
1425
1452
|
}
|
|
1426
1453
|
return null;
|
|
1427
1454
|
case "beforeDate": {
|
|
1428
|
-
const
|
|
1429
|
-
return
|
|
1455
|
+
const C = this.normalizeDate(t);
|
|
1456
|
+
return C ? NE(E, C) : null;
|
|
1430
1457
|
}
|
|
1431
1458
|
case "afterDate": {
|
|
1432
|
-
const
|
|
1433
|
-
return
|
|
1459
|
+
const C = this.normalizeDate(t);
|
|
1460
|
+
return C ? tE(E, C) : null;
|
|
1434
1461
|
}
|
|
1435
1462
|
case "between":
|
|
1436
|
-
return
|
|
1437
|
-
$(E,
|
|
1438
|
-
g(E,
|
|
1463
|
+
return I.length >= 2 ? p(
|
|
1464
|
+
$(E, I[0]),
|
|
1465
|
+
g(E, I[1])
|
|
1439
1466
|
) : null;
|
|
1440
1467
|
case "notBetween":
|
|
1441
|
-
return
|
|
1442
|
-
NE(E,
|
|
1443
|
-
tE(E,
|
|
1468
|
+
return I.length >= 2 ? IE(
|
|
1469
|
+
NE(E, I[0]),
|
|
1470
|
+
tE(E, I[1])
|
|
1444
1471
|
) : null;
|
|
1445
1472
|
case "in":
|
|
1446
|
-
return
|
|
1473
|
+
return I.length > 0 ? OE(E, I) : null;
|
|
1447
1474
|
case "notIn":
|
|
1448
|
-
return
|
|
1475
|
+
return I.length > 0 ? gE(E, I) : null;
|
|
1449
1476
|
case "like":
|
|
1450
|
-
return this.databaseAdapter.buildStringCondition(E, "like",
|
|
1477
|
+
return this.databaseAdapter.buildStringCondition(E, "like", t);
|
|
1451
1478
|
case "notLike":
|
|
1452
|
-
return this.databaseAdapter.buildStringCondition(E, "notLike",
|
|
1479
|
+
return this.databaseAdapter.buildStringCondition(E, "notLike", t);
|
|
1453
1480
|
case "ilike":
|
|
1454
|
-
return this.databaseAdapter.buildStringCondition(E, "ilike",
|
|
1481
|
+
return this.databaseAdapter.buildStringCondition(E, "ilike", t);
|
|
1455
1482
|
case "regex":
|
|
1456
|
-
return this.databaseAdapter.buildStringCondition(E, "regex",
|
|
1483
|
+
return this.databaseAdapter.buildStringCondition(E, "regex", t);
|
|
1457
1484
|
case "notRegex":
|
|
1458
|
-
return this.databaseAdapter.buildStringCondition(E, "notRegex",
|
|
1485
|
+
return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
|
|
1459
1486
|
case "isEmpty":
|
|
1460
1487
|
return IE(
|
|
1461
1488
|
$E(E),
|
|
@@ -1491,9 +1518,9 @@ class sR {
|
|
|
1491
1518
|
if (typeof T == "string") {
|
|
1492
1519
|
const A = this.parseRelativeDateRange(T);
|
|
1493
1520
|
if (A) {
|
|
1494
|
-
let
|
|
1495
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (
|
|
1496
|
-
$(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),
|
|
1497
1524
|
g(E, s)
|
|
1498
1525
|
);
|
|
1499
1526
|
}
|
|
@@ -1503,10 +1530,10 @@ class sR {
|
|
|
1503
1530
|
I.setUTCHours(0, 0, 0, 0);
|
|
1504
1531
|
const t = new Date(S);
|
|
1505
1532
|
t.setUTCHours(23, 59, 59, 999);
|
|
1506
|
-
let C,
|
|
1507
|
-
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(
|
|
1508
1535
|
$(E, C),
|
|
1509
|
-
g(E,
|
|
1536
|
+
g(E, O)
|
|
1510
1537
|
);
|
|
1511
1538
|
}
|
|
1512
1539
|
return null;
|
|
@@ -1518,73 +1545,80 @@ class sR {
|
|
|
1518
1545
|
parseRelativeDateRange(E) {
|
|
1519
1546
|
const T = /* @__PURE__ */ new Date(), A = E.toLowerCase().trim(), e = T.getUTCFullYear(), S = T.getUTCMonth(), I = T.getUTCDate(), t = T.getUTCDay();
|
|
1520
1547
|
if (A === "today") {
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1523
|
-
const
|
|
1524
|
-
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 };
|
|
1525
1552
|
}
|
|
1526
1553
|
if (A === "yesterday") {
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
const
|
|
1530
|
-
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 };
|
|
1531
1558
|
}
|
|
1532
1559
|
if (A === "this week") {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
const
|
|
1536
|
-
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 };
|
|
1537
1564
|
}
|
|
1538
1565
|
if (A === "this month") {
|
|
1539
|
-
const
|
|
1540
|
-
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 };
|
|
1541
1568
|
}
|
|
1542
1569
|
if (A === "this quarter") {
|
|
1543
|
-
const
|
|
1544
|
-
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 };
|
|
1545
1572
|
}
|
|
1546
1573
|
if (A === "this year") {
|
|
1547
|
-
const
|
|
1548
|
-
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 };
|
|
1549
1576
|
}
|
|
1550
1577
|
const C = A.match(/^last\s+(\d+)\s+days?$/);
|
|
1551
1578
|
if (C) {
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
const
|
|
1555
|
-
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 };
|
|
1556
1590
|
}
|
|
1557
1591
|
if (A === "last week") {
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1560
|
-
const
|
|
1561
|
-
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 };
|
|
1562
1596
|
}
|
|
1563
1597
|
if (A === "last month") {
|
|
1564
|
-
const
|
|
1565
|
-
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 };
|
|
1566
1600
|
}
|
|
1567
1601
|
if (A === "last quarter") {
|
|
1568
|
-
const
|
|
1569
|
-
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 };
|
|
1570
1604
|
}
|
|
1571
1605
|
if (A === "last year") {
|
|
1572
|
-
const
|
|
1573
|
-
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 };
|
|
1574
1608
|
}
|
|
1575
1609
|
if (A === "last 12 months") {
|
|
1576
|
-
const
|
|
1577
|
-
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 };
|
|
1578
1612
|
}
|
|
1579
1613
|
const N = A.match(/^last\s+(\d+)\s+months?$/);
|
|
1580
1614
|
if (N) {
|
|
1581
|
-
const
|
|
1582
|
-
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 };
|
|
1583
1617
|
}
|
|
1584
|
-
const
|
|
1585
|
-
if (
|
|
1586
|
-
const
|
|
1587
|
-
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 };
|
|
1588
1622
|
}
|
|
1589
1623
|
return null;
|
|
1590
1624
|
}
|
|
@@ -1623,45 +1657,45 @@ class sR {
|
|
|
1623
1657
|
const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
|
|
1624
1658
|
if (T.dimensions)
|
|
1625
1659
|
for (const C of T.dimensions) {
|
|
1626
|
-
const [
|
|
1627
|
-
if (s && s.dimensions && s.dimensions[
|
|
1628
|
-
if (e?.preAggregationCTEs?.some((
|
|
1629
|
-
const
|
|
1630
|
-
if (
|
|
1631
|
-
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);
|
|
1632
1666
|
else {
|
|
1633
|
-
const o =
|
|
1667
|
+
const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
|
|
1634
1668
|
S.push(o);
|
|
1635
1669
|
}
|
|
1636
1670
|
} else {
|
|
1637
|
-
const
|
|
1638
|
-
S.push(
|
|
1671
|
+
const L = s.dimensions[N], i = X(L.sql, A);
|
|
1672
|
+
S.push(i);
|
|
1639
1673
|
}
|
|
1640
1674
|
}
|
|
1641
1675
|
if (T.timeDimensions)
|
|
1642
1676
|
for (const C of T.timeDimensions) {
|
|
1643
|
-
const [
|
|
1644
|
-
if (s && s.dimensions && s.dimensions[
|
|
1645
|
-
if (e?.preAggregationCTEs?.some((
|
|
1646
|
-
const
|
|
1647
|
-
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) {
|
|
1648
1682
|
const o = this.buildTimeDimensionExpression(
|
|
1649
|
-
|
|
1683
|
+
i.sourceColumnObj,
|
|
1650
1684
|
C.granularity,
|
|
1651
1685
|
A
|
|
1652
1686
|
);
|
|
1653
1687
|
S.push(o);
|
|
1654
1688
|
} else {
|
|
1655
|
-
const o =
|
|
1689
|
+
const o = n`${n.identifier(L.cteAlias)}.${n.identifier(N)}`;
|
|
1656
1690
|
S.push(o);
|
|
1657
1691
|
}
|
|
1658
1692
|
} else {
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1693
|
+
const L = s.dimensions[N], i = this.buildTimeDimensionExpression(
|
|
1694
|
+
L.sql,
|
|
1661
1695
|
C.granularity,
|
|
1662
1696
|
A
|
|
1663
1697
|
);
|
|
1664
|
-
S.push(
|
|
1698
|
+
S.push(i);
|
|
1665
1699
|
}
|
|
1666
1700
|
}
|
|
1667
1701
|
return S;
|
|
@@ -1679,7 +1713,7 @@ class sR {
|
|
|
1679
1713
|
for (const [S, I] of Object.entries(E.order)) {
|
|
1680
1714
|
if (!e.includes(S))
|
|
1681
1715
|
throw new Error(`Cannot order by '${S}': field is not selected in the query`);
|
|
1682
|
-
const t = I === "desc" ? ZT(
|
|
1716
|
+
const t = I === "desc" ? ZT(n.identifier(S)) : wE(n.identifier(S));
|
|
1683
1717
|
A.push(t);
|
|
1684
1718
|
}
|
|
1685
1719
|
if (E.timeDimensions && E.timeDimensions.length > 0) {
|
|
@@ -1687,7 +1721,7 @@ class sR {
|
|
|
1687
1721
|
(t, C) => t.dimension.localeCompare(C.dimension)
|
|
1688
1722
|
);
|
|
1689
1723
|
for (const t of I)
|
|
1690
|
-
S.has(t.dimension) || A.push(wE(
|
|
1724
|
+
S.has(t.dimension) || A.push(wE(n.identifier(t.dimension)));
|
|
1691
1725
|
}
|
|
1692
1726
|
return A;
|
|
1693
1727
|
}
|
|
@@ -1701,8 +1735,8 @@ class sR {
|
|
|
1701
1735
|
for (const S of T.dimensions) {
|
|
1702
1736
|
const [I, t] = S.split("."), C = e.get(I);
|
|
1703
1737
|
if (C) {
|
|
1704
|
-
const
|
|
1705
|
-
|
|
1738
|
+
const O = C.dimensions[t];
|
|
1739
|
+
O && O.type === "number" && A.push(S);
|
|
1706
1740
|
}
|
|
1707
1741
|
}
|
|
1708
1742
|
return A;
|
|
@@ -1817,7 +1851,7 @@ class CR {
|
|
|
1817
1851
|
groupByFields: []
|
|
1818
1852
|
// Will be built by QueryBuilder
|
|
1819
1853
|
};
|
|
1820
|
-
const C = this.buildJoinPlan(E, t, S, A),
|
|
1854
|
+
const C = this.buildJoinPlan(E, t, S, A), O = this.planPreAggregationCTEs(E, t, C, T);
|
|
1821
1855
|
return {
|
|
1822
1856
|
primaryCube: t,
|
|
1823
1857
|
joinCubes: C,
|
|
@@ -1827,7 +1861,7 @@ class CR {
|
|
|
1827
1861
|
// Will be built by QueryBuilder
|
|
1828
1862
|
groupByFields: [],
|
|
1829
1863
|
// Will be built by QueryBuilder
|
|
1830
|
-
preAggregationCTEs:
|
|
1864
|
+
preAggregationCTEs: O
|
|
1831
1865
|
};
|
|
1832
1866
|
}
|
|
1833
1867
|
/**
|
|
@@ -1881,48 +1915,48 @@ class CR {
|
|
|
1881
1915
|
for (const C of t) {
|
|
1882
1916
|
if (I.has(C))
|
|
1883
1917
|
continue;
|
|
1884
|
-
const
|
|
1885
|
-
if (!
|
|
1918
|
+
const O = this.findJoinPath(E, T.name, C, I);
|
|
1919
|
+
if (!O || O.length === 0)
|
|
1886
1920
|
throw new Error(`No join path found from '${T.name}' to '${C}'`);
|
|
1887
|
-
for (const { toCube:
|
|
1888
|
-
if (I.has(
|
|
1921
|
+
for (const { toCube: N, joinDef: s } of O) {
|
|
1922
|
+
if (I.has(N))
|
|
1889
1923
|
continue;
|
|
1890
|
-
const
|
|
1891
|
-
if (!
|
|
1892
|
-
throw new Error(`Cube '${
|
|
1924
|
+
const r = E.get(N);
|
|
1925
|
+
if (!r)
|
|
1926
|
+
throw new Error(`Cube '${N}' not found`);
|
|
1893
1927
|
if (s.relationship === "belongsToMany" && s.through) {
|
|
1894
|
-
const
|
|
1928
|
+
const L = IR(s, e.securityContext);
|
|
1895
1929
|
S.push({
|
|
1896
|
-
cube:
|
|
1897
|
-
alias: `${
|
|
1898
|
-
joinType:
|
|
1930
|
+
cube: r,
|
|
1931
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1932
|
+
joinType: L.junctionJoins[1].joinType,
|
|
1899
1933
|
// Use the target join type
|
|
1900
|
-
joinCondition:
|
|
1934
|
+
joinCondition: L.junctionJoins[1].condition,
|
|
1901
1935
|
// Target join condition
|
|
1902
1936
|
junctionTable: {
|
|
1903
1937
|
table: s.through.table,
|
|
1904
|
-
alias: `junction_${
|
|
1905
|
-
joinType:
|
|
1906
|
-
joinCondition:
|
|
1938
|
+
alias: `junction_${N.toLowerCase()}`,
|
|
1939
|
+
joinType: L.junctionJoins[0].joinType,
|
|
1940
|
+
joinCondition: L.junctionJoins[0].condition,
|
|
1907
1941
|
securitySql: s.through.securitySql
|
|
1908
1942
|
}
|
|
1909
1943
|
});
|
|
1910
1944
|
} else {
|
|
1911
|
-
const
|
|
1945
|
+
const L = this.buildJoinCondition(
|
|
1912
1946
|
s,
|
|
1913
1947
|
null,
|
|
1914
1948
|
// No source alias needed - use the actual column
|
|
1915
1949
|
null
|
|
1916
1950
|
// No target alias needed - use the actual column
|
|
1917
|
-
),
|
|
1951
|
+
), i = dT(s.relationship, s.sqlJoinType);
|
|
1918
1952
|
S.push({
|
|
1919
|
-
cube:
|
|
1920
|
-
alias: `${
|
|
1921
|
-
joinType:
|
|
1922
|
-
joinCondition:
|
|
1953
|
+
cube: r,
|
|
1954
|
+
alias: `${N.toLowerCase()}_cube`,
|
|
1955
|
+
joinType: i,
|
|
1956
|
+
joinCondition: L
|
|
1923
1957
|
});
|
|
1924
1958
|
}
|
|
1925
|
-
I.add(
|
|
1959
|
+
I.add(N);
|
|
1926
1960
|
}
|
|
1927
1961
|
}
|
|
1928
1962
|
return S;
|
|
@@ -1933,7 +1967,7 @@ class CR {
|
|
|
1933
1967
|
buildJoinCondition(E, T, A) {
|
|
1934
1968
|
const e = [];
|
|
1935
1969
|
for (const S of E.on) {
|
|
1936
|
-
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;
|
|
1937
1971
|
e.push(C(I, t));
|
|
1938
1972
|
}
|
|
1939
1973
|
return p(...e);
|
|
@@ -1949,20 +1983,20 @@ class CR {
|
|
|
1949
1983
|
{ cube: T, path: [] }
|
|
1950
1984
|
], I = /* @__PURE__ */ new Set([T, ...e]);
|
|
1951
1985
|
for (; S.length > 0; ) {
|
|
1952
|
-
const { cube: t, path: C } = S.shift(),
|
|
1953
|
-
if (
|
|
1954
|
-
for (const [,
|
|
1955
|
-
const
|
|
1956
|
-
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))
|
|
1957
1991
|
continue;
|
|
1958
|
-
const
|
|
1992
|
+
const L = [...C, {
|
|
1959
1993
|
fromCube: t,
|
|
1960
|
-
toCube:
|
|
1961
|
-
joinDef:
|
|
1994
|
+
toCube: r,
|
|
1995
|
+
joinDef: N
|
|
1962
1996
|
}];
|
|
1963
|
-
if (
|
|
1964
|
-
return
|
|
1965
|
-
I.add(
|
|
1997
|
+
if (r === A)
|
|
1998
|
+
return L;
|
|
1999
|
+
I.add(r), S.push({ cube: r, path: L });
|
|
1966
2000
|
}
|
|
1967
2001
|
}
|
|
1968
2002
|
return null;
|
|
@@ -1981,24 +2015,24 @@ class CR {
|
|
|
1981
2015
|
if (!t)
|
|
1982
2016
|
continue;
|
|
1983
2017
|
const C = e.measures ? e.measures.filter(
|
|
1984
|
-
(
|
|
1985
|
-
) : [],
|
|
1986
|
-
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)
|
|
1987
2021
|
continue;
|
|
1988
2022
|
const s = this.expandCalculatedMeasureDependencies(
|
|
1989
2023
|
I.cube,
|
|
1990
|
-
|
|
1991
|
-
),
|
|
1992
|
-
sourceColumn:
|
|
1993
|
-
targetColumn:
|
|
1994
|
-
sourceColumnObj:
|
|
1995
|
-
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
|
|
1996
2030
|
}));
|
|
1997
2031
|
S.push({
|
|
1998
2032
|
cube: I.cube,
|
|
1999
2033
|
alias: I.alias,
|
|
2000
2034
|
cteAlias: `${I.cube.name.toLowerCase()}_agg`,
|
|
2001
|
-
joinKeys:
|
|
2035
|
+
joinKeys: r,
|
|
2002
2036
|
measures: s
|
|
2003
2037
|
});
|
|
2004
2038
|
}
|
|
@@ -2020,8 +2054,8 @@ class CR {
|
|
|
2020
2054
|
const t = E.measures[I];
|
|
2021
2055
|
if (t.type === "calculated" && t.calculatedSql) {
|
|
2022
2056
|
const C = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
|
|
2023
|
-
for (const
|
|
2024
|
-
A.has(
|
|
2057
|
+
for (const O of C)
|
|
2058
|
+
A.has(O) || e.push(O);
|
|
2025
2059
|
}
|
|
2026
2060
|
}
|
|
2027
2061
|
return Array.from(A);
|
|
@@ -2070,23 +2104,23 @@ class CE {
|
|
|
2070
2104
|
db: this.dbExecutor.db,
|
|
2071
2105
|
schema: this.dbExecutor.schema,
|
|
2072
2106
|
securityContext: A
|
|
2073
|
-
}, I = this.queryPlanner.createQueryPlan(E, T, S), t = this.buildUnifiedQuery(I, T, S), C = this.queryBuilder.collectNumericFields(E, T),
|
|
2074
|
-
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 };
|
|
2075
2109
|
if (T.timeDimensions) {
|
|
2076
|
-
for (const
|
|
2077
|
-
if (
|
|
2078
|
-
let o =
|
|
2110
|
+
for (const i of T.timeDimensions)
|
|
2111
|
+
if (i.dimension in L) {
|
|
2112
|
+
let o = L[i.dimension];
|
|
2079
2113
|
if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
2080
2114
|
const l = o.replace(" ", "T"), P = !l.endsWith("Z") && !l.includes("+") ? l + "Z" : l;
|
|
2081
2115
|
o = new Date(P);
|
|
2082
2116
|
}
|
|
2083
|
-
o = this.databaseAdapter.convertTimeDimensionResult(o),
|
|
2117
|
+
o = this.databaseAdapter.convertTimeDimensionResult(o), L[i.dimension] = o;
|
|
2084
2118
|
}
|
|
2085
2119
|
}
|
|
2086
|
-
return
|
|
2087
|
-
}) : [
|
|
2120
|
+
return L;
|
|
2121
|
+
}) : [O], s = this.generateAnnotations(I, T);
|
|
2088
2122
|
return {
|
|
2089
|
-
data:
|
|
2123
|
+
data: N,
|
|
2090
2124
|
annotation: s
|
|
2091
2125
|
};
|
|
2092
2126
|
} catch (e) {
|
|
@@ -2109,18 +2143,18 @@ class CE {
|
|
|
2109
2143
|
if (P.targetColumnObj) {
|
|
2110
2144
|
t[P.targetColumn] = P.targetColumnObj;
|
|
2111
2145
|
for (const [c, M] of Object.entries(S.dimensions || {}))
|
|
2112
|
-
M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] =
|
|
2146
|
+
M.sql === P.targetColumnObj && c !== P.targetColumn && (t[c] = n`${P.targetColumnObj}`.as(c));
|
|
2113
2147
|
}
|
|
2114
|
-
const C = S.name,
|
|
2148
|
+
const C = S.name, O = /* @__PURE__ */ new Map([[C, S]]), N = this.queryBuilder.buildResolvedMeasures(
|
|
2115
2149
|
E.measures,
|
|
2116
|
-
|
|
2150
|
+
O,
|
|
2117
2151
|
A
|
|
2118
2152
|
);
|
|
2119
2153
|
for (const P of E.measures) {
|
|
2120
|
-
const [, c] = P.split("."), M =
|
|
2154
|
+
const [, c] = P.split("."), M = N.get(P);
|
|
2121
2155
|
if (M) {
|
|
2122
2156
|
const u = M();
|
|
2123
|
-
t[c] =
|
|
2157
|
+
t[c] = n`${u}`.as(c);
|
|
2124
2158
|
}
|
|
2125
2159
|
}
|
|
2126
2160
|
if (T.dimensions)
|
|
@@ -2128,7 +2162,7 @@ class CE {
|
|
|
2128
2162
|
const [c, M] = P.split(".");
|
|
2129
2163
|
if (c === C && S.dimensions && S.dimensions[M]) {
|
|
2130
2164
|
const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A);
|
|
2131
|
-
t[M] =
|
|
2165
|
+
t[M] = n`${H}`.as(M);
|
|
2132
2166
|
}
|
|
2133
2167
|
}
|
|
2134
2168
|
if (T.timeDimensions)
|
|
@@ -2136,22 +2170,22 @@ class CE {
|
|
|
2136
2170
|
const [c, M] = P.dimension.split(".");
|
|
2137
2171
|
if (c === C && S.dimensions && S.dimensions[M]) {
|
|
2138
2172
|
const u = S.dimensions[M], H = this.queryBuilder.buildTimeDimensionExpression(u.sql, P.granularity, A);
|
|
2139
|
-
t[M] =
|
|
2173
|
+
t[M] = n`${H}`.as(M);
|
|
2140
2174
|
}
|
|
2141
2175
|
}
|
|
2142
2176
|
if (Object.keys(t).length === 0)
|
|
2143
2177
|
return null;
|
|
2144
2178
|
let s = A.db.select(t).from(I.from);
|
|
2145
|
-
const
|
|
2179
|
+
const r = e ? {
|
|
2146
2180
|
...e,
|
|
2147
2181
|
preAggregationCTEs: e.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
|
|
2148
|
-
} : void 0,
|
|
2182
|
+
} : void 0, L = this.queryBuilder.buildWhereConditions(S, T, A, r), i = [];
|
|
2149
2183
|
if (T.timeDimensions)
|
|
2150
2184
|
for (const P of T.timeDimensions) {
|
|
2151
2185
|
const [c, M] = P.dimension.split(".");
|
|
2152
2186
|
if (c === C && S.dimensions && S.dimensions[M] && P.dateRange) {
|
|
2153
2187
|
const u = S.dimensions[M], H = this.queryBuilder.buildMeasureExpression({ sql: u.sql, type: "number" }, A), B = this.queryBuilder.buildDateRangeCondition(H, P.dateRange);
|
|
2154
|
-
B &&
|
|
2188
|
+
B && i.push(B);
|
|
2155
2189
|
}
|
|
2156
2190
|
}
|
|
2157
2191
|
if (T.filters) {
|
|
@@ -2162,13 +2196,13 @@ class CE {
|
|
|
2162
2196
|
const H = S.dimensions[u];
|
|
2163
2197
|
if (c.operator === "inDateRange") {
|
|
2164
2198
|
const B = this.queryBuilder.buildMeasureExpression({ sql: H.sql, type: "number" }, A), Y = this.queryBuilder.buildDateRangeCondition(B, c.values);
|
|
2165
|
-
Y &&
|
|
2199
|
+
Y && i.push(Y);
|
|
2166
2200
|
}
|
|
2167
2201
|
}
|
|
2168
2202
|
}
|
|
2169
2203
|
}
|
|
2170
2204
|
const o = [];
|
|
2171
|
-
if (I.where && o.push(I.where), o.push(...
|
|
2205
|
+
if (I.where && o.push(I.where), o.push(...L, ...i), o.length > 0) {
|
|
2172
2206
|
const P = o.length === 1 ? o[0] : p(...o);
|
|
2173
2207
|
s = s.where(P);
|
|
2174
2208
|
}
|
|
@@ -2203,7 +2237,7 @@ class CE {
|
|
|
2203
2237
|
throw new Error(`CTE info not found for cube ${E.cube.name}`);
|
|
2204
2238
|
const S = [];
|
|
2205
2239
|
for (const I of e.joinKeys) {
|
|
2206
|
-
const t = I.sourceColumnObj ||
|
|
2240
|
+
const t = I.sourceColumnObj || n.identifier(I.sourceColumn), C = n`${n.identifier(T)}.${n.identifier(I.targetColumn)}`;
|
|
2207
2241
|
S.push(x(t, C));
|
|
2208
2242
|
}
|
|
2209
2243
|
return S.length === 1 ? S[0] : p(...S);
|
|
@@ -2243,7 +2277,7 @@ class CE {
|
|
|
2243
2277
|
A
|
|
2244
2278
|
);
|
|
2245
2279
|
} else {
|
|
2246
|
-
const B =
|
|
2280
|
+
const B = n`${n.identifier(o.cteAlias)}.${n.identifier(c)}`;
|
|
2247
2281
|
switch (u.type) {
|
|
2248
2282
|
case "count":
|
|
2249
2283
|
case "countDistinct":
|
|
@@ -2266,7 +2300,7 @@ class CE {
|
|
|
2266
2300
|
H = f(B);
|
|
2267
2301
|
}
|
|
2268
2302
|
}
|
|
2269
|
-
C[P] =
|
|
2303
|
+
C[P] = n`${H}`.as(P);
|
|
2270
2304
|
}
|
|
2271
2305
|
}
|
|
2272
2306
|
for (const P in C) {
|
|
@@ -2279,27 +2313,27 @@ class CE {
|
|
|
2279
2313
|
const eE = u.dimensions[M].sql;
|
|
2280
2314
|
Y = o.joinKeys.find((JT) => JT.targetColumnObj === eE);
|
|
2281
2315
|
}
|
|
2282
|
-
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));
|
|
2283
2317
|
}
|
|
2284
2318
|
}
|
|
2285
2319
|
}
|
|
2286
2320
|
}
|
|
2287
|
-
const
|
|
2288
|
-
let
|
|
2289
|
-
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)
|
|
2290
2324
|
for (const o of I.joins)
|
|
2291
2325
|
switch (o.type || "left") {
|
|
2292
2326
|
case "left":
|
|
2293
|
-
|
|
2327
|
+
N = N.leftJoin(o.table, o.on);
|
|
2294
2328
|
break;
|
|
2295
2329
|
case "inner":
|
|
2296
|
-
|
|
2330
|
+
N = N.innerJoin(o.table, o.on);
|
|
2297
2331
|
break;
|
|
2298
2332
|
case "right":
|
|
2299
|
-
|
|
2333
|
+
N = N.rightJoin(o.table, o.on);
|
|
2300
2334
|
break;
|
|
2301
2335
|
case "full":
|
|
2302
|
-
|
|
2336
|
+
N = N.fullJoin(o.table, o.on);
|
|
2303
2337
|
break;
|
|
2304
2338
|
}
|
|
2305
2339
|
if (E.joinCubes && E.joinCubes.length > 0)
|
|
@@ -2314,48 +2348,48 @@ class CE {
|
|
|
2314
2348
|
try {
|
|
2315
2349
|
switch (M.joinType || "left") {
|
|
2316
2350
|
case "left":
|
|
2317
|
-
|
|
2351
|
+
N = N.leftJoin(M.table, M.joinCondition);
|
|
2318
2352
|
break;
|
|
2319
2353
|
case "inner":
|
|
2320
|
-
|
|
2354
|
+
N = N.innerJoin(M.table, M.joinCondition);
|
|
2321
2355
|
break;
|
|
2322
2356
|
case "right":
|
|
2323
|
-
|
|
2357
|
+
N = N.rightJoin(M.table, M.joinCondition);
|
|
2324
2358
|
break;
|
|
2325
2359
|
case "full":
|
|
2326
|
-
|
|
2360
|
+
N = N.fullJoin(M.table, M.joinCondition);
|
|
2327
2361
|
break;
|
|
2328
2362
|
}
|
|
2329
|
-
u.length > 0 &&
|
|
2363
|
+
u.length > 0 && O.push(...u);
|
|
2330
2364
|
} catch {
|
|
2331
2365
|
}
|
|
2332
2366
|
}
|
|
2333
2367
|
let P, c;
|
|
2334
|
-
l ? (P =
|
|
2368
|
+
l ? (P = n`${n.identifier(l)}`, c = this.buildCTEJoinCondition(o, l, E)) : (P = o.cube.sql(A).from, c = o.joinCondition);
|
|
2335
2369
|
try {
|
|
2336
2370
|
switch (o.joinType || "left") {
|
|
2337
2371
|
case "left":
|
|
2338
|
-
|
|
2372
|
+
N = N.leftJoin(P, c);
|
|
2339
2373
|
break;
|
|
2340
2374
|
case "inner":
|
|
2341
|
-
|
|
2375
|
+
N = N.innerJoin(P, c);
|
|
2342
2376
|
break;
|
|
2343
2377
|
case "right":
|
|
2344
|
-
|
|
2378
|
+
N = N.rightJoin(P, c);
|
|
2345
2379
|
break;
|
|
2346
2380
|
case "full":
|
|
2347
|
-
|
|
2381
|
+
N = N.fullJoin(P, c);
|
|
2348
2382
|
break;
|
|
2349
2383
|
}
|
|
2350
2384
|
} catch {
|
|
2351
2385
|
}
|
|
2352
2386
|
}
|
|
2353
|
-
if (I.where &&
|
|
2387
|
+
if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
|
|
2354
2388
|
for (const o of E.joinCubes) {
|
|
2355
2389
|
if (S.get(o.cube.name))
|
|
2356
2390
|
continue;
|
|
2357
2391
|
const P = o.cube.sql(A);
|
|
2358
|
-
P.where &&
|
|
2392
|
+
P.where && O.push(P.where);
|
|
2359
2393
|
}
|
|
2360
2394
|
const s = this.queryBuilder.buildWhereConditions(
|
|
2361
2395
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
@@ -2365,11 +2399,11 @@ class CE {
|
|
|
2365
2399
|
E
|
|
2366
2400
|
// Pass the queryPlan to handle CTE scenarios
|
|
2367
2401
|
);
|
|
2368
|
-
if (s.length > 0 &&
|
|
2369
|
-
const o =
|
|
2370
|
-
|
|
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);
|
|
2371
2405
|
}
|
|
2372
|
-
const
|
|
2406
|
+
const r = this.queryBuilder.buildGroupByFields(
|
|
2373
2407
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
2374
2408
|
// Single cube
|
|
2375
2409
|
T,
|
|
@@ -2377,8 +2411,8 @@ class CE {
|
|
|
2377
2411
|
E
|
|
2378
2412
|
// Pass the queryPlan to handle CTE scenarios
|
|
2379
2413
|
);
|
|
2380
|
-
|
|
2381
|
-
const
|
|
2414
|
+
r.length > 0 && (N = N.groupBy(...r));
|
|
2415
|
+
const L = this.queryBuilder.buildHavingConditions(
|
|
2382
2416
|
E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
|
|
2383
2417
|
// Single cube
|
|
2384
2418
|
T,
|
|
@@ -2386,12 +2420,12 @@ class CE {
|
|
|
2386
2420
|
E
|
|
2387
2421
|
// Pass the queryPlan to handle CTE scenarios
|
|
2388
2422
|
);
|
|
2389
|
-
if (
|
|
2390
|
-
const o =
|
|
2391
|
-
|
|
2423
|
+
if (L.length > 0) {
|
|
2424
|
+
const o = L.length === 1 ? L[0] : p(...L);
|
|
2425
|
+
N = N.having(o);
|
|
2392
2426
|
}
|
|
2393
|
-
const
|
|
2394
|
-
return
|
|
2427
|
+
const i = this.queryBuilder.buildOrderBy(T);
|
|
2428
|
+
return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, T), N;
|
|
2395
2429
|
}
|
|
2396
2430
|
/**
|
|
2397
2431
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -2437,36 +2471,36 @@ class CE {
|
|
|
2437
2471
|
const A = {}, e = {}, S = {}, I = [E.primaryCube];
|
|
2438
2472
|
if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), T.measures)
|
|
2439
2473
|
for (const t of T.measures) {
|
|
2440
|
-
const [C,
|
|
2441
|
-
if (
|
|
2442
|
-
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];
|
|
2443
2477
|
A[t] = {
|
|
2444
|
-
title: s.title ||
|
|
2445
|
-
shortTitle: s.title ||
|
|
2478
|
+
title: s.title || O,
|
|
2479
|
+
shortTitle: s.title || O,
|
|
2446
2480
|
type: s.type
|
|
2447
2481
|
};
|
|
2448
2482
|
}
|
|
2449
2483
|
}
|
|
2450
2484
|
if (T.dimensions)
|
|
2451
2485
|
for (const t of T.dimensions) {
|
|
2452
|
-
const [C,
|
|
2453
|
-
if (
|
|
2454
|
-
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];
|
|
2455
2489
|
e[t] = {
|
|
2456
|
-
title: s.title ||
|
|
2457
|
-
shortTitle: s.title ||
|
|
2490
|
+
title: s.title || O,
|
|
2491
|
+
shortTitle: s.title || O,
|
|
2458
2492
|
type: s.type
|
|
2459
2493
|
};
|
|
2460
2494
|
}
|
|
2461
2495
|
}
|
|
2462
2496
|
if (T.timeDimensions)
|
|
2463
2497
|
for (const t of T.timeDimensions) {
|
|
2464
|
-
const [C,
|
|
2465
|
-
if (
|
|
2466
|
-
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];
|
|
2467
2501
|
S[t.dimension] = {
|
|
2468
|
-
title: s.title ||
|
|
2469
|
-
shortTitle: s.title ||
|
|
2502
|
+
title: s.title || O,
|
|
2503
|
+
shortTitle: s.title || O,
|
|
2470
2504
|
type: s.type,
|
|
2471
2505
|
granularity: t.granularity
|
|
2472
2506
|
};
|
|
@@ -2480,7 +2514,7 @@ class CE {
|
|
|
2480
2514
|
};
|
|
2481
2515
|
}
|
|
2482
2516
|
}
|
|
2483
|
-
const
|
|
2517
|
+
const _ = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.replace(/ +/g, " ").trim(), rR = (R) => ({
|
|
2484
2518
|
type: "mandatory_block",
|
|
2485
2519
|
items: XE(R, 0)[0]
|
|
2486
2520
|
}), XE = (R, E, T) => {
|
|
@@ -2545,23 +2579,23 @@ const L = (R) => R.flatMap(LR), LR = (R) => k(rR(R)).map(_R), _R = (R) => R.repl
|
|
|
2545
2579
|
T.push(A + e);
|
|
2546
2580
|
return T;
|
|
2547
2581
|
};
|
|
2548
|
-
var
|
|
2582
|
+
var D;
|
|
2549
2583
|
(function(R) {
|
|
2550
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";
|
|
2551
|
-
})(
|
|
2585
|
+
})(D = D || (D = {}));
|
|
2552
2586
|
const FT = (R) => ({
|
|
2553
|
-
type:
|
|
2587
|
+
type: D.EOF,
|
|
2554
2588
|
raw: "«EOF»",
|
|
2555
2589
|
text: "«EOF»",
|
|
2556
2590
|
start: R
|
|
2557
2591
|
}), v = FT(1 / 0), w = (R) => (E) => E.type === R.type && E.text === R.text, y = {
|
|
2558
|
-
ARRAY: w({ text: "ARRAY", type:
|
|
2559
|
-
BY: w({ text: "BY", type:
|
|
2560
|
-
SET: w({ text: "SET", type:
|
|
2561
|
-
STRUCT: w({ text: "STRUCT", type:
|
|
2562
|
-
WINDOW: w({ text: "WINDOW", type:
|
|
2563
|
-
VALUES: w({ text: "VALUES", type:
|
|
2564
|
-
}, 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 = [
|
|
2565
2599
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
|
|
2566
2600
|
"KEYS.NEW_KEYSET",
|
|
2567
2601
|
"KEYS.ADD_KEY_FROM_RAW_BYTES",
|
|
@@ -3238,7 +3272,7 @@ const FT = (R) => ({
|
|
|
3238
3272
|
"STRUCT",
|
|
3239
3273
|
"TIME",
|
|
3240
3274
|
"TIMEZONE"
|
|
3241
|
-
], GR =
|
|
3275
|
+
], GR = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), lR = _([
|
|
3242
3276
|
// Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
|
|
3243
3277
|
"WITH [RECURSIVE]",
|
|
3244
3278
|
"FROM",
|
|
@@ -3267,9 +3301,9 @@ const FT = (R) => ({
|
|
|
3267
3301
|
"WITH CONNECTION",
|
|
3268
3302
|
"WITH PARTITION COLUMNS",
|
|
3269
3303
|
"REMOTE WITH CONNECTION"
|
|
3270
|
-
]), ZE =
|
|
3304
|
+
]), ZE = _([
|
|
3271
3305
|
"CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
3272
|
-
]), LE =
|
|
3306
|
+
]), LE = _([
|
|
3273
3307
|
// - create:
|
|
3274
3308
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
3275
3309
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -3357,15 +3391,15 @@ const FT = (R) => ({
|
|
|
3357
3391
|
"ASSERT",
|
|
3358
3392
|
// Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
|
|
3359
3393
|
"EXPORT DATA"
|
|
3360
|
-
]), uR =
|
|
3394
|
+
]), uR = _([
|
|
3361
3395
|
"UNION {ALL | DISTINCT}",
|
|
3362
3396
|
"EXCEPT DISTINCT",
|
|
3363
3397
|
"INTERSECT DISTINCT"
|
|
3364
|
-
]), HR =
|
|
3398
|
+
]), HR = _([
|
|
3365
3399
|
"JOIN",
|
|
3366
3400
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
3367
3401
|
"{INNER | CROSS} JOIN"
|
|
3368
|
-
]), BR =
|
|
3402
|
+
]), BR = _([
|
|
3369
3403
|
// https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
|
|
3370
3404
|
"TABLESAMPLE SYSTEM",
|
|
3371
3405
|
// From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
|
|
@@ -3376,7 +3410,7 @@ const FT = (R) => ({
|
|
|
3376
3410
|
"{ROWS | RANGE} BETWEEN",
|
|
3377
3411
|
// comparison operator
|
|
3378
3412
|
"IS [NOT] DISTINCT FROM"
|
|
3379
|
-
]), dR =
|
|
3413
|
+
]), dR = _([]), FR = {
|
|
3380
3414
|
name: "bigquery",
|
|
3381
3415
|
tokenizerOptions: {
|
|
3382
3416
|
reservedSelect: GR,
|
|
@@ -3417,7 +3451,7 @@ function mR(R) {
|
|
|
3417
3451
|
}
|
|
3418
3452
|
function pR(R) {
|
|
3419
3453
|
let E = v;
|
|
3420
|
-
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));
|
|
3421
3455
|
}
|
|
3422
3456
|
function YR(R) {
|
|
3423
3457
|
var E;
|
|
@@ -3427,7 +3461,7 @@ function YR(R) {
|
|
|
3427
3461
|
if ((y.ARRAY(e) || y.STRUCT(e)) && ((E = R[A + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
|
|
3428
3462
|
const S = hR(R, A + 1), I = R.slice(A, S + 1);
|
|
3429
3463
|
T.push({
|
|
3430
|
-
type:
|
|
3464
|
+
type: D.IDENTIFIER,
|
|
3431
3465
|
raw: I.map(qE("raw")).join(""),
|
|
3432
3466
|
text: I.map(qE("text")).join(""),
|
|
3433
3467
|
start: e.start
|
|
@@ -3437,7 +3471,7 @@ function YR(R) {
|
|
|
3437
3471
|
}
|
|
3438
3472
|
return T;
|
|
3439
3473
|
}
|
|
3440
|
-
const qE = (R) => (E) => E.type ===
|
|
3474
|
+
const qE = (R) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[R] + " " : E[R];
|
|
3441
3475
|
function hR(R, E) {
|
|
3442
3476
|
let T = 0;
|
|
3443
3477
|
for (let A = E; A < R.length; A++) {
|
|
@@ -4210,7 +4244,7 @@ const fR = [
|
|
|
4210
4244
|
"VARBINARY",
|
|
4211
4245
|
"VARCHAR",
|
|
4212
4246
|
"VARGRAPHIC"
|
|
4213
|
-
], XR =
|
|
4247
|
+
], XR = _(["SELECT [ALL | DISTINCT]"]), bR = _([
|
|
4214
4248
|
// queries
|
|
4215
4249
|
"WITH",
|
|
4216
4250
|
"FROM",
|
|
@@ -4239,9 +4273,9 @@ const fR = [
|
|
|
4239
4273
|
"WHEN [NOT] MATCHED [THEN]",
|
|
4240
4274
|
"UPDATE SET",
|
|
4241
4275
|
"INSERT"
|
|
4242
|
-
]), jE =
|
|
4276
|
+
]), jE = _([
|
|
4243
4277
|
"CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
4244
|
-
]), _E =
|
|
4278
|
+
]), _E = _([
|
|
4245
4279
|
// - create:
|
|
4246
4280
|
"CREATE [OR REPLACE] VIEW",
|
|
4247
4281
|
// - update:
|
|
@@ -4444,16 +4478,16 @@ const fR = [
|
|
|
4444
4478
|
"TRANSFER OWNERSHIP OF",
|
|
4445
4479
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
|
|
4446
4480
|
"WHILE"
|
|
4447
|
-
]), yR =
|
|
4481
|
+
]), yR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), KR = _([
|
|
4448
4482
|
"JOIN",
|
|
4449
4483
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
4450
4484
|
"{INNER | CROSS} JOIN"
|
|
4451
|
-
]), $R =
|
|
4485
|
+
]), $R = _([
|
|
4452
4486
|
"ON DELETE",
|
|
4453
4487
|
"ON UPDATE",
|
|
4454
4488
|
"SET NULL",
|
|
4455
4489
|
"{ROWS | RANGE} BETWEEN"
|
|
4456
|
-
]), gR =
|
|
4490
|
+
]), gR = _([]), wR = {
|
|
4457
4491
|
name: "db2",
|
|
4458
4492
|
tokenizerOptions: {
|
|
4459
4493
|
reservedSelect: XR,
|
|
@@ -5364,7 +5398,7 @@ const fR = [
|
|
|
5364
5398
|
"VARCHAR",
|
|
5365
5399
|
"VARGRAPHIC",
|
|
5366
5400
|
"XML"
|
|
5367
|
-
], QR =
|
|
5401
|
+
], QR = _(["SELECT [ALL | DISTINCT]"]), ZR = _([
|
|
5368
5402
|
// queries
|
|
5369
5403
|
"WITH [RECURSIVE]",
|
|
5370
5404
|
"INTO",
|
|
@@ -5394,7 +5428,7 @@ const fR = [
|
|
|
5394
5428
|
"INSERT",
|
|
5395
5429
|
// Data definition - table
|
|
5396
5430
|
"FOR SYSTEM NAME"
|
|
5397
|
-
]), kE =
|
|
5431
|
+
]), kE = _(["CREATE [OR REPLACE] TABLE"]), rE = _([
|
|
5398
5432
|
// - create:
|
|
5399
5433
|
"CREATE [OR REPLACE] [RECURSIVE] VIEW",
|
|
5400
5434
|
// - update:
|
|
@@ -5490,17 +5524,17 @@ const fR = [
|
|
|
5490
5524
|
"TAG",
|
|
5491
5525
|
"TRANSFER OWNERSHIP OF",
|
|
5492
5526
|
"WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
|
|
5493
|
-
]), qR =
|
|
5527
|
+
]), qR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), jR = _([
|
|
5494
5528
|
"JOIN",
|
|
5495
5529
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
5496
5530
|
"[LEFT | RIGHT] EXCEPTION JOIN",
|
|
5497
5531
|
"{INNER | CROSS} JOIN"
|
|
5498
|
-
]), kR =
|
|
5532
|
+
]), kR = _([
|
|
5499
5533
|
"ON DELETE",
|
|
5500
5534
|
"ON UPDATE",
|
|
5501
5535
|
"SET NULL",
|
|
5502
5536
|
"{ROWS | RANGE} BETWEEN"
|
|
5503
|
-
]), zR =
|
|
5537
|
+
]), zR = _([]), EA = {
|
|
5504
5538
|
name: "db2i",
|
|
5505
5539
|
tokenizerOptions: {
|
|
5506
5540
|
reservedSelect: QR,
|
|
@@ -6353,7 +6387,7 @@ const fR = [
|
|
|
6353
6387
|
"UUID",
|
|
6354
6388
|
"VARBINARY",
|
|
6355
6389
|
"VARCHAR"
|
|
6356
|
-
], eA =
|
|
6390
|
+
], eA = _(["SELECT [ALL | DISTINCT]"]), SA = _([
|
|
6357
6391
|
// queries
|
|
6358
6392
|
"WITH [RECURSIVE]",
|
|
6359
6393
|
"FROM",
|
|
@@ -6377,9 +6411,9 @@ const fR = [
|
|
|
6377
6411
|
"SET",
|
|
6378
6412
|
// other:
|
|
6379
6413
|
"RETURNING"
|
|
6380
|
-
]), zE =
|
|
6414
|
+
]), zE = _([
|
|
6381
6415
|
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
6382
|
-
]), nE =
|
|
6416
|
+
]), nE = _([
|
|
6383
6417
|
// TABLE
|
|
6384
6418
|
// - update:
|
|
6385
6419
|
"UPDATE",
|
|
@@ -6457,11 +6491,11 @@ const fR = [
|
|
|
6457
6491
|
"PREPARE",
|
|
6458
6492
|
"EXECUTE",
|
|
6459
6493
|
"DEALLOCATE [PREPARE]"
|
|
6460
|
-
]), IA =
|
|
6494
|
+
]), IA = _([
|
|
6461
6495
|
"UNION [ALL | BY NAME]",
|
|
6462
6496
|
"EXCEPT [ALL]",
|
|
6463
6497
|
"INTERSECT [ALL]"
|
|
6464
|
-
]), OA =
|
|
6498
|
+
]), OA = _([
|
|
6465
6499
|
"JOIN",
|
|
6466
6500
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
6467
6501
|
"{INNER | CROSS} JOIN",
|
|
@@ -6470,11 +6504,11 @@ const fR = [
|
|
|
6470
6504
|
"POSITIONAL JOIN",
|
|
6471
6505
|
"ANTI JOIN",
|
|
6472
6506
|
"SEMI JOIN"
|
|
6473
|
-
]), NA =
|
|
6507
|
+
]), NA = _([
|
|
6474
6508
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
6475
6509
|
"SIMILAR TO",
|
|
6476
6510
|
"IS [NOT] DISTINCT FROM"
|
|
6477
|
-
]), tA =
|
|
6511
|
+
]), tA = _(["TIMESTAMP WITH TIME ZONE"]), sA = {
|
|
6478
6512
|
name: "duckdb",
|
|
6479
6513
|
tokenizerOptions: {
|
|
6480
6514
|
reservedSelect: eA,
|
|
@@ -7094,7 +7128,7 @@ const fR = [
|
|
|
7094
7128
|
"STRUCT",
|
|
7095
7129
|
"TIMESTAMP",
|
|
7096
7130
|
"VARCHAR"
|
|
7097
|
-
], rA =
|
|
7131
|
+
], rA = _(["SELECT [ALL | DISTINCT]"]), nA = _([
|
|
7098
7132
|
// queries
|
|
7099
7133
|
"WITH",
|
|
7100
7134
|
"FROM",
|
|
@@ -7128,9 +7162,9 @@ const fR = [
|
|
|
7128
7162
|
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
|
|
7129
7163
|
"LOAD DATA [LOCAL] INPATH",
|
|
7130
7164
|
"[OVERWRITE] INTO TABLE"
|
|
7131
|
-
]), ET =
|
|
7165
|
+
]), ET = _([
|
|
7132
7166
|
"CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
|
|
7133
|
-
]), iE =
|
|
7167
|
+
]), iE = _([
|
|
7134
7168
|
// - create:
|
|
7135
7169
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
7136
7170
|
// - update:
|
|
@@ -7155,13 +7189,13 @@ const fR = [
|
|
|
7155
7189
|
"STORED AS",
|
|
7156
7190
|
"STORED BY",
|
|
7157
7191
|
"ROW FORMAT"
|
|
7158
|
-
]), iA =
|
|
7192
|
+
]), iA = _(["UNION [ALL | DISTINCT]"]), aA = _([
|
|
7159
7193
|
"JOIN",
|
|
7160
7194
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
7161
7195
|
"{INNER | CROSS} JOIN",
|
|
7162
7196
|
// non-standard joins
|
|
7163
7197
|
"LEFT SEMI JOIN"
|
|
7164
|
-
]), oA =
|
|
7198
|
+
]), oA = _(["{ROWS | RANGE} BETWEEN"]), DA = _([]), PA = {
|
|
7165
7199
|
name: "hive",
|
|
7166
7200
|
tokenizerOptions: {
|
|
7167
7201
|
reservedSelect: rA,
|
|
@@ -7188,9 +7222,9 @@ function AE(R) {
|
|
|
7188
7222
|
return R.map((E, T) => {
|
|
7189
7223
|
const A = R[T + 1] || v;
|
|
7190
7224
|
if (y.SET(E) && A.text === "(")
|
|
7191
|
-
return Object.assign(Object.assign({}, E), { type:
|
|
7225
|
+
return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
|
|
7192
7226
|
const e = R[T - 1] || v;
|
|
7193
|
-
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;
|
|
7194
7228
|
});
|
|
7195
7229
|
}
|
|
7196
7230
|
const MA = [
|
|
@@ -7699,7 +7733,7 @@ const MA = [
|
|
|
7699
7733
|
// CASE expression shorthands
|
|
7700
7734
|
"COALESCE",
|
|
7701
7735
|
"NULLIF"
|
|
7702
|
-
], GA =
|
|
7736
|
+
], GA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), lA = _([
|
|
7703
7737
|
// queries
|
|
7704
7738
|
"WITH [RECURSIVE]",
|
|
7705
7739
|
"FROM",
|
|
@@ -7721,9 +7755,9 @@ const MA = [
|
|
|
7721
7755
|
"SET",
|
|
7722
7756
|
// other
|
|
7723
7757
|
"RETURNING"
|
|
7724
|
-
]), TT =
|
|
7758
|
+
]), TT = _([
|
|
7725
7759
|
"CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
7726
|
-
]), aE =
|
|
7760
|
+
]), aE = _([
|
|
7727
7761
|
// - create:
|
|
7728
7762
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
7729
7763
|
// - update:
|
|
@@ -7930,12 +7964,12 @@ const MA = [
|
|
|
7930
7964
|
"XA RECOVER",
|
|
7931
7965
|
"XA ROLLBACK",
|
|
7932
7966
|
"XA START"
|
|
7933
|
-
]), uA =
|
|
7967
|
+
]), uA = _([
|
|
7934
7968
|
"UNION [ALL | DISTINCT]",
|
|
7935
7969
|
"EXCEPT [ALL | DISTINCT]",
|
|
7936
7970
|
"INTERSECT [ALL | DISTINCT]",
|
|
7937
7971
|
"MINUS [ALL | DISTINCT]"
|
|
7938
|
-
]), HA =
|
|
7972
|
+
]), HA = _([
|
|
7939
7973
|
"JOIN",
|
|
7940
7974
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
7941
7975
|
"{INNER | CROSS} JOIN",
|
|
@@ -7943,12 +7977,12 @@ const MA = [
|
|
|
7943
7977
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
7944
7978
|
// non-standard joins
|
|
7945
7979
|
"STRAIGHT_JOIN"
|
|
7946
|
-
]), BA =
|
|
7980
|
+
]), BA = _([
|
|
7947
7981
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
7948
7982
|
"CHARACTER SET",
|
|
7949
7983
|
"{ROWS | RANGE} BETWEEN",
|
|
7950
7984
|
"IDENTIFIED BY"
|
|
7951
|
-
]), dA =
|
|
7985
|
+
]), dA = _([]), FA = {
|
|
7952
7986
|
name: "mariadb",
|
|
7953
7987
|
tokenizerOptions: {
|
|
7954
7988
|
reservedSelect: GA,
|
|
@@ -8705,7 +8739,7 @@ const MA = [
|
|
|
8705
8739
|
// 'XOR',
|
|
8706
8740
|
"YEAR",
|
|
8707
8741
|
"YEARWEEK"
|
|
8708
|
-
], hA =
|
|
8742
|
+
], hA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), fA = _([
|
|
8709
8743
|
// queries
|
|
8710
8744
|
"WITH [RECURSIVE]",
|
|
8711
8745
|
"FROM",
|
|
@@ -8725,7 +8759,7 @@ const MA = [
|
|
|
8725
8759
|
"ON DUPLICATE KEY UPDATE",
|
|
8726
8760
|
// - update:
|
|
8727
8761
|
"SET"
|
|
8728
|
-
]), RT =
|
|
8762
|
+
]), RT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), oE = _([
|
|
8729
8763
|
// - create:
|
|
8730
8764
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
8731
8765
|
// - update:
|
|
@@ -8906,7 +8940,7 @@ const MA = [
|
|
|
8906
8940
|
"REPEAT",
|
|
8907
8941
|
"RETURN",
|
|
8908
8942
|
"WHILE"
|
|
8909
|
-
]), VA =
|
|
8943
|
+
]), VA = _(["UNION [ALL | DISTINCT]"]), WA = _([
|
|
8910
8944
|
"JOIN",
|
|
8911
8945
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
8912
8946
|
"{INNER | CROSS} JOIN",
|
|
@@ -8914,12 +8948,12 @@ const MA = [
|
|
|
8914
8948
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
8915
8949
|
// non-standard joins
|
|
8916
8950
|
"STRAIGHT_JOIN"
|
|
8917
|
-
]), XA =
|
|
8951
|
+
]), XA = _([
|
|
8918
8952
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
8919
8953
|
"CHARACTER SET",
|
|
8920
8954
|
"{ROWS | RANGE} BETWEEN",
|
|
8921
8955
|
"IDENTIFIED BY"
|
|
8922
|
-
]), bA =
|
|
8956
|
+
]), bA = _([]), yA = {
|
|
8923
8957
|
name: "mysql",
|
|
8924
8958
|
tokenizerOptions: {
|
|
8925
8959
|
reservedSelect: hA,
|
|
@@ -9537,7 +9571,7 @@ const MA = [
|
|
|
9537
9571
|
// 'XOR',
|
|
9538
9572
|
"YEAR",
|
|
9539
9573
|
"YEARWEEK"
|
|
9540
|
-
], wA =
|
|
9574
|
+
], wA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), JA = _([
|
|
9541
9575
|
// queries
|
|
9542
9576
|
"WITH [RECURSIVE]",
|
|
9543
9577
|
"FROM",
|
|
@@ -9557,7 +9591,7 @@ const MA = [
|
|
|
9557
9591
|
"ON DUPLICATE KEY UPDATE",
|
|
9558
9592
|
// - update:
|
|
9559
9593
|
"SET"
|
|
9560
|
-
]), AT =
|
|
9594
|
+
]), AT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), DE = _([
|
|
9561
9595
|
// https://docs.pingcap.com/tidb/stable/sql-statement-create-view
|
|
9562
9596
|
"CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
|
|
9563
9597
|
// https://docs.pingcap.com/tidb/stable/sql-statement-update
|
|
@@ -9672,7 +9706,7 @@ const MA = [
|
|
|
9672
9706
|
"UNLOCK TABLES",
|
|
9673
9707
|
// https://docs.pingcap.com/tidb/stable/sql-statement-use
|
|
9674
9708
|
"USE"
|
|
9675
|
-
]), xA =
|
|
9709
|
+
]), xA = _(["UNION [ALL | DISTINCT]"]), vA = _([
|
|
9676
9710
|
"JOIN",
|
|
9677
9711
|
"{LEFT | RIGHT} [OUTER] JOIN",
|
|
9678
9712
|
"{INNER | CROSS} JOIN",
|
|
@@ -9680,12 +9714,12 @@ const MA = [
|
|
|
9680
9714
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
9681
9715
|
// non-standard joins
|
|
9682
9716
|
"STRAIGHT_JOIN"
|
|
9683
|
-
]), QA =
|
|
9717
|
+
]), QA = _([
|
|
9684
9718
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
9685
9719
|
"CHARACTER SET",
|
|
9686
9720
|
"{ROWS | RANGE} BETWEEN",
|
|
9687
9721
|
"IDENTIFIED BY"
|
|
9688
|
-
]), ZA =
|
|
9722
|
+
]), ZA = _([]), qA = {
|
|
9689
9723
|
name: "tidb",
|
|
9690
9724
|
tokenizerOptions: {
|
|
9691
9725
|
reservedSelect: wA,
|
|
@@ -10183,7 +10217,7 @@ const MA = [
|
|
|
10183
10217
|
// which it actually doesn't use.
|
|
10184
10218
|
//
|
|
10185
10219
|
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
|
|
10186
|
-
], Ee =
|
|
10220
|
+
], Ee = _(["SELECT [ALL | DISTINCT]"]), Te = _([
|
|
10187
10221
|
// queries
|
|
10188
10222
|
"WITH",
|
|
10189
10223
|
"FROM",
|
|
@@ -10210,7 +10244,7 @@ const MA = [
|
|
|
10210
10244
|
"NEST",
|
|
10211
10245
|
"UNNEST",
|
|
10212
10246
|
"RETURNING"
|
|
10213
|
-
]), eT =
|
|
10247
|
+
]), eT = _([
|
|
10214
10248
|
// - update:
|
|
10215
10249
|
"UPDATE",
|
|
10216
10250
|
// - delete:
|
|
@@ -10250,7 +10284,7 @@ const MA = [
|
|
|
10250
10284
|
"SET CURRENT SCHEMA",
|
|
10251
10285
|
"SHOW",
|
|
10252
10286
|
"USE [PRIMARY] KEYS"
|
|
10253
|
-
]), Re =
|
|
10287
|
+
]), Re = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), Ae = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), ee = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), Se = _([]), Ie = {
|
|
10254
10288
|
name: "n1ql",
|
|
10255
10289
|
tokenizerOptions: {
|
|
10256
10290
|
reservedSelect: Ee,
|
|
@@ -10884,7 +10918,7 @@ const MA = [
|
|
|
10884
10918
|
"PRESENTNNV",
|
|
10885
10919
|
"PRESENTV",
|
|
10886
10920
|
"PREVIOUS"
|
|
10887
|
-
], se =
|
|
10921
|
+
], se = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), Ce = _([
|
|
10888
10922
|
// queries
|
|
10889
10923
|
"WITH",
|
|
10890
10924
|
"FROM",
|
|
@@ -10908,9 +10942,9 @@ const MA = [
|
|
|
10908
10942
|
"UPDATE SET",
|
|
10909
10943
|
// other
|
|
10910
10944
|
"RETURNING"
|
|
10911
|
-
]), ST =
|
|
10945
|
+
]), ST = _([
|
|
10912
10946
|
"CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
|
|
10913
|
-
]), PE =
|
|
10947
|
+
]), PE = _([
|
|
10914
10948
|
// - create:
|
|
10915
10949
|
"CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
|
|
10916
10950
|
"CREATE MATERIALIZED VIEW",
|
|
@@ -10938,7 +10972,7 @@ const MA = [
|
|
|
10938
10972
|
"EXCEPTION",
|
|
10939
10973
|
"LOOP",
|
|
10940
10974
|
"START WITH"
|
|
10941
|
-
]), Le =
|
|
10975
|
+
]), Le = _(["UNION [ALL]", "MINUS", "INTERSECT"]), _e = _([
|
|
10942
10976
|
"JOIN",
|
|
10943
10977
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10944
10978
|
"{INNER | CROSS} JOIN",
|
|
@@ -10946,11 +10980,11 @@ const MA = [
|
|
|
10946
10980
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
10947
10981
|
// non-standard joins
|
|
10948
10982
|
"{CROSS | OUTER} APPLY"
|
|
10949
|
-
]), re =
|
|
10983
|
+
]), re = _([
|
|
10950
10984
|
"ON {UPDATE | DELETE} [SET NULL]",
|
|
10951
10985
|
"ON COMMIT",
|
|
10952
10986
|
"{ROWS | RANGE} BETWEEN"
|
|
10953
|
-
]), ne =
|
|
10987
|
+
]), ne = _([]), ie = {
|
|
10954
10988
|
name: "plsql",
|
|
10955
10989
|
tokenizerOptions: {
|
|
10956
10990
|
reservedSelect: se,
|
|
@@ -10997,7 +11031,7 @@ const MA = [
|
|
|
10997
11031
|
};
|
|
10998
11032
|
function ae(R) {
|
|
10999
11033
|
let E = v;
|
|
11000
|
-
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));
|
|
11001
11035
|
}
|
|
11002
11036
|
const oe = [
|
|
11003
11037
|
// https://www.postgresql.org/docs/14/functions.html
|
|
@@ -11836,7 +11870,7 @@ const oe = [
|
|
|
11836
11870
|
"VARCHAR",
|
|
11837
11871
|
"XML",
|
|
11838
11872
|
"ZONE"
|
|
11839
|
-
], Me =
|
|
11873
|
+
], Me = _(["SELECT [ALL | DISTINCT]"]), Ue = _([
|
|
11840
11874
|
// queries
|
|
11841
11875
|
"WITH [RECURSIVE]",
|
|
11842
11876
|
"FROM",
|
|
@@ -11859,9 +11893,9 @@ const oe = [
|
|
|
11859
11893
|
"SET",
|
|
11860
11894
|
// other
|
|
11861
11895
|
"RETURNING"
|
|
11862
|
-
]), IT =
|
|
11896
|
+
]), IT = _([
|
|
11863
11897
|
"CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
|
|
11864
|
-
]), ME =
|
|
11898
|
+
]), ME = _([
|
|
11865
11899
|
// - create
|
|
11866
11900
|
"CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
|
|
11867
11901
|
"CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
|
|
@@ -12059,17 +12093,17 @@ const oe = [
|
|
|
12059
12093
|
"START TRANSACTION",
|
|
12060
12094
|
"UNLISTEN",
|
|
12061
12095
|
"VACUUM"
|
|
12062
|
-
]), ce =
|
|
12096
|
+
]), ce = _([
|
|
12063
12097
|
"UNION [ALL | DISTINCT]",
|
|
12064
12098
|
"EXCEPT [ALL | DISTINCT]",
|
|
12065
12099
|
"INTERSECT [ALL | DISTINCT]"
|
|
12066
|
-
]), Ge =
|
|
12100
|
+
]), Ge = _([
|
|
12067
12101
|
"JOIN",
|
|
12068
12102
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12069
12103
|
"{INNER | CROSS} JOIN",
|
|
12070
12104
|
"NATURAL [INNER] JOIN",
|
|
12071
12105
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12072
|
-
]), le =
|
|
12106
|
+
]), le = _([
|
|
12073
12107
|
"PRIMARY KEY",
|
|
12074
12108
|
"GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
|
|
12075
12109
|
"ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
|
|
@@ -12080,7 +12114,7 @@ const oe = [
|
|
|
12080
12114
|
"IS [NOT] DISTINCT FROM",
|
|
12081
12115
|
"NULLS {FIRST | LAST}",
|
|
12082
12116
|
"WITH ORDINALITY"
|
|
12083
|
-
]), ue =
|
|
12117
|
+
]), ue = _([
|
|
12084
12118
|
// https://www.postgresql.org/docs/current/datatype-datetime.html
|
|
12085
12119
|
"[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
|
|
12086
12120
|
]), He = {
|
|
@@ -12765,7 +12799,7 @@ const oe = [
|
|
|
12765
12799
|
"TEXT",
|
|
12766
12800
|
"VARBYTE",
|
|
12767
12801
|
"VARCHAR"
|
|
12768
|
-
], me =
|
|
12802
|
+
], me = _(["SELECT [ALL | DISTINCT]"]), pe = _([
|
|
12769
12803
|
// queries
|
|
12770
12804
|
"WITH [RECURSIVE]",
|
|
12771
12805
|
"FROM",
|
|
@@ -12783,9 +12817,9 @@ const oe = [
|
|
|
12783
12817
|
"VALUES",
|
|
12784
12818
|
// - update:
|
|
12785
12819
|
"SET"
|
|
12786
|
-
]), OT =
|
|
12820
|
+
]), OT = _([
|
|
12787
12821
|
"CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
|
|
12788
|
-
]), UE =
|
|
12822
|
+
]), UE = _([
|
|
12789
12823
|
// - create:
|
|
12790
12824
|
"CREATE [OR REPLACE | MATERIALIZED] VIEW",
|
|
12791
12825
|
// - update:
|
|
@@ -12876,13 +12910,13 @@ const oe = [
|
|
|
12876
12910
|
"START TRANSACTION",
|
|
12877
12911
|
"UNLOAD",
|
|
12878
12912
|
"VACUUM"
|
|
12879
|
-
]), Ye =
|
|
12913
|
+
]), Ye = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), he = _([
|
|
12880
12914
|
"JOIN",
|
|
12881
12915
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
12882
12916
|
"{INNER | CROSS} JOIN",
|
|
12883
12917
|
"NATURAL [INNER] JOIN",
|
|
12884
12918
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
12885
|
-
]), fe =
|
|
12919
|
+
]), fe = _([
|
|
12886
12920
|
// https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
|
|
12887
12921
|
"NULL AS",
|
|
12888
12922
|
// https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
|
|
@@ -12890,7 +12924,7 @@ const oe = [
|
|
|
12890
12924
|
"HIVE METASTORE",
|
|
12891
12925
|
// in window specifications
|
|
12892
12926
|
"{ROWS | RANGE} BETWEEN"
|
|
12893
|
-
]), Ve =
|
|
12927
|
+
]), Ve = _([]), We = {
|
|
12894
12928
|
name: "redshift",
|
|
12895
12929
|
tokenizerOptions: {
|
|
12896
12930
|
reservedSelect: me,
|
|
@@ -13546,7 +13580,7 @@ const oe = [
|
|
|
13546
13580
|
// Shorthand functions to use in place of CASE expression
|
|
13547
13581
|
"COALESCE",
|
|
13548
13582
|
"NULLIF"
|
|
13549
|
-
], Ke =
|
|
13583
|
+
], Ke = _(["SELECT [ALL | DISTINCT]"]), $e = _([
|
|
13550
13584
|
// queries
|
|
13551
13585
|
"WITH",
|
|
13552
13586
|
"FROM",
|
|
@@ -13571,7 +13605,7 @@ const oe = [
|
|
|
13571
13605
|
// https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
|
|
13572
13606
|
"LOAD DATA [LOCAL] INPATH",
|
|
13573
13607
|
"[OVERWRITE] INTO TABLE"
|
|
13574
|
-
]), NT =
|
|
13608
|
+
]), NT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), cE = _([
|
|
13575
13609
|
// - create:
|
|
13576
13610
|
"CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
|
|
13577
13611
|
// - drop table:
|
|
@@ -13627,11 +13661,11 @@ const oe = [
|
|
|
13627
13661
|
"SHOW TBLPROPERTIES",
|
|
13628
13662
|
"SHOW VIEWS",
|
|
13629
13663
|
"UNCACHE TABLE"
|
|
13630
|
-
]), ge =
|
|
13664
|
+
]), ge = _([
|
|
13631
13665
|
"UNION [ALL | DISTINCT]",
|
|
13632
13666
|
"EXCEPT [ALL | DISTINCT]",
|
|
13633
13667
|
"INTERSECT [ALL | DISTINCT]"
|
|
13634
|
-
]), we =
|
|
13668
|
+
]), we = _([
|
|
13635
13669
|
"JOIN",
|
|
13636
13670
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
13637
13671
|
"{INNER | CROSS} JOIN",
|
|
@@ -13640,12 +13674,12 @@ const oe = [
|
|
|
13640
13674
|
// non-standard-joins
|
|
13641
13675
|
"[LEFT] {ANTI | SEMI} JOIN",
|
|
13642
13676
|
"NATURAL [LEFT] {ANTI | SEMI} JOIN"
|
|
13643
|
-
]), Je =
|
|
13677
|
+
]), Je = _([
|
|
13644
13678
|
"ON DELETE",
|
|
13645
13679
|
"ON UPDATE",
|
|
13646
13680
|
"CURRENT ROW",
|
|
13647
13681
|
"{ROWS | RANGE} BETWEEN"
|
|
13648
|
-
]), xe =
|
|
13682
|
+
]), xe = _([]), ve = {
|
|
13649
13683
|
name: "spark",
|
|
13650
13684
|
tokenizerOptions: {
|
|
13651
13685
|
reservedSelect: Ke,
|
|
@@ -13679,7 +13713,7 @@ const oe = [
|
|
|
13679
13713
|
function Qe(R) {
|
|
13680
13714
|
return R.map((E, T) => {
|
|
13681
13715
|
const A = R[T - 1] || v, e = R[T + 1] || v;
|
|
13682
|
-
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;
|
|
13683
13717
|
});
|
|
13684
13718
|
}
|
|
13685
13719
|
const Ze = [
|
|
@@ -13980,7 +14014,7 @@ const Ze = [
|
|
|
13980
14014
|
"TEXT",
|
|
13981
14015
|
"VARCHAR",
|
|
13982
14016
|
"VARYING CHARACTER"
|
|
13983
|
-
], ke =
|
|
14017
|
+
], ke = _(["SELECT [ALL | DISTINCT]"]), ze = _([
|
|
13984
14018
|
// queries
|
|
13985
14019
|
"WITH [RECURSIVE]",
|
|
13986
14020
|
"FROM",
|
|
@@ -14001,7 +14035,7 @@ const Ze = [
|
|
|
14001
14035
|
"SET",
|
|
14002
14036
|
// other:
|
|
14003
14037
|
"RETURNING"
|
|
14004
|
-
]), tT =
|
|
14038
|
+
]), tT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), GE = _([
|
|
14005
14039
|
// - create:
|
|
14006
14040
|
"CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
14007
14041
|
// - update:
|
|
@@ -14020,17 +14054,17 @@ const Ze = [
|
|
|
14020
14054
|
"RENAME TO",
|
|
14021
14055
|
// - set schema
|
|
14022
14056
|
"SET SCHEMA"
|
|
14023
|
-
]), ES =
|
|
14057
|
+
]), ES = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), TS = _([
|
|
14024
14058
|
"JOIN",
|
|
14025
14059
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14026
14060
|
"{INNER | CROSS} JOIN",
|
|
14027
14061
|
"NATURAL [INNER] JOIN",
|
|
14028
14062
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14029
|
-
]), RS =
|
|
14063
|
+
]), RS = _([
|
|
14030
14064
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14031
14065
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
14032
14066
|
"DO UPDATE"
|
|
14033
|
-
]), AS =
|
|
14067
|
+
]), AS = _([]), eS = {
|
|
14034
14068
|
name: "sqlite",
|
|
14035
14069
|
tokenizerOptions: {
|
|
14036
14070
|
reservedSelect: ke,
|
|
@@ -14392,7 +14426,7 @@ const Ze = [
|
|
|
14392
14426
|
"TIMESTAMP",
|
|
14393
14427
|
"VARBINARY",
|
|
14394
14428
|
"VARCHAR"
|
|
14395
|
-
], NS =
|
|
14429
|
+
], NS = _(["SELECT [ALL | DISTINCT]"]), tS = _([
|
|
14396
14430
|
// queries
|
|
14397
14431
|
"WITH [RECURSIVE]",
|
|
14398
14432
|
"FROM",
|
|
@@ -14411,7 +14445,7 @@ const Ze = [
|
|
|
14411
14445
|
"VALUES",
|
|
14412
14446
|
// - update:
|
|
14413
14447
|
"SET"
|
|
14414
|
-
]), sT =
|
|
14448
|
+
]), sT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), lE = _([
|
|
14415
14449
|
// - create:
|
|
14416
14450
|
"CREATE [RECURSIVE] VIEW",
|
|
14417
14451
|
// - update:
|
|
@@ -14436,20 +14470,20 @@ const Ze = [
|
|
|
14436
14470
|
"TRUNCATE TABLE",
|
|
14437
14471
|
// other
|
|
14438
14472
|
"SET SCHEMA"
|
|
14439
|
-
]), sS =
|
|
14473
|
+
]), sS = _([
|
|
14440
14474
|
"UNION [ALL | DISTINCT]",
|
|
14441
14475
|
"EXCEPT [ALL | DISTINCT]",
|
|
14442
14476
|
"INTERSECT [ALL | DISTINCT]"
|
|
14443
|
-
]), CS =
|
|
14477
|
+
]), CS = _([
|
|
14444
14478
|
"JOIN",
|
|
14445
14479
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
14446
14480
|
"{INNER | CROSS} JOIN",
|
|
14447
14481
|
"NATURAL [INNER] JOIN",
|
|
14448
14482
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
14449
|
-
]), LS =
|
|
14483
|
+
]), LS = _([
|
|
14450
14484
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
14451
14485
|
"{ROWS | RANGE} BETWEEN"
|
|
14452
|
-
]), _S =
|
|
14486
|
+
]), _S = _([]), rS = {
|
|
14453
14487
|
name: "sql",
|
|
14454
14488
|
tokenizerOptions: {
|
|
14455
14489
|
reservedSelect: NS,
|
|
@@ -15183,7 +15217,7 @@ const Ze = [
|
|
|
15183
15217
|
"CODEPOINTS",
|
|
15184
15218
|
"FUNCTION",
|
|
15185
15219
|
"JSONPATH"
|
|
15186
|
-
], oS =
|
|
15220
|
+
], oS = _(["SELECT [ALL | DISTINCT]"]), DS = _([
|
|
15187
15221
|
// queries
|
|
15188
15222
|
"WITH [RECURSIVE]",
|
|
15189
15223
|
"FROM",
|
|
@@ -15211,7 +15245,7 @@ const Ze = [
|
|
|
15211
15245
|
"PATTERN",
|
|
15212
15246
|
"SUBSET",
|
|
15213
15247
|
"DEFINE"
|
|
15214
|
-
]), CT =
|
|
15248
|
+
]), CT = _(["CREATE TABLE [IF NOT EXISTS]"]), uE = _([
|
|
15215
15249
|
// - create:
|
|
15216
15250
|
"CREATE [OR REPLACE] [MATERIALIZED] VIEW",
|
|
15217
15251
|
// - update:
|
|
@@ -15269,21 +15303,21 @@ const Ze = [
|
|
|
15269
15303
|
"SHOW ROLE GRANTS",
|
|
15270
15304
|
"SHOW FUNCTIONS",
|
|
15271
15305
|
"SHOW SESSION"
|
|
15272
|
-
]), PS =
|
|
15306
|
+
]), PS = _([
|
|
15273
15307
|
"UNION [ALL | DISTINCT]",
|
|
15274
15308
|
"EXCEPT [ALL | DISTINCT]",
|
|
15275
15309
|
"INTERSECT [ALL | DISTINCT]"
|
|
15276
|
-
]), MS =
|
|
15310
|
+
]), MS = _([
|
|
15277
15311
|
"JOIN",
|
|
15278
15312
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
15279
15313
|
"{INNER | CROSS} JOIN",
|
|
15280
15314
|
"NATURAL [INNER] JOIN",
|
|
15281
15315
|
"NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
|
|
15282
|
-
]), US =
|
|
15316
|
+
]), US = _([
|
|
15283
15317
|
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
15284
15318
|
// comparison operator
|
|
15285
15319
|
"IS [NOT] DISTINCT FROM"
|
|
15286
|
-
]), cS =
|
|
15320
|
+
]), cS = _([]), GS = {
|
|
15287
15321
|
name: "trino",
|
|
15288
15322
|
tokenizerOptions: {
|
|
15289
15323
|
reservedSelect: oS,
|
|
@@ -15839,7 +15873,7 @@ const Ze = [
|
|
|
15839
15873
|
"TIMESTAMP",
|
|
15840
15874
|
"VARBINARY",
|
|
15841
15875
|
"VARCHAR"
|
|
15842
|
-
], BS =
|
|
15876
|
+
], BS = _(["SELECT [ALL | DISTINCT]"]), dS = _([
|
|
15843
15877
|
// queries
|
|
15844
15878
|
"WITH",
|
|
15845
15879
|
"INTO",
|
|
@@ -15864,7 +15898,7 @@ const Ze = [
|
|
|
15864
15898
|
"MERGE [INTO]",
|
|
15865
15899
|
"WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
|
|
15866
15900
|
"UPDATE SET"
|
|
15867
|
-
]), LT =
|
|
15901
|
+
]), LT = _(["CREATE TABLE"]), HE = _([
|
|
15868
15902
|
// - create:
|
|
15869
15903
|
"CREATE [OR ALTER] [MATERIALIZED] VIEW",
|
|
15870
15904
|
// - update:
|
|
@@ -16044,16 +16078,16 @@ const Ze = [
|
|
|
16044
16078
|
"XACT_ABORT",
|
|
16045
16079
|
"XML INDEX",
|
|
16046
16080
|
"XML SCHEMA COLLECTION"
|
|
16047
|
-
]), FS =
|
|
16081
|
+
]), FS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), mS = _([
|
|
16048
16082
|
"JOIN",
|
|
16049
16083
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16050
16084
|
"{INNER | CROSS} JOIN",
|
|
16051
16085
|
// non-standard joins
|
|
16052
16086
|
"{CROSS | OUTER} APPLY"
|
|
16053
|
-
]), pS =
|
|
16087
|
+
]), pS = _([
|
|
16054
16088
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
|
|
16055
16089
|
"{ROWS | RANGE} BETWEEN"
|
|
16056
|
-
]), YS =
|
|
16090
|
+
]), YS = _([]), hS = {
|
|
16057
16091
|
name: "transactsql",
|
|
16058
16092
|
tokenizerOptions: {
|
|
16059
16093
|
reservedSelect: BS,
|
|
@@ -16639,7 +16673,7 @@ const Ze = [
|
|
|
16639
16673
|
"WEEKDAY",
|
|
16640
16674
|
"WEEKOFYEAR",
|
|
16641
16675
|
"YEAR"
|
|
16642
|
-
], XS =
|
|
16676
|
+
], XS = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), bS = _([
|
|
16643
16677
|
// queries
|
|
16644
16678
|
"WITH",
|
|
16645
16679
|
"FROM",
|
|
@@ -16661,9 +16695,9 @@ const Ze = [
|
|
|
16661
16695
|
// Data definition
|
|
16662
16696
|
"CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
|
|
16663
16697
|
"CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
|
|
16664
|
-
]), _T =
|
|
16698
|
+
]), _T = _([
|
|
16665
16699
|
"CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
|
|
16666
|
-
]), BE =
|
|
16700
|
+
]), BE = _([
|
|
16667
16701
|
// - create:
|
|
16668
16702
|
"CREATE VIEW",
|
|
16669
16703
|
// - update:
|
|
@@ -16840,25 +16874,25 @@ const Ze = [
|
|
|
16840
16874
|
"REPEAT",
|
|
16841
16875
|
"RETURN",
|
|
16842
16876
|
"WHILE"
|
|
16843
|
-
]), yS =
|
|
16877
|
+
]), yS = _([
|
|
16844
16878
|
"UNION [ALL | DISTINCT]",
|
|
16845
16879
|
"EXCEPT",
|
|
16846
16880
|
"INTERSECT",
|
|
16847
16881
|
"MINUS"
|
|
16848
|
-
]), KS =
|
|
16882
|
+
]), KS = _([
|
|
16849
16883
|
"JOIN",
|
|
16850
16884
|
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
16851
16885
|
"{INNER | CROSS} JOIN",
|
|
16852
16886
|
"NATURAL {LEFT | RIGHT} [OUTER] JOIN",
|
|
16853
16887
|
// non-standard joins
|
|
16854
16888
|
"STRAIGHT_JOIN"
|
|
16855
|
-
]), $S =
|
|
16889
|
+
]), $S = _([
|
|
16856
16890
|
"ON DELETE",
|
|
16857
16891
|
"ON UPDATE",
|
|
16858
16892
|
"CHARACTER SET",
|
|
16859
16893
|
"{ROWS | RANGE} BETWEEN",
|
|
16860
16894
|
"IDENTIFIED BY"
|
|
16861
|
-
]), gS =
|
|
16895
|
+
]), gS = _([]), wS = {
|
|
16862
16896
|
name: "singlestoredb",
|
|
16863
16897
|
tokenizerOptions: {
|
|
16864
16898
|
reservedSelect: XS,
|
|
@@ -17651,7 +17685,7 @@ const Ze = [
|
|
|
17651
17685
|
"ARRAY",
|
|
17652
17686
|
"GEOGRAPHY",
|
|
17653
17687
|
"GEOMETRY"
|
|
17654
|
-
], QS =
|
|
17688
|
+
], QS = _(["SELECT [ALL | DISTINCT]"]), ZS = _([
|
|
17655
17689
|
// queries
|
|
17656
17690
|
"WITH [RECURSIVE]",
|
|
17657
17691
|
"FROM",
|
|
@@ -17679,10 +17713,10 @@ const Ze = [
|
|
|
17679
17713
|
"WHEN MATCHED [AND]",
|
|
17680
17714
|
"THEN {UPDATE SET | DELETE}",
|
|
17681
17715
|
"WHEN NOT MATCHED THEN INSERT"
|
|
17682
|
-
]), rT =
|
|
17716
|
+
]), rT = _([
|
|
17683
17717
|
"CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
|
|
17684
17718
|
"CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
|
|
17685
|
-
]), dE =
|
|
17719
|
+
]), dE = _([
|
|
17686
17720
|
// - create:
|
|
17687
17721
|
"CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
|
|
17688
17722
|
// - update:
|
|
@@ -17923,14 +17957,14 @@ const Ze = [
|
|
|
17923
17957
|
"USE SCHEMA",
|
|
17924
17958
|
"USE SECONDARY ROLES",
|
|
17925
17959
|
"USE WAREHOUSE"
|
|
17926
|
-
]), qS =
|
|
17960
|
+
]), qS = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), jS = _([
|
|
17927
17961
|
"[INNER] JOIN",
|
|
17928
17962
|
"[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
17929
17963
|
"{CROSS | NATURAL} JOIN"
|
|
17930
|
-
]), kS =
|
|
17964
|
+
]), kS = _([
|
|
17931
17965
|
"{ROWS | RANGE} BETWEEN",
|
|
17932
17966
|
"ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
|
|
17933
|
-
]), zS =
|
|
17967
|
+
]), zS = _([]), EI = {
|
|
17934
17968
|
name: "snowflake",
|
|
17935
17969
|
tokenizerOptions: {
|
|
17936
17970
|
reservedSelect: QS,
|
|
@@ -18159,125 +18193,125 @@ class rI {
|
|
|
18159
18193
|
var T, A, e;
|
|
18160
18194
|
return this.validRules([
|
|
18161
18195
|
{
|
|
18162
|
-
type:
|
|
18196
|
+
type: D.DISABLE_COMMENT,
|
|
18163
18197
|
regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
|
|
18164
18198
|
},
|
|
18165
18199
|
{
|
|
18166
|
-
type:
|
|
18200
|
+
type: D.BLOCK_COMMENT,
|
|
18167
18201
|
regex: E.nestedBlockComments ? new _I() : /(\/\*[^]*?\*\/)/uy
|
|
18168
18202
|
},
|
|
18169
18203
|
{
|
|
18170
|
-
type:
|
|
18204
|
+
type: D.LINE_COMMENT,
|
|
18171
18205
|
regex: SI((T = E.lineCommentTypes) !== null && T !== void 0 ? T : ["--"])
|
|
18172
18206
|
},
|
|
18173
18207
|
{
|
|
18174
|
-
type:
|
|
18208
|
+
type: D.QUOTED_IDENTIFIER,
|
|
18175
18209
|
regex: DT(E.identTypes)
|
|
18176
18210
|
},
|
|
18177
18211
|
{
|
|
18178
|
-
type:
|
|
18212
|
+
type: D.NUMBER,
|
|
18179
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
|
|
18180
18214
|
},
|
|
18181
18215
|
// RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
|
|
18182
18216
|
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
18183
18217
|
{
|
|
18184
|
-
type:
|
|
18218
|
+
type: D.RESERVED_KEYWORD_PHRASE,
|
|
18185
18219
|
regex: V((A = E.reservedKeywordPhrases) !== null && A !== void 0 ? A : [], E.identChars),
|
|
18186
18220
|
text: d
|
|
18187
18221
|
},
|
|
18188
18222
|
{
|
|
18189
|
-
type:
|
|
18223
|
+
type: D.RESERVED_DATA_TYPE_PHRASE,
|
|
18190
18224
|
regex: V((e = E.reservedDataTypePhrases) !== null && e !== void 0 ? e : [], E.identChars),
|
|
18191
18225
|
text: d
|
|
18192
18226
|
},
|
|
18193
18227
|
{
|
|
18194
|
-
type:
|
|
18228
|
+
type: D.CASE,
|
|
18195
18229
|
regex: /CASE\b/iuy,
|
|
18196
18230
|
text: d
|
|
18197
18231
|
},
|
|
18198
18232
|
{
|
|
18199
|
-
type:
|
|
18233
|
+
type: D.END,
|
|
18200
18234
|
regex: /END\b/iuy,
|
|
18201
18235
|
text: d
|
|
18202
18236
|
},
|
|
18203
18237
|
{
|
|
18204
|
-
type:
|
|
18238
|
+
type: D.BETWEEN,
|
|
18205
18239
|
regex: /BETWEEN\b/iuy,
|
|
18206
18240
|
text: d
|
|
18207
18241
|
},
|
|
18208
18242
|
{
|
|
18209
|
-
type:
|
|
18243
|
+
type: D.LIMIT,
|
|
18210
18244
|
regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
18211
18245
|
text: d
|
|
18212
18246
|
},
|
|
18213
18247
|
{
|
|
18214
|
-
type:
|
|
18248
|
+
type: D.RESERVED_CLAUSE,
|
|
18215
18249
|
regex: V(E.reservedClauses, E.identChars),
|
|
18216
18250
|
text: d
|
|
18217
18251
|
},
|
|
18218
18252
|
{
|
|
18219
|
-
type:
|
|
18253
|
+
type: D.RESERVED_SELECT,
|
|
18220
18254
|
regex: V(E.reservedSelect, E.identChars),
|
|
18221
18255
|
text: d
|
|
18222
18256
|
},
|
|
18223
18257
|
{
|
|
18224
|
-
type:
|
|
18258
|
+
type: D.RESERVED_SET_OPERATION,
|
|
18225
18259
|
regex: V(E.reservedSetOperations, E.identChars),
|
|
18226
18260
|
text: d
|
|
18227
18261
|
},
|
|
18228
18262
|
{
|
|
18229
|
-
type:
|
|
18263
|
+
type: D.WHEN,
|
|
18230
18264
|
regex: /WHEN\b/iuy,
|
|
18231
18265
|
text: d
|
|
18232
18266
|
},
|
|
18233
18267
|
{
|
|
18234
|
-
type:
|
|
18268
|
+
type: D.ELSE,
|
|
18235
18269
|
regex: /ELSE\b/iuy,
|
|
18236
18270
|
text: d
|
|
18237
18271
|
},
|
|
18238
18272
|
{
|
|
18239
|
-
type:
|
|
18273
|
+
type: D.THEN,
|
|
18240
18274
|
regex: /THEN\b/iuy,
|
|
18241
18275
|
text: d
|
|
18242
18276
|
},
|
|
18243
18277
|
{
|
|
18244
|
-
type:
|
|
18278
|
+
type: D.RESERVED_JOIN,
|
|
18245
18279
|
regex: V(E.reservedJoins, E.identChars),
|
|
18246
18280
|
text: d
|
|
18247
18281
|
},
|
|
18248
18282
|
{
|
|
18249
|
-
type:
|
|
18283
|
+
type: D.AND,
|
|
18250
18284
|
regex: /AND\b/iuy,
|
|
18251
18285
|
text: d
|
|
18252
18286
|
},
|
|
18253
18287
|
{
|
|
18254
|
-
type:
|
|
18288
|
+
type: D.OR,
|
|
18255
18289
|
regex: /OR\b/iuy,
|
|
18256
18290
|
text: d
|
|
18257
18291
|
},
|
|
18258
18292
|
{
|
|
18259
|
-
type:
|
|
18293
|
+
type: D.XOR,
|
|
18260
18294
|
regex: E.supportsXor ? /XOR\b/iuy : void 0,
|
|
18261
18295
|
text: d
|
|
18262
18296
|
},
|
|
18263
18297
|
...E.operatorKeyword ? [
|
|
18264
18298
|
{
|
|
18265
|
-
type:
|
|
18299
|
+
type: D.OPERATOR,
|
|
18266
18300
|
regex: /OPERATOR *\([^)]+\)/iuy
|
|
18267
18301
|
}
|
|
18268
18302
|
] : [],
|
|
18269
18303
|
{
|
|
18270
|
-
type:
|
|
18304
|
+
type: D.RESERVED_FUNCTION_NAME,
|
|
18271
18305
|
regex: V(E.reservedFunctionNames, E.identChars),
|
|
18272
18306
|
text: d
|
|
18273
18307
|
},
|
|
18274
18308
|
{
|
|
18275
|
-
type:
|
|
18309
|
+
type: D.RESERVED_DATA_TYPE,
|
|
18276
18310
|
regex: V(E.reservedDataTypes, E.identChars),
|
|
18277
18311
|
text: d
|
|
18278
18312
|
},
|
|
18279
18313
|
{
|
|
18280
|
-
type:
|
|
18314
|
+
type: D.RESERVED_KEYWORD,
|
|
18281
18315
|
regex: V(E.reservedKeywords, E.identChars),
|
|
18282
18316
|
text: d
|
|
18283
18317
|
}
|
|
@@ -18289,26 +18323,26 @@ class rI {
|
|
|
18289
18323
|
var T, A;
|
|
18290
18324
|
return this.validRules([
|
|
18291
18325
|
{
|
|
18292
|
-
type:
|
|
18326
|
+
type: D.VARIABLE,
|
|
18293
18327
|
regex: E.variableTypes ? NI(E.variableTypes) : void 0
|
|
18294
18328
|
},
|
|
18295
|
-
{ type:
|
|
18329
|
+
{ type: D.STRING, regex: DT(E.stringTypes) },
|
|
18296
18330
|
{
|
|
18297
|
-
type:
|
|
18331
|
+
type: D.IDENTIFIER,
|
|
18298
18332
|
regex: tI(E.identChars)
|
|
18299
18333
|
},
|
|
18300
|
-
{ type:
|
|
18301
|
-
{ type:
|
|
18334
|
+
{ type: D.DELIMITER, regex: /[;]/uy },
|
|
18335
|
+
{ type: D.COMMA, regex: /[,]/y },
|
|
18302
18336
|
{
|
|
18303
|
-
type:
|
|
18337
|
+
type: D.OPEN_PAREN,
|
|
18304
18338
|
regex: iT("open", E.extraParens)
|
|
18305
18339
|
},
|
|
18306
18340
|
{
|
|
18307
|
-
type:
|
|
18341
|
+
type: D.CLOSE_PAREN,
|
|
18308
18342
|
regex: iT("close", E.extraParens)
|
|
18309
18343
|
},
|
|
18310
18344
|
{
|
|
18311
|
-
type:
|
|
18345
|
+
type: D.OPERATOR,
|
|
18312
18346
|
regex: aT([
|
|
18313
18347
|
// standard operators
|
|
18314
18348
|
"+",
|
|
@@ -18324,9 +18358,9 @@ class rI {
|
|
|
18324
18358
|
...(T = E.operators) !== null && T !== void 0 ? T : []
|
|
18325
18359
|
])
|
|
18326
18360
|
},
|
|
18327
|
-
{ type:
|
|
18361
|
+
{ type: D.ASTERISK, regex: /[*]/uy },
|
|
18328
18362
|
{
|
|
18329
|
-
type:
|
|
18363
|
+
type: D.PROPERTY_ACCESS_OPERATOR,
|
|
18330
18364
|
regex: aT([".", ...(A = E.propertyAccessOperators) !== null && A !== void 0 ? A : []])
|
|
18331
18365
|
}
|
|
18332
18366
|
]);
|
|
@@ -18344,33 +18378,33 @@ class rI {
|
|
|
18344
18378
|
};
|
|
18345
18379
|
return this.validRules([
|
|
18346
18380
|
{
|
|
18347
|
-
type:
|
|
18381
|
+
type: D.NAMED_PARAMETER,
|
|
18348
18382
|
regex: mE(C.named, fT(E.paramChars || E.identChars)),
|
|
18349
|
-
key: (
|
|
18383
|
+
key: (O) => O.slice(1)
|
|
18350
18384
|
},
|
|
18351
18385
|
{
|
|
18352
|
-
type:
|
|
18386
|
+
type: D.QUOTED_PARAMETER,
|
|
18353
18387
|
regex: mE(C.quoted, hT(E.identTypes)),
|
|
18354
|
-
key: (
|
|
18355
|
-
tokenKey:
|
|
18356
|
-
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)
|
|
18357
18391
|
})
|
|
18358
18392
|
},
|
|
18359
18393
|
{
|
|
18360
|
-
type:
|
|
18394
|
+
type: D.NUMBERED_PARAMETER,
|
|
18361
18395
|
regex: mE(C.numbered, "[0-9]+"),
|
|
18362
|
-
key: (
|
|
18396
|
+
key: (O) => O.slice(1)
|
|
18363
18397
|
},
|
|
18364
18398
|
{
|
|
18365
|
-
type:
|
|
18399
|
+
type: D.POSITIONAL_PARAMETER,
|
|
18366
18400
|
regex: C.positional ? /[?]/y : void 0
|
|
18367
18401
|
},
|
|
18368
|
-
...C.custom.map((
|
|
18369
|
-
var
|
|
18402
|
+
...C.custom.map((O) => {
|
|
18403
|
+
var N;
|
|
18370
18404
|
return {
|
|
18371
|
-
type:
|
|
18372
|
-
regex: K(
|
|
18373
|
-
key: (
|
|
18405
|
+
type: D.CUSTOM_PARAMETER,
|
|
18406
|
+
regex: K(O.regex),
|
|
18407
|
+
key: (N = O.key) !== null && N !== void 0 ? N : ((s) => s)
|
|
18374
18408
|
};
|
|
18375
18409
|
})
|
|
18376
18410
|
]);
|
|
@@ -18432,195 +18466,195 @@ function UI() {
|
|
|
18432
18466
|
(function(E, T) {
|
|
18433
18467
|
R.exports ? R.exports = T() : E.nearley = T();
|
|
18434
18468
|
})(MI, function() {
|
|
18435
|
-
function E(
|
|
18436
|
-
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;
|
|
18437
18471
|
}
|
|
18438
|
-
E.highestId = 0, E.prototype.toString = function(
|
|
18439
|
-
var
|
|
18440
|
-
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;
|
|
18441
18475
|
};
|
|
18442
|
-
function T(
|
|
18443
|
-
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;
|
|
18444
18478
|
}
|
|
18445
18479
|
T.prototype.toString = function() {
|
|
18446
18480
|
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
18447
|
-
}, T.prototype.nextState = function(
|
|
18448
|
-
var
|
|
18449
|
-
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;
|
|
18450
18484
|
}, T.prototype.build = function() {
|
|
18451
|
-
var
|
|
18485
|
+
var O = [], N = this;
|
|
18452
18486
|
do
|
|
18453
|
-
|
|
18454
|
-
while (
|
|
18455
|
-
return
|
|
18487
|
+
O.push(N.right.data), N = N.left;
|
|
18488
|
+
while (N.left);
|
|
18489
|
+
return O.reverse(), O;
|
|
18456
18490
|
}, T.prototype.finish = function() {
|
|
18457
18491
|
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
|
|
18458
18492
|
};
|
|
18459
|
-
function A(
|
|
18460
|
-
this.grammar =
|
|
18493
|
+
function A(O, N) {
|
|
18494
|
+
this.grammar = O, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
18461
18495
|
}
|
|
18462
|
-
A.prototype.process = function(
|
|
18463
|
-
for (var
|
|
18464
|
-
var
|
|
18465
|
-
if (
|
|
18466
|
-
if (
|
|
18467
|
-
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--; ) {
|
|
18468
18502
|
var P = o[l];
|
|
18469
|
-
this.complete(P,
|
|
18503
|
+
this.complete(P, i);
|
|
18470
18504
|
}
|
|
18471
|
-
if (
|
|
18472
|
-
var c =
|
|
18473
|
-
(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);
|
|
18474
18508
|
}
|
|
18475
18509
|
}
|
|
18476
18510
|
} else {
|
|
18477
|
-
var c =
|
|
18511
|
+
var c = i.rule.symbols[i.dot];
|
|
18478
18512
|
if (typeof c != "string") {
|
|
18479
|
-
this.scannable.push(
|
|
18513
|
+
this.scannable.push(i);
|
|
18480
18514
|
continue;
|
|
18481
18515
|
}
|
|
18482
18516
|
if (s[c]) {
|
|
18483
|
-
if (s[c].push(
|
|
18484
|
-
for (var M =
|
|
18517
|
+
if (s[c].push(i), r.hasOwnProperty(c))
|
|
18518
|
+
for (var M = r[c], l = 0; l < M.length; l++) {
|
|
18485
18519
|
var u = M[l];
|
|
18486
|
-
this.complete(
|
|
18520
|
+
this.complete(i, u);
|
|
18487
18521
|
}
|
|
18488
18522
|
} else
|
|
18489
|
-
s[c] = [
|
|
18523
|
+
s[c] = [i], this.predict(c);
|
|
18490
18524
|
}
|
|
18491
18525
|
}
|
|
18492
|
-
}, A.prototype.predict = function(
|
|
18493
|
-
for (var
|
|
18494
|
-
var
|
|
18495
|
-
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);
|
|
18496
18530
|
}
|
|
18497
|
-
}, A.prototype.complete = function(
|
|
18498
|
-
var s =
|
|
18531
|
+
}, A.prototype.complete = function(O, N) {
|
|
18532
|
+
var s = O.nextState(N);
|
|
18499
18533
|
this.states.push(s);
|
|
18500
18534
|
};
|
|
18501
|
-
function e(
|
|
18502
|
-
this.rules =
|
|
18535
|
+
function e(O, N) {
|
|
18536
|
+
this.rules = O, this.start = N || this.rules[0].name;
|
|
18503
18537
|
var s = this.byName = {};
|
|
18504
|
-
this.rules.forEach(function(
|
|
18505
|
-
s.hasOwnProperty(
|
|
18538
|
+
this.rules.forEach(function(r) {
|
|
18539
|
+
s.hasOwnProperty(r.name) || (s[r.name] = []), s[r.name].push(r);
|
|
18506
18540
|
});
|
|
18507
18541
|
}
|
|
18508
|
-
e.fromCompiled = function(
|
|
18509
|
-
var s =
|
|
18510
|
-
|
|
18511
|
-
var
|
|
18512
|
-
return new E(
|
|
18513
|
-
}),
|
|
18514
|
-
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;
|
|
18515
18549
|
};
|
|
18516
18550
|
function S() {
|
|
18517
18551
|
this.reset("");
|
|
18518
18552
|
}
|
|
18519
|
-
S.prototype.reset = function(
|
|
18520
|
-
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;
|
|
18521
18555
|
}, S.prototype.next = function() {
|
|
18522
18556
|
if (this.index < this.buffer.length) {
|
|
18523
|
-
var
|
|
18524
|
-
return
|
|
18525
|
-
` && (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 };
|
|
18526
18560
|
}
|
|
18527
18561
|
}, S.prototype.save = function() {
|
|
18528
18562
|
return {
|
|
18529
18563
|
line: this.line,
|
|
18530
18564
|
col: this.index - this.lastLineBreak
|
|
18531
18565
|
};
|
|
18532
|
-
}, S.prototype.formatError = function(
|
|
18566
|
+
}, S.prototype.formatError = function(O, N) {
|
|
18533
18567
|
var s = this.buffer;
|
|
18534
18568
|
if (typeof s == "string") {
|
|
18535
|
-
var
|
|
18569
|
+
var r = s.split(`
|
|
18536
18570
|
`).slice(
|
|
18537
18571
|
Math.max(0, this.line - 5),
|
|
18538
18572
|
this.line
|
|
18539
|
-
),
|
|
18573
|
+
), L = s.indexOf(`
|
|
18540
18574
|
`, this.index);
|
|
18541
|
-
|
|
18542
|
-
var
|
|
18543
|
-
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 + `:
|
|
18544
18578
|
|
|
18545
|
-
`,
|
|
18546
|
-
return l(this.line -
|
|
18579
|
+
`, N += r.map(function(P, c) {
|
|
18580
|
+
return l(this.line - r.length + c + 1, o) + " " + P;
|
|
18547
18581
|
}, this).join(`
|
|
18548
|
-
`),
|
|
18549
|
-
` + l("", o +
|
|
18550
|
-
`,
|
|
18582
|
+
`), N += `
|
|
18583
|
+
` + l("", o + i) + `^
|
|
18584
|
+
`, N;
|
|
18551
18585
|
} else
|
|
18552
|
-
return
|
|
18586
|
+
return N + " at index " + (this.index - 1);
|
|
18553
18587
|
function l(P, c) {
|
|
18554
18588
|
var M = String(P);
|
|
18555
18589
|
return Array(c - M.length + 1).join(" ") + M;
|
|
18556
18590
|
}
|
|
18557
18591
|
};
|
|
18558
|
-
function I(
|
|
18559
|
-
if (
|
|
18560
|
-
var
|
|
18592
|
+
function I(O, N, s) {
|
|
18593
|
+
if (O instanceof e)
|
|
18594
|
+
var r = O, s = N;
|
|
18561
18595
|
else
|
|
18562
|
-
var
|
|
18563
|
-
this.grammar =
|
|
18596
|
+
var r = e.fromCompiled(O, N);
|
|
18597
|
+
this.grammar = r, this.options = {
|
|
18564
18598
|
keepHistory: !1,
|
|
18565
|
-
lexer:
|
|
18599
|
+
lexer: r.lexer || new S()
|
|
18566
18600
|
};
|
|
18567
|
-
for (var
|
|
18568
|
-
this.options[
|
|
18601
|
+
for (var L in s || {})
|
|
18602
|
+
this.options[L] = s[L];
|
|
18569
18603
|
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
18570
|
-
var
|
|
18571
|
-
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;
|
|
18572
18606
|
}
|
|
18573
|
-
I.fail = {}, I.prototype.feed = function(
|
|
18574
|
-
var
|
|
18575
|
-
|
|
18607
|
+
I.fail = {}, I.prototype.feed = function(O) {
|
|
18608
|
+
var N = this.lexer;
|
|
18609
|
+
N.reset(O, this.lexerState);
|
|
18576
18610
|
for (var s; ; ) {
|
|
18577
18611
|
try {
|
|
18578
|
-
if (s =
|
|
18612
|
+
if (s = N.next(), !s)
|
|
18579
18613
|
break;
|
|
18580
18614
|
} catch (Y) {
|
|
18581
18615
|
var o = new A(this.grammar, this.current + 1);
|
|
18582
18616
|
this.table.push(o);
|
|
18583
|
-
var
|
|
18584
|
-
throw
|
|
18617
|
+
var r = new Error(this.reportLexerError(Y));
|
|
18618
|
+
throw r.offset = this.current, r.token = Y.token, r;
|
|
18585
18619
|
}
|
|
18586
|
-
var
|
|
18620
|
+
var L = this.table[this.current];
|
|
18587
18621
|
this.options.keepHistory || delete this.table[this.current - 1];
|
|
18588
|
-
var
|
|
18622
|
+
var i = this.current + 1, o = new A(this.grammar, i);
|
|
18589
18623
|
this.table.push(o);
|
|
18590
|
-
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--; ) {
|
|
18591
18625
|
var u = c[M], H = u.rule.symbols[u.dot];
|
|
18592
18626
|
if (H.test ? H.test(P) : H.type ? H.type === s.type : H.literal === l) {
|
|
18593
|
-
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 });
|
|
18594
18628
|
o.states.push(B);
|
|
18595
18629
|
}
|
|
18596
18630
|
}
|
|
18597
18631
|
if (o.process(), o.states.length === 0) {
|
|
18598
|
-
var
|
|
18599
|
-
throw
|
|
18632
|
+
var r = new Error(this.reportError(s));
|
|
18633
|
+
throw r.offset = this.current, r.token = s, r;
|
|
18600
18634
|
}
|
|
18601
|
-
this.options.keepHistory && (
|
|
18635
|
+
this.options.keepHistory && (L.lexerState = N.save()), this.current++;
|
|
18602
18636
|
}
|
|
18603
|
-
return
|
|
18604
|
-
}, I.prototype.reportLexerError = function(
|
|
18605
|
-
var
|
|
18606
|
-
return
|
|
18607
|
-
}, I.prototype.reportError = function(
|
|
18608
|
-
var
|
|
18609
|
-
return this.reportErrorCommon(s,
|
|
18610
|
-
}, 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) {
|
|
18611
18645
|
var s = [];
|
|
18612
|
-
s.push(
|
|
18613
|
-
var
|
|
18646
|
+
s.push(O);
|
|
18647
|
+
var r = this.table.length - 2, L = this.table[r], i = L.states.filter(function(l) {
|
|
18614
18648
|
var P = l.rule.symbols[l.dot];
|
|
18615
18649
|
return P && typeof P != "string";
|
|
18616
18650
|
});
|
|
18617
|
-
if (
|
|
18618
|
-
s.push("Unexpected " +
|
|
18619
|
-
`), 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);
|
|
18620
18654
|
else {
|
|
18621
|
-
s.push("Unexpected " +
|
|
18655
|
+
s.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
|
|
18622
18656
|
`);
|
|
18623
|
-
var o =
|
|
18657
|
+
var o = i.map(function(l) {
|
|
18624
18658
|
return this.buildFirstStateStack(l, []) || [l];
|
|
18625
18659
|
}, this);
|
|
18626
18660
|
o.forEach(function(l) {
|
|
@@ -18630,68 +18664,68 @@ function UI() {
|
|
|
18630
18664
|
}
|
|
18631
18665
|
return s.push(""), s.join(`
|
|
18632
18666
|
`);
|
|
18633
|
-
}, I.prototype.displayStateStack = function(
|
|
18634
|
-
for (var s,
|
|
18635
|
-
var
|
|
18636
|
-
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;
|
|
18637
18671
|
}
|
|
18638
|
-
}, I.prototype.getSymbolDisplay = function(
|
|
18639
|
-
return t(
|
|
18640
|
-
}, I.prototype.buildFirstStateStack = function(
|
|
18641
|
-
if (
|
|
18672
|
+
}, I.prototype.getSymbolDisplay = function(O) {
|
|
18673
|
+
return t(O);
|
|
18674
|
+
}, I.prototype.buildFirstStateStack = function(O, N) {
|
|
18675
|
+
if (N.indexOf(O) !== -1)
|
|
18642
18676
|
return null;
|
|
18643
|
-
if (
|
|
18644
|
-
return [
|
|
18645
|
-
var s =
|
|
18646
|
-
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);
|
|
18647
18681
|
}, I.prototype.save = function() {
|
|
18648
|
-
var
|
|
18649
|
-
return
|
|
18650
|
-
}, I.prototype.restore = function(
|
|
18651
|
-
var
|
|
18652
|
-
this.current =
|
|
18653
|
-
}, 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) {
|
|
18654
18688
|
if (!this.options.keepHistory)
|
|
18655
18689
|
throw new Error("set option `keepHistory` to enable rewinding");
|
|
18656
|
-
this.restore(this.table[
|
|
18690
|
+
this.restore(this.table[O]);
|
|
18657
18691
|
}, I.prototype.finish = function() {
|
|
18658
|
-
var
|
|
18659
|
-
return s.states.forEach(function(
|
|
18660
|
-
|
|
18661
|
-
}),
|
|
18662
|
-
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;
|
|
18663
18697
|
});
|
|
18664
18698
|
};
|
|
18665
|
-
function t(
|
|
18666
|
-
var
|
|
18667
|
-
if (
|
|
18668
|
-
return
|
|
18669
|
-
if (
|
|
18670
|
-
if (
|
|
18671
|
-
return JSON.stringify(
|
|
18672
|
-
if (
|
|
18673
|
-
return "character matching " +
|
|
18674
|
-
if (
|
|
18675
|
-
return
|
|
18676
|
-
if (
|
|
18677
|
-
return "token matching " + String(
|
|
18678
|
-
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);
|
|
18679
18713
|
}
|
|
18680
18714
|
}
|
|
18681
|
-
function C(
|
|
18682
|
-
var
|
|
18683
|
-
if (
|
|
18684
|
-
return
|
|
18685
|
-
if (
|
|
18686
|
-
if (
|
|
18687
|
-
return JSON.stringify(
|
|
18688
|
-
if (
|
|
18689
|
-
return
|
|
18690
|
-
if (
|
|
18691
|
-
return "%" +
|
|
18692
|
-
if (
|
|
18693
|
-
return "<" + String(
|
|
18694
|
-
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);
|
|
18695
18729
|
}
|
|
18696
18730
|
}
|
|
18697
18731
|
return {
|
|
@@ -18710,39 +18744,39 @@ function lI(R) {
|
|
|
18710
18744
|
const uI = (R, E, T) => {
|
|
18711
18745
|
if (mT(R.type)) {
|
|
18712
18746
|
const A = mI(T, E);
|
|
18713
|
-
if (A && A.type ===
|
|
18714
|
-
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 });
|
|
18715
18749
|
const e = Q(T, E);
|
|
18716
|
-
if (e && e.type ===
|
|
18717
|
-
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 });
|
|
18718
18752
|
}
|
|
18719
18753
|
return R;
|
|
18720
18754
|
}, HI = (R, E, T) => {
|
|
18721
|
-
if (R.type ===
|
|
18755
|
+
if (R.type === D.RESERVED_FUNCTION_NAME) {
|
|
18722
18756
|
const A = Q(T, E);
|
|
18723
18757
|
if (!A || !WT(A))
|
|
18724
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18758
|
+
return Object.assign(Object.assign({}, R), { type: D.IDENTIFIER, text: R.raw });
|
|
18725
18759
|
}
|
|
18726
18760
|
return R;
|
|
18727
18761
|
}, BI = (R, E, T) => {
|
|
18728
|
-
if (R.type ===
|
|
18762
|
+
if (R.type === D.RESERVED_DATA_TYPE) {
|
|
18729
18763
|
const A = Q(T, E);
|
|
18730
18764
|
if (A && WT(A))
|
|
18731
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18765
|
+
return Object.assign(Object.assign({}, R), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
18732
18766
|
}
|
|
18733
18767
|
return R;
|
|
18734
18768
|
}, dI = (R, E, T) => {
|
|
18735
|
-
if (R.type ===
|
|
18769
|
+
if (R.type === D.IDENTIFIER) {
|
|
18736
18770
|
const A = Q(T, E);
|
|
18737
18771
|
if (A && XT(A))
|
|
18738
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18772
|
+
return Object.assign(Object.assign({}, R), { type: D.ARRAY_IDENTIFIER });
|
|
18739
18773
|
}
|
|
18740
18774
|
return R;
|
|
18741
18775
|
}, FI = (R, E, T) => {
|
|
18742
|
-
if (R.type ===
|
|
18776
|
+
if (R.type === D.RESERVED_DATA_TYPE) {
|
|
18743
18777
|
const A = Q(T, E);
|
|
18744
18778
|
if (A && XT(A))
|
|
18745
|
-
return Object.assign(Object.assign({}, R), { type:
|
|
18779
|
+
return Object.assign(Object.assign({}, R), { type: D.ARRAY_KEYWORD });
|
|
18746
18780
|
}
|
|
18747
18781
|
return R;
|
|
18748
18782
|
}, mI = (R, E) => Q(R, E, -1), Q = (R, E, T = 1) => {
|
|
@@ -18750,7 +18784,7 @@ const uI = (R, E, T) => {
|
|
|
18750
18784
|
for (; R[E + A * T] && pI(R[E + A * T]); )
|
|
18751
18785
|
A++;
|
|
18752
18786
|
return R[E + A * T];
|
|
18753
|
-
}, 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;
|
|
18754
18788
|
class bT {
|
|
18755
18789
|
constructor(E) {
|
|
18756
18790
|
this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
|
|
@@ -18768,7 +18802,7 @@ class bT {
|
|
|
18768
18802
|
return `Parse error at token: ${E.text} at line ${T} column ${A}`;
|
|
18769
18803
|
}
|
|
18770
18804
|
has(E) {
|
|
18771
|
-
return E in
|
|
18805
|
+
return E in D;
|
|
18772
18806
|
}
|
|
18773
18807
|
}
|
|
18774
18808
|
var U;
|
|
@@ -18818,7 +18852,7 @@ const G = new bT((R) => []), W = ([[R]]) => R, F = (R) => ({
|
|
|
18818
18852
|
postprocess: ([R, [E]]) => ({
|
|
18819
18853
|
type: U.statement,
|
|
18820
18854
|
children: R,
|
|
18821
|
-
hasSemicolon: E.type ===
|
|
18855
|
+
hasSemicolon: E.type === D.DELIMITER
|
|
18822
18856
|
})
|
|
18823
18857
|
},
|
|
18824
18858
|
{ name: "expressions_or_clauses$ebnf$1", symbols: [] },
|
|
@@ -19212,10 +19246,10 @@ ${JSON.stringify(I, void 0, 2)}`);
|
|
|
19212
19246
|
}
|
|
19213
19247
|
};
|
|
19214
19248
|
}
|
|
19215
|
-
var
|
|
19249
|
+
var a;
|
|
19216
19250
|
(function(R) {
|
|
19217
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";
|
|
19218
|
-
})(
|
|
19252
|
+
})(a = a || (a = {}));
|
|
19219
19253
|
class yT {
|
|
19220
19254
|
constructor(E) {
|
|
19221
19255
|
this.indentation = E, this.items = [];
|
|
@@ -19226,26 +19260,26 @@ class yT {
|
|
|
19226
19260
|
add(...E) {
|
|
19227
19261
|
for (const T of E)
|
|
19228
19262
|
switch (T) {
|
|
19229
|
-
case
|
|
19230
|
-
this.items.push(
|
|
19263
|
+
case a.SPACE:
|
|
19264
|
+
this.items.push(a.SPACE);
|
|
19231
19265
|
break;
|
|
19232
|
-
case
|
|
19266
|
+
case a.NO_SPACE:
|
|
19233
19267
|
this.trimHorizontalWhitespace();
|
|
19234
19268
|
break;
|
|
19235
|
-
case
|
|
19269
|
+
case a.NO_NEWLINE:
|
|
19236
19270
|
this.trimWhitespace();
|
|
19237
19271
|
break;
|
|
19238
|
-
case
|
|
19239
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
19272
|
+
case a.NEWLINE:
|
|
19273
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
|
|
19240
19274
|
break;
|
|
19241
|
-
case
|
|
19242
|
-
this.trimHorizontalWhitespace(), this.addNewline(
|
|
19275
|
+
case a.MANDATORY_NEWLINE:
|
|
19276
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
|
|
19243
19277
|
break;
|
|
19244
|
-
case
|
|
19278
|
+
case a.INDENT:
|
|
19245
19279
|
this.addIndentation();
|
|
19246
19280
|
break;
|
|
19247
|
-
case
|
|
19248
|
-
this.items.push(
|
|
19281
|
+
case a.SINGLE_INDENT:
|
|
19282
|
+
this.items.push(a.SINGLE_INDENT);
|
|
19249
19283
|
break;
|
|
19250
19284
|
default:
|
|
19251
19285
|
this.items.push(T);
|
|
@@ -19262,10 +19296,10 @@ class yT {
|
|
|
19262
19296
|
addNewline(E) {
|
|
19263
19297
|
if (this.items.length > 0)
|
|
19264
19298
|
switch (Z(this.items)) {
|
|
19265
|
-
case
|
|
19299
|
+
case a.NEWLINE:
|
|
19266
19300
|
this.items.pop(), this.items.push(E);
|
|
19267
19301
|
break;
|
|
19268
|
-
case
|
|
19302
|
+
case a.MANDATORY_NEWLINE:
|
|
19269
19303
|
break;
|
|
19270
19304
|
default:
|
|
19271
19305
|
this.items.push(E);
|
|
@@ -19274,7 +19308,7 @@ class yT {
|
|
|
19274
19308
|
}
|
|
19275
19309
|
addIndentation() {
|
|
19276
19310
|
for (let E = 0; E < this.indentation.getLevel(); E++)
|
|
19277
|
-
this.items.push(
|
|
19311
|
+
this.items.push(a.SINGLE_INDENT);
|
|
19278
19312
|
}
|
|
19279
19313
|
/**
|
|
19280
19314
|
* Returns the final SQL string.
|
|
@@ -19290,20 +19324,20 @@ class yT {
|
|
|
19290
19324
|
}
|
|
19291
19325
|
itemToString(E) {
|
|
19292
19326
|
switch (E) {
|
|
19293
|
-
case
|
|
19327
|
+
case a.SPACE:
|
|
19294
19328
|
return " ";
|
|
19295
|
-
case
|
|
19296
|
-
case
|
|
19329
|
+
case a.NEWLINE:
|
|
19330
|
+
case a.MANDATORY_NEWLINE:
|
|
19297
19331
|
return `
|
|
19298
19332
|
`;
|
|
19299
|
-
case
|
|
19333
|
+
case a.SINGLE_INDENT:
|
|
19300
19334
|
return this.indentation.getSingleIndent();
|
|
19301
19335
|
default:
|
|
19302
19336
|
return E;
|
|
19303
19337
|
}
|
|
19304
19338
|
}
|
|
19305
19339
|
}
|
|
19306
|
-
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;
|
|
19307
19341
|
function GT(R, E) {
|
|
19308
19342
|
if (E === "standard")
|
|
19309
19343
|
return R;
|
|
@@ -19311,7 +19345,7 @@ function GT(R, E) {
|
|
|
19311
19345
|
return R.length >= 10 && R.includes(" ") && ([R, ...T] = R.split(" ")), E === "tabularLeft" ? R = R.padEnd(9, " ") : R = R.padStart(9, " "), R + ["", ...T].join(" ");
|
|
19312
19346
|
}
|
|
19313
19347
|
function lT(R) {
|
|
19314
|
-
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;
|
|
19315
19349
|
}
|
|
19316
19350
|
const YE = "top-level", yI = "block-level";
|
|
19317
19351
|
class KT {
|
|
@@ -19375,9 +19409,9 @@ class KI extends yT {
|
|
|
19375
19409
|
if (typeof E == "string")
|
|
19376
19410
|
this.length += E.length, this.trailingSpace = !1;
|
|
19377
19411
|
else {
|
|
19378
|
-
if (E ===
|
|
19412
|
+
if (E === a.MANDATORY_NEWLINE || E === a.NEWLINE)
|
|
19379
19413
|
throw new hE();
|
|
19380
|
-
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--);
|
|
19381
19415
|
}
|
|
19382
19416
|
}
|
|
19383
19417
|
}
|
|
@@ -19473,23 +19507,23 @@ class RE {
|
|
|
19473
19507
|
}), this.formatNode(E.parenthesis);
|
|
19474
19508
|
}
|
|
19475
19509
|
formatPropertyAccess(E) {
|
|
19476
|
-
this.formatNode(E.object), this.layout.add(
|
|
19510
|
+
this.formatNode(E.object), this.layout.add(a.NO_SPACE, E.operator), this.formatNode(E.property);
|
|
19477
19511
|
}
|
|
19478
19512
|
formatParenthesis(E) {
|
|
19479
19513
|
const T = this.formatInlineExpression(E.children);
|
|
19480
|
-
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));
|
|
19481
19515
|
}
|
|
19482
19516
|
formatBetweenPredicate(E) {
|
|
19483
|
-
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);
|
|
19484
19518
|
}
|
|
19485
19519
|
formatCaseExpression(E) {
|
|
19486
|
-
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);
|
|
19487
19521
|
}
|
|
19488
19522
|
formatCaseWhen(E) {
|
|
19489
|
-
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);
|
|
19490
19524
|
}
|
|
19491
19525
|
formatCaseElse(E) {
|
|
19492
|
-
this.layout.add(
|
|
19526
|
+
this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
|
|
19493
19527
|
}
|
|
19494
19528
|
formatClause(E) {
|
|
19495
19529
|
this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : J(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
|
|
@@ -19498,39 +19532,39 @@ class RE {
|
|
|
19498
19532
|
return J(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
|
|
19499
19533
|
}
|
|
19500
19534
|
formatClauseInIndentedStyle(E) {
|
|
19501
|
-
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();
|
|
19502
19536
|
}
|
|
19503
19537
|
formatClauseInOnelineStyle(E) {
|
|
19504
|
-
this.layout.add(
|
|
19538
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout = this.formatSubExpression(E.children);
|
|
19505
19539
|
}
|
|
19506
19540
|
formatClauseInTabularStyle(E) {
|
|
19507
|
-
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();
|
|
19508
19542
|
}
|
|
19509
19543
|
formatSetOperation(E) {
|
|
19510
|
-
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);
|
|
19511
19545
|
}
|
|
19512
19546
|
formatLimitClause(E) {
|
|
19513
19547
|
this.withComments(E.limitKw, () => {
|
|
19514
|
-
this.layout.add(
|
|
19515
|
-
}), 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();
|
|
19516
19550
|
}
|
|
19517
19551
|
formatAllColumnsAsterisk(E) {
|
|
19518
|
-
this.layout.add("*",
|
|
19552
|
+
this.layout.add("*", a.SPACE);
|
|
19519
19553
|
}
|
|
19520
19554
|
formatLiteral(E) {
|
|
19521
|
-
this.layout.add(E.text,
|
|
19555
|
+
this.layout.add(E.text, a.SPACE);
|
|
19522
19556
|
}
|
|
19523
19557
|
formatIdentifier(E) {
|
|
19524
|
-
this.layout.add(this.showIdentifier(E),
|
|
19558
|
+
this.layout.add(this.showIdentifier(E), a.SPACE);
|
|
19525
19559
|
}
|
|
19526
19560
|
formatParameter(E) {
|
|
19527
|
-
this.layout.add(this.params.get(E),
|
|
19561
|
+
this.layout.add(this.params.get(E), a.SPACE);
|
|
19528
19562
|
}
|
|
19529
19563
|
formatOperator({ text: E }) {
|
|
19530
|
-
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);
|
|
19531
19565
|
}
|
|
19532
19566
|
formatComma(E) {
|
|
19533
|
-
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);
|
|
19534
19568
|
}
|
|
19535
19569
|
withComments(E, T) {
|
|
19536
19570
|
this.formatComments(E.leadingComments), T(), this.formatComments(E.trailingComments);
|
|
@@ -19541,12 +19575,12 @@ class RE {
|
|
|
19541
19575
|
});
|
|
19542
19576
|
}
|
|
19543
19577
|
formatLineComment(E) {
|
|
19544
|
-
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);
|
|
19545
19579
|
}
|
|
19546
19580
|
formatBlockComment(E) {
|
|
19547
19581
|
E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((T) => {
|
|
19548
|
-
this.layout.add(
|
|
19549
|
-
}), 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);
|
|
19550
19584
|
}
|
|
19551
19585
|
isMultilineBlockComment(E) {
|
|
19552
19586
|
return FE(E.text) || FE(E.precedingWhitespace || "");
|
|
@@ -19619,27 +19653,27 @@ class RE {
|
|
|
19619
19653
|
}
|
|
19620
19654
|
formatKeywordNode(E) {
|
|
19621
19655
|
switch (E.tokenType) {
|
|
19622
|
-
case
|
|
19656
|
+
case D.RESERVED_JOIN:
|
|
19623
19657
|
return this.formatJoin(E);
|
|
19624
|
-
case
|
|
19625
|
-
case
|
|
19626
|
-
case
|
|
19658
|
+
case D.AND:
|
|
19659
|
+
case D.OR:
|
|
19660
|
+
case D.XOR:
|
|
19627
19661
|
return this.formatLogicalOperator(E);
|
|
19628
19662
|
default:
|
|
19629
19663
|
return this.formatKeyword(E);
|
|
19630
19664
|
}
|
|
19631
19665
|
}
|
|
19632
19666
|
formatJoin(E) {
|
|
19633
|
-
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);
|
|
19634
19668
|
}
|
|
19635
19669
|
formatKeyword(E) {
|
|
19636
|
-
this.layout.add(this.showKw(E),
|
|
19670
|
+
this.layout.add(this.showKw(E), a.SPACE);
|
|
19637
19671
|
}
|
|
19638
19672
|
formatLogicalOperator(E) {
|
|
19639
|
-
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);
|
|
19640
19674
|
}
|
|
19641
19675
|
formatDataType(E) {
|
|
19642
|
-
this.layout.add(this.showDataType(E),
|
|
19676
|
+
this.layout.add(this.showDataType(E), a.SPACE);
|
|
19643
19677
|
}
|
|
19644
19678
|
showKw(E) {
|
|
19645
19679
|
return lT(E.tokenType) ? GT(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
|
|
@@ -19719,7 +19753,7 @@ class $I {
|
|
|
19719
19753
|
params: this.params,
|
|
19720
19754
|
layout: new yT(new KT(oI(this.cfg)))
|
|
19721
19755
|
}).format(E.children);
|
|
19722
|
-
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();
|
|
19723
19757
|
}
|
|
19724
19758
|
}
|
|
19725
19759
|
class TE extends Error {
|
|
@@ -19986,27 +20020,27 @@ ${T.join(`
|
|
|
19986
20020
|
generateCubeMetadata(E) {
|
|
19987
20021
|
const T = Object.keys(E.measures), A = Object.keys(E.dimensions), e = new Array(T.length), S = new Array(A.length);
|
|
19988
20022
|
for (let t = 0; t < T.length; t++) {
|
|
19989
|
-
const C = T[t],
|
|
20023
|
+
const C = T[t], O = E.measures[C];
|
|
19990
20024
|
e[t] = {
|
|
19991
20025
|
name: `${E.name}.${C}`,
|
|
19992
|
-
title:
|
|
19993
|
-
shortTitle:
|
|
19994
|
-
type:
|
|
20026
|
+
title: O.title || C,
|
|
20027
|
+
shortTitle: O.title || C,
|
|
20028
|
+
type: O.type,
|
|
19995
20029
|
format: void 0,
|
|
19996
20030
|
// Measure doesn't have format field
|
|
19997
|
-
description:
|
|
20031
|
+
description: O.description
|
|
19998
20032
|
};
|
|
19999
20033
|
}
|
|
20000
20034
|
for (let t = 0; t < A.length; t++) {
|
|
20001
|
-
const C = A[t],
|
|
20035
|
+
const C = A[t], O = E.dimensions[C];
|
|
20002
20036
|
S[t] = {
|
|
20003
20037
|
name: `${E.name}.${C}`,
|
|
20004
|
-
title:
|
|
20005
|
-
shortTitle:
|
|
20006
|
-
type:
|
|
20038
|
+
title: O.title || C,
|
|
20039
|
+
shortTitle: O.title || C,
|
|
20040
|
+
type: O.type,
|
|
20007
20041
|
format: void 0,
|
|
20008
20042
|
// Dimension doesn't have format field
|
|
20009
|
-
description:
|
|
20043
|
+
description: O.description
|
|
20010
20044
|
};
|
|
20011
20045
|
}
|
|
20012
20046
|
const I = [];
|
|
@@ -20016,9 +20050,9 @@ ${T.join(`
|
|
|
20016
20050
|
I.push({
|
|
20017
20051
|
targetCube: C.name,
|
|
20018
20052
|
relationship: t.relationship,
|
|
20019
|
-
joinFields: t.on.map((
|
|
20020
|
-
sourceField: this.getColumnName(
|
|
20021
|
-
targetField: this.getColumnName(
|
|
20053
|
+
joinFields: t.on.map((O) => ({
|
|
20054
|
+
sourceField: this.getColumnName(O.source),
|
|
20055
|
+
targetField: this.getColumnName(O.target)
|
|
20022
20056
|
}))
|
|
20023
20057
|
});
|
|
20024
20058
|
}
|