@marimo-team/islands 0.13.1-dev9 → 0.13.2-dev3
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/{ConnectedDataExplorerComponent-CyoQPS9m.js → ConnectedDataExplorerComponent-CGbRw3IM.js} +681 -692
- package/dist/{VegaLite-CHzOOWp-.js → VegaLite-Dw4K_USN.js} +3 -3
- package/dist/{_baseUniq-DNoPin-E.js → _baseUniq-DXsDFVSe.js} +67 -67
- package/dist/{any-language-editor-Mq1tVFyx.js → any-language-editor-DGn5zl16.js} +61 -61
- package/dist/{architectureDiagram-IEHRJDOE-DJrc8fHr.js → architectureDiagram-IEHRJDOE-CfwX0b3T.js} +5 -5
- package/dist/{blockDiagram-JOT3LUYC-BLS8XVig.js → blockDiagram-JOT3LUYC-DdW82UG1.js} +4 -4
- package/dist/{c4Diagram-VJAJSXHY-BQh1Xgtg.js → c4Diagram-VJAJSXHY-DsppCMht.js} +2 -2
- package/dist/{channel-BzYjWFRA.js → channel-CZPYfBeZ.js} +1 -1
- package/dist/{chunk-4BMEZGHF-DhbiOHIu.js → chunk-4BMEZGHF-BT7jNqQ8.js} +1 -1
- package/dist/{chunk-A2AXSNBT-Do9s3PW3.js → chunk-A2AXSNBT-D3uGVZVG.js} +2 -2
- package/dist/{chunk-AEK57VVT-DGeJHpzu.js → chunk-AEK57VVT-CSUfx73f.js} +2 -2
- package/dist/{chunk-D6G4REZN-Cdh0N5uJ.js → chunk-D6G4REZN-FJauKOLj.js} +1 -1
- package/dist/{chunk-RZ5BOZE2-C2eF5zYv.js → chunk-RZ5BOZE2-oVXi60pb.js} +1 -1
- package/dist/{chunk-XZIHB7SX-C3ESb7z_.js → chunk-XZIHB7SX-CRAIEX_R.js} +1 -1
- package/dist/{classDiagram-GIVACNV2-eNRGRSZW.js → classDiagram-GIVACNV2-DXsHqNIy.js} +2 -2
- package/dist/{classDiagram-v2-COTLJTTW-eNRGRSZW.js → classDiagram-v2-COTLJTTW-DXsHqNIy.js} +2 -2
- package/dist/{clone-BjM1LrG5.js → clone-BsyWPbqs.js} +1 -1
- package/dist/{dagre-OKDRZEBW-BrWQjrmT.js → dagre-OKDRZEBW-DO7a8tJG.js} +6 -6
- package/dist/{data-editor-DKZDEBwL.js → data-editor-DPThhgPp.js} +1 -1
- package/dist/{diagram-SSKATNLV-q8tb2YMl.js → diagram-SSKATNLV-Bls5R58o.js} +3 -3
- package/dist/{diagram-VNBRO52H-BCjXfGEW.js → diagram-VNBRO52H-BpEC5gvz.js} +3 -3
- package/dist/{erDiagram-Q7BY3M3F-C9FOmgEw.js → erDiagram-Q7BY3M3F-DTMK16eS.js} +3 -3
- package/dist/{flowDiagram-4HSFHLVR-Bk8kx-M9.js → flowDiagram-4HSFHLVR-CV9qBAZp.js} +3 -3
- package/dist/{ganttDiagram-APWFNJXF-CSVZ8sfW.js → ganttDiagram-APWFNJXF-FDimH8ps.js} +4 -4
- package/dist/{gitGraphDiagram-7IBYFJ6S-2mFEK2N3.js → gitGraphDiagram-7IBYFJ6S-BqCm_3Ft.js} +4 -4
- package/dist/{graph-BGRO911q.js → graph-C8K286C_.js} +8 -8
- package/dist/{index-z0SX-fHz.js → index-8RoOqM37.js} +1 -1
- package/dist/{index-yRrl6HUz.js → index-Bojqt6Xl.js} +1 -1
- package/dist/{index-Cj6FBL4x.js → index-ByDUfEyZ.js} +4 -4
- package/dist/{index-jAY18BnE.js → index-C-djkhIK.js} +1 -1
- package/dist/{index-jTEe5X3a.js → index-C1HuMzyj.js} +3 -3
- package/dist/{index-BwupU5OL.js → index-CCdvhmXu.js} +4 -4
- package/dist/{index-p47X4P70.js → index-CL4y9xRv.js} +11 -11
- package/dist/{index-6ivx6BpR.js → index-CRGlOrnH.js} +9 -9
- package/dist/{index-75OJBYle.js → index-CqJaarDD.js} +3 -3
- package/dist/{index-nvEO_Uun.js → index-D64j2b3f.js} +4 -4
- package/dist/{index-DE7MQC00.js → index-DEA2sLBY.js} +1 -1
- package/dist/{index-CHqr_CA6.js → index-DKpc3EB8.js} +24 -24
- package/dist/{index-DtEUmT62.js → index-DMM58L7Q.js} +3 -3
- package/dist/{index-DEkvsQUm.js → index-DjMZkeB9.js} +1 -1
- package/dist/{index-du4FDzgd.js → index-V3h2pkxR.js} +1 -1
- package/dist/index-X-mspTRy.js +2875 -0
- package/dist/{infoDiagram-PH2N3AL5-B8OQ9Apl.js → infoDiagram-PH2N3AL5-DB5Fowou.js} +2 -2
- package/dist/{journeyDiagram-U35MCT3I-D5yqAqCS.js → journeyDiagram-U35MCT3I-CKKTlQx-.js} +2 -2
- package/dist/{kanban-definition-NDS4AKOZ-O3sKQPyw.js → kanban-definition-NDS4AKOZ-CETacQXj.js} +1 -1
- package/dist/{layout-Mb3CmDem.js → layout-BDyhlwkN.js} +69 -69
- package/dist/{linear-CqgwiRCz.js → linear-DGVa1PyM.js} +14 -14
- package/dist/{main-B5cqxs0F.js → main-CT_ppgCd.js} +33391 -32542
- package/dist/main.js +1 -1
- package/dist/{mermaid-CQCrXf_j.js → mermaid-Da6Qb2z_.js} +28 -28
- package/dist/min-BQ5rX-0-.js +80 -0
- package/dist/{mindmap-definition-ALO5MXBD-CpKAWOTA.js → mindmap-definition-ALO5MXBD-DKGHUjQ5.js} +2 -2
- package/dist/{pieDiagram-IB7DONF6-CKYDEGrF.js → pieDiagram-IB7DONF6-BDmzYf8t.js} +3 -3
- package/dist/{quadrantDiagram-7GDLP6J5-B2GHWVkB.js → quadrantDiagram-7GDLP6J5-lmnKmt8i.js} +2 -2
- package/dist/{radar-MK3ICKWK-zlyvHGsS.js → radar-MK3ICKWK-CEuUZpCU.js} +5 -5
- package/dist/{react-plotly-r5vpSBLa.js → react-plotly-C5gwIfQS.js} +1 -1
- package/dist/{requirementDiagram-KVF5MWMF-DW6fscc4.js → requirementDiagram-KVF5MWMF-Cx936Y81.js} +2 -2
- package/dist/{sankeyDiagram-QLVOVGJD-K-xOehyp.js → sankeyDiagram-QLVOVGJD-BRnouCOc.js} +1 -1
- package/dist/{sequenceDiagram-X6HHIX6F-D9RGb1Rb.js → sequenceDiagram-X6HHIX6F-LOOoR9Y0.js} +3 -3
- package/dist/{slides-component-BLb0AtUK.js → slides-component-BCYGTf_d.js} +25 -25
- package/dist/{stateDiagram-DGXRK772-BTO8zB_Z.js → stateDiagram-DGXRK772-C8ROrJdW.js} +4 -4
- package/dist/{stateDiagram-v2-YXO3MK2T-lqN429HZ.js → stateDiagram-v2-YXO3MK2T-DqsfOJDr.js} +2 -2
- package/dist/style.css +1 -1
- package/dist/{time-DawTwGO0.js → time-VStXNjnw.js} +35 -35
- package/dist/{timeline-definition-BDJGKUSR-C8A3928m.js → timeline-definition-BDJGKUSR-DhxmAVMB.js} +1 -1
- package/dist/{vega-component-vgOZfXFy.js → vega-component-Dtd8gt79.js} +29 -37
- package/dist/{xychartDiagram-VJFVF3MP-kNUmW-0z.js → xychartDiagram-VJFVF3MP-Dd6KnayK.js} +2 -2
- package/package.json +7 -6
- package/dist/chart-spec-DREm07PV.js +0 -136
- package/dist/min-FLQLNHG5.js +0 -80
|
@@ -0,0 +1,2875 @@
|
|
|
1
|
+
import { S as me } from "./main-CT_ppgCd.js";
|
|
2
|
+
const d = (s) => s.flatMap(Oe), Oe = (s) => G(fe(s)).map(Le), Le = (s) => s.replace(/ +/g, " ").trim(), fe = (s) => ({
|
|
3
|
+
type: "mandatory_block",
|
|
4
|
+
items: q(s, 0)[0]
|
|
5
|
+
}), q = (s, e, t) => {
|
|
6
|
+
const r = [];
|
|
7
|
+
for (; s[e]; ) {
|
|
8
|
+
const [o, c] = Ce(s, e);
|
|
9
|
+
if (r.push(o), e = c, s[e] === "|")
|
|
10
|
+
e++;
|
|
11
|
+
else if (s[e] === "}" || s[e] === "]") {
|
|
12
|
+
if (t !== s[e])
|
|
13
|
+
throw new Error(`Unbalanced parenthesis in: ${s}`);
|
|
14
|
+
return e++, [r, e];
|
|
15
|
+
} else if (e === s.length) {
|
|
16
|
+
if (t)
|
|
17
|
+
throw new Error(`Unbalanced parenthesis in: ${s}`);
|
|
18
|
+
return [r, e];
|
|
19
|
+
} else
|
|
20
|
+
throw new Error(`Unexpected "${s[e]}"`);
|
|
21
|
+
}
|
|
22
|
+
return [r, e];
|
|
23
|
+
}, Ce = (s, e) => {
|
|
24
|
+
const t = [];
|
|
25
|
+
for (; ; ) {
|
|
26
|
+
const [r, o] = ye(s, e);
|
|
27
|
+
if (r)
|
|
28
|
+
t.push(r), e = o;
|
|
29
|
+
else
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
return t.length === 1 ? [t[0], e] : [{ type: "concatenation", items: t }, e];
|
|
33
|
+
}, ye = (s, e) => {
|
|
34
|
+
if (s[e] === "{")
|
|
35
|
+
return Pe(s, e + 1);
|
|
36
|
+
if (s[e] === "[")
|
|
37
|
+
return De(s, e + 1);
|
|
38
|
+
{
|
|
39
|
+
let t = "";
|
|
40
|
+
for (; s[e] && /[A-Za-z0-9_ ]/.test(s[e]); )
|
|
41
|
+
t += s[e], e++;
|
|
42
|
+
return [t, e];
|
|
43
|
+
}
|
|
44
|
+
}, Pe = (s, e) => {
|
|
45
|
+
const [t, r] = q(s, e, "}");
|
|
46
|
+
return [{ type: "mandatory_block", items: t }, r];
|
|
47
|
+
}, De = (s, e) => {
|
|
48
|
+
const [t, r] = q(s, e, "]");
|
|
49
|
+
return [{ type: "optional_block", items: t }, r];
|
|
50
|
+
}, G = (s) => {
|
|
51
|
+
if (typeof s == "string")
|
|
52
|
+
return [s];
|
|
53
|
+
if (s.type === "concatenation")
|
|
54
|
+
return s.items.map(G).reduce(be, [""]);
|
|
55
|
+
if (s.type === "mandatory_block")
|
|
56
|
+
return s.items.flatMap(G);
|
|
57
|
+
if (s.type === "optional_block")
|
|
58
|
+
return ["", ...s.items.flatMap(G)];
|
|
59
|
+
throw new Error(`Unknown node type: ${s}`);
|
|
60
|
+
}, be = (s, e) => {
|
|
61
|
+
const t = [];
|
|
62
|
+
for (const r of s)
|
|
63
|
+
for (const o of e)
|
|
64
|
+
t.push(r + o);
|
|
65
|
+
return t;
|
|
66
|
+
};
|
|
67
|
+
var n;
|
|
68
|
+
(function(s) {
|
|
69
|
+
s.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", s.IDENTIFIER = "IDENTIFIER", s.STRING = "STRING", s.VARIABLE = "VARIABLE", s.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", s.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", s.RESERVED_KEYWORD = "RESERVED_KEYWORD", s.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", s.RESERVED_PHRASE = "RESERVED_PHRASE", s.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", s.RESERVED_CLAUSE = "RESERVED_CLAUSE", s.RESERVED_SELECT = "RESERVED_SELECT", s.RESERVED_JOIN = "RESERVED_JOIN", s.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", s.ARRAY_KEYWORD = "ARRAY_KEYWORD", s.CASE = "CASE", s.END = "END", s.WHEN = "WHEN", s.ELSE = "ELSE", s.THEN = "THEN", s.LIMIT = "LIMIT", s.BETWEEN = "BETWEEN", s.AND = "AND", s.OR = "OR", s.XOR = "XOR", s.OPERATOR = "OPERATOR", s.COMMA = "COMMA", s.ASTERISK = "ASTERISK", s.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", s.OPEN_PAREN = "OPEN_PAREN", s.CLOSE_PAREN = "CLOSE_PAREN", s.LINE_COMMENT = "LINE_COMMENT", s.BLOCK_COMMENT = "BLOCK_COMMENT", s.DISABLE_COMMENT = "DISABLE_COMMENT", s.NUMBER = "NUMBER", s.NAMED_PARAMETER = "NAMED_PARAMETER", s.QUOTED_PARAMETER = "QUOTED_PARAMETER", s.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", s.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", s.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", s.DELIMITER = "DELIMITER", s.EOF = "EOF";
|
|
70
|
+
})(n = n || (n = {}));
|
|
71
|
+
const le = (s) => ({
|
|
72
|
+
type: n.EOF,
|
|
73
|
+
raw: "«EOF»",
|
|
74
|
+
text: "«EOF»",
|
|
75
|
+
start: s
|
|
76
|
+
});
|
|
77
|
+
le(1 / 0);
|
|
78
|
+
const x = (s) => (e) => e.type === s.type && e.text === s.text;
|
|
79
|
+
x({ text: "ARRAY", type: n.RESERVED_DATA_TYPE }), x({ text: "BY", type: n.RESERVED_KEYWORD }), x({ text: "SET", type: n.RESERVED_CLAUSE }), x({ text: "STRUCT", type: n.RESERVED_DATA_TYPE }), x({ text: "WINDOW", type: n.RESERVED_CLAUSE }), x({ text: "VALUES", type: n.RESERVED_CLAUSE });
|
|
80
|
+
const de = (s) => s === n.RESERVED_DATA_TYPE || s === n.RESERVED_KEYWORD || s === n.RESERVED_FUNCTION_NAME || s === n.RESERVED_PHRASE || s === n.RESERVED_CLAUSE || s === n.RESERVED_SELECT || s === n.RESERVED_SET_OPERATION || s === n.RESERVED_JOIN || s === n.ARRAY_KEYWORD || s === n.CASE || s === n.END || s === n.WHEN || s === n.ELSE || s === n.THEN || s === n.LIMIT || s === n.BETWEEN || s === n.AND || s === n.OR || s === n.XOR, Me = (s) => s === n.AND || s === n.OR || s === n.XOR, xe = [
|
|
81
|
+
// Functions from DuckDB (excluding those that start with an underscore):
|
|
82
|
+
// SELECT DISTINCT upper(function_name) AS function_name
|
|
83
|
+
// FROM duckdb_functions()
|
|
84
|
+
// WHERE function_name SIMILAR TO '^[a-z].*'
|
|
85
|
+
// ORDER BY function_name
|
|
86
|
+
"ABS",
|
|
87
|
+
"ACOS",
|
|
88
|
+
"ADD",
|
|
89
|
+
"ADD_PARQUET_KEY",
|
|
90
|
+
"AGE",
|
|
91
|
+
"AGGREGATE",
|
|
92
|
+
"ALIAS",
|
|
93
|
+
"ALL_PROFILING_OUTPUT",
|
|
94
|
+
"ANY_VALUE",
|
|
95
|
+
"APPLY",
|
|
96
|
+
"APPROX_COUNT_DISTINCT",
|
|
97
|
+
"APPROX_QUANTILE",
|
|
98
|
+
"ARBITRARY",
|
|
99
|
+
"ARGMAX",
|
|
100
|
+
"ARGMIN",
|
|
101
|
+
"ARG_MAX",
|
|
102
|
+
"ARG_MAX_NULL",
|
|
103
|
+
"ARG_MIN",
|
|
104
|
+
"ARG_MIN_NULL",
|
|
105
|
+
"ARRAY_AGG",
|
|
106
|
+
"ARRAY_AGGR",
|
|
107
|
+
"ARRAY_AGGREGATE",
|
|
108
|
+
"ARRAY_APPEND",
|
|
109
|
+
"ARRAY_APPLY",
|
|
110
|
+
"ARRAY_CAT",
|
|
111
|
+
"ARRAY_CONCAT",
|
|
112
|
+
"ARRAY_CONTAINS",
|
|
113
|
+
"ARRAY_COSINE_SIMILARITY",
|
|
114
|
+
"ARRAY_CROSS_PRODUCT",
|
|
115
|
+
"ARRAY_DISTANCE",
|
|
116
|
+
"ARRAY_DISTINCT",
|
|
117
|
+
"ARRAY_DOT_PRODUCT",
|
|
118
|
+
"ARRAY_EXTRACT",
|
|
119
|
+
"ARRAY_FILTER",
|
|
120
|
+
"ARRAY_GRADE_UP",
|
|
121
|
+
"ARRAY_HAS",
|
|
122
|
+
"ARRAY_HAS_ALL",
|
|
123
|
+
"ARRAY_HAS_ANY",
|
|
124
|
+
"ARRAY_INDEXOF",
|
|
125
|
+
"ARRAY_INNER_PRODUCT",
|
|
126
|
+
"ARRAY_INTERSECT",
|
|
127
|
+
"ARRAY_LENGTH",
|
|
128
|
+
"ARRAY_POP_BACK",
|
|
129
|
+
"ARRAY_POP_FRONT",
|
|
130
|
+
"ARRAY_POSITION",
|
|
131
|
+
"ARRAY_PREPEND",
|
|
132
|
+
"ARRAY_PUSH_BACK",
|
|
133
|
+
"ARRAY_PUSH_FRONT",
|
|
134
|
+
"ARRAY_REDUCE",
|
|
135
|
+
"ARRAY_RESIZE",
|
|
136
|
+
"ARRAY_REVERSE",
|
|
137
|
+
"ARRAY_REVERSE_SORT",
|
|
138
|
+
"ARRAY_SELECT",
|
|
139
|
+
"ARRAY_SLICE",
|
|
140
|
+
"ARRAY_SORT",
|
|
141
|
+
"ARRAY_TO_JSON",
|
|
142
|
+
"ARRAY_TO_STRING",
|
|
143
|
+
"ARRAY_TRANSFORM",
|
|
144
|
+
"ARRAY_UNIQUE",
|
|
145
|
+
"ARRAY_VALUE",
|
|
146
|
+
"ARRAY_WHERE",
|
|
147
|
+
"ARRAY_ZIP",
|
|
148
|
+
"ARROW_SCAN",
|
|
149
|
+
"ARROW_SCAN_DUMB",
|
|
150
|
+
"ASCII",
|
|
151
|
+
"ASIN",
|
|
152
|
+
"ATAN",
|
|
153
|
+
"ATAN2",
|
|
154
|
+
"AVG",
|
|
155
|
+
"BASE64",
|
|
156
|
+
"BIN",
|
|
157
|
+
"BITSTRING",
|
|
158
|
+
"BITSTRING_AGG",
|
|
159
|
+
"BIT_AND",
|
|
160
|
+
"BIT_COUNT",
|
|
161
|
+
"BIT_LENGTH",
|
|
162
|
+
"BIT_OR",
|
|
163
|
+
"BIT_POSITION",
|
|
164
|
+
"BIT_XOR",
|
|
165
|
+
"BOOL_AND",
|
|
166
|
+
"BOOL_OR",
|
|
167
|
+
"CARDINALITY",
|
|
168
|
+
"CBRT",
|
|
169
|
+
"CEIL",
|
|
170
|
+
"CEILING",
|
|
171
|
+
"CENTURY",
|
|
172
|
+
"CHECKPOINT",
|
|
173
|
+
"CHR",
|
|
174
|
+
"COLLATIONS",
|
|
175
|
+
"COL_DESCRIPTION",
|
|
176
|
+
"COMBINE",
|
|
177
|
+
"CONCAT",
|
|
178
|
+
"CONCAT_WS",
|
|
179
|
+
"CONSTANT_OR_NULL",
|
|
180
|
+
"CONTAINS",
|
|
181
|
+
"COPY_DATABASE",
|
|
182
|
+
"CORR",
|
|
183
|
+
"COS",
|
|
184
|
+
"COT",
|
|
185
|
+
"COUNT",
|
|
186
|
+
"COUNT_IF",
|
|
187
|
+
"COUNT_STAR",
|
|
188
|
+
"COVAR_POP",
|
|
189
|
+
"COVAR_SAMP",
|
|
190
|
+
"CREATE_SORT_KEY",
|
|
191
|
+
"CURRENT_CATALOG",
|
|
192
|
+
"CURRENT_DATABASE",
|
|
193
|
+
"CURRENT_DATE",
|
|
194
|
+
"CURRENT_LOCALTIME",
|
|
195
|
+
"CURRENT_LOCALTIMESTAMP",
|
|
196
|
+
"CURRENT_QUERY",
|
|
197
|
+
"CURRENT_ROLE",
|
|
198
|
+
"CURRENT_SCHEMA",
|
|
199
|
+
"CURRENT_SCHEMAS",
|
|
200
|
+
"CURRENT_SETTING",
|
|
201
|
+
"CURRENT_USER",
|
|
202
|
+
"CURRVAL",
|
|
203
|
+
"DAMERAU_LEVENSHTEIN",
|
|
204
|
+
"DATABASE_LIST",
|
|
205
|
+
"DATABASE_SIZE",
|
|
206
|
+
"DATEDIFF",
|
|
207
|
+
"DATEPART",
|
|
208
|
+
"DATESUB",
|
|
209
|
+
"DATETRUNC",
|
|
210
|
+
"DATE_ADD",
|
|
211
|
+
"DATE_DIFF",
|
|
212
|
+
"DATE_PART",
|
|
213
|
+
"DATE_SUB",
|
|
214
|
+
"DATE_TRUNC",
|
|
215
|
+
"DAY",
|
|
216
|
+
"DAYNAME",
|
|
217
|
+
"DAYOFMONTH",
|
|
218
|
+
"DAYOFWEEK",
|
|
219
|
+
"DAYOFYEAR",
|
|
220
|
+
"DECADE",
|
|
221
|
+
"DECODE",
|
|
222
|
+
"DEGREES",
|
|
223
|
+
"DISABLE_CHECKPOINT_ON_SHUTDOWN",
|
|
224
|
+
"DISABLE_OBJECT_CACHE",
|
|
225
|
+
"DISABLE_OPTIMIZER",
|
|
226
|
+
"DISABLE_PRINT_PROGRESS_BAR",
|
|
227
|
+
"DISABLE_PROFILE",
|
|
228
|
+
"DISABLE_PROFILING",
|
|
229
|
+
"DISABLE_PROGRESS_BAR",
|
|
230
|
+
"DISABLE_VERIFICATION",
|
|
231
|
+
"DISABLE_VERIFY_EXTERNAL",
|
|
232
|
+
"DISABLE_VERIFY_FETCH_ROW",
|
|
233
|
+
"DISABLE_VERIFY_PARALLELISM",
|
|
234
|
+
"DISABLE_VERIFY_SERIALIZER",
|
|
235
|
+
"DIVIDE",
|
|
236
|
+
"DUCKDB_COLUMNS",
|
|
237
|
+
"DUCKDB_CONSTRAINTS",
|
|
238
|
+
"DUCKDB_DATABASES",
|
|
239
|
+
"DUCKDB_DEPENDENCIES",
|
|
240
|
+
"DUCKDB_EXTENSIONS",
|
|
241
|
+
"DUCKDB_FUNCTIONS",
|
|
242
|
+
"DUCKDB_INDEXES",
|
|
243
|
+
"DUCKDB_KEYWORDS",
|
|
244
|
+
"DUCKDB_MEMORY",
|
|
245
|
+
"DUCKDB_OPTIMIZERS",
|
|
246
|
+
"DUCKDB_SCHEMAS",
|
|
247
|
+
"DUCKDB_SECRETS",
|
|
248
|
+
"DUCKDB_SEQUENCES",
|
|
249
|
+
"DUCKDB_SETTINGS",
|
|
250
|
+
"DUCKDB_TABLES",
|
|
251
|
+
"DUCKDB_TEMPORARY_FILES",
|
|
252
|
+
"DUCKDB_TYPES",
|
|
253
|
+
"DUCKDB_VIEWS",
|
|
254
|
+
"EDIT",
|
|
255
|
+
"EDITDIST3",
|
|
256
|
+
"ELEMENT_AT",
|
|
257
|
+
"ENABLE_CHECKPOINT_ON_SHUTDOWN",
|
|
258
|
+
"ENABLE_OBJECT_CACHE",
|
|
259
|
+
"ENABLE_OPTIMIZER",
|
|
260
|
+
"ENABLE_PRINT_PROGRESS_BAR",
|
|
261
|
+
"ENABLE_PROFILE",
|
|
262
|
+
"ENABLE_PROFILING",
|
|
263
|
+
"ENABLE_PROGRESS_BAR",
|
|
264
|
+
"ENABLE_VERIFICATION",
|
|
265
|
+
"ENCODE",
|
|
266
|
+
"ENDS_WITH",
|
|
267
|
+
"ENTROPY",
|
|
268
|
+
"ENUM_CODE",
|
|
269
|
+
"ENUM_FIRST",
|
|
270
|
+
"ENUM_LAST",
|
|
271
|
+
"ENUM_RANGE",
|
|
272
|
+
"ENUM_RANGE_BOUNDARY",
|
|
273
|
+
"EPOCH",
|
|
274
|
+
"EPOCH_MS",
|
|
275
|
+
"EPOCH_NS",
|
|
276
|
+
"EPOCH_US",
|
|
277
|
+
"ERA",
|
|
278
|
+
"ERROR",
|
|
279
|
+
"EVEN",
|
|
280
|
+
"EXP",
|
|
281
|
+
"FACTORIAL",
|
|
282
|
+
"FAVG",
|
|
283
|
+
"FDIV",
|
|
284
|
+
"FILTER",
|
|
285
|
+
"FINALIZE",
|
|
286
|
+
"FIRST",
|
|
287
|
+
"FLATTEN",
|
|
288
|
+
"FLOOR",
|
|
289
|
+
"FMOD",
|
|
290
|
+
"FORCE_CHECKPOINT",
|
|
291
|
+
"FORMAT",
|
|
292
|
+
"FORMATREADABLEDECIMALSIZE",
|
|
293
|
+
"FORMATREADABLESIZE",
|
|
294
|
+
"FORMAT_BYTES",
|
|
295
|
+
"FORMAT_PG_TYPE",
|
|
296
|
+
"FORMAT_TYPE",
|
|
297
|
+
"FROM_BASE64",
|
|
298
|
+
"FROM_BINARY",
|
|
299
|
+
"FROM_HEX",
|
|
300
|
+
"FROM_JSON",
|
|
301
|
+
"FROM_JSON_STRICT",
|
|
302
|
+
"FSUM",
|
|
303
|
+
"FUNCTIONS",
|
|
304
|
+
"GAMMA",
|
|
305
|
+
"GCD",
|
|
306
|
+
"GENERATE_SERIES",
|
|
307
|
+
"GENERATE_SUBSCRIPTS",
|
|
308
|
+
"GEN_RANDOM_UUID",
|
|
309
|
+
"GEOMEAN",
|
|
310
|
+
"GEOMETRIC_MEAN",
|
|
311
|
+
"GETENV",
|
|
312
|
+
"GET_BIT",
|
|
313
|
+
"GET_BLOCK_SIZE",
|
|
314
|
+
"GET_CURRENT_TIME",
|
|
315
|
+
"GET_CURRENT_TIMESTAMP",
|
|
316
|
+
"GLOB",
|
|
317
|
+
"GRADE_UP",
|
|
318
|
+
"GREATEST",
|
|
319
|
+
"GREATEST_COMMON_DIVISOR",
|
|
320
|
+
"GROUP_CONCAT",
|
|
321
|
+
"HAMMING",
|
|
322
|
+
"HASH",
|
|
323
|
+
"HAS_ANY_COLUMN_PRIVILEGE",
|
|
324
|
+
"HAS_COLUMN_PRIVILEGE",
|
|
325
|
+
"HAS_DATABASE_PRIVILEGE",
|
|
326
|
+
"HAS_FOREIGN_DATA_WRAPPER_PRIVILEGE",
|
|
327
|
+
"HAS_FUNCTION_PRIVILEGE",
|
|
328
|
+
"HAS_LANGUAGE_PRIVILEGE",
|
|
329
|
+
"HAS_SCHEMA_PRIVILEGE",
|
|
330
|
+
"HAS_SEQUENCE_PRIVILEGE",
|
|
331
|
+
"HAS_SERVER_PRIVILEGE",
|
|
332
|
+
"HAS_TABLESPACE_PRIVILEGE",
|
|
333
|
+
"HAS_TABLE_PRIVILEGE",
|
|
334
|
+
"HEX",
|
|
335
|
+
"HISTOGRAM",
|
|
336
|
+
"HOUR",
|
|
337
|
+
"ICU_CALENDAR_NAMES",
|
|
338
|
+
"ICU_SORT_KEY",
|
|
339
|
+
"ILIKE_ESCAPE",
|
|
340
|
+
"IMPORT_DATABASE",
|
|
341
|
+
"INDEX_SCAN",
|
|
342
|
+
"INET_CLIENT_ADDR",
|
|
343
|
+
"INET_CLIENT_PORT",
|
|
344
|
+
"INET_SERVER_ADDR",
|
|
345
|
+
"INET_SERVER_PORT",
|
|
346
|
+
"INSTR",
|
|
347
|
+
"IN_SEARCH_PATH",
|
|
348
|
+
"ISFINITE",
|
|
349
|
+
"ISINF",
|
|
350
|
+
"ISNAN",
|
|
351
|
+
"ISODOW",
|
|
352
|
+
"ISOYEAR",
|
|
353
|
+
"JACCARD",
|
|
354
|
+
"JARO_SIMILARITY",
|
|
355
|
+
"JARO_WINKLER_SIMILARITY",
|
|
356
|
+
// 'JSON',
|
|
357
|
+
"JSON_ARRAY",
|
|
358
|
+
"JSON_ARRAY_LENGTH",
|
|
359
|
+
"JSON_CONTAINS",
|
|
360
|
+
"JSON_DESERIALIZE_SQL",
|
|
361
|
+
"JSON_EXECUTE_SERIALIZED_SQL",
|
|
362
|
+
"JSON_EXTRACT",
|
|
363
|
+
"JSON_EXTRACT_PATH",
|
|
364
|
+
"JSON_EXTRACT_PATH_TEXT",
|
|
365
|
+
"JSON_EXTRACT_STRING",
|
|
366
|
+
"JSON_GROUP_ARRAY",
|
|
367
|
+
"JSON_GROUP_OBJECT",
|
|
368
|
+
"JSON_GROUP_STRUCTURE",
|
|
369
|
+
"JSON_KEYS",
|
|
370
|
+
"JSON_MERGE_PATCH",
|
|
371
|
+
"JSON_OBJECT",
|
|
372
|
+
"JSON_QUOTE",
|
|
373
|
+
"JSON_SERIALIZE_PLAN",
|
|
374
|
+
"JSON_SERIALIZE_SQL",
|
|
375
|
+
"JSON_STRUCTURE",
|
|
376
|
+
"JSON_TRANSFORM",
|
|
377
|
+
"JSON_TRANSFORM_STRICT",
|
|
378
|
+
"JSON_TYPE",
|
|
379
|
+
"JSON_VALID",
|
|
380
|
+
"JULIAN",
|
|
381
|
+
"KAHAN_SUM",
|
|
382
|
+
"KURTOSIS",
|
|
383
|
+
"KURTOSIS_POP",
|
|
384
|
+
"LAST",
|
|
385
|
+
"LAST_DAY",
|
|
386
|
+
"LCASE",
|
|
387
|
+
"LCM",
|
|
388
|
+
"LEAST",
|
|
389
|
+
"LEAST_COMMON_MULTIPLE",
|
|
390
|
+
"LEFT",
|
|
391
|
+
"LEFT_GRAPHEME",
|
|
392
|
+
"LEN",
|
|
393
|
+
"LENGTH",
|
|
394
|
+
"LENGTH_GRAPHEME",
|
|
395
|
+
"LEVENSHTEIN",
|
|
396
|
+
"LGAMMA",
|
|
397
|
+
"LIKE_ESCAPE",
|
|
398
|
+
"LIST",
|
|
399
|
+
"LISTAGG",
|
|
400
|
+
"LIST_AGGR",
|
|
401
|
+
"LIST_AGGREGATE",
|
|
402
|
+
"LIST_ANY_VALUE",
|
|
403
|
+
"LIST_APPEND",
|
|
404
|
+
"LIST_APPLY",
|
|
405
|
+
"LIST_APPROX_COUNT_DISTINCT",
|
|
406
|
+
"LIST_AVG",
|
|
407
|
+
"LIST_BIT_AND",
|
|
408
|
+
"LIST_BIT_OR",
|
|
409
|
+
"LIST_BIT_XOR",
|
|
410
|
+
"LIST_BOOL_AND",
|
|
411
|
+
"LIST_BOOL_OR",
|
|
412
|
+
"LIST_CAT",
|
|
413
|
+
"LIST_CONCAT",
|
|
414
|
+
"LIST_CONTAINS",
|
|
415
|
+
"LIST_COSINE_SIMILARITY",
|
|
416
|
+
"LIST_COUNT",
|
|
417
|
+
"LIST_DISTANCE",
|
|
418
|
+
"LIST_DISTINCT",
|
|
419
|
+
"LIST_DOT_PRODUCT",
|
|
420
|
+
"LIST_ELEMENT",
|
|
421
|
+
"LIST_ENTROPY",
|
|
422
|
+
"LIST_EXTRACT",
|
|
423
|
+
"LIST_FILTER",
|
|
424
|
+
"LIST_FIRST",
|
|
425
|
+
"LIST_GRADE_UP",
|
|
426
|
+
"LIST_HAS",
|
|
427
|
+
"LIST_HAS_ALL",
|
|
428
|
+
"LIST_HAS_ANY",
|
|
429
|
+
"LIST_HISTOGRAM",
|
|
430
|
+
"LIST_INDEXOF",
|
|
431
|
+
"LIST_INNER_PRODUCT",
|
|
432
|
+
"LIST_INTERSECT",
|
|
433
|
+
"LIST_KURTOSIS",
|
|
434
|
+
"LIST_KURTOSIS_POP",
|
|
435
|
+
"LIST_LAST",
|
|
436
|
+
"LIST_MAD",
|
|
437
|
+
"LIST_MAX",
|
|
438
|
+
"LIST_MEDIAN",
|
|
439
|
+
"LIST_MIN",
|
|
440
|
+
"LIST_MODE",
|
|
441
|
+
"LIST_PACK",
|
|
442
|
+
"LIST_POSITION",
|
|
443
|
+
"LIST_PREPEND",
|
|
444
|
+
"LIST_PRODUCT",
|
|
445
|
+
"LIST_REDUCE",
|
|
446
|
+
"LIST_RESIZE",
|
|
447
|
+
"LIST_REVERSE",
|
|
448
|
+
"LIST_REVERSE_SORT",
|
|
449
|
+
"LIST_SELECT",
|
|
450
|
+
"LIST_SEM",
|
|
451
|
+
"LIST_SKEWNESS",
|
|
452
|
+
"LIST_SLICE",
|
|
453
|
+
"LIST_SORT",
|
|
454
|
+
"LIST_STDDEV_POP",
|
|
455
|
+
"LIST_STDDEV_SAMP",
|
|
456
|
+
"LIST_STRING_AGG",
|
|
457
|
+
"LIST_SUM",
|
|
458
|
+
"LIST_TRANSFORM",
|
|
459
|
+
"LIST_UNIQUE",
|
|
460
|
+
"LIST_VALUE",
|
|
461
|
+
"LIST_VAR_POP",
|
|
462
|
+
"LIST_VAR_SAMP",
|
|
463
|
+
"LIST_WHERE",
|
|
464
|
+
"LIST_ZIP",
|
|
465
|
+
"LN",
|
|
466
|
+
"LOG",
|
|
467
|
+
"LOG10",
|
|
468
|
+
"LOG2",
|
|
469
|
+
"LOWER",
|
|
470
|
+
"LPAD",
|
|
471
|
+
"LSMODE",
|
|
472
|
+
"LTRIM",
|
|
473
|
+
"MAD",
|
|
474
|
+
"MAKE_DATE",
|
|
475
|
+
"MAKE_TIME",
|
|
476
|
+
"MAKE_TIMESTAMP",
|
|
477
|
+
"MAKE_TIMESTAMPTZ",
|
|
478
|
+
"MAP",
|
|
479
|
+
"MAP_CONCAT",
|
|
480
|
+
"MAP_ENTRIES",
|
|
481
|
+
"MAP_EXTRACT",
|
|
482
|
+
"MAP_FROM_ENTRIES",
|
|
483
|
+
"MAP_KEYS",
|
|
484
|
+
"MAP_VALUES",
|
|
485
|
+
"MAX",
|
|
486
|
+
"MAX_BY",
|
|
487
|
+
"MD5",
|
|
488
|
+
"MD5_NUMBER",
|
|
489
|
+
"MD5_NUMBER_LOWER",
|
|
490
|
+
"MD5_NUMBER_UPPER",
|
|
491
|
+
"MEAN",
|
|
492
|
+
"MEDIAN",
|
|
493
|
+
"METADATA_INFO",
|
|
494
|
+
"MICROSECOND",
|
|
495
|
+
"MILLENNIUM",
|
|
496
|
+
"MILLISECOND",
|
|
497
|
+
"MIN",
|
|
498
|
+
"MINUTE",
|
|
499
|
+
"MIN_BY",
|
|
500
|
+
"MISMATCHES",
|
|
501
|
+
"MOD",
|
|
502
|
+
"MODE",
|
|
503
|
+
"MONTH",
|
|
504
|
+
"MONTHNAME",
|
|
505
|
+
"MULTIPLY",
|
|
506
|
+
"NEXTAFTER",
|
|
507
|
+
"NEXTVAL",
|
|
508
|
+
"NFC_NORMALIZE",
|
|
509
|
+
"NOT_ILIKE_ESCAPE",
|
|
510
|
+
"NOT_LIKE_ESCAPE",
|
|
511
|
+
"NOW",
|
|
512
|
+
"NULLIF",
|
|
513
|
+
"OBJ_DESCRIPTION",
|
|
514
|
+
"OCTET_LENGTH",
|
|
515
|
+
"ORD",
|
|
516
|
+
"PARQUET_FILE_METADATA",
|
|
517
|
+
"PARQUET_KV_METADATA",
|
|
518
|
+
"PARQUET_METADATA",
|
|
519
|
+
"PARQUET_SCAN",
|
|
520
|
+
"PARQUET_SCHEMA",
|
|
521
|
+
"PARSE_DIRNAME",
|
|
522
|
+
"PARSE_DIRPATH",
|
|
523
|
+
"PARSE_FILENAME",
|
|
524
|
+
"PARSE_PATH",
|
|
525
|
+
"PG_COLLATION_IS_VISIBLE",
|
|
526
|
+
"PG_CONF_LOAD_TIME",
|
|
527
|
+
"PG_CONVERSION_IS_VISIBLE",
|
|
528
|
+
"PG_FUNCTION_IS_VISIBLE",
|
|
529
|
+
"PG_GET_CONSTRAINTDEF",
|
|
530
|
+
"PG_GET_EXPR",
|
|
531
|
+
"PG_GET_VIEWDEF",
|
|
532
|
+
"PG_HAS_ROLE",
|
|
533
|
+
"PG_IS_OTHER_TEMP_SCHEMA",
|
|
534
|
+
"PG_MY_TEMP_SCHEMA",
|
|
535
|
+
"PG_OPCLASS_IS_VISIBLE",
|
|
536
|
+
"PG_OPERATOR_IS_VISIBLE",
|
|
537
|
+
"PG_OPFAMILY_IS_VISIBLE",
|
|
538
|
+
"PG_POSTMASTER_START_TIME",
|
|
539
|
+
"PG_SIZE_PRETTY",
|
|
540
|
+
"PG_TABLE_IS_VISIBLE",
|
|
541
|
+
"PG_TIMEZONE_NAMES",
|
|
542
|
+
"PG_TS_CONFIG_IS_VISIBLE",
|
|
543
|
+
"PG_TS_DICT_IS_VISIBLE",
|
|
544
|
+
"PG_TS_PARSER_IS_VISIBLE",
|
|
545
|
+
"PG_TS_TEMPLATE_IS_VISIBLE",
|
|
546
|
+
"PG_TYPEOF",
|
|
547
|
+
"PG_TYPE_IS_VISIBLE",
|
|
548
|
+
"PI",
|
|
549
|
+
"PLATFORM",
|
|
550
|
+
"POSITION",
|
|
551
|
+
"POW",
|
|
552
|
+
"POWER",
|
|
553
|
+
"PRAGMA_COLLATIONS",
|
|
554
|
+
"PRAGMA_DATABASE_SIZE",
|
|
555
|
+
"PRAGMA_METADATA_INFO",
|
|
556
|
+
"PRAGMA_PLATFORM",
|
|
557
|
+
"PRAGMA_SHOW",
|
|
558
|
+
"PRAGMA_STORAGE_INFO",
|
|
559
|
+
"PRAGMA_TABLE_INFO",
|
|
560
|
+
"PRAGMA_USER_AGENT",
|
|
561
|
+
"PRAGMA_VERSION",
|
|
562
|
+
"PREFIX",
|
|
563
|
+
"PRINTF",
|
|
564
|
+
"PRODUCT",
|
|
565
|
+
"QUANTILE",
|
|
566
|
+
"QUANTILE_CONT",
|
|
567
|
+
"QUANTILE_DISC",
|
|
568
|
+
"QUARTER",
|
|
569
|
+
"RADIANS",
|
|
570
|
+
"RANDOM",
|
|
571
|
+
"RANGE",
|
|
572
|
+
"READFILE",
|
|
573
|
+
"READ_BLOB",
|
|
574
|
+
"READ_CSV",
|
|
575
|
+
"READ_CSV_AUTO",
|
|
576
|
+
"READ_JSON",
|
|
577
|
+
"READ_JSON_AUTO",
|
|
578
|
+
"READ_JSON_OBJECTS",
|
|
579
|
+
"READ_JSON_OBJECTS_AUTO",
|
|
580
|
+
"READ_NDJSON",
|
|
581
|
+
"READ_NDJSON_AUTO",
|
|
582
|
+
"READ_NDJSON_OBJECTS",
|
|
583
|
+
"READ_PARQUET",
|
|
584
|
+
"READ_TEXT",
|
|
585
|
+
"REDUCE",
|
|
586
|
+
"REGEXP_ESCAPE",
|
|
587
|
+
"REGEXP_EXTRACT",
|
|
588
|
+
"REGEXP_EXTRACT_ALL",
|
|
589
|
+
"REGEXP_FULL_MATCH",
|
|
590
|
+
"REGEXP_MATCHES",
|
|
591
|
+
"REGEXP_REPLACE",
|
|
592
|
+
"REGEXP_SPLIT_TO_ARRAY",
|
|
593
|
+
"REGEXP_SPLIT_TO_TABLE",
|
|
594
|
+
"REGR_AVGX",
|
|
595
|
+
"REGR_AVGY",
|
|
596
|
+
"REGR_COUNT",
|
|
597
|
+
"REGR_INTERCEPT",
|
|
598
|
+
"REGR_R2",
|
|
599
|
+
"REGR_SLOPE",
|
|
600
|
+
"REGR_SXX",
|
|
601
|
+
"REGR_SXY",
|
|
602
|
+
"REGR_SYY",
|
|
603
|
+
"REPEAT",
|
|
604
|
+
"REPEAT_ROW",
|
|
605
|
+
"REPLACE",
|
|
606
|
+
"RESERVOIR_QUANTILE",
|
|
607
|
+
"REVERSE",
|
|
608
|
+
"RIGHT",
|
|
609
|
+
"RIGHT_GRAPHEME",
|
|
610
|
+
"ROUND",
|
|
611
|
+
"ROUNDBANKERS",
|
|
612
|
+
"ROUND_EVEN",
|
|
613
|
+
"ROW",
|
|
614
|
+
"ROW_TO_JSON",
|
|
615
|
+
"RPAD",
|
|
616
|
+
"RTRIM",
|
|
617
|
+
"SECOND",
|
|
618
|
+
"SEM",
|
|
619
|
+
"SEQ_SCAN",
|
|
620
|
+
"SESSION_USER",
|
|
621
|
+
"SETSEED",
|
|
622
|
+
"SET_BIT",
|
|
623
|
+
"SHA256",
|
|
624
|
+
"SHA3",
|
|
625
|
+
"SHELL_ADD_SCHEMA",
|
|
626
|
+
"SHELL_ESCAPE_CRNL",
|
|
627
|
+
"SHELL_IDQUOTE",
|
|
628
|
+
"SHELL_MODULE_SCHEMA",
|
|
629
|
+
"SHELL_PUTSNL",
|
|
630
|
+
"SHOBJ_DESCRIPTION",
|
|
631
|
+
"SHOW",
|
|
632
|
+
"SHOW_DATABASES",
|
|
633
|
+
"SHOW_TABLES",
|
|
634
|
+
"SHOW_TABLES_EXPANDED",
|
|
635
|
+
"SIGN",
|
|
636
|
+
"SIGNBIT",
|
|
637
|
+
"SIN",
|
|
638
|
+
"SKEWNESS",
|
|
639
|
+
"SNIFF_CSV",
|
|
640
|
+
"SPLIT",
|
|
641
|
+
"SPLIT_PART",
|
|
642
|
+
"SQL_AUTO_COMPLETE",
|
|
643
|
+
"SQRT",
|
|
644
|
+
"STARTS_WITH",
|
|
645
|
+
"STATS",
|
|
646
|
+
"STDDEV",
|
|
647
|
+
"STDDEV_POP",
|
|
648
|
+
"STDDEV_SAMP",
|
|
649
|
+
"STORAGE_INFO",
|
|
650
|
+
"STRFTIME",
|
|
651
|
+
"STRING_AGG",
|
|
652
|
+
"STRING_SPLIT",
|
|
653
|
+
"STRING_SPLIT_REGEX",
|
|
654
|
+
"STRING_TO_ARRAY",
|
|
655
|
+
"STRIP_ACCENTS",
|
|
656
|
+
"STRLEN",
|
|
657
|
+
"STRPOS",
|
|
658
|
+
"STRPTIME",
|
|
659
|
+
"STRUCT_EXTRACT",
|
|
660
|
+
"STRUCT_INSERT",
|
|
661
|
+
"STRUCT_PACK",
|
|
662
|
+
"STR_SPLIT",
|
|
663
|
+
"STR_SPLIT_REGEX",
|
|
664
|
+
"SUBSTR",
|
|
665
|
+
"SUBSTRING",
|
|
666
|
+
"SUBSTRING_GRAPHEME",
|
|
667
|
+
"SUBTRACT",
|
|
668
|
+
"SUFFIX",
|
|
669
|
+
"SUM",
|
|
670
|
+
"SUMKAHAN",
|
|
671
|
+
"SUMMARY",
|
|
672
|
+
"SUM_NO_OVERFLOW",
|
|
673
|
+
"TABLE_INFO",
|
|
674
|
+
"TAN",
|
|
675
|
+
"TEST_ALL_TYPES",
|
|
676
|
+
"TEST_VECTOR_TYPES",
|
|
677
|
+
"TIMEZONE",
|
|
678
|
+
"TIMEZONE_HOUR",
|
|
679
|
+
"TIMEZONE_MINUTE",
|
|
680
|
+
"TIME_BUCKET",
|
|
681
|
+
"TODAY",
|
|
682
|
+
"TO_BASE",
|
|
683
|
+
"TO_BASE64",
|
|
684
|
+
"TO_BINARY",
|
|
685
|
+
"TO_CENTURIES",
|
|
686
|
+
"TO_DAYS",
|
|
687
|
+
"TO_DECADES",
|
|
688
|
+
"TO_HEX",
|
|
689
|
+
"TO_HOURS",
|
|
690
|
+
"TO_JSON",
|
|
691
|
+
"TO_MICROSECONDS",
|
|
692
|
+
"TO_MILLENNIA",
|
|
693
|
+
"TO_MILLISECONDS",
|
|
694
|
+
"TO_MINUTES",
|
|
695
|
+
"TO_MONTHS",
|
|
696
|
+
"TO_SECONDS",
|
|
697
|
+
"TO_TIMESTAMP",
|
|
698
|
+
"TO_WEEKS",
|
|
699
|
+
"TO_YEARS",
|
|
700
|
+
"TRANSACTION_TIMESTAMP",
|
|
701
|
+
"TRANSLATE",
|
|
702
|
+
"TRIM",
|
|
703
|
+
"TRUNC",
|
|
704
|
+
"TRY_STRPTIME",
|
|
705
|
+
"TXID_CURRENT",
|
|
706
|
+
"TYPEOF",
|
|
707
|
+
"UCASE",
|
|
708
|
+
"UNBIN",
|
|
709
|
+
"UNHEX",
|
|
710
|
+
"UNICODE",
|
|
711
|
+
"UNION_EXTRACT",
|
|
712
|
+
"UNION_TAG",
|
|
713
|
+
"UNION_VALUE",
|
|
714
|
+
"UNNEST",
|
|
715
|
+
"UNPIVOT_LIST",
|
|
716
|
+
"UPPER",
|
|
717
|
+
"USER",
|
|
718
|
+
"USER_AGENT",
|
|
719
|
+
"UUID",
|
|
720
|
+
"VARIANCE",
|
|
721
|
+
"VAR_POP",
|
|
722
|
+
"VAR_SAMP",
|
|
723
|
+
"VECTOR_TYPE",
|
|
724
|
+
"VERIFY_EXTERNAL",
|
|
725
|
+
"VERIFY_FETCH_ROW",
|
|
726
|
+
"VERIFY_PARALLELISM",
|
|
727
|
+
"VERIFY_SERIALIZER",
|
|
728
|
+
"VERSION",
|
|
729
|
+
"WEEK",
|
|
730
|
+
"WEEKDAY",
|
|
731
|
+
"WEEKOFYEAR",
|
|
732
|
+
"WHICH_SECRET",
|
|
733
|
+
"WRITEFILE",
|
|
734
|
+
"XOR",
|
|
735
|
+
"YEAR",
|
|
736
|
+
"YEARWEEK",
|
|
737
|
+
// Keywords that also need to be listed as functions
|
|
738
|
+
"CAST",
|
|
739
|
+
"COALESCE",
|
|
740
|
+
"NULL",
|
|
741
|
+
"RANK",
|
|
742
|
+
"ROW_NUMBER"
|
|
743
|
+
], $e = [
|
|
744
|
+
// Keywords from DuckDB:
|
|
745
|
+
// SELECT upper(keyword_name)
|
|
746
|
+
// FROM duckdb_keywords()
|
|
747
|
+
// WHERE keyword_category = 'reserved'
|
|
748
|
+
// ORDER BY keyword_name
|
|
749
|
+
"ALL",
|
|
750
|
+
"ANALYSE",
|
|
751
|
+
"ANALYZE",
|
|
752
|
+
"AND",
|
|
753
|
+
"ANY",
|
|
754
|
+
"AS",
|
|
755
|
+
"ASC",
|
|
756
|
+
"ATTACH",
|
|
757
|
+
"ASYMMETRIC",
|
|
758
|
+
"BOTH",
|
|
759
|
+
"CASE",
|
|
760
|
+
"CAST",
|
|
761
|
+
"CHECK",
|
|
762
|
+
"COLLATE",
|
|
763
|
+
"COLUMN",
|
|
764
|
+
"CONSTRAINT",
|
|
765
|
+
"CREATE",
|
|
766
|
+
"DEFAULT",
|
|
767
|
+
"DEFERRABLE",
|
|
768
|
+
"DESC",
|
|
769
|
+
"DESCRIBE",
|
|
770
|
+
"DETACH",
|
|
771
|
+
"DISTINCT",
|
|
772
|
+
"DO",
|
|
773
|
+
"ELSE",
|
|
774
|
+
"END",
|
|
775
|
+
"EXCEPT",
|
|
776
|
+
"FALSE",
|
|
777
|
+
"FETCH",
|
|
778
|
+
"FOR",
|
|
779
|
+
"FOREIGN",
|
|
780
|
+
"FROM",
|
|
781
|
+
"GRANT",
|
|
782
|
+
"GROUP",
|
|
783
|
+
"HAVING",
|
|
784
|
+
"IN",
|
|
785
|
+
"INITIALLY",
|
|
786
|
+
"INTERSECT",
|
|
787
|
+
"INTO",
|
|
788
|
+
"LATERAL",
|
|
789
|
+
"LEADING",
|
|
790
|
+
"LIMIT",
|
|
791
|
+
"NOT",
|
|
792
|
+
"NULL",
|
|
793
|
+
"OFFSET",
|
|
794
|
+
"ON",
|
|
795
|
+
"ONLY",
|
|
796
|
+
"OR",
|
|
797
|
+
"ORDER",
|
|
798
|
+
"PIVOT",
|
|
799
|
+
"PIVOT_LONGER",
|
|
800
|
+
"PIVOT_WIDER",
|
|
801
|
+
"PLACING",
|
|
802
|
+
"PRIMARY",
|
|
803
|
+
"REFERENCES",
|
|
804
|
+
"RETURNING",
|
|
805
|
+
"SELECT",
|
|
806
|
+
"SHOW",
|
|
807
|
+
"SOME",
|
|
808
|
+
"SUMMARIZE",
|
|
809
|
+
"SYMMETRIC",
|
|
810
|
+
"TABLE",
|
|
811
|
+
"THEN",
|
|
812
|
+
"TO",
|
|
813
|
+
"TRAILING",
|
|
814
|
+
"TRUE",
|
|
815
|
+
"UNION",
|
|
816
|
+
"UNIQUE",
|
|
817
|
+
"UNPIVOT",
|
|
818
|
+
"USING",
|
|
819
|
+
"VARIADIC",
|
|
820
|
+
"WHEN",
|
|
821
|
+
"WHERE",
|
|
822
|
+
"WINDOW",
|
|
823
|
+
"WITH"
|
|
824
|
+
], Ue = [
|
|
825
|
+
// Types from DuckDB:
|
|
826
|
+
// SELECT DISTINCT upper(type_name)
|
|
827
|
+
// FROM duckdb_types()
|
|
828
|
+
// ORDER BY type_name
|
|
829
|
+
"ARRAY",
|
|
830
|
+
"BIGINT",
|
|
831
|
+
"BINARY",
|
|
832
|
+
"BIT",
|
|
833
|
+
"BITSTRING",
|
|
834
|
+
"BLOB",
|
|
835
|
+
"BOOL",
|
|
836
|
+
"BOOLEAN",
|
|
837
|
+
"BPCHAR",
|
|
838
|
+
"BYTEA",
|
|
839
|
+
"CHAR",
|
|
840
|
+
"DATE",
|
|
841
|
+
"DATETIME",
|
|
842
|
+
"DEC",
|
|
843
|
+
"DECIMAL",
|
|
844
|
+
"DOUBLE",
|
|
845
|
+
"ENUM",
|
|
846
|
+
"FLOAT",
|
|
847
|
+
"FLOAT4",
|
|
848
|
+
"FLOAT8",
|
|
849
|
+
"GUID",
|
|
850
|
+
"HUGEINT",
|
|
851
|
+
"INET",
|
|
852
|
+
"INT",
|
|
853
|
+
"INT1",
|
|
854
|
+
"INT128",
|
|
855
|
+
"INT16",
|
|
856
|
+
"INT2",
|
|
857
|
+
"INT32",
|
|
858
|
+
"INT4",
|
|
859
|
+
"INT64",
|
|
860
|
+
"INT8",
|
|
861
|
+
"INTEGER",
|
|
862
|
+
"INTEGRAL",
|
|
863
|
+
"INTERVAL",
|
|
864
|
+
"JSON",
|
|
865
|
+
"LIST",
|
|
866
|
+
"LOGICAL",
|
|
867
|
+
"LONG",
|
|
868
|
+
"MAP",
|
|
869
|
+
// 'NULL' is a keyword
|
|
870
|
+
"NUMERIC",
|
|
871
|
+
"NVARCHAR",
|
|
872
|
+
"OID",
|
|
873
|
+
"REAL",
|
|
874
|
+
"ROW",
|
|
875
|
+
"SHORT",
|
|
876
|
+
"SIGNED",
|
|
877
|
+
"SMALLINT",
|
|
878
|
+
"STRING",
|
|
879
|
+
"STRUCT",
|
|
880
|
+
"TEXT",
|
|
881
|
+
"TIME",
|
|
882
|
+
"TIMESTAMP_MS",
|
|
883
|
+
"TIMESTAMP_NS",
|
|
884
|
+
"TIMESTAMP_S",
|
|
885
|
+
"TIMESTAMP_US",
|
|
886
|
+
"TIMESTAMP",
|
|
887
|
+
"TIMESTAMPTZ",
|
|
888
|
+
"TIMETZ",
|
|
889
|
+
"TINYINT",
|
|
890
|
+
"UBIGINT",
|
|
891
|
+
"UHUGEINT",
|
|
892
|
+
"UINT128",
|
|
893
|
+
"UINT16",
|
|
894
|
+
"UINT32",
|
|
895
|
+
"UINT64",
|
|
896
|
+
"UINT8",
|
|
897
|
+
"UINTEGER",
|
|
898
|
+
"UNION",
|
|
899
|
+
"USMALLINT",
|
|
900
|
+
"UTINYINT",
|
|
901
|
+
"UUID",
|
|
902
|
+
"VARBINARY",
|
|
903
|
+
"VARCHAR"
|
|
904
|
+
], we = d(["SELECT [ALL | DISTINCT]"]), ge = d([
|
|
905
|
+
// queries
|
|
906
|
+
"WITH [RECURSIVE]",
|
|
907
|
+
"FROM",
|
|
908
|
+
"WHERE",
|
|
909
|
+
"GROUP BY [ALL]",
|
|
910
|
+
"HAVING",
|
|
911
|
+
"WINDOW",
|
|
912
|
+
"PARTITION BY",
|
|
913
|
+
"ORDER BY [ALL]",
|
|
914
|
+
"LIMIT",
|
|
915
|
+
"OFFSET",
|
|
916
|
+
// 'USING' (conflicts with 'USING' in JOIN)
|
|
917
|
+
"USING SAMPLE",
|
|
918
|
+
"QUALIFY",
|
|
919
|
+
// Data manipulation
|
|
920
|
+
// - insert:
|
|
921
|
+
"INSERT [OR REPLACE] INTO",
|
|
922
|
+
"VALUES",
|
|
923
|
+
"DEFAULT VALUES",
|
|
924
|
+
// - update:
|
|
925
|
+
"SET",
|
|
926
|
+
// other:
|
|
927
|
+
"RETURNING"
|
|
928
|
+
]), Q = d([
|
|
929
|
+
"CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
|
|
930
|
+
]), V = d([
|
|
931
|
+
// TABLE
|
|
932
|
+
// - update:
|
|
933
|
+
"UPDATE",
|
|
934
|
+
// - insert:
|
|
935
|
+
"ON CONFLICT",
|
|
936
|
+
// - delete:
|
|
937
|
+
"DELETE FROM",
|
|
938
|
+
// - drop table:
|
|
939
|
+
"DROP TABLE [IF EXISTS]",
|
|
940
|
+
// - truncate
|
|
941
|
+
"TRUNCATE",
|
|
942
|
+
// - alter table:
|
|
943
|
+
"ALTER TABLE",
|
|
944
|
+
"ADD [COLUMN] [IF NOT EXISTS]",
|
|
945
|
+
"ADD PRIMARY KEY",
|
|
946
|
+
"DROP [COLUMN] [IF EXISTS]",
|
|
947
|
+
"ALTER [COLUMN]",
|
|
948
|
+
"RENAME [COLUMN]",
|
|
949
|
+
"RENAME TO",
|
|
950
|
+
"SET [DATA] TYPE",
|
|
951
|
+
"{SET | DROP} DEFAULT",
|
|
952
|
+
"{SET | DROP} NOT NULL",
|
|
953
|
+
// MACRO / FUNCTION
|
|
954
|
+
"CREATE [OR REPLACE] [TEMPORARY | TEMP] {MACRO | FUNCTION}",
|
|
955
|
+
"DROP MACRO [TABLE] [IF EXISTS]",
|
|
956
|
+
"DROP FUNCTION [IF EXISTS]",
|
|
957
|
+
// INDEX
|
|
958
|
+
"CREATE [UNIQUE] INDEX [IF NOT EXISTS]",
|
|
959
|
+
"DROP INDEX [IF EXISTS]",
|
|
960
|
+
// SCHEMA
|
|
961
|
+
"CREATE [OR REPLACE] SCHEMA [IF NOT EXISTS]",
|
|
962
|
+
"DROP SCHEMA [IF EXISTS]",
|
|
963
|
+
// SECRET
|
|
964
|
+
"CREATE [OR REPLACE] [PERSISTENT | TEMPORARY] SECRET [IF NOT EXISTS]",
|
|
965
|
+
"DROP [PERSISTENT | TEMPORARY] SECRET [IF EXISTS]",
|
|
966
|
+
// SEQUENCE
|
|
967
|
+
"CREATE [OR REPLACE] [TEMPORARY | TEMP] SEQUENCE",
|
|
968
|
+
"DROP SEQUENCE [IF EXISTS]",
|
|
969
|
+
// VIEW
|
|
970
|
+
"CREATE [OR REPLACE] [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
|
|
971
|
+
"DROP VIEW [IF EXISTS]",
|
|
972
|
+
"ALTER VIEW",
|
|
973
|
+
// TYPE
|
|
974
|
+
"CREATE TYPE",
|
|
975
|
+
"DROP TYPE [IF EXISTS]",
|
|
976
|
+
// other
|
|
977
|
+
"ANALYZE",
|
|
978
|
+
"ATTACH [DATABASE] [IF NOT EXISTS]",
|
|
979
|
+
"DETACH [DATABASE] [IF EXISTS]",
|
|
980
|
+
"CALL",
|
|
981
|
+
"[FORCE] CHECKPOINT",
|
|
982
|
+
"COMMENT ON [TABLE | COLUMN | VIEW | INDEX | SEQUENCE | TYPE | MACRO | MACRO TABLE]",
|
|
983
|
+
"COPY [FROM DATABASE]",
|
|
984
|
+
"DESCRIBE",
|
|
985
|
+
"EXPORT DATABASE",
|
|
986
|
+
"IMPORT DATABASE",
|
|
987
|
+
"INSTALL",
|
|
988
|
+
"LOAD",
|
|
989
|
+
"PIVOT",
|
|
990
|
+
"PIVOT_WIDER",
|
|
991
|
+
"UNPIVOT",
|
|
992
|
+
"EXPLAIN [ANALYZE]",
|
|
993
|
+
// plain SET conflicts with SET clause in UPDATE
|
|
994
|
+
"SET {LOCAL | SESSION | GLOBAL}",
|
|
995
|
+
"RESET [LOCAL | SESSION | GLOBAL]",
|
|
996
|
+
"{SET | RESET} VARIABLE",
|
|
997
|
+
"SUMMARIZE",
|
|
998
|
+
"BEGIN TRANSACTION",
|
|
999
|
+
"ROLLBACK",
|
|
1000
|
+
"COMMIT",
|
|
1001
|
+
"ABORT",
|
|
1002
|
+
"USE",
|
|
1003
|
+
"VACUUM [ANALYZE]",
|
|
1004
|
+
// prepared statements
|
|
1005
|
+
"PREPARE",
|
|
1006
|
+
"EXECUTE",
|
|
1007
|
+
"DEALLOCATE [PREPARE]"
|
|
1008
|
+
]), Be = d([
|
|
1009
|
+
"UNION [ALL | BY NAME]",
|
|
1010
|
+
"EXCEPT [ALL]",
|
|
1011
|
+
"INTERSECT [ALL]"
|
|
1012
|
+
]), Ge = d([
|
|
1013
|
+
"JOIN",
|
|
1014
|
+
"{LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
1015
|
+
"{INNER | CROSS} JOIN",
|
|
1016
|
+
"{NATURAL | ASOF} [INNER] JOIN",
|
|
1017
|
+
"{NATURAL | ASOF} {LEFT | RIGHT | FULL} [OUTER] JOIN",
|
|
1018
|
+
"POSITIONAL JOIN",
|
|
1019
|
+
"ANTI JOIN",
|
|
1020
|
+
"SEMI JOIN"
|
|
1021
|
+
]), Ye = d([
|
|
1022
|
+
"{ROWS | RANGE | GROUPS} BETWEEN",
|
|
1023
|
+
"SIMILAR TO",
|
|
1024
|
+
"IS [NOT] DISTINCT FROM",
|
|
1025
|
+
"TIMESTAMP WITH TIME ZONE"
|
|
1026
|
+
]), xs = {
|
|
1027
|
+
name: "duckdb",
|
|
1028
|
+
tokenizerOptions: {
|
|
1029
|
+
reservedSelect: we,
|
|
1030
|
+
reservedClauses: [...ge, ...Q, ...V],
|
|
1031
|
+
reservedSetOperations: Be,
|
|
1032
|
+
reservedJoins: Ge,
|
|
1033
|
+
reservedPhrases: Ye,
|
|
1034
|
+
supportsXor: !0,
|
|
1035
|
+
reservedKeywords: $e,
|
|
1036
|
+
reservedDataTypes: Ue,
|
|
1037
|
+
reservedFunctionNames: xe,
|
|
1038
|
+
nestedBlockComments: !0,
|
|
1039
|
+
extraParens: ["[]", "{}"],
|
|
1040
|
+
stringTypes: [
|
|
1041
|
+
"$$",
|
|
1042
|
+
"''-qq",
|
|
1043
|
+
{ quote: "''-qq-bs", prefixes: ["E"], requirePrefix: !0 },
|
|
1044
|
+
{ quote: "''-raw", prefixes: ["B", "X"], requirePrefix: !0 }
|
|
1045
|
+
],
|
|
1046
|
+
identTypes: ['""-qq'],
|
|
1047
|
+
identChars: { rest: "$" },
|
|
1048
|
+
// TODO: named params $foo currently conflict with $$-quoted strings
|
|
1049
|
+
paramTypes: { positional: !0, numbered: ["$"], quoted: ["$"] },
|
|
1050
|
+
operators: [
|
|
1051
|
+
// Arithmetic:
|
|
1052
|
+
"//",
|
|
1053
|
+
"%",
|
|
1054
|
+
"**",
|
|
1055
|
+
"^",
|
|
1056
|
+
"!",
|
|
1057
|
+
// Bitwise:
|
|
1058
|
+
"&",
|
|
1059
|
+
"|",
|
|
1060
|
+
"~",
|
|
1061
|
+
"<<",
|
|
1062
|
+
">>",
|
|
1063
|
+
// Cast:
|
|
1064
|
+
"::",
|
|
1065
|
+
// Comparison:
|
|
1066
|
+
"==",
|
|
1067
|
+
// Lambda:
|
|
1068
|
+
"->",
|
|
1069
|
+
// key-value separator:
|
|
1070
|
+
":",
|
|
1071
|
+
// Named function params:
|
|
1072
|
+
":=",
|
|
1073
|
+
"=>",
|
|
1074
|
+
// Pattern matching:
|
|
1075
|
+
"~~",
|
|
1076
|
+
"!~~",
|
|
1077
|
+
"~~*",
|
|
1078
|
+
"!~~*",
|
|
1079
|
+
"~~~",
|
|
1080
|
+
// Regular expressions:
|
|
1081
|
+
"~",
|
|
1082
|
+
"!~",
|
|
1083
|
+
"~*",
|
|
1084
|
+
"!~*",
|
|
1085
|
+
// String:
|
|
1086
|
+
"^@",
|
|
1087
|
+
"||",
|
|
1088
|
+
// INET extension:
|
|
1089
|
+
">>=",
|
|
1090
|
+
"<<="
|
|
1091
|
+
]
|
|
1092
|
+
},
|
|
1093
|
+
formatOptions: {
|
|
1094
|
+
alwaysDenseOperators: ["::"],
|
|
1095
|
+
onelineClauses: [...Q, ...V],
|
|
1096
|
+
tabularOnelineClauses: V
|
|
1097
|
+
}
|
|
1098
|
+
}, B = (s) => s[s.length - 1], _e = (s) => s.sort((e, t) => t.length - e.length || e.localeCompare(t)), Y = (s) => s.replace(/\s+/gu, " "), H = (s) => /\n/.test(s), C = (s) => s.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), Z = /\s+/uy, M = (s) => new RegExp(`(?:${s})`, "uy"), Fe = (s) => s.split("").map((e) => / /gu.test(e) ? "\\s+" : `[${e.toUpperCase()}${e.toLowerCase()}]`).join(""), ve = (s) => s + "(?:-" + s + ")*", Ve = ({ prefixes: s, requirePrefix: e }) => `(?:${s.map(Fe).join("|")}${e ? "" : "|"})`, He = (s) => new RegExp(`(?:${s.map(C).join("|")}).*?(?=\r
|
|
1099
|
+
|\r|
|
|
1100
|
+
|$)`, "uy"), z = (s, e = []) => {
|
|
1101
|
+
const t = s === "open" ? 0 : 1, r = ["()", ...e].map((o) => o[t]);
|
|
1102
|
+
return M(r.map(C).join("|"));
|
|
1103
|
+
}, ee = (s) => M(`${_e(s).map(C).join("|")}`), We = ({ rest: s, dashes: e }) => s || e ? `(?![${s || ""}${e ? "-" : ""}])` : "", D = (s, e = {}) => {
|
|
1104
|
+
if (s.length === 0)
|
|
1105
|
+
return /^\b$/u;
|
|
1106
|
+
const t = We(e), r = _e(s).map(C).join("|").replace(/ /gu, "\\s+");
|
|
1107
|
+
return new RegExp(`(?:${r})${t}\\b`, "iuy");
|
|
1108
|
+
}, W = (s, e) => {
|
|
1109
|
+
if (!s.length)
|
|
1110
|
+
return;
|
|
1111
|
+
const t = s.map(C).join("|");
|
|
1112
|
+
return M(`(?:${t})(?:${e})`);
|
|
1113
|
+
}, Ke = () => {
|
|
1114
|
+
const s = {
|
|
1115
|
+
"<": ">",
|
|
1116
|
+
"[": "]",
|
|
1117
|
+
"(": ")",
|
|
1118
|
+
"{": "}"
|
|
1119
|
+
}, e = "{left}(?:(?!{right}').)*?{right}", t = Object.entries(s).map(([S, y]) => e.replace(/{left}/g, C(S)).replace(/{right}/g, C(y))), r = C(Object.keys(s).join(""));
|
|
1120
|
+
return `[Qq]'(?:${String.raw`(?<tag>[^\s${r}])(?:(?!\k<tag>').)*?\k<tag>`}|${t.join("|")})'`;
|
|
1121
|
+
}, se = {
|
|
1122
|
+
// - backtick quoted (using `` to escape)
|
|
1123
|
+
"``": "(?:`[^`]*`)+",
|
|
1124
|
+
// - Transact-SQL square bracket quoted (using ]] to escape)
|
|
1125
|
+
"[]": String.raw`(?:\[[^\]]*\])(?:\][^\]]*\])*`,
|
|
1126
|
+
// double-quoted
|
|
1127
|
+
'""-qq': String.raw`(?:"[^"]*")+`,
|
|
1128
|
+
'""-bs': String.raw`(?:"[^"\\]*(?:\\.[^"\\]*)*")`,
|
|
1129
|
+
'""-qq-bs': String.raw`(?:"[^"\\]*(?:\\.[^"\\]*)*")+`,
|
|
1130
|
+
'""-raw': String.raw`(?:"[^"]*")`,
|
|
1131
|
+
// single-quoted
|
|
1132
|
+
"''-qq": String.raw`(?:'[^']*')+`,
|
|
1133
|
+
"''-bs": String.raw`(?:'[^'\\]*(?:\\.[^'\\]*)*')`,
|
|
1134
|
+
"''-qq-bs": String.raw`(?:'[^'\\]*(?:\\.[^'\\]*)*')+`,
|
|
1135
|
+
"''-raw": String.raw`(?:'[^']*')`,
|
|
1136
|
+
// PostgreSQL dollar-quoted
|
|
1137
|
+
$$: String.raw`(?<tag>\$\w*\$)[\s\S]*?\k<tag>`,
|
|
1138
|
+
// BigQuery '''triple-quoted''' (using \' to escape)
|
|
1139
|
+
"'''..'''": String.raw`'''[^\\]*?(?:\\.[^\\]*?)*?'''`,
|
|
1140
|
+
// BigQuery """triple-quoted""" (using \" to escape)
|
|
1141
|
+
'""".."""': String.raw`"""[^\\]*?(?:\\.[^\\]*?)*?"""`,
|
|
1142
|
+
// Hive and Spark variables: ${name}
|
|
1143
|
+
"{}": String.raw`(?:\{[^\}]*\})`,
|
|
1144
|
+
// Oracle q'' strings: q'<text>' q'|text|' ...
|
|
1145
|
+
"q''": Ke()
|
|
1146
|
+
}, Re = (s) => typeof s == "string" ? se[s] : "regex" in s ? s.regex : Ve(s) + se[s.quote], ke = (s) => M(s.map((e) => "regex" in e ? e.regex : Re(e)).join("|")), Ae = (s) => s.map(Re).join("|"), te = (s) => M(Ae(s)), Xe = (s = {}) => M(Te(s)), Te = ({ first: s, rest: e, dashes: t, allowFirstCharNumber: r } = {}) => {
|
|
1147
|
+
const o = "\\p{Alphabetic}\\p{Mark}_", c = "\\p{Decimal_Number}", S = C(s ?? ""), y = C(e ?? ""), f = r ? `[${o}${c}${S}][${o}${c}${y}]*` : `[${o}${S}][${o}${c}${y}]*`;
|
|
1148
|
+
return t ? ve(f) : f;
|
|
1149
|
+
};
|
|
1150
|
+
function Se(s, e) {
|
|
1151
|
+
const t = s.slice(0, e).split(/\n/);
|
|
1152
|
+
return { line: t.length, col: t[t.length - 1].length + 1 };
|
|
1153
|
+
}
|
|
1154
|
+
class Je {
|
|
1155
|
+
constructor(e, t) {
|
|
1156
|
+
this.rules = e, this.dialectName = t, this.input = "", this.index = 0;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Takes a SQL string and breaks it into tokens.
|
|
1160
|
+
* Each token is an object with type and value.
|
|
1161
|
+
*
|
|
1162
|
+
* @param {string} input - The SQL string
|
|
1163
|
+
* @returns {Token[]} output token stream
|
|
1164
|
+
*/
|
|
1165
|
+
tokenize(e) {
|
|
1166
|
+
this.input = e, this.index = 0;
|
|
1167
|
+
const t = [];
|
|
1168
|
+
let r;
|
|
1169
|
+
for (; this.index < this.input.length; ) {
|
|
1170
|
+
const o = this.getWhitespace();
|
|
1171
|
+
if (this.index < this.input.length) {
|
|
1172
|
+
if (r = this.getNextToken(), !r)
|
|
1173
|
+
throw this.createParseError();
|
|
1174
|
+
t.push(Object.assign(Object.assign({}, r), { precedingWhitespace: o }));
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
return t;
|
|
1178
|
+
}
|
|
1179
|
+
createParseError() {
|
|
1180
|
+
const e = this.input.slice(this.index, this.index + 10), { line: t, col: r } = Se(this.input, this.index);
|
|
1181
|
+
return new Error(`Parse error: Unexpected "${e}" at line ${t} column ${r}.
|
|
1182
|
+
${this.dialectInfo()}`);
|
|
1183
|
+
}
|
|
1184
|
+
dialectInfo() {
|
|
1185
|
+
return this.dialectName === "sql" ? `This likely happens because you're using the default "sql" dialect.
|
|
1186
|
+
If possible, please select a more specific dialect (like sqlite, postgresql, etc).` : `SQL dialect used: "${this.dialectName}".`;
|
|
1187
|
+
}
|
|
1188
|
+
getWhitespace() {
|
|
1189
|
+
Z.lastIndex = this.index;
|
|
1190
|
+
const e = Z.exec(this.input);
|
|
1191
|
+
if (e)
|
|
1192
|
+
return this.index += e[0].length, e[0];
|
|
1193
|
+
}
|
|
1194
|
+
getNextToken() {
|
|
1195
|
+
for (const e of this.rules) {
|
|
1196
|
+
const t = this.match(e);
|
|
1197
|
+
if (t)
|
|
1198
|
+
return t;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
// Attempts to match token rule regex at current position in input
|
|
1202
|
+
match(e) {
|
|
1203
|
+
e.regex.lastIndex = this.index;
|
|
1204
|
+
const t = e.regex.exec(this.input);
|
|
1205
|
+
if (t) {
|
|
1206
|
+
const r = t[0], o = {
|
|
1207
|
+
type: e.type,
|
|
1208
|
+
raw: r,
|
|
1209
|
+
text: e.text ? e.text(r) : r,
|
|
1210
|
+
start: this.index
|
|
1211
|
+
};
|
|
1212
|
+
return e.key && (o.key = e.key(r)), this.index += r.length, o;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
const re = /\/\*/uy, qe = /[\s\S]/uy, je = /\*\//uy;
|
|
1217
|
+
class Qe {
|
|
1218
|
+
constructor() {
|
|
1219
|
+
this.lastIndex = 0;
|
|
1220
|
+
}
|
|
1221
|
+
exec(e) {
|
|
1222
|
+
let t = "", r, o = 0;
|
|
1223
|
+
if (r = this.matchSection(re, e))
|
|
1224
|
+
t += r, o++;
|
|
1225
|
+
else
|
|
1226
|
+
return null;
|
|
1227
|
+
for (; o > 0; )
|
|
1228
|
+
if (r = this.matchSection(re, e))
|
|
1229
|
+
t += r, o++;
|
|
1230
|
+
else if (r = this.matchSection(je, e))
|
|
1231
|
+
t += r, o--;
|
|
1232
|
+
else if (r = this.matchSection(qe, e))
|
|
1233
|
+
t += r;
|
|
1234
|
+
else
|
|
1235
|
+
return null;
|
|
1236
|
+
return [t];
|
|
1237
|
+
}
|
|
1238
|
+
matchSection(e, t) {
|
|
1239
|
+
e.lastIndex = this.lastIndex;
|
|
1240
|
+
const r = e.exec(t);
|
|
1241
|
+
return r && (this.lastIndex += r[0].length), r ? r[0] : null;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
class Ze {
|
|
1245
|
+
constructor(e, t) {
|
|
1246
|
+
this.cfg = e, this.dialectName = t, this.rulesBeforeParams = this.buildRulesBeforeParams(e), this.rulesAfterParams = this.buildRulesAfterParams(e);
|
|
1247
|
+
}
|
|
1248
|
+
tokenize(e, t) {
|
|
1249
|
+
const r = [
|
|
1250
|
+
...this.rulesBeforeParams,
|
|
1251
|
+
...this.buildParamRules(this.cfg, t),
|
|
1252
|
+
...this.rulesAfterParams
|
|
1253
|
+
], o = new Je(r, this.dialectName).tokenize(e);
|
|
1254
|
+
return this.cfg.postProcess ? this.cfg.postProcess(o) : o;
|
|
1255
|
+
}
|
|
1256
|
+
// These rules can be cached as they only depend on
|
|
1257
|
+
// the Tokenizer config options specified for each SQL dialect
|
|
1258
|
+
buildRulesBeforeParams(e) {
|
|
1259
|
+
var t, r;
|
|
1260
|
+
return this.validRules([
|
|
1261
|
+
{
|
|
1262
|
+
type: n.BLOCK_COMMENT,
|
|
1263
|
+
regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
type: n.BLOCK_COMMENT,
|
|
1267
|
+
regex: e.nestedBlockComments ? new Qe() : /(\/\*[^]*?\*\/)/uy
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
type: n.LINE_COMMENT,
|
|
1271
|
+
regex: He((t = e.lineCommentTypes) !== null && t !== void 0 ? t : ["--"])
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
type: n.QUOTED_IDENTIFIER,
|
|
1275
|
+
regex: te(e.identTypes)
|
|
1276
|
+
},
|
|
1277
|
+
{
|
|
1278
|
+
type: n.NUMBER,
|
|
1279
|
+
regex: /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
|
|
1280
|
+
},
|
|
1281
|
+
// RESERVED_PHRASE is matched before all other keyword tokens
|
|
1282
|
+
// to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
|
|
1283
|
+
{
|
|
1284
|
+
type: n.RESERVED_PHRASE,
|
|
1285
|
+
regex: D((r = e.reservedPhrases) !== null && r !== void 0 ? r : [], e.identChars),
|
|
1286
|
+
text: h
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
type: n.CASE,
|
|
1290
|
+
regex: /CASE\b/iuy,
|
|
1291
|
+
text: h
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
type: n.END,
|
|
1295
|
+
regex: /END\b/iuy,
|
|
1296
|
+
text: h
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
type: n.BETWEEN,
|
|
1300
|
+
regex: /BETWEEN\b/iuy,
|
|
1301
|
+
text: h
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
type: n.LIMIT,
|
|
1305
|
+
regex: e.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
|
|
1306
|
+
text: h
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
type: n.RESERVED_CLAUSE,
|
|
1310
|
+
regex: D(e.reservedClauses, e.identChars),
|
|
1311
|
+
text: h
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
type: n.RESERVED_SELECT,
|
|
1315
|
+
regex: D(e.reservedSelect, e.identChars),
|
|
1316
|
+
text: h
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
type: n.RESERVED_SET_OPERATION,
|
|
1320
|
+
regex: D(e.reservedSetOperations, e.identChars),
|
|
1321
|
+
text: h
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
type: n.WHEN,
|
|
1325
|
+
regex: /WHEN\b/iuy,
|
|
1326
|
+
text: h
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
type: n.ELSE,
|
|
1330
|
+
regex: /ELSE\b/iuy,
|
|
1331
|
+
text: h
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
type: n.THEN,
|
|
1335
|
+
regex: /THEN\b/iuy,
|
|
1336
|
+
text: h
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
type: n.RESERVED_JOIN,
|
|
1340
|
+
regex: D(e.reservedJoins, e.identChars),
|
|
1341
|
+
text: h
|
|
1342
|
+
},
|
|
1343
|
+
{
|
|
1344
|
+
type: n.AND,
|
|
1345
|
+
regex: /AND\b/iuy,
|
|
1346
|
+
text: h
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
type: n.OR,
|
|
1350
|
+
regex: /OR\b/iuy,
|
|
1351
|
+
text: h
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
type: n.XOR,
|
|
1355
|
+
regex: e.supportsXor ? /XOR\b/iuy : void 0,
|
|
1356
|
+
text: h
|
|
1357
|
+
},
|
|
1358
|
+
...e.operatorKeyword ? [
|
|
1359
|
+
{
|
|
1360
|
+
type: n.OPERATOR,
|
|
1361
|
+
regex: /OPERATOR *\([^)]+\)/iuy
|
|
1362
|
+
}
|
|
1363
|
+
] : [],
|
|
1364
|
+
{
|
|
1365
|
+
type: n.RESERVED_FUNCTION_NAME,
|
|
1366
|
+
regex: D(e.reservedFunctionNames, e.identChars),
|
|
1367
|
+
text: h
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
type: n.RESERVED_DATA_TYPE,
|
|
1371
|
+
regex: D(e.reservedDataTypes, e.identChars),
|
|
1372
|
+
text: h
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
type: n.RESERVED_KEYWORD,
|
|
1376
|
+
regex: D(e.reservedKeywords, e.identChars),
|
|
1377
|
+
text: h
|
|
1378
|
+
}
|
|
1379
|
+
]);
|
|
1380
|
+
}
|
|
1381
|
+
// These rules can also be cached as they only depend on
|
|
1382
|
+
// the Tokenizer config options specified for each SQL dialect
|
|
1383
|
+
buildRulesAfterParams(e) {
|
|
1384
|
+
var t, r;
|
|
1385
|
+
return this.validRules([
|
|
1386
|
+
{
|
|
1387
|
+
type: n.VARIABLE,
|
|
1388
|
+
regex: e.variableTypes ? ke(e.variableTypes) : void 0
|
|
1389
|
+
},
|
|
1390
|
+
{ type: n.STRING, regex: te(e.stringTypes) },
|
|
1391
|
+
{
|
|
1392
|
+
type: n.IDENTIFIER,
|
|
1393
|
+
regex: Xe(e.identChars)
|
|
1394
|
+
},
|
|
1395
|
+
{ type: n.DELIMITER, regex: /[;]/uy },
|
|
1396
|
+
{ type: n.COMMA, regex: /[,]/y },
|
|
1397
|
+
{
|
|
1398
|
+
type: n.OPEN_PAREN,
|
|
1399
|
+
regex: z("open", e.extraParens)
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
type: n.CLOSE_PAREN,
|
|
1403
|
+
regex: z("close", e.extraParens)
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
type: n.OPERATOR,
|
|
1407
|
+
regex: ee([
|
|
1408
|
+
// standard operators
|
|
1409
|
+
"+",
|
|
1410
|
+
"-",
|
|
1411
|
+
"/",
|
|
1412
|
+
">",
|
|
1413
|
+
"<",
|
|
1414
|
+
"=",
|
|
1415
|
+
"<>",
|
|
1416
|
+
"<=",
|
|
1417
|
+
">=",
|
|
1418
|
+
"!=",
|
|
1419
|
+
...(t = e.operators) !== null && t !== void 0 ? t : []
|
|
1420
|
+
])
|
|
1421
|
+
},
|
|
1422
|
+
{ type: n.ASTERISK, regex: /[*]/uy },
|
|
1423
|
+
{
|
|
1424
|
+
type: n.PROPERTY_ACCESS_OPERATOR,
|
|
1425
|
+
regex: ee([".", ...(r = e.propertyAccessOperators) !== null && r !== void 0 ? r : []])
|
|
1426
|
+
}
|
|
1427
|
+
]);
|
|
1428
|
+
}
|
|
1429
|
+
// These rules can't be blindly cached as the paramTypesOverrides object
|
|
1430
|
+
// can differ on each invocation of the format() function.
|
|
1431
|
+
buildParamRules(e, t) {
|
|
1432
|
+
var r, o, c, S, y;
|
|
1433
|
+
const f = {
|
|
1434
|
+
named: (t == null ? void 0 : t.named) || ((r = e.paramTypes) === null || r === void 0 ? void 0 : r.named) || [],
|
|
1435
|
+
quoted: (t == null ? void 0 : t.quoted) || ((o = e.paramTypes) === null || o === void 0 ? void 0 : o.quoted) || [],
|
|
1436
|
+
numbered: (t == null ? void 0 : t.numbered) || ((c = e.paramTypes) === null || c === void 0 ? void 0 : c.numbered) || [],
|
|
1437
|
+
positional: typeof (t == null ? void 0 : t.positional) == "boolean" ? t.positional : (S = e.paramTypes) === null || S === void 0 ? void 0 : S.positional,
|
|
1438
|
+
custom: (t == null ? void 0 : t.custom) || ((y = e.paramTypes) === null || y === void 0 ? void 0 : y.custom) || []
|
|
1439
|
+
};
|
|
1440
|
+
return this.validRules([
|
|
1441
|
+
{
|
|
1442
|
+
type: n.NAMED_PARAMETER,
|
|
1443
|
+
regex: W(f.named, Te(e.paramChars || e.identChars)),
|
|
1444
|
+
key: (i) => i.slice(1)
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
type: n.QUOTED_PARAMETER,
|
|
1448
|
+
regex: W(f.quoted, Ae(e.identTypes)),
|
|
1449
|
+
key: (i) => (({ tokenKey: E, quoteChar: l }) => E.replace(new RegExp(C("\\" + l), "gu"), l))({
|
|
1450
|
+
tokenKey: i.slice(2, -1),
|
|
1451
|
+
quoteChar: i.slice(-1)
|
|
1452
|
+
})
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
type: n.NUMBERED_PARAMETER,
|
|
1456
|
+
regex: W(f.numbered, "[0-9]+"),
|
|
1457
|
+
key: (i) => i.slice(1)
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
type: n.POSITIONAL_PARAMETER,
|
|
1461
|
+
regex: f.positional ? /[?]/y : void 0
|
|
1462
|
+
},
|
|
1463
|
+
...f.custom.map((i) => {
|
|
1464
|
+
var E;
|
|
1465
|
+
return {
|
|
1466
|
+
type: n.CUSTOM_PARAMETER,
|
|
1467
|
+
regex: M(i.regex),
|
|
1468
|
+
key: (E = i.key) !== null && E !== void 0 ? E : (l) => l
|
|
1469
|
+
};
|
|
1470
|
+
})
|
|
1471
|
+
]);
|
|
1472
|
+
}
|
|
1473
|
+
// filters out rules for token types whose regex is undefined
|
|
1474
|
+
validRules(e) {
|
|
1475
|
+
return e.filter((t) => !!t.regex);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
const h = (s) => Y(s.toUpperCase()), ae = /* @__PURE__ */ new Map(), ze = (s) => {
|
|
1479
|
+
let e = ae.get(s);
|
|
1480
|
+
return e || (e = es(s), ae.set(s, e)), e;
|
|
1481
|
+
}, es = (s) => ({
|
|
1482
|
+
tokenizer: new Ze(s.tokenizerOptions, s.name),
|
|
1483
|
+
formatOptions: ss(s.formatOptions)
|
|
1484
|
+
}), ss = (s) => {
|
|
1485
|
+
var e;
|
|
1486
|
+
return {
|
|
1487
|
+
alwaysDenseOperators: s.alwaysDenseOperators || [],
|
|
1488
|
+
onelineClauses: Object.fromEntries(s.onelineClauses.map((t) => [t, !0])),
|
|
1489
|
+
tabularOnelineClauses: Object.fromEntries(((e = s.tabularOnelineClauses) !== null && e !== void 0 ? e : s.onelineClauses).map((t) => [t, !0]))
|
|
1490
|
+
};
|
|
1491
|
+
};
|
|
1492
|
+
function ts(s) {
|
|
1493
|
+
return s.indentStyle === "tabularLeft" || s.indentStyle === "tabularRight" ? " ".repeat(10) : s.useTabs ? " " : " ".repeat(s.tabWidth);
|
|
1494
|
+
}
|
|
1495
|
+
function $(s) {
|
|
1496
|
+
return s.indentStyle === "tabularLeft" || s.indentStyle === "tabularRight";
|
|
1497
|
+
}
|
|
1498
|
+
class rs {
|
|
1499
|
+
constructor(e) {
|
|
1500
|
+
this.params = e, this.index = 0;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Returns param value that matches given placeholder with param key.
|
|
1504
|
+
*/
|
|
1505
|
+
get({ key: e, text: t }) {
|
|
1506
|
+
return this.params ? e ? this.params[e] : this.params[this.index++] : t;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Returns index of current positional parameter.
|
|
1510
|
+
*/
|
|
1511
|
+
getPositionalParameterIndex() {
|
|
1512
|
+
return this.index;
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Sets index of current positional parameter.
|
|
1516
|
+
*/
|
|
1517
|
+
setPositionalParameterIndex(e) {
|
|
1518
|
+
this.index = e;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
var F = { exports: {} }, as = F.exports, ie;
|
|
1522
|
+
function is() {
|
|
1523
|
+
return ie || (ie = 1, function(s) {
|
|
1524
|
+
(function(e, t) {
|
|
1525
|
+
s.exports ? s.exports = t() : e.nearley = t();
|
|
1526
|
+
})(as, function() {
|
|
1527
|
+
function e(i, E, l) {
|
|
1528
|
+
return this.id = ++e.highestId, this.name = i, this.symbols = E, this.postprocess = l, this;
|
|
1529
|
+
}
|
|
1530
|
+
e.highestId = 0, e.prototype.toString = function(i) {
|
|
1531
|
+
var E = typeof i > "u" ? this.symbols.map(f).join(" ") : this.symbols.slice(0, i).map(f).join(" ") + " ● " + this.symbols.slice(i).map(f).join(" ");
|
|
1532
|
+
return this.name + " → " + E;
|
|
1533
|
+
};
|
|
1534
|
+
function t(i, E, l, R) {
|
|
1535
|
+
this.rule = i, this.dot = E, this.reference = l, this.data = [], this.wantedBy = R, this.isComplete = this.dot === i.symbols.length;
|
|
1536
|
+
}
|
|
1537
|
+
t.prototype.toString = function() {
|
|
1538
|
+
return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
|
|
1539
|
+
}, t.prototype.nextState = function(i) {
|
|
1540
|
+
var E = new t(this.rule, this.dot + 1, this.reference, this.wantedBy);
|
|
1541
|
+
return E.left = this, E.right = i, E.isComplete && (E.data = E.build(), E.right = void 0), E;
|
|
1542
|
+
}, t.prototype.build = function() {
|
|
1543
|
+
var i = [], E = this;
|
|
1544
|
+
do
|
|
1545
|
+
i.push(E.right.data), E = E.left;
|
|
1546
|
+
while (E.left);
|
|
1547
|
+
return i.reverse(), i;
|
|
1548
|
+
}, t.prototype.finish = function() {
|
|
1549
|
+
this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, S.fail));
|
|
1550
|
+
};
|
|
1551
|
+
function r(i, E) {
|
|
1552
|
+
this.grammar = i, this.index = E, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
|
|
1553
|
+
}
|
|
1554
|
+
r.prototype.process = function(i) {
|
|
1555
|
+
for (var E = this.states, l = this.wants, R = this.completed, p = 0; p < E.length; p++) {
|
|
1556
|
+
var T = E[p];
|
|
1557
|
+
if (T.isComplete) {
|
|
1558
|
+
if (T.finish(), T.data !== S.fail) {
|
|
1559
|
+
for (var u = T.wantedBy, I = u.length; I--; ) {
|
|
1560
|
+
var L = u[I];
|
|
1561
|
+
this.complete(L, T);
|
|
1562
|
+
}
|
|
1563
|
+
if (T.reference === this.index) {
|
|
1564
|
+
var N = T.rule.name;
|
|
1565
|
+
(this.completed[N] = this.completed[N] || []).push(T);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
} else {
|
|
1569
|
+
var N = T.rule.symbols[T.dot];
|
|
1570
|
+
if (typeof N != "string") {
|
|
1571
|
+
this.scannable.push(T);
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (l[N]) {
|
|
1575
|
+
if (l[N].push(T), R.hasOwnProperty(N))
|
|
1576
|
+
for (var P = R[N], I = 0; I < P.length; I++) {
|
|
1577
|
+
var w = P[I];
|
|
1578
|
+
this.complete(T, w);
|
|
1579
|
+
}
|
|
1580
|
+
} else
|
|
1581
|
+
l[N] = [T], this.predict(N);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}, r.prototype.predict = function(i) {
|
|
1585
|
+
for (var E = this.grammar.byName[i] || [], l = 0; l < E.length; l++) {
|
|
1586
|
+
var R = E[l], p = this.wants[i], T = new t(R, 0, this.index, p);
|
|
1587
|
+
this.states.push(T);
|
|
1588
|
+
}
|
|
1589
|
+
}, r.prototype.complete = function(i, E) {
|
|
1590
|
+
var l = i.nextState(E);
|
|
1591
|
+
this.states.push(l);
|
|
1592
|
+
};
|
|
1593
|
+
function o(i, E) {
|
|
1594
|
+
this.rules = i, this.start = E || this.rules[0].name;
|
|
1595
|
+
var l = this.byName = {};
|
|
1596
|
+
this.rules.forEach(function(R) {
|
|
1597
|
+
l.hasOwnProperty(R.name) || (l[R.name] = []), l[R.name].push(R);
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
o.fromCompiled = function(R, E) {
|
|
1601
|
+
var l = R.Lexer;
|
|
1602
|
+
R.ParserStart && (E = R.ParserStart, R = R.ParserRules);
|
|
1603
|
+
var R = R.map(function(T) {
|
|
1604
|
+
return new e(T.name, T.symbols, T.postprocess);
|
|
1605
|
+
}), p = new o(R, E);
|
|
1606
|
+
return p.lexer = l, p;
|
|
1607
|
+
};
|
|
1608
|
+
function c() {
|
|
1609
|
+
this.reset("");
|
|
1610
|
+
}
|
|
1611
|
+
c.prototype.reset = function(i, E) {
|
|
1612
|
+
this.buffer = i, this.index = 0, this.line = E ? E.line : 1, this.lastLineBreak = E ? -E.col : 0;
|
|
1613
|
+
}, c.prototype.next = function() {
|
|
1614
|
+
if (this.index < this.buffer.length) {
|
|
1615
|
+
var i = this.buffer[this.index++];
|
|
1616
|
+
return i === `
|
|
1617
|
+
` && (this.line += 1, this.lastLineBreak = this.index), { value: i };
|
|
1618
|
+
}
|
|
1619
|
+
}, c.prototype.save = function() {
|
|
1620
|
+
return {
|
|
1621
|
+
line: this.line,
|
|
1622
|
+
col: this.index - this.lastLineBreak
|
|
1623
|
+
};
|
|
1624
|
+
}, c.prototype.formatError = function(i, E) {
|
|
1625
|
+
var l = this.buffer;
|
|
1626
|
+
if (typeof l == "string") {
|
|
1627
|
+
var R = l.split(`
|
|
1628
|
+
`).slice(
|
|
1629
|
+
Math.max(0, this.line - 5),
|
|
1630
|
+
this.line
|
|
1631
|
+
), p = l.indexOf(`
|
|
1632
|
+
`, this.index);
|
|
1633
|
+
p === -1 && (p = l.length);
|
|
1634
|
+
var T = this.index - this.lastLineBreak, u = String(this.line).length;
|
|
1635
|
+
return E += " at line " + this.line + " col " + T + `:
|
|
1636
|
+
|
|
1637
|
+
`, E += R.map(function(L, N) {
|
|
1638
|
+
return I(this.line - R.length + N + 1, u) + " " + L;
|
|
1639
|
+
}, this).join(`
|
|
1640
|
+
`), E += `
|
|
1641
|
+
` + I("", u + T) + `^
|
|
1642
|
+
`, E;
|
|
1643
|
+
} else
|
|
1644
|
+
return E + " at index " + (this.index - 1);
|
|
1645
|
+
function I(L, N) {
|
|
1646
|
+
var P = String(L);
|
|
1647
|
+
return Array(N - P.length + 1).join(" ") + P;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
function S(i, E, l) {
|
|
1651
|
+
if (i instanceof o)
|
|
1652
|
+
var R = i, l = E;
|
|
1653
|
+
else
|
|
1654
|
+
var R = o.fromCompiled(i, E);
|
|
1655
|
+
this.grammar = R, this.options = {
|
|
1656
|
+
keepHistory: !1,
|
|
1657
|
+
lexer: R.lexer || new c()
|
|
1658
|
+
};
|
|
1659
|
+
for (var p in l || {})
|
|
1660
|
+
this.options[p] = l[p];
|
|
1661
|
+
this.lexer = this.options.lexer, this.lexerState = void 0;
|
|
1662
|
+
var T = new r(R, 0);
|
|
1663
|
+
this.table = [T], T.wants[R.start] = [], T.predict(R.start), T.process(), this.current = 0;
|
|
1664
|
+
}
|
|
1665
|
+
S.fail = {}, S.prototype.feed = function(i) {
|
|
1666
|
+
var E = this.lexer;
|
|
1667
|
+
E.reset(i, this.lexerState);
|
|
1668
|
+
for (var l; ; ) {
|
|
1669
|
+
try {
|
|
1670
|
+
if (l = E.next(), !l)
|
|
1671
|
+
break;
|
|
1672
|
+
} catch (j) {
|
|
1673
|
+
var u = new r(this.grammar, this.current + 1);
|
|
1674
|
+
this.table.push(u);
|
|
1675
|
+
var R = new Error(this.reportLexerError(j));
|
|
1676
|
+
throw R.offset = this.current, R.token = j.token, R;
|
|
1677
|
+
}
|
|
1678
|
+
var p = this.table[this.current];
|
|
1679
|
+
this.options.keepHistory || delete this.table[this.current - 1];
|
|
1680
|
+
var T = this.current + 1, u = new r(this.grammar, T);
|
|
1681
|
+
this.table.push(u);
|
|
1682
|
+
for (var I = l.text !== void 0 ? l.text : l.value, L = E.constructor === c ? l.value : l, N = p.scannable, P = N.length; P--; ) {
|
|
1683
|
+
var w = N[P], g = w.rule.symbols[w.dot];
|
|
1684
|
+
if (g.test ? g.test(L) : g.type ? g.type === l.type : g.literal === I) {
|
|
1685
|
+
var he = w.nextState({ data: L, token: l, isToken: !0, reference: T - 1 });
|
|
1686
|
+
u.states.push(he);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
if (u.process(), u.states.length === 0) {
|
|
1690
|
+
var R = new Error(this.reportError(l));
|
|
1691
|
+
throw R.offset = this.current, R.token = l, R;
|
|
1692
|
+
}
|
|
1693
|
+
this.options.keepHistory && (p.lexerState = E.save()), this.current++;
|
|
1694
|
+
}
|
|
1695
|
+
return p && (this.lexerState = E.save()), this.results = this.finish(), this;
|
|
1696
|
+
}, S.prototype.reportLexerError = function(i) {
|
|
1697
|
+
var E, l, R = i.token;
|
|
1698
|
+
return R ? (E = "input " + JSON.stringify(R.text[0]) + " (lexer error)", l = this.lexer.formatError(R, "Syntax error")) : (E = "input (lexer error)", l = i.message), this.reportErrorCommon(l, E);
|
|
1699
|
+
}, S.prototype.reportError = function(i) {
|
|
1700
|
+
var E = (i.type ? i.type + " token: " : "") + JSON.stringify(i.value !== void 0 ? i.value : i), l = this.lexer.formatError(i, "Syntax error");
|
|
1701
|
+
return this.reportErrorCommon(l, E);
|
|
1702
|
+
}, S.prototype.reportErrorCommon = function(i, E) {
|
|
1703
|
+
var l = [];
|
|
1704
|
+
l.push(i);
|
|
1705
|
+
var R = this.table.length - 2, p = this.table[R], T = p.states.filter(function(I) {
|
|
1706
|
+
var L = I.rule.symbols[I.dot];
|
|
1707
|
+
return L && typeof L != "string";
|
|
1708
|
+
});
|
|
1709
|
+
if (T.length === 0)
|
|
1710
|
+
l.push("Unexpected " + E + `. I did not expect any more input. Here is the state of my parse table:
|
|
1711
|
+
`), this.displayStateStack(p.states, l);
|
|
1712
|
+
else {
|
|
1713
|
+
l.push("Unexpected " + E + `. Instead, I was expecting to see one of the following:
|
|
1714
|
+
`);
|
|
1715
|
+
var u = T.map(function(I) {
|
|
1716
|
+
return this.buildFirstStateStack(I, []) || [I];
|
|
1717
|
+
}, this);
|
|
1718
|
+
u.forEach(function(I) {
|
|
1719
|
+
var L = I[0], N = L.rule.symbols[L.dot], P = this.getSymbolDisplay(N);
|
|
1720
|
+
l.push("A " + P + " based on:"), this.displayStateStack(I, l);
|
|
1721
|
+
}, this);
|
|
1722
|
+
}
|
|
1723
|
+
return l.push(""), l.join(`
|
|
1724
|
+
`);
|
|
1725
|
+
}, S.prototype.displayStateStack = function(i, E) {
|
|
1726
|
+
for (var l, R = 0, p = 0; p < i.length; p++) {
|
|
1727
|
+
var T = i[p], u = T.rule.toString(T.dot);
|
|
1728
|
+
u === l ? R++ : (R > 0 && E.push(" ^ " + R + " more lines identical to this"), R = 0, E.push(" " + u)), l = u;
|
|
1729
|
+
}
|
|
1730
|
+
}, S.prototype.getSymbolDisplay = function(i) {
|
|
1731
|
+
return y(i);
|
|
1732
|
+
}, S.prototype.buildFirstStateStack = function(i, E) {
|
|
1733
|
+
if (E.indexOf(i) !== -1)
|
|
1734
|
+
return null;
|
|
1735
|
+
if (i.wantedBy.length === 0)
|
|
1736
|
+
return [i];
|
|
1737
|
+
var l = i.wantedBy[0], R = [i].concat(E), p = this.buildFirstStateStack(l, R);
|
|
1738
|
+
return p === null ? null : [i].concat(p);
|
|
1739
|
+
}, S.prototype.save = function() {
|
|
1740
|
+
var i = this.table[this.current];
|
|
1741
|
+
return i.lexerState = this.lexerState, i;
|
|
1742
|
+
}, S.prototype.restore = function(i) {
|
|
1743
|
+
var E = i.index;
|
|
1744
|
+
this.current = E, this.table[E] = i, this.table.splice(E + 1), this.lexerState = i.lexerState, this.results = this.finish();
|
|
1745
|
+
}, S.prototype.rewind = function(i) {
|
|
1746
|
+
if (!this.options.keepHistory)
|
|
1747
|
+
throw new Error("set option `keepHistory` to enable rewinding");
|
|
1748
|
+
this.restore(this.table[i]);
|
|
1749
|
+
}, S.prototype.finish = function() {
|
|
1750
|
+
var i = [], E = this.grammar.start, l = this.table[this.table.length - 1];
|
|
1751
|
+
return l.states.forEach(function(R) {
|
|
1752
|
+
R.rule.name === E && R.dot === R.rule.symbols.length && R.reference === 0 && R.data !== S.fail && i.push(R);
|
|
1753
|
+
}), i.map(function(R) {
|
|
1754
|
+
return R.data;
|
|
1755
|
+
});
|
|
1756
|
+
};
|
|
1757
|
+
function y(i) {
|
|
1758
|
+
var E = typeof i;
|
|
1759
|
+
if (E === "string")
|
|
1760
|
+
return i;
|
|
1761
|
+
if (E === "object") {
|
|
1762
|
+
if (i.literal)
|
|
1763
|
+
return JSON.stringify(i.literal);
|
|
1764
|
+
if (i instanceof RegExp)
|
|
1765
|
+
return "character matching " + i;
|
|
1766
|
+
if (i.type)
|
|
1767
|
+
return i.type + " token";
|
|
1768
|
+
if (i.test)
|
|
1769
|
+
return "token matching " + String(i.test);
|
|
1770
|
+
throw new Error("Unknown symbol type: " + i);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
function f(i) {
|
|
1774
|
+
var E = typeof i;
|
|
1775
|
+
if (E === "string")
|
|
1776
|
+
return i;
|
|
1777
|
+
if (E === "object") {
|
|
1778
|
+
if (i.literal)
|
|
1779
|
+
return JSON.stringify(i.literal);
|
|
1780
|
+
if (i instanceof RegExp)
|
|
1781
|
+
return i.toString();
|
|
1782
|
+
if (i.type)
|
|
1783
|
+
return "%" + i.type;
|
|
1784
|
+
if (i.test)
|
|
1785
|
+
return "<" + String(i.test) + ">";
|
|
1786
|
+
throw new Error("Unknown symbol type: " + i);
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return {
|
|
1790
|
+
Parser: S,
|
|
1791
|
+
Grammar: o,
|
|
1792
|
+
Rule: e
|
|
1793
|
+
};
|
|
1794
|
+
});
|
|
1795
|
+
}(F)), F.exports;
|
|
1796
|
+
}
|
|
1797
|
+
var ns = is();
|
|
1798
|
+
const Es = /* @__PURE__ */ me(ns);
|
|
1799
|
+
function os(s) {
|
|
1800
|
+
return s.map(ls).map(_s).map(Rs).map(As).map(Ts);
|
|
1801
|
+
}
|
|
1802
|
+
const ls = (s, e, t) => {
|
|
1803
|
+
if (de(s.type)) {
|
|
1804
|
+
const r = Ss(t, e);
|
|
1805
|
+
if (r && r.type === n.PROPERTY_ACCESS_OPERATOR)
|
|
1806
|
+
return Object.assign(Object.assign({}, s), { type: n.IDENTIFIER, text: s.raw });
|
|
1807
|
+
const o = U(t, e);
|
|
1808
|
+
if (o && o.type === n.PROPERTY_ACCESS_OPERATOR)
|
|
1809
|
+
return Object.assign(Object.assign({}, s), { type: n.IDENTIFIER, text: s.raw });
|
|
1810
|
+
}
|
|
1811
|
+
return s;
|
|
1812
|
+
}, _s = (s, e, t) => {
|
|
1813
|
+
if (s.type === n.RESERVED_FUNCTION_NAME) {
|
|
1814
|
+
const r = U(t, e);
|
|
1815
|
+
if (!r || !pe(r))
|
|
1816
|
+
return Object.assign(Object.assign({}, s), { type: n.IDENTIFIER, text: s.raw });
|
|
1817
|
+
}
|
|
1818
|
+
return s;
|
|
1819
|
+
}, Rs = (s, e, t) => {
|
|
1820
|
+
if (s.type === n.RESERVED_DATA_TYPE) {
|
|
1821
|
+
const r = U(t, e);
|
|
1822
|
+
if (r && pe(r))
|
|
1823
|
+
return Object.assign(Object.assign({}, s), { type: n.RESERVED_PARAMETERIZED_DATA_TYPE });
|
|
1824
|
+
}
|
|
1825
|
+
return s;
|
|
1826
|
+
}, As = (s, e, t) => {
|
|
1827
|
+
if (s.type === n.IDENTIFIER) {
|
|
1828
|
+
const r = U(t, e);
|
|
1829
|
+
if (r && ce(r))
|
|
1830
|
+
return Object.assign(Object.assign({}, s), { type: n.ARRAY_IDENTIFIER });
|
|
1831
|
+
}
|
|
1832
|
+
return s;
|
|
1833
|
+
}, Ts = (s, e, t) => {
|
|
1834
|
+
if (s.type === n.RESERVED_DATA_TYPE) {
|
|
1835
|
+
const r = U(t, e);
|
|
1836
|
+
if (r && ce(r))
|
|
1837
|
+
return Object.assign(Object.assign({}, s), { type: n.ARRAY_KEYWORD });
|
|
1838
|
+
}
|
|
1839
|
+
return s;
|
|
1840
|
+
}, Ss = (s, e) => U(s, e, -1), U = (s, e, t = 1) => {
|
|
1841
|
+
let r = 1;
|
|
1842
|
+
for (; s[e + r * t] && ps(s[e + r * t]); )
|
|
1843
|
+
r++;
|
|
1844
|
+
return s[e + r * t];
|
|
1845
|
+
}, pe = (s) => s.type === n.OPEN_PAREN && s.text === "(", ce = (s) => s.type === n.OPEN_PAREN && s.text === "[", ps = (s) => s.type === n.BLOCK_COMMENT || s.type === n.LINE_COMMENT;
|
|
1846
|
+
class Ie {
|
|
1847
|
+
constructor(e) {
|
|
1848
|
+
this.tokenize = e, this.index = 0, this.tokens = [], this.input = "";
|
|
1849
|
+
}
|
|
1850
|
+
reset(e, t) {
|
|
1851
|
+
this.input = e, this.index = 0, this.tokens = this.tokenize(e);
|
|
1852
|
+
}
|
|
1853
|
+
next() {
|
|
1854
|
+
return this.tokens[this.index++];
|
|
1855
|
+
}
|
|
1856
|
+
save() {
|
|
1857
|
+
}
|
|
1858
|
+
formatError(e) {
|
|
1859
|
+
const { line: t, col: r } = Se(this.input, e.start);
|
|
1860
|
+
return `Parse error at token: ${e.text} at line ${t} column ${r}`;
|
|
1861
|
+
}
|
|
1862
|
+
has(e) {
|
|
1863
|
+
return e in n;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
var _;
|
|
1867
|
+
(function(s) {
|
|
1868
|
+
s.statement = "statement", s.clause = "clause", s.set_operation = "set_operation", s.function_call = "function_call", s.parameterized_data_type = "parameterized_data_type", s.array_subscript = "array_subscript", s.property_access = "property_access", s.parenthesis = "parenthesis", s.between_predicate = "between_predicate", s.case_expression = "case_expression", s.case_when = "case_when", s.case_else = "case_else", s.limit_clause = "limit_clause", s.all_columns_asterisk = "all_columns_asterisk", s.literal = "literal", s.identifier = "identifier", s.keyword = "keyword", s.data_type = "data_type", s.parameter = "parameter", s.operator = "operator", s.comma = "comma", s.line_comment = "line_comment", s.block_comment = "block_comment", s.disable_comment = "disable_comment";
|
|
1869
|
+
})(_ = _ || (_ = {}));
|
|
1870
|
+
function K(s) {
|
|
1871
|
+
return s[0];
|
|
1872
|
+
}
|
|
1873
|
+
const A = new Ie((s) => []), b = ([[s]]) => s, m = (s) => ({
|
|
1874
|
+
type: _.keyword,
|
|
1875
|
+
tokenType: s.type,
|
|
1876
|
+
text: s.text,
|
|
1877
|
+
raw: s.raw
|
|
1878
|
+
}), ne = (s) => ({
|
|
1879
|
+
type: _.data_type,
|
|
1880
|
+
text: s.text,
|
|
1881
|
+
raw: s.raw
|
|
1882
|
+
}), O = (s, { leading: e, trailing: t }) => (e != null && e.length && (s = Object.assign(Object.assign({}, s), { leadingComments: e })), t != null && t.length && (s = Object.assign(Object.assign({}, s), { trailingComments: t })), s), cs = (s, { leading: e, trailing: t }) => {
|
|
1883
|
+
if (e != null && e.length) {
|
|
1884
|
+
const [r, ...o] = s;
|
|
1885
|
+
s = [O(r, { leading: e }), ...o];
|
|
1886
|
+
}
|
|
1887
|
+
if (t != null && t.length) {
|
|
1888
|
+
const r = s.slice(0, -1), o = s[s.length - 1];
|
|
1889
|
+
s = [...r, O(o, { trailing: t })];
|
|
1890
|
+
}
|
|
1891
|
+
return s;
|
|
1892
|
+
}, Is = {
|
|
1893
|
+
Lexer: A,
|
|
1894
|
+
ParserRules: [
|
|
1895
|
+
{ name: "main$ebnf$1", symbols: [] },
|
|
1896
|
+
{ name: "main$ebnf$1", symbols: ["main$ebnf$1", "statement"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1897
|
+
{
|
|
1898
|
+
name: "main",
|
|
1899
|
+
symbols: ["main$ebnf$1"],
|
|
1900
|
+
postprocess: ([s]) => {
|
|
1901
|
+
const e = s[s.length - 1];
|
|
1902
|
+
return e && !e.hasSemicolon ? e.children.length > 0 ? s : s.slice(0, -1) : s;
|
|
1903
|
+
}
|
|
1904
|
+
},
|
|
1905
|
+
{ name: "statement$subexpression$1", symbols: [A.has("DELIMITER") ? { type: "DELIMITER" } : DELIMITER] },
|
|
1906
|
+
{ name: "statement$subexpression$1", symbols: [A.has("EOF") ? { type: "EOF" } : EOF] },
|
|
1907
|
+
{
|
|
1908
|
+
name: "statement",
|
|
1909
|
+
symbols: ["expressions_or_clauses", "statement$subexpression$1"],
|
|
1910
|
+
postprocess: ([s, [e]]) => ({
|
|
1911
|
+
type: _.statement,
|
|
1912
|
+
children: s,
|
|
1913
|
+
hasSemicolon: e.type === n.DELIMITER
|
|
1914
|
+
})
|
|
1915
|
+
},
|
|
1916
|
+
{ name: "expressions_or_clauses$ebnf$1", symbols: [] },
|
|
1917
|
+
{ name: "expressions_or_clauses$ebnf$1", symbols: ["expressions_or_clauses$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1918
|
+
{ name: "expressions_or_clauses$ebnf$2", symbols: [] },
|
|
1919
|
+
{ name: "expressions_or_clauses$ebnf$2", symbols: ["expressions_or_clauses$ebnf$2", "clause"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1920
|
+
{
|
|
1921
|
+
name: "expressions_or_clauses",
|
|
1922
|
+
symbols: ["expressions_or_clauses$ebnf$1", "expressions_or_clauses$ebnf$2"],
|
|
1923
|
+
postprocess: ([s, e]) => [...s, ...e]
|
|
1924
|
+
},
|
|
1925
|
+
{ name: "clause$subexpression$1", symbols: ["limit_clause"] },
|
|
1926
|
+
{ name: "clause$subexpression$1", symbols: ["select_clause"] },
|
|
1927
|
+
{ name: "clause$subexpression$1", symbols: ["other_clause"] },
|
|
1928
|
+
{ name: "clause$subexpression$1", symbols: ["set_operation"] },
|
|
1929
|
+
{ name: "clause", symbols: ["clause$subexpression$1"], postprocess: b },
|
|
1930
|
+
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
|
|
1931
|
+
{ name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1932
|
+
{ name: "limit_clause$ebnf$1$subexpression$1", symbols: [A.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
|
|
1933
|
+
{ name: "limit_clause$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1"], postprocess: K },
|
|
1934
|
+
{ name: "limit_clause$ebnf$1", symbols: [], postprocess: () => null },
|
|
1935
|
+
{
|
|
1936
|
+
name: "limit_clause",
|
|
1937
|
+
symbols: [A.has("LIMIT") ? { type: "LIMIT" } : LIMIT, "_", "expression_chain_", "limit_clause$ebnf$1"],
|
|
1938
|
+
postprocess: ([s, e, t, r]) => {
|
|
1939
|
+
if (r) {
|
|
1940
|
+
const [o, c] = r;
|
|
1941
|
+
return {
|
|
1942
|
+
type: _.limit_clause,
|
|
1943
|
+
limitKw: O(m(s), { trailing: e }),
|
|
1944
|
+
offset: t,
|
|
1945
|
+
count: c
|
|
1946
|
+
};
|
|
1947
|
+
} else
|
|
1948
|
+
return {
|
|
1949
|
+
type: _.limit_clause,
|
|
1950
|
+
limitKw: O(m(s), { trailing: e }),
|
|
1951
|
+
count: t
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
},
|
|
1955
|
+
{ name: "select_clause$subexpression$1$ebnf$1", symbols: [] },
|
|
1956
|
+
{ name: "select_clause$subexpression$1$ebnf$1", symbols: ["select_clause$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1957
|
+
{ name: "select_clause$subexpression$1", symbols: ["all_columns_asterisk", "select_clause$subexpression$1$ebnf$1"] },
|
|
1958
|
+
{ name: "select_clause$subexpression$1$ebnf$2", symbols: [] },
|
|
1959
|
+
{ name: "select_clause$subexpression$1$ebnf$2", symbols: ["select_clause$subexpression$1$ebnf$2", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1960
|
+
{ name: "select_clause$subexpression$1", symbols: ["asteriskless_free_form_sql", "select_clause$subexpression$1$ebnf$2"] },
|
|
1961
|
+
{
|
|
1962
|
+
name: "select_clause",
|
|
1963
|
+
symbols: [A.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
|
|
1964
|
+
postprocess: ([s, [e, t]]) => ({
|
|
1965
|
+
type: _.clause,
|
|
1966
|
+
nameKw: m(s),
|
|
1967
|
+
children: [e, ...t]
|
|
1968
|
+
})
|
|
1969
|
+
},
|
|
1970
|
+
{
|
|
1971
|
+
name: "select_clause",
|
|
1972
|
+
symbols: [A.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
|
|
1973
|
+
postprocess: ([s]) => ({
|
|
1974
|
+
type: _.clause,
|
|
1975
|
+
nameKw: m(s),
|
|
1976
|
+
children: []
|
|
1977
|
+
})
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
name: "all_columns_asterisk",
|
|
1981
|
+
symbols: [A.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK],
|
|
1982
|
+
postprocess: () => ({ type: _.all_columns_asterisk })
|
|
1983
|
+
},
|
|
1984
|
+
{ name: "other_clause$ebnf$1", symbols: [] },
|
|
1985
|
+
{ name: "other_clause$ebnf$1", symbols: ["other_clause$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1986
|
+
{
|
|
1987
|
+
name: "other_clause",
|
|
1988
|
+
symbols: [A.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
|
|
1989
|
+
postprocess: ([s, e]) => ({
|
|
1990
|
+
type: _.clause,
|
|
1991
|
+
nameKw: m(s),
|
|
1992
|
+
children: e
|
|
1993
|
+
})
|
|
1994
|
+
},
|
|
1995
|
+
{ name: "set_operation$ebnf$1", symbols: [] },
|
|
1996
|
+
{ name: "set_operation$ebnf$1", symbols: ["set_operation$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
1997
|
+
{
|
|
1998
|
+
name: "set_operation",
|
|
1999
|
+
symbols: [A.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
|
|
2000
|
+
postprocess: ([s, e]) => ({
|
|
2001
|
+
type: _.set_operation,
|
|
2002
|
+
nameKw: m(s),
|
|
2003
|
+
children: e
|
|
2004
|
+
})
|
|
2005
|
+
},
|
|
2006
|
+
{ name: "expression_chain_$ebnf$1", symbols: ["expression_with_comments_"] },
|
|
2007
|
+
{ name: "expression_chain_$ebnf$1", symbols: ["expression_chain_$ebnf$1", "expression_with_comments_"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2008
|
+
{ name: "expression_chain_", symbols: ["expression_chain_$ebnf$1"], postprocess: K },
|
|
2009
|
+
{ name: "expression_chain$ebnf$1", symbols: [] },
|
|
2010
|
+
{ name: "expression_chain$ebnf$1", symbols: ["expression_chain$ebnf$1", "_expression_with_comments"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2011
|
+
{
|
|
2012
|
+
name: "expression_chain",
|
|
2013
|
+
symbols: ["expression", "expression_chain$ebnf$1"],
|
|
2014
|
+
postprocess: ([s, e]) => [s, ...e]
|
|
2015
|
+
},
|
|
2016
|
+
{ name: "andless_expression_chain$ebnf$1", symbols: [] },
|
|
2017
|
+
{ name: "andless_expression_chain$ebnf$1", symbols: ["andless_expression_chain$ebnf$1", "_andless_expression_with_comments"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2018
|
+
{
|
|
2019
|
+
name: "andless_expression_chain",
|
|
2020
|
+
symbols: ["andless_expression", "andless_expression_chain$ebnf$1"],
|
|
2021
|
+
postprocess: ([s, e]) => [s, ...e]
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
name: "expression_with_comments_",
|
|
2025
|
+
symbols: ["expression", "_"],
|
|
2026
|
+
postprocess: ([s, e]) => O(s, { trailing: e })
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
name: "_expression_with_comments",
|
|
2030
|
+
symbols: ["_", "expression"],
|
|
2031
|
+
postprocess: ([s, e]) => O(e, { leading: s })
|
|
2032
|
+
},
|
|
2033
|
+
{
|
|
2034
|
+
name: "_andless_expression_with_comments",
|
|
2035
|
+
symbols: ["_", "andless_expression"],
|
|
2036
|
+
postprocess: ([s, e]) => O(e, { leading: s })
|
|
2037
|
+
},
|
|
2038
|
+
{ name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
|
|
2039
|
+
{ name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
|
|
2040
|
+
{ name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess: b },
|
|
2041
|
+
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
2042
|
+
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["logic_operator"] },
|
|
2043
|
+
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comma"] },
|
|
2044
|
+
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comment"] },
|
|
2045
|
+
{ name: "asteriskless_free_form_sql$subexpression$1", symbols: ["other_keyword"] },
|
|
2046
|
+
{ name: "asteriskless_free_form_sql", symbols: ["asteriskless_free_form_sql$subexpression$1"], postprocess: b },
|
|
2047
|
+
{ name: "expression$subexpression$1", symbols: ["andless_expression"] },
|
|
2048
|
+
{ name: "expression$subexpression$1", symbols: ["logic_operator"] },
|
|
2049
|
+
{ name: "expression", symbols: ["expression$subexpression$1"], postprocess: b },
|
|
2050
|
+
{ name: "andless_expression$subexpression$1", symbols: ["asteriskless_andless_expression"] },
|
|
2051
|
+
{ name: "andless_expression$subexpression$1", symbols: ["asterisk"] },
|
|
2052
|
+
{ name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess: b },
|
|
2053
|
+
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["atomic_expression"] },
|
|
2054
|
+
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["between_predicate"] },
|
|
2055
|
+
{ name: "asteriskless_andless_expression$subexpression$1", symbols: ["case_expression"] },
|
|
2056
|
+
{ name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess: b },
|
|
2057
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["array_subscript"] },
|
|
2058
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["function_call"] },
|
|
2059
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["property_access"] },
|
|
2060
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["parenthesis"] },
|
|
2061
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["curly_braces"] },
|
|
2062
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["square_brackets"] },
|
|
2063
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["operator"] },
|
|
2064
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["identifier"] },
|
|
2065
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["parameter"] },
|
|
2066
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["literal"] },
|
|
2067
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["data_type"] },
|
|
2068
|
+
{ name: "atomic_expression$subexpression$1", symbols: ["keyword"] },
|
|
2069
|
+
{ name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess: b },
|
|
2070
|
+
{
|
|
2071
|
+
name: "array_subscript",
|
|
2072
|
+
symbols: [A.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
|
|
2073
|
+
postprocess: ([s, e, t]) => ({
|
|
2074
|
+
type: _.array_subscript,
|
|
2075
|
+
array: O({ type: _.identifier, quoted: !1, text: s.text }, { trailing: e }),
|
|
2076
|
+
parenthesis: t
|
|
2077
|
+
})
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
name: "array_subscript",
|
|
2081
|
+
symbols: [A.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
|
|
2082
|
+
postprocess: ([s, e, t]) => ({
|
|
2083
|
+
type: _.array_subscript,
|
|
2084
|
+
array: O(m(s), { trailing: e }),
|
|
2085
|
+
parenthesis: t
|
|
2086
|
+
})
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
name: "function_call",
|
|
2090
|
+
symbols: [A.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
|
|
2091
|
+
postprocess: ([s, e, t]) => ({
|
|
2092
|
+
type: _.function_call,
|
|
2093
|
+
nameKw: O(m(s), { trailing: e }),
|
|
2094
|
+
parenthesis: t
|
|
2095
|
+
})
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
name: "parenthesis",
|
|
2099
|
+
symbols: [{ literal: "(" }, "expressions_or_clauses", { literal: ")" }],
|
|
2100
|
+
postprocess: ([s, e, t]) => ({
|
|
2101
|
+
type: _.parenthesis,
|
|
2102
|
+
children: e,
|
|
2103
|
+
openParen: "(",
|
|
2104
|
+
closeParen: ")"
|
|
2105
|
+
})
|
|
2106
|
+
},
|
|
2107
|
+
{ name: "curly_braces$ebnf$1", symbols: [] },
|
|
2108
|
+
{ name: "curly_braces$ebnf$1", symbols: ["curly_braces$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2109
|
+
{
|
|
2110
|
+
name: "curly_braces",
|
|
2111
|
+
symbols: [{ literal: "{" }, "curly_braces$ebnf$1", { literal: "}" }],
|
|
2112
|
+
postprocess: ([s, e, t]) => ({
|
|
2113
|
+
type: _.parenthesis,
|
|
2114
|
+
children: e,
|
|
2115
|
+
openParen: "{",
|
|
2116
|
+
closeParen: "}"
|
|
2117
|
+
})
|
|
2118
|
+
},
|
|
2119
|
+
{ name: "square_brackets$ebnf$1", symbols: [] },
|
|
2120
|
+
{ name: "square_brackets$ebnf$1", symbols: ["square_brackets$ebnf$1", "free_form_sql"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2121
|
+
{
|
|
2122
|
+
name: "square_brackets",
|
|
2123
|
+
symbols: [{ literal: "[" }, "square_brackets$ebnf$1", { literal: "]" }],
|
|
2124
|
+
postprocess: ([s, e, t]) => ({
|
|
2125
|
+
type: _.parenthesis,
|
|
2126
|
+
children: e,
|
|
2127
|
+
openParen: "[",
|
|
2128
|
+
closeParen: "]"
|
|
2129
|
+
})
|
|
2130
|
+
},
|
|
2131
|
+
{ name: "property_access$subexpression$1", symbols: ["identifier"] },
|
|
2132
|
+
{ name: "property_access$subexpression$1", symbols: ["array_subscript"] },
|
|
2133
|
+
{ name: "property_access$subexpression$1", symbols: ["all_columns_asterisk"] },
|
|
2134
|
+
{ name: "property_access$subexpression$1", symbols: ["parameter"] },
|
|
2135
|
+
{
|
|
2136
|
+
name: "property_access",
|
|
2137
|
+
symbols: ["atomic_expression", "_", A.has("PROPERTY_ACCESS_OPERATOR") ? { type: "PROPERTY_ACCESS_OPERATOR" } : PROPERTY_ACCESS_OPERATOR, "_", "property_access$subexpression$1"],
|
|
2138
|
+
postprocess: (
|
|
2139
|
+
// Allowing property to be <array_subscript> is currently a hack.
|
|
2140
|
+
// A better way would be to allow <property_access> on the left side of array_subscript,
|
|
2141
|
+
// but we currently can't do that because of another hack that requires
|
|
2142
|
+
// %ARRAY_IDENTIFIER on the left side of <array_subscript>.
|
|
2143
|
+
([s, e, t, r, [o]]) => ({
|
|
2144
|
+
type: _.property_access,
|
|
2145
|
+
object: O(s, { trailing: e }),
|
|
2146
|
+
operator: t.text,
|
|
2147
|
+
property: O(o, { leading: r })
|
|
2148
|
+
})
|
|
2149
|
+
)
|
|
2150
|
+
},
|
|
2151
|
+
{
|
|
2152
|
+
name: "between_predicate",
|
|
2153
|
+
symbols: [A.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", A.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
|
|
2154
|
+
postprocess: ([s, e, t, r, o, c, S]) => ({
|
|
2155
|
+
type: _.between_predicate,
|
|
2156
|
+
betweenKw: m(s),
|
|
2157
|
+
expr1: cs(t, { leading: e, trailing: r }),
|
|
2158
|
+
andKw: m(o),
|
|
2159
|
+
expr2: [O(S, { leading: c })]
|
|
2160
|
+
})
|
|
2161
|
+
},
|
|
2162
|
+
{ name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: K },
|
|
2163
|
+
{ name: "case_expression$ebnf$1", symbols: [], postprocess: () => null },
|
|
2164
|
+
{ name: "case_expression$ebnf$2", symbols: [] },
|
|
2165
|
+
{ name: "case_expression$ebnf$2", symbols: ["case_expression$ebnf$2", "case_clause"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2166
|
+
{
|
|
2167
|
+
name: "case_expression",
|
|
2168
|
+
symbols: [A.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", A.has("END") ? { type: "END" } : END],
|
|
2169
|
+
postprocess: ([s, e, t, r, o]) => ({
|
|
2170
|
+
type: _.case_expression,
|
|
2171
|
+
caseKw: O(m(s), { trailing: e }),
|
|
2172
|
+
endKw: m(o),
|
|
2173
|
+
expr: t || [],
|
|
2174
|
+
clauses: r
|
|
2175
|
+
})
|
|
2176
|
+
},
|
|
2177
|
+
{
|
|
2178
|
+
name: "case_clause",
|
|
2179
|
+
symbols: [A.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", A.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
|
|
2180
|
+
postprocess: ([s, e, t, r, o, c]) => ({
|
|
2181
|
+
type: _.case_when,
|
|
2182
|
+
whenKw: O(m(s), { trailing: e }),
|
|
2183
|
+
thenKw: O(m(r), { trailing: o }),
|
|
2184
|
+
condition: t,
|
|
2185
|
+
result: c
|
|
2186
|
+
})
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
name: "case_clause",
|
|
2190
|
+
symbols: [A.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
|
|
2191
|
+
postprocess: ([s, e, t]) => ({
|
|
2192
|
+
type: _.case_else,
|
|
2193
|
+
elseKw: O(m(s), { trailing: e }),
|
|
2194
|
+
result: t
|
|
2195
|
+
})
|
|
2196
|
+
},
|
|
2197
|
+
{ name: "comma$subexpression$1", symbols: [A.has("COMMA") ? { type: "COMMA" } : COMMA] },
|
|
2198
|
+
{ name: "comma", symbols: ["comma$subexpression$1"], postprocess: ([[s]]) => ({ type: _.comma }) },
|
|
2199
|
+
{ name: "asterisk$subexpression$1", symbols: [A.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK] },
|
|
2200
|
+
{ name: "asterisk", symbols: ["asterisk$subexpression$1"], postprocess: ([[s]]) => ({ type: _.operator, text: s.text }) },
|
|
2201
|
+
{ name: "operator$subexpression$1", symbols: [A.has("OPERATOR") ? { type: "OPERATOR" } : OPERATOR] },
|
|
2202
|
+
{ name: "operator", symbols: ["operator$subexpression$1"], postprocess: ([[s]]) => ({ type: _.operator, text: s.text }) },
|
|
2203
|
+
{ name: "identifier$subexpression$1", symbols: [A.has("IDENTIFIER") ? { type: "IDENTIFIER" } : IDENTIFIER] },
|
|
2204
|
+
{ name: "identifier$subexpression$1", symbols: [A.has("QUOTED_IDENTIFIER") ? { type: "QUOTED_IDENTIFIER" } : QUOTED_IDENTIFIER] },
|
|
2205
|
+
{ name: "identifier$subexpression$1", symbols: [A.has("VARIABLE") ? { type: "VARIABLE" } : VARIABLE] },
|
|
2206
|
+
{ name: "identifier", symbols: ["identifier$subexpression$1"], postprocess: ([[s]]) => ({ type: _.identifier, quoted: s.type !== "IDENTIFIER", text: s.text }) },
|
|
2207
|
+
{ name: "parameter$subexpression$1", symbols: [A.has("NAMED_PARAMETER") ? { type: "NAMED_PARAMETER" } : NAMED_PARAMETER] },
|
|
2208
|
+
{ name: "parameter$subexpression$1", symbols: [A.has("QUOTED_PARAMETER") ? { type: "QUOTED_PARAMETER" } : QUOTED_PARAMETER] },
|
|
2209
|
+
{ name: "parameter$subexpression$1", symbols: [A.has("NUMBERED_PARAMETER") ? { type: "NUMBERED_PARAMETER" } : NUMBERED_PARAMETER] },
|
|
2210
|
+
{ name: "parameter$subexpression$1", symbols: [A.has("POSITIONAL_PARAMETER") ? { type: "POSITIONAL_PARAMETER" } : POSITIONAL_PARAMETER] },
|
|
2211
|
+
{ name: "parameter$subexpression$1", symbols: [A.has("CUSTOM_PARAMETER") ? { type: "CUSTOM_PARAMETER" } : CUSTOM_PARAMETER] },
|
|
2212
|
+
{ name: "parameter", symbols: ["parameter$subexpression$1"], postprocess: ([[s]]) => ({ type: _.parameter, key: s.key, text: s.text }) },
|
|
2213
|
+
{ name: "literal$subexpression$1", symbols: [A.has("NUMBER") ? { type: "NUMBER" } : NUMBER] },
|
|
2214
|
+
{ name: "literal$subexpression$1", symbols: [A.has("STRING") ? { type: "STRING" } : STRING] },
|
|
2215
|
+
{ name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[s]]) => ({ type: _.literal, text: s.text }) },
|
|
2216
|
+
{ name: "keyword$subexpression$1", symbols: [A.has("RESERVED_KEYWORD") ? { type: "RESERVED_KEYWORD" } : RESERVED_KEYWORD] },
|
|
2217
|
+
{ name: "keyword$subexpression$1", symbols: [A.has("RESERVED_PHRASE") ? { type: "RESERVED_PHRASE" } : RESERVED_PHRASE] },
|
|
2218
|
+
{ name: "keyword$subexpression$1", symbols: [A.has("RESERVED_JOIN") ? { type: "RESERVED_JOIN" } : RESERVED_JOIN] },
|
|
2219
|
+
{
|
|
2220
|
+
name: "keyword",
|
|
2221
|
+
symbols: ["keyword$subexpression$1"],
|
|
2222
|
+
postprocess: ([[s]]) => m(s)
|
|
2223
|
+
},
|
|
2224
|
+
{ name: "data_type$subexpression$1", symbols: [A.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
|
|
2225
|
+
{
|
|
2226
|
+
name: "data_type",
|
|
2227
|
+
symbols: ["data_type$subexpression$1"],
|
|
2228
|
+
postprocess: ([[s]]) => ne(s)
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
name: "data_type",
|
|
2232
|
+
symbols: [A.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
|
|
2233
|
+
postprocess: ([s, e, t]) => ({
|
|
2234
|
+
type: _.parameterized_data_type,
|
|
2235
|
+
dataType: O(ne(s), { trailing: e }),
|
|
2236
|
+
parenthesis: t
|
|
2237
|
+
})
|
|
2238
|
+
},
|
|
2239
|
+
{ name: "logic_operator$subexpression$1", symbols: [A.has("AND") ? { type: "AND" } : AND] },
|
|
2240
|
+
{ name: "logic_operator$subexpression$1", symbols: [A.has("OR") ? { type: "OR" } : OR] },
|
|
2241
|
+
{ name: "logic_operator$subexpression$1", symbols: [A.has("XOR") ? { type: "XOR" } : XOR] },
|
|
2242
|
+
{
|
|
2243
|
+
name: "logic_operator",
|
|
2244
|
+
symbols: ["logic_operator$subexpression$1"],
|
|
2245
|
+
postprocess: ([[s]]) => m(s)
|
|
2246
|
+
},
|
|
2247
|
+
{ name: "other_keyword$subexpression$1", symbols: [A.has("WHEN") ? { type: "WHEN" } : WHEN] },
|
|
2248
|
+
{ name: "other_keyword$subexpression$1", symbols: [A.has("THEN") ? { type: "THEN" } : THEN] },
|
|
2249
|
+
{ name: "other_keyword$subexpression$1", symbols: [A.has("ELSE") ? { type: "ELSE" } : ELSE] },
|
|
2250
|
+
{ name: "other_keyword$subexpression$1", symbols: [A.has("END") ? { type: "END" } : END] },
|
|
2251
|
+
{
|
|
2252
|
+
name: "other_keyword",
|
|
2253
|
+
symbols: ["other_keyword$subexpression$1"],
|
|
2254
|
+
postprocess: ([[s]]) => m(s)
|
|
2255
|
+
},
|
|
2256
|
+
{ name: "_$ebnf$1", symbols: [] },
|
|
2257
|
+
{ name: "_$ebnf$1", symbols: ["_$ebnf$1", "comment"], postprocess: (s) => s[0].concat([s[1]]) },
|
|
2258
|
+
{ name: "_", symbols: ["_$ebnf$1"], postprocess: ([s]) => s },
|
|
2259
|
+
{
|
|
2260
|
+
name: "comment",
|
|
2261
|
+
symbols: [A.has("LINE_COMMENT") ? { type: "LINE_COMMENT" } : LINE_COMMENT],
|
|
2262
|
+
postprocess: ([s]) => ({
|
|
2263
|
+
type: _.line_comment,
|
|
2264
|
+
text: s.text,
|
|
2265
|
+
precedingWhitespace: s.precedingWhitespace
|
|
2266
|
+
})
|
|
2267
|
+
},
|
|
2268
|
+
{
|
|
2269
|
+
name: "comment",
|
|
2270
|
+
symbols: [A.has("BLOCK_COMMENT") ? { type: "BLOCK_COMMENT" } : BLOCK_COMMENT],
|
|
2271
|
+
postprocess: ([s]) => ({
|
|
2272
|
+
type: _.block_comment,
|
|
2273
|
+
text: s.text,
|
|
2274
|
+
precedingWhitespace: s.precedingWhitespace
|
|
2275
|
+
})
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
name: "comment",
|
|
2279
|
+
symbols: [A.has("DISABLE_COMMENT") ? { type: "DISABLE_COMMENT" } : DISABLE_COMMENT],
|
|
2280
|
+
postprocess: ([s]) => ({
|
|
2281
|
+
type: _.disable_comment,
|
|
2282
|
+
text: s.text,
|
|
2283
|
+
precedingWhitespace: s.precedingWhitespace
|
|
2284
|
+
})
|
|
2285
|
+
}
|
|
2286
|
+
],
|
|
2287
|
+
ParserStart: "main"
|
|
2288
|
+
}, { Parser: Ns, Grammar: us } = Es;
|
|
2289
|
+
function hs(s) {
|
|
2290
|
+
let e = {};
|
|
2291
|
+
const t = new Ie((o) => [
|
|
2292
|
+
...os(s.tokenize(o, e)),
|
|
2293
|
+
le(o.length)
|
|
2294
|
+
]), r = new Ns(us.fromCompiled(Is), { lexer: t });
|
|
2295
|
+
return {
|
|
2296
|
+
parse: (o, c) => {
|
|
2297
|
+
e = c;
|
|
2298
|
+
const { results: S } = r.feed(o);
|
|
2299
|
+
if (S.length === 1)
|
|
2300
|
+
return S[0];
|
|
2301
|
+
throw S.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
|
|
2302
|
+
${JSON.stringify(S, void 0, 2)}`);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
var a;
|
|
2307
|
+
(function(s) {
|
|
2308
|
+
s[s.SPACE = 0] = "SPACE", s[s.NO_SPACE = 1] = "NO_SPACE", s[s.NO_NEWLINE = 2] = "NO_NEWLINE", s[s.NEWLINE = 3] = "NEWLINE", s[s.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", s[s.INDENT = 5] = "INDENT", s[s.SINGLE_INDENT = 6] = "SINGLE_INDENT";
|
|
2309
|
+
})(a = a || (a = {}));
|
|
2310
|
+
class Ne {
|
|
2311
|
+
constructor(e) {
|
|
2312
|
+
this.indentation = e, this.items = [];
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* Appends token strings and whitespace modifications to SQL string.
|
|
2316
|
+
*/
|
|
2317
|
+
add(...e) {
|
|
2318
|
+
for (const t of e)
|
|
2319
|
+
switch (t) {
|
|
2320
|
+
case a.SPACE:
|
|
2321
|
+
this.items.push(a.SPACE);
|
|
2322
|
+
break;
|
|
2323
|
+
case a.NO_SPACE:
|
|
2324
|
+
this.trimHorizontalWhitespace();
|
|
2325
|
+
break;
|
|
2326
|
+
case a.NO_NEWLINE:
|
|
2327
|
+
this.trimWhitespace();
|
|
2328
|
+
break;
|
|
2329
|
+
case a.NEWLINE:
|
|
2330
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
|
|
2331
|
+
break;
|
|
2332
|
+
case a.MANDATORY_NEWLINE:
|
|
2333
|
+
this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
|
|
2334
|
+
break;
|
|
2335
|
+
case a.INDENT:
|
|
2336
|
+
this.addIndentation();
|
|
2337
|
+
break;
|
|
2338
|
+
case a.SINGLE_INDENT:
|
|
2339
|
+
this.items.push(a.SINGLE_INDENT);
|
|
2340
|
+
break;
|
|
2341
|
+
default:
|
|
2342
|
+
this.items.push(t);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
trimHorizontalWhitespace() {
|
|
2346
|
+
for (; ms(B(this.items)); )
|
|
2347
|
+
this.items.pop();
|
|
2348
|
+
}
|
|
2349
|
+
trimWhitespace() {
|
|
2350
|
+
for (; Os(B(this.items)); )
|
|
2351
|
+
this.items.pop();
|
|
2352
|
+
}
|
|
2353
|
+
addNewline(e) {
|
|
2354
|
+
if (this.items.length > 0)
|
|
2355
|
+
switch (B(this.items)) {
|
|
2356
|
+
case a.NEWLINE:
|
|
2357
|
+
this.items.pop(), this.items.push(e);
|
|
2358
|
+
break;
|
|
2359
|
+
case a.MANDATORY_NEWLINE:
|
|
2360
|
+
break;
|
|
2361
|
+
default:
|
|
2362
|
+
this.items.push(e);
|
|
2363
|
+
break;
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
addIndentation() {
|
|
2367
|
+
for (let e = 0; e < this.indentation.getLevel(); e++)
|
|
2368
|
+
this.items.push(a.SINGLE_INDENT);
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Returns the final SQL string.
|
|
2372
|
+
*/
|
|
2373
|
+
toString() {
|
|
2374
|
+
return this.items.map((e) => this.itemToString(e)).join("");
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Returns the internal layout data
|
|
2378
|
+
*/
|
|
2379
|
+
getLayoutItems() {
|
|
2380
|
+
return this.items;
|
|
2381
|
+
}
|
|
2382
|
+
itemToString(e) {
|
|
2383
|
+
switch (e) {
|
|
2384
|
+
case a.SPACE:
|
|
2385
|
+
return " ";
|
|
2386
|
+
case a.NEWLINE:
|
|
2387
|
+
case a.MANDATORY_NEWLINE:
|
|
2388
|
+
return `
|
|
2389
|
+
`;
|
|
2390
|
+
case a.SINGLE_INDENT:
|
|
2391
|
+
return this.indentation.getSingleIndent();
|
|
2392
|
+
default:
|
|
2393
|
+
return e;
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
const ms = (s) => s === a.SPACE || s === a.SINGLE_INDENT, Os = (s) => s === a.SPACE || s === a.SINGLE_INDENT || s === a.NEWLINE;
|
|
2398
|
+
function Ee(s, e) {
|
|
2399
|
+
if (e === "standard")
|
|
2400
|
+
return s;
|
|
2401
|
+
let t = [];
|
|
2402
|
+
return s.length >= 10 && s.includes(" ") && ([s, ...t] = s.split(" ")), e === "tabularLeft" ? s = s.padEnd(9, " ") : s = s.padStart(9, " "), s + ["", ...t].join(" ");
|
|
2403
|
+
}
|
|
2404
|
+
function oe(s) {
|
|
2405
|
+
return Me(s) || s === n.RESERVED_CLAUSE || s === n.RESERVED_SELECT || s === n.RESERVED_SET_OPERATION || s === n.RESERVED_JOIN || s === n.LIMIT;
|
|
2406
|
+
}
|
|
2407
|
+
const k = "top-level", Ls = "block-level";
|
|
2408
|
+
class ue {
|
|
2409
|
+
/**
|
|
2410
|
+
* @param {string} indent A string to indent with
|
|
2411
|
+
*/
|
|
2412
|
+
constructor(e) {
|
|
2413
|
+
this.indent = e, this.indentTypes = [];
|
|
2414
|
+
}
|
|
2415
|
+
/**
|
|
2416
|
+
* Returns indentation string for single indentation step.
|
|
2417
|
+
*/
|
|
2418
|
+
getSingleIndent() {
|
|
2419
|
+
return this.indent;
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Returns current indentation level
|
|
2423
|
+
*/
|
|
2424
|
+
getLevel() {
|
|
2425
|
+
return this.indentTypes.length;
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Increases indentation by one top-level indent.
|
|
2429
|
+
*/
|
|
2430
|
+
increaseTopLevel() {
|
|
2431
|
+
this.indentTypes.push(k);
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Increases indentation by one block-level indent.
|
|
2435
|
+
*/
|
|
2436
|
+
increaseBlockLevel() {
|
|
2437
|
+
this.indentTypes.push(Ls);
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Decreases indentation by one top-level indent.
|
|
2441
|
+
* Does nothing when the previous indent is not top-level.
|
|
2442
|
+
*/
|
|
2443
|
+
decreaseTopLevel() {
|
|
2444
|
+
this.indentTypes.length > 0 && B(this.indentTypes) === k && this.indentTypes.pop();
|
|
2445
|
+
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Decreases indentation by one block-level indent.
|
|
2448
|
+
* If there are top-level indents within the block-level indent,
|
|
2449
|
+
* throws away these as well.
|
|
2450
|
+
*/
|
|
2451
|
+
decreaseBlockLevel() {
|
|
2452
|
+
for (; this.indentTypes.length > 0 && this.indentTypes.pop() === k; )
|
|
2453
|
+
;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
class fs extends Ne {
|
|
2457
|
+
constructor(e) {
|
|
2458
|
+
super(new ue("")), this.expressionWidth = e, this.length = 0, this.trailingSpace = !1;
|
|
2459
|
+
}
|
|
2460
|
+
add(...e) {
|
|
2461
|
+
if (e.forEach((t) => this.addToLength(t)), this.length > this.expressionWidth)
|
|
2462
|
+
throw new J();
|
|
2463
|
+
super.add(...e);
|
|
2464
|
+
}
|
|
2465
|
+
addToLength(e) {
|
|
2466
|
+
if (typeof e == "string")
|
|
2467
|
+
this.length += e.length, this.trailingSpace = !1;
|
|
2468
|
+
else {
|
|
2469
|
+
if (e === a.MANDATORY_NEWLINE || e === a.NEWLINE)
|
|
2470
|
+
throw new J();
|
|
2471
|
+
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--);
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
class J extends Error {
|
|
2476
|
+
}
|
|
2477
|
+
class v {
|
|
2478
|
+
constructor({ cfg: e, dialectCfg: t, params: r, layout: o, inline: c = !1 }) {
|
|
2479
|
+
this.inline = !1, this.nodes = [], this.index = -1, this.cfg = e, this.dialectCfg = t, this.inline = c, this.params = r, this.layout = o;
|
|
2480
|
+
}
|
|
2481
|
+
format(e) {
|
|
2482
|
+
for (this.nodes = e, this.index = 0; this.index < this.nodes.length; this.index++)
|
|
2483
|
+
this.formatNode(this.nodes[this.index]);
|
|
2484
|
+
return this.layout;
|
|
2485
|
+
}
|
|
2486
|
+
formatNode(e) {
|
|
2487
|
+
this.formatComments(e.leadingComments), this.formatNodeWithoutComments(e), this.formatComments(e.trailingComments);
|
|
2488
|
+
}
|
|
2489
|
+
formatNodeWithoutComments(e) {
|
|
2490
|
+
switch (e.type) {
|
|
2491
|
+
case _.function_call:
|
|
2492
|
+
return this.formatFunctionCall(e);
|
|
2493
|
+
case _.parameterized_data_type:
|
|
2494
|
+
return this.formatParameterizedDataType(e);
|
|
2495
|
+
case _.array_subscript:
|
|
2496
|
+
return this.formatArraySubscript(e);
|
|
2497
|
+
case _.property_access:
|
|
2498
|
+
return this.formatPropertyAccess(e);
|
|
2499
|
+
case _.parenthesis:
|
|
2500
|
+
return this.formatParenthesis(e);
|
|
2501
|
+
case _.between_predicate:
|
|
2502
|
+
return this.formatBetweenPredicate(e);
|
|
2503
|
+
case _.case_expression:
|
|
2504
|
+
return this.formatCaseExpression(e);
|
|
2505
|
+
case _.case_when:
|
|
2506
|
+
return this.formatCaseWhen(e);
|
|
2507
|
+
case _.case_else:
|
|
2508
|
+
return this.formatCaseElse(e);
|
|
2509
|
+
case _.clause:
|
|
2510
|
+
return this.formatClause(e);
|
|
2511
|
+
case _.set_operation:
|
|
2512
|
+
return this.formatSetOperation(e);
|
|
2513
|
+
case _.limit_clause:
|
|
2514
|
+
return this.formatLimitClause(e);
|
|
2515
|
+
case _.all_columns_asterisk:
|
|
2516
|
+
return this.formatAllColumnsAsterisk(e);
|
|
2517
|
+
case _.literal:
|
|
2518
|
+
return this.formatLiteral(e);
|
|
2519
|
+
case _.identifier:
|
|
2520
|
+
return this.formatIdentifier(e);
|
|
2521
|
+
case _.parameter:
|
|
2522
|
+
return this.formatParameter(e);
|
|
2523
|
+
case _.operator:
|
|
2524
|
+
return this.formatOperator(e);
|
|
2525
|
+
case _.comma:
|
|
2526
|
+
return this.formatComma(e);
|
|
2527
|
+
case _.line_comment:
|
|
2528
|
+
return this.formatLineComment(e);
|
|
2529
|
+
case _.block_comment:
|
|
2530
|
+
return this.formatBlockComment(e);
|
|
2531
|
+
case _.disable_comment:
|
|
2532
|
+
return this.formatBlockComment(e);
|
|
2533
|
+
case _.data_type:
|
|
2534
|
+
return this.formatDataType(e);
|
|
2535
|
+
case _.keyword:
|
|
2536
|
+
return this.formatKeywordNode(e);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
formatFunctionCall(e) {
|
|
2540
|
+
this.withComments(e.nameKw, () => {
|
|
2541
|
+
this.layout.add(this.showFunctionKw(e.nameKw));
|
|
2542
|
+
}), this.formatNode(e.parenthesis);
|
|
2543
|
+
}
|
|
2544
|
+
formatParameterizedDataType(e) {
|
|
2545
|
+
this.withComments(e.dataType, () => {
|
|
2546
|
+
this.layout.add(this.showDataType(e.dataType));
|
|
2547
|
+
}), this.formatNode(e.parenthesis);
|
|
2548
|
+
}
|
|
2549
|
+
formatArraySubscript(e) {
|
|
2550
|
+
let t;
|
|
2551
|
+
switch (e.array.type) {
|
|
2552
|
+
case _.data_type:
|
|
2553
|
+
t = this.showDataType(e.array);
|
|
2554
|
+
break;
|
|
2555
|
+
case _.keyword:
|
|
2556
|
+
t = this.showKw(e.array);
|
|
2557
|
+
break;
|
|
2558
|
+
default:
|
|
2559
|
+
t = this.showIdentifier(e.array);
|
|
2560
|
+
break;
|
|
2561
|
+
}
|
|
2562
|
+
this.withComments(e.array, () => {
|
|
2563
|
+
this.layout.add(t);
|
|
2564
|
+
}), this.formatNode(e.parenthesis);
|
|
2565
|
+
}
|
|
2566
|
+
formatPropertyAccess(e) {
|
|
2567
|
+
this.formatNode(e.object), this.layout.add(a.NO_SPACE, e.operator), this.formatNode(e.property);
|
|
2568
|
+
}
|
|
2569
|
+
formatParenthesis(e) {
|
|
2570
|
+
const t = this.formatInlineExpression(e.children);
|
|
2571
|
+
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), $(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));
|
|
2572
|
+
}
|
|
2573
|
+
formatBetweenPredicate(e) {
|
|
2574
|
+
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);
|
|
2575
|
+
}
|
|
2576
|
+
formatCaseExpression(e) {
|
|
2577
|
+
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);
|
|
2578
|
+
}
|
|
2579
|
+
formatCaseWhen(e) {
|
|
2580
|
+
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);
|
|
2581
|
+
}
|
|
2582
|
+
formatCaseElse(e) {
|
|
2583
|
+
this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(e.elseKw), this.layout = this.formatSubExpression(e.result);
|
|
2584
|
+
}
|
|
2585
|
+
formatClause(e) {
|
|
2586
|
+
this.isOnelineClause(e) ? this.formatClauseInOnelineStyle(e) : $(this.cfg) ? this.formatClauseInTabularStyle(e) : this.formatClauseInIndentedStyle(e);
|
|
2587
|
+
}
|
|
2588
|
+
isOnelineClause(e) {
|
|
2589
|
+
return $(this.cfg) ? this.dialectCfg.tabularOnelineClauses[e.nameKw.text] : this.dialectCfg.onelineClauses[e.nameKw.text];
|
|
2590
|
+
}
|
|
2591
|
+
formatClauseInIndentedStyle(e) {
|
|
2592
|
+
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();
|
|
2593
|
+
}
|
|
2594
|
+
formatClauseInOnelineStyle(e) {
|
|
2595
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(e.nameKw), a.SPACE), this.layout = this.formatSubExpression(e.children);
|
|
2596
|
+
}
|
|
2597
|
+
formatClauseInTabularStyle(e) {
|
|
2598
|
+
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();
|
|
2599
|
+
}
|
|
2600
|
+
formatSetOperation(e) {
|
|
2601
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(e.nameKw), a.NEWLINE), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(e.children);
|
|
2602
|
+
}
|
|
2603
|
+
formatLimitClause(e) {
|
|
2604
|
+
this.withComments(e.limitKw, () => {
|
|
2605
|
+
this.layout.add(a.NEWLINE, a.INDENT, this.showKw(e.limitKw));
|
|
2606
|
+
}), this.layout.indentation.increaseTopLevel(), $(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();
|
|
2607
|
+
}
|
|
2608
|
+
formatAllColumnsAsterisk(e) {
|
|
2609
|
+
this.layout.add("*", a.SPACE);
|
|
2610
|
+
}
|
|
2611
|
+
formatLiteral(e) {
|
|
2612
|
+
this.layout.add(e.text, a.SPACE);
|
|
2613
|
+
}
|
|
2614
|
+
formatIdentifier(e) {
|
|
2615
|
+
this.layout.add(this.showIdentifier(e), a.SPACE);
|
|
2616
|
+
}
|
|
2617
|
+
formatParameter(e) {
|
|
2618
|
+
this.layout.add(this.params.get(e), a.SPACE);
|
|
2619
|
+
}
|
|
2620
|
+
formatOperator({ text: e }) {
|
|
2621
|
+
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);
|
|
2622
|
+
}
|
|
2623
|
+
formatComma(e) {
|
|
2624
|
+
this.inline ? this.layout.add(a.NO_SPACE, ",", a.SPACE) : this.layout.add(a.NO_SPACE, ",", a.NEWLINE, a.INDENT);
|
|
2625
|
+
}
|
|
2626
|
+
withComments(e, t) {
|
|
2627
|
+
this.formatComments(e.leadingComments), t(), this.formatComments(e.trailingComments);
|
|
2628
|
+
}
|
|
2629
|
+
formatComments(e) {
|
|
2630
|
+
e && e.forEach((t) => {
|
|
2631
|
+
t.type === _.line_comment ? this.formatLineComment(t) : this.formatBlockComment(t);
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
formatLineComment(e) {
|
|
2635
|
+
H(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);
|
|
2636
|
+
}
|
|
2637
|
+
formatBlockComment(e) {
|
|
2638
|
+
e.type === _.block_comment && this.isMultilineBlockComment(e) ? (this.splitBlockComment(e.text).forEach((t) => {
|
|
2639
|
+
this.layout.add(a.NEWLINE, a.INDENT, t);
|
|
2640
|
+
}), this.layout.add(a.NEWLINE, a.INDENT)) : this.layout.add(e.text, a.SPACE);
|
|
2641
|
+
}
|
|
2642
|
+
isMultilineBlockComment(e) {
|
|
2643
|
+
return H(e.text) || H(e.precedingWhitespace || "");
|
|
2644
|
+
}
|
|
2645
|
+
isDocComment(e) {
|
|
2646
|
+
const t = e.split(/\n/);
|
|
2647
|
+
return (
|
|
2648
|
+
// first line starts with /* or /**
|
|
2649
|
+
/^\/\*\*?$/.test(t[0]) && // intermediate lines start with *
|
|
2650
|
+
t.slice(1, t.length - 1).every((r) => /^\s*\*/.test(r)) && // last line ends with */
|
|
2651
|
+
/^\s*\*\/$/.test(B(t))
|
|
2652
|
+
);
|
|
2653
|
+
}
|
|
2654
|
+
// Breaks up block comment to multiple lines.
|
|
2655
|
+
// For example this doc-comment (dots representing leading whitespace):
|
|
2656
|
+
//
|
|
2657
|
+
// ..../**
|
|
2658
|
+
// .....* Some description here
|
|
2659
|
+
// .....* and here too
|
|
2660
|
+
// .....*/
|
|
2661
|
+
//
|
|
2662
|
+
// gets broken to this array (note the leading single spaces):
|
|
2663
|
+
//
|
|
2664
|
+
// [ '/**',
|
|
2665
|
+
// '.* Some description here',
|
|
2666
|
+
// '.* and here too',
|
|
2667
|
+
// '.*/' ]
|
|
2668
|
+
//
|
|
2669
|
+
// However, a normal comment (non-doc-comment) like this:
|
|
2670
|
+
//
|
|
2671
|
+
// ..../*
|
|
2672
|
+
// ....Some description here
|
|
2673
|
+
// ....*/
|
|
2674
|
+
//
|
|
2675
|
+
// gets broken to this array (no leading spaces):
|
|
2676
|
+
//
|
|
2677
|
+
// [ '/*',
|
|
2678
|
+
// 'Some description here',
|
|
2679
|
+
// '*/' ]
|
|
2680
|
+
//
|
|
2681
|
+
splitBlockComment(e) {
|
|
2682
|
+
return this.isDocComment(e) ? e.split(/\n/).map((t) => /^\s*\*/.test(t) ? " " + t.replace(/^\s*/, "") : t) : e.split(/\n/).map((t) => t.replace(/^\s*/, ""));
|
|
2683
|
+
}
|
|
2684
|
+
formatSubExpression(e) {
|
|
2685
|
+
return new v({
|
|
2686
|
+
cfg: this.cfg,
|
|
2687
|
+
dialectCfg: this.dialectCfg,
|
|
2688
|
+
params: this.params,
|
|
2689
|
+
layout: this.layout,
|
|
2690
|
+
inline: this.inline
|
|
2691
|
+
}).format(e);
|
|
2692
|
+
}
|
|
2693
|
+
formatInlineExpression(e) {
|
|
2694
|
+
const t = this.params.getPositionalParameterIndex();
|
|
2695
|
+
try {
|
|
2696
|
+
return new v({
|
|
2697
|
+
cfg: this.cfg,
|
|
2698
|
+
dialectCfg: this.dialectCfg,
|
|
2699
|
+
params: this.params,
|
|
2700
|
+
layout: new fs(this.cfg.expressionWidth),
|
|
2701
|
+
inline: !0
|
|
2702
|
+
}).format(e);
|
|
2703
|
+
} catch (r) {
|
|
2704
|
+
if (r instanceof J) {
|
|
2705
|
+
this.params.setPositionalParameterIndex(t);
|
|
2706
|
+
return;
|
|
2707
|
+
} else
|
|
2708
|
+
throw r;
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
formatKeywordNode(e) {
|
|
2712
|
+
switch (e.tokenType) {
|
|
2713
|
+
case n.RESERVED_JOIN:
|
|
2714
|
+
return this.formatJoin(e);
|
|
2715
|
+
case n.AND:
|
|
2716
|
+
case n.OR:
|
|
2717
|
+
case n.XOR:
|
|
2718
|
+
return this.formatLogicalOperator(e);
|
|
2719
|
+
default:
|
|
2720
|
+
return this.formatKeyword(e);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
formatJoin(e) {
|
|
2724
|
+
$(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);
|
|
2725
|
+
}
|
|
2726
|
+
formatKeyword(e) {
|
|
2727
|
+
this.layout.add(this.showKw(e), a.SPACE);
|
|
2728
|
+
}
|
|
2729
|
+
formatLogicalOperator(e) {
|
|
2730
|
+
this.cfg.logicalOperatorNewline === "before" ? $(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);
|
|
2731
|
+
}
|
|
2732
|
+
formatDataType(e) {
|
|
2733
|
+
this.layout.add(this.showDataType(e), a.SPACE);
|
|
2734
|
+
}
|
|
2735
|
+
showKw(e) {
|
|
2736
|
+
return oe(e.tokenType) ? Ee(this.showNonTabularKw(e), this.cfg.indentStyle) : this.showNonTabularKw(e);
|
|
2737
|
+
}
|
|
2738
|
+
// Like showKw(), but skips tabular formatting
|
|
2739
|
+
showNonTabularKw(e) {
|
|
2740
|
+
switch (this.cfg.keywordCase) {
|
|
2741
|
+
case "preserve":
|
|
2742
|
+
return Y(e.raw);
|
|
2743
|
+
case "upper":
|
|
2744
|
+
return e.text;
|
|
2745
|
+
case "lower":
|
|
2746
|
+
return e.text.toLowerCase();
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
showFunctionKw(e) {
|
|
2750
|
+
return oe(e.tokenType) ? Ee(this.showNonTabularFunctionKw(e), this.cfg.indentStyle) : this.showNonTabularFunctionKw(e);
|
|
2751
|
+
}
|
|
2752
|
+
// Like showFunctionKw(), but skips tabular formatting
|
|
2753
|
+
showNonTabularFunctionKw(e) {
|
|
2754
|
+
switch (this.cfg.functionCase) {
|
|
2755
|
+
case "preserve":
|
|
2756
|
+
return Y(e.raw);
|
|
2757
|
+
case "upper":
|
|
2758
|
+
return e.text;
|
|
2759
|
+
case "lower":
|
|
2760
|
+
return e.text.toLowerCase();
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
showIdentifier(e) {
|
|
2764
|
+
if (e.quoted)
|
|
2765
|
+
return e.text;
|
|
2766
|
+
switch (this.cfg.identifierCase) {
|
|
2767
|
+
case "preserve":
|
|
2768
|
+
return e.text;
|
|
2769
|
+
case "upper":
|
|
2770
|
+
return e.text.toUpperCase();
|
|
2771
|
+
case "lower":
|
|
2772
|
+
return e.text.toLowerCase();
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
showDataType(e) {
|
|
2776
|
+
switch (this.cfg.dataTypeCase) {
|
|
2777
|
+
case "preserve":
|
|
2778
|
+
return Y(e.raw);
|
|
2779
|
+
case "upper":
|
|
2780
|
+
return e.text;
|
|
2781
|
+
case "lower":
|
|
2782
|
+
return e.text.toLowerCase();
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
class Cs {
|
|
2787
|
+
constructor(e, t) {
|
|
2788
|
+
this.dialect = e, this.cfg = t, this.params = new rs(this.cfg.params);
|
|
2789
|
+
}
|
|
2790
|
+
/**
|
|
2791
|
+
* Formats an SQL query.
|
|
2792
|
+
* @param {string} query - The SQL query string to be formatted
|
|
2793
|
+
* @return {string} The formatter query
|
|
2794
|
+
*/
|
|
2795
|
+
format(e) {
|
|
2796
|
+
const t = this.parse(e);
|
|
2797
|
+
return this.formatAst(t).trimEnd();
|
|
2798
|
+
}
|
|
2799
|
+
parse(e) {
|
|
2800
|
+
return hs(this.dialect.tokenizer).parse(e, this.cfg.paramTypes || {});
|
|
2801
|
+
}
|
|
2802
|
+
formatAst(e) {
|
|
2803
|
+
return e.map((t) => this.formatStatement(t)).join(`
|
|
2804
|
+
`.repeat(this.cfg.linesBetweenQueries + 1));
|
|
2805
|
+
}
|
|
2806
|
+
formatStatement(e) {
|
|
2807
|
+
const t = new v({
|
|
2808
|
+
cfg: this.cfg,
|
|
2809
|
+
dialectCfg: this.dialect.formatOptions,
|
|
2810
|
+
params: this.params,
|
|
2811
|
+
layout: new Ne(new ue(ts(this.cfg)))
|
|
2812
|
+
}).format(e.children);
|
|
2813
|
+
return e.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? t.add(a.NEWLINE, ";") : t.add(a.NO_NEWLINE, ";")), t.toString();
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
class X extends Error {
|
|
2817
|
+
}
|
|
2818
|
+
function ys(s) {
|
|
2819
|
+
const e = [
|
|
2820
|
+
"multilineLists",
|
|
2821
|
+
"newlineBeforeOpenParen",
|
|
2822
|
+
"newlineBeforeCloseParen",
|
|
2823
|
+
"aliasAs",
|
|
2824
|
+
"commaPosition",
|
|
2825
|
+
"tabulateAlias"
|
|
2826
|
+
];
|
|
2827
|
+
for (const t of e)
|
|
2828
|
+
if (t in s)
|
|
2829
|
+
throw new X(`${t} config is no more supported.`);
|
|
2830
|
+
if (s.expressionWidth <= 0)
|
|
2831
|
+
throw new X(`expressionWidth config must be positive number. Received ${s.expressionWidth} instead.`);
|
|
2832
|
+
if (s.params && !Ps(s.params) && console.warn('WARNING: All "params" option values should be strings.'), s.paramTypes && !Ds(s.paramTypes))
|
|
2833
|
+
throw new X("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");
|
|
2834
|
+
return s;
|
|
2835
|
+
}
|
|
2836
|
+
function Ps(s) {
|
|
2837
|
+
return (s instanceof Array ? s : Object.values(s)).every((t) => typeof t == "string");
|
|
2838
|
+
}
|
|
2839
|
+
function Ds(s) {
|
|
2840
|
+
return s.custom && Array.isArray(s.custom) ? s.custom.every((e) => e.regex !== "") : !0;
|
|
2841
|
+
}
|
|
2842
|
+
var bs = function(s, e) {
|
|
2843
|
+
var t = {};
|
|
2844
|
+
for (var r in s) Object.prototype.hasOwnProperty.call(s, r) && e.indexOf(r) < 0 && (t[r] = s[r]);
|
|
2845
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
2846
|
+
for (var o = 0, r = Object.getOwnPropertySymbols(s); o < r.length; o++)
|
|
2847
|
+
e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(s, r[o]) && (t[r[o]] = s[r[o]]);
|
|
2848
|
+
return t;
|
|
2849
|
+
};
|
|
2850
|
+
const ds = {
|
|
2851
|
+
tabWidth: 2,
|
|
2852
|
+
useTabs: !1,
|
|
2853
|
+
keywordCase: "preserve",
|
|
2854
|
+
identifierCase: "preserve",
|
|
2855
|
+
dataTypeCase: "preserve",
|
|
2856
|
+
functionCase: "preserve",
|
|
2857
|
+
indentStyle: "standard",
|
|
2858
|
+
logicalOperatorNewline: "before",
|
|
2859
|
+
expressionWidth: 50,
|
|
2860
|
+
linesBetweenQueries: 1,
|
|
2861
|
+
denseOperators: !1,
|
|
2862
|
+
newlineBeforeSemicolon: !1
|
|
2863
|
+
}, $s = (s, e) => {
|
|
2864
|
+
var { dialect: t } = e, r = bs(e, ["dialect"]);
|
|
2865
|
+
if (typeof s != "string")
|
|
2866
|
+
throw new Error("Invalid query argument. Expected string, instead got " + typeof s);
|
|
2867
|
+
const o = ys(Object.assign(Object.assign({}, ds), r));
|
|
2868
|
+
return new Cs(ze(t), o).format(s);
|
|
2869
|
+
};
|
|
2870
|
+
export {
|
|
2871
|
+
X as ConfigError,
|
|
2872
|
+
xs as duckdb,
|
|
2873
|
+
d as expandPhrases,
|
|
2874
|
+
$s as formatDialect
|
|
2875
|
+
};
|