-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
statement.opt
341 lines (283 loc) · 9.02 KB
/
statement.opt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# statement.opt contains Optgen language definitions for non-DML statements with
# specific optimizer support, such as CreateTable.
#
# Although though many of them have no return result, they are still treated as
# if they were expressions with a zero row, zero column result.
# CreateTable represents a CREATE TABLE statement.
[Relational, DDL, Mutation]
define CreateTable {
# Input is only used if the AS clause was used in the CREATE TABLE
# statement. If it was not used, then the Input is a dummy zero row, zero
# column Values expression (and nil inputs are not allowed).
Input RelExpr
_ CreateTablePrivate
}
[Private]
define CreateTablePrivate {
# Schema is the ID of the catalog schema into which the new table goes.
Schema SchemaID
# InputCols gives the ordering and naming of input columns. It is only
# defined when the AS clause was used in the CREATE TABLE statement.
InputCols Presentation
# Syntax is the CREATE TABLE AST node. All data sources inside AsSource are
# fully qualified.
Syntax CreateTable
}
[Relational, DDL, Mutation]
define CreateView {
_ CreateViewPrivate
}
[Private]
define CreateViewPrivate {
# Schema is the ID of the catalog schema into which the new table goes.
Schema SchemaID
ViewName TableName
Persistence Persistence
IfNotExists bool
Replace bool
Materialized bool
# ViewQuery contains the query for the view; data sources are always fully
# qualified.
ViewQuery string
# Columns that correspond to the output of the view query, with the names
# they will have as part of the view.
Columns Presentation
# Deps contains the data source dependencies of the view.
Deps SchemaDeps
# TypeDeps contains the type dependencies of the view.
TypeDeps SchemaTypeDeps
# WithData indicates if the materialized view is populated
# with data upon creation.
WithData bool
}
[Relational, DDL, Mutation]
define CreateFunction {
_ CreateFunctionPrivate
}
[Private]
define CreateFunctionPrivate {
Schema SchemaID
FunctionName FunctionName
Replace bool
Args FuncArgs
ReturnType FuncReturnType
Options FunctionOptions
FuncBody FunctionBodyStr
Deps SchemaDeps
TypeDeps SchemaTypeDeps
}
# Explain returns information about the execution plan of the "input"
# expression.
[Relational]
define Explain {
Input RelExpr
_ ExplainPrivate
}
[Private]
define ExplainPrivate {
# Options contains settings that control the output of the explain statement.
Options ExplainOptions
# ColList stores the column IDs for the explain columns.
ColList ColList
# Props stores the required physical properties for the enclosed expression.
Props PhysProps
# StmtType stores the type of the statement return we are explaining.
StmtType StatementReturnType
}
# ShowTraceForSession returns the current session traces.
[Relational]
define ShowTraceForSession {
_ ShowTracePrivate
}
[Private]
define ShowTracePrivate {
TraceType ShowTraceType
# Compact indicates that we output a smaller set of columns; set
# when SHOW COMPACT [KV] TRACE is used.
Compact bool
# ColList stores the column IDs for the SHOW TRACE columns.
ColList ColList
}
# OpaqueRel is an opaque relational operator which is planned outside of the
# optimizer. The operator contains an opaque metadata which is passed to the
# exec factory.
#
# This is used for statements that are not directly supported by the optimizer,
# and which don't use the result of other relational expressions (in other
# words, they are a "leaf" operator).
#
# OpaqueRel can produce data and can be used as a data source as part of a
# larger enclosing query.
[Relational]
define OpaqueRel {
_ OpaqueRelPrivate
}
# OpaqueMutation is a variant of OpaqueRel for operators that can mutate data as
# part of the transaction.
[Relational, Mutation]
define OpaqueMutation {
_ OpaqueRelPrivate
}
# OpaqueMutation is a variant of OpaqueRel for operators that cause a schema
# change and cannot be executed following a mutation in the same transaction.
[Relational, Mutation, DDL]
define OpaqueDDL {
_ OpaqueRelPrivate
}
[Private]
define OpaqueRelPrivate {
Columns ColList
Metadata OpaqueMetadata
}
# AlterTableSplit represents an `ALTER TABLE/INDEX .. SPLIT AT ..` statement.
[Relational, Mutation]
define AlterTableSplit {
# The input expression provides values for the index columns (or a prefix of
# them).
Input RelExpr
# Expiration is a string scalar that indicates a timestamp after which the
# ranges are eligible for automatic merging (or Null if there is no
# expiration).
Expiration ScalarExpr
_ AlterTableSplitPrivate
}
[Private]
define AlterTableSplitPrivate {
# Table identifies the table to alter. It is an id that can be passed to
# the Metadata.Table method in order to fetch cat.Table metadata.
Table TableID
# Index identifies the index to scan (whether primary or secondary). It
# can be passed to the cat.Table.Index() method in order to fetch the
# cat.Index metadata.
Index IndexOrdinal
# Props stores the required physical properties for the input expression.
Props PhysProps
# Columns stores the column IDs for the statement result columns.
Columns ColList
}
# AlterTableUnsplit represents an `ALTER TABLE/INDEX .. UNSPLIT AT ..`
# statement.
[Relational, Mutation]
define AlterTableUnsplit {
Input RelExpr
_ AlterTableSplitPrivate
}
# AlterTableUnsplit represents an `ALTER TABLE/INDEX .. UNSPLIT ALL` statement.
[Relational, Mutation]
define AlterTableUnsplitAll {
_ AlterTableSplitPrivate
}
# AlterTableRelocate represents an `ALTER TABLE/INDEX .. SPLIT AT ..` statement.
[Relational, Mutation]
define AlterTableRelocate {
# The input expression provides values for the index columns (or a prefix of
# them).
Input RelExpr
_ AlterTableRelocatePrivate
}
[Private]
define AlterTableRelocatePrivate {
SubjectReplicas RelocateSubject
_ AlterTableSplitPrivate
}
# ControlJobs represents a `PAUSE/CANCEL/RESUME JOBS` statement.
[Relational]
define ControlJobs {
# The input expression returns job IDs (as integers).
Input RelExpr
# Reason is the reason string for the command job.
Reason ScalarExpr
_ ControlJobsPrivate
}
[Private]
define ControlJobsPrivate {
# Props stores the required physical properties for the input
# expression.
Props PhysProps
Command JobCommand
}
# ControlSchedules represents a `PAUSE/CANCEL/RESUME SCHEDULES` statement.
[Relational]
define ControlSchedules {
# The input expression returns schedule IDs (as integers).
Input RelExpr
_ ControlSchedulesPrivate
}
[Private]
define ControlSchedulesPrivate {
# Props stores the required physical properties for the input
# expression.
Props PhysProps
Command ScheduleCommand
}
# CancelQueries represents a `CANCEL QUERIES` statement.
[Relational]
define CancelQueries {
# The input expression returns query IDs (as strings).
Input RelExpr
_ CancelPrivate
}
[Private]
define CancelPrivate {
# Props stores the required physical properties for the input
# expression.
Props PhysProps
# IfExists is set if we should tolerate IDs that don't exist.
IfExists bool
}
# CancelSessions represents a `CANCEL SESSIONS` statement.
[Relational]
define CancelSessions {
# The input expression returns session IDs (as strings).
Input RelExpr
_ CancelPrivate
}
# Export represents an `EXPORT` statement.
[Relational]
define Export {
# Input is the relational expression for the data we are exporting.
Input RelExpr
# FileName is the string URI for the output file.
FileName ScalarExpr
Options KVOptionsExpr
_ ExportPrivate
}
[Private]
define ExportPrivate {
# FileFormat describes the requested format, e.g. "CSV".
FileFormat string
# Props stores the required physical properties for the input expression.
Props PhysProps
# Columns stores the column IDs for the statement result columns.
Columns ColList
}
# CreateStatistics represents a CREATE STATISTICS or ANALYZE statement.
[Relational]
define CreateStatistics {
_ CreateStatisticsPrivate
}
[Private]
define CreateStatisticsPrivate {
# Syntax is the tree.CreateStats AST node.
Syntax CreateStats
}
# AlterRangeRelocate represents an `ALTER RANGE .. RELOCATE ..` statement.
[Relational, Mutation]
define AlterRangeRelocate {
# The input expression provides range IDs as integers.
Input RelExpr
# ToStoreID is the destination store ID.
ToStoreID ScalarExpr
# FromStoreID is the origin store ID, set to NULL when transfering the leaseholder (subject LEASE).
FromStoreID ScalarExpr
_ AlterRangeRelocatePrivate
}
[Private]
define AlterRangeRelocatePrivate {
# The subject indicates which replicas will be relocated.
SubjectReplicas RelocateSubject
# Columns stores the column IDs for the statement result columns.
Columns ColList
# Props stores the required physical properties for the input expression.
Props PhysProps
}