Edit on GitHub

sqlglot expressions DDL.

  1"""sqlglot expressions DDL."""
  2
  3from __future__ import annotations
  4
  5import typing as t
  6
  7from sqlglot.helper import trait
  8from sqlglot.expressions.core import Expression, Expr, Func
  9from sqlglot.expressions.query import Query, Selectable
 10
 11if t.TYPE_CHECKING:
 12    from sqlglot.expressions.query import CTE
 13
 14
 15@trait
 16class DDL(Selectable):
 17    @property
 18    def ctes(self) -> list[CTE]:
 19        """Returns a list of all the CTEs attached to this statement."""
 20        with_ = self.args.get("with_")
 21        return with_.expressions if with_ else []
 22
 23    @property
 24    def selects(self) -> list[Expr]:
 25        """If this statement contains a query (e.g. a CTAS), this returns the query's projections."""
 26        expression = self.expression
 27        return expression.selects if isinstance(expression, Query) else []
 28
 29    @property
 30    def named_selects(self) -> list[str]:
 31        """
 32        If this statement contains a query (e.g. a CTAS), this returns the output
 33        names of the query's projections.
 34        """
 35        expression = self.expression
 36        return expression.named_selects if isinstance(expression, Query) else []
 37
 38
 39class Create(Expression, DDL):
 40    arg_types = {
 41        "with_": False,
 42        "this": True,
 43        "kind": True,
 44        "expression": False,
 45        "exists": False,
 46        "properties": False,
 47        "replace": False,
 48        "refresh": False,
 49        "unique": False,
 50        "indexes": False,
 51        "no_schema_binding": False,
 52        "begin": False,
 53        "clone": False,
 54        "concurrently": False,
 55        "clustered": False,
 56    }
 57
 58    @property
 59    def kind(self) -> str | None:
 60        kind = self.args.get("kind")
 61        return kind and kind.upper()
 62
 63
 64class SequenceProperties(Expression):
 65    arg_types = {
 66        "increment": False,
 67        "minvalue": False,
 68        "maxvalue": False,
 69        "cache": False,
 70        "start": False,
 71        "owned": False,
 72        "options": False,
 73    }
 74
 75
 76class TriggerProperties(Expression):
 77    arg_types = {
 78        "table": True,
 79        "timing": True,
 80        "events": True,
 81        "execute": True,
 82        "constraint": False,
 83        "referenced_table": False,
 84        "deferrable": False,
 85        "initially": False,
 86        "referencing": False,
 87        "for_each": False,
 88        "when": False,
 89    }
 90
 91
 92class TriggerExecute(Expression):
 93    pass
 94
 95
 96class TriggerEvent(Expression):
 97    arg_types = {"this": True, "columns": False}
 98
 99
100class TriggerReferencing(Expression):
101    arg_types = {"old": False, "new": False}
102
103
104class TruncateTable(Expression):
105    arg_types = {
106        "expressions": True,
107        "is_database": False,
108        "exists": False,
109        "only": False,
110        "cluster": False,
111        "identity": False,
112        "option": False,
113        "partition": False,
114    }
115
116
117class Clone(Expression):
118    arg_types = {"this": True, "shallow": False, "copy": False}
119
120
121class Describe(Expression):
122    arg_types = {
123        "this": True,
124        "style": False,
125        "kind": False,
126        "properties": False,
127        "expressions": False,
128        "partition": False,
129        "format": False,
130        "as_json": False,
131    }
132
133
134class Attach(Expression):
135    arg_types = {"this": True, "exists": False, "expressions": False}
136
137
138class Detach(Expression):
139    arg_types = {
140        "this": True,
141        "kind": False,
142        "exists": False,
143        "cluster": False,
144        "permanent": False,
145        "sync": False,
146    }
147
148
149class Install(Expression):
150    arg_types = {"this": True, "from_": False, "force": False}
151
152
153class Summarize(Expression):
154    arg_types = {"this": True, "table": False}
155
156
157class Kill(Expression):
158    arg_types = {"this": True, "kind": False}
159
160
161class Pragma(Expression):
162    pass
163
164
165class Declare(Expression):
166    arg_types = {"expressions": True, "replace": False}
167
168
169class DeclareItem(Expression):
170    arg_types = {"this": True, "kind": False, "default": False}
171
172
173class Set(Expression):
174    arg_types = {"expressions": False, "unset": False, "tag": False}
175
176
177class Heredoc(Expression):
178    arg_types = {"this": True, "tag": False}
179
180
181class SetItem(Expression):
182    arg_types = {
183        "this": False,
184        "expressions": False,
185        "kind": False,
186        "collate": False,  # MySQL SET NAMES statement
187        "global_": False,
188    }
189
190
191class Show(Expression):
192    arg_types = {
193        "this": True,
194        "history": False,
195        "terse": False,
196        "target": False,
197        "offset": False,
198        "starts_with": False,
199        "limit": False,
200        "from_": False,
201        "like": False,
202        "where": False,
203        "db": False,
204        "scope": False,
205        "scope_kind": False,
206        "full": False,
207        "mutex": False,
208        "query": False,
209        "channel": False,
210        "global_": False,
211        "log": False,
212        "position": False,
213        "types": False,
214        "privileges": False,
215        "for_table": False,
216        "for_group": False,
217        "for_user": False,
218        "for_role": False,
219        "into_outfile": False,
220        "json": False,
221        "iceberg": False,
222    }
223
224
225class UserDefinedFunction(Expression):
226    arg_types = {"this": True, "expressions": False, "wrapped": False}
227
228
229class CharacterSet(Expression):
230    arg_types = {"this": True, "default": False}
231
232
233class AlterColumn(Expression):
234    arg_types = {
235        "this": True,
236        "dtype": False,
237        "collate": False,
238        "using": False,
239        "default": False,
240        "drop": False,
241        "comment": False,
242        "allow_null": False,
243        "visible": False,
244        "rename_to": False,
245    }
246
247
248class AlterIndex(Expression):
249    arg_types = {"this": True, "visible": True}
250
251
252class AlterDistStyle(Expression):
253    pass
254
255
256class AlterSortKey(Expression):
257    arg_types = {"this": False, "expressions": False, "compound": False}
258
259
260class AlterSet(Expression):
261    arg_types = {
262        "expressions": False,
263        "option": False,
264        "tablespace": False,
265        "access_method": False,
266        "file_format": False,
267        "copy_options": False,
268        "tag": False,
269        "location": False,
270        "serde": False,
271    }
272
273
274class RenameColumn(Expression):
275    arg_types = {"this": True, "to": True, "exists": False}
276
277
278class AlterRename(Expression):
279    pass
280
281
282class RenameIndex(Expression):
283    arg_types = {"this": True, "to": True}
284
285
286class AlterModifySqlSecurity(Expression):
287    arg_types = {"expressions": True}
288
289
290class SwapTable(Expression):
291    pass
292
293
294class Comment(Expression):
295    arg_types = {
296        "this": True,
297        "kind": True,
298        "expression": True,
299        "exists": False,
300        "materialized": False,
301    }
302
303
304class Comprehension(Expression):
305    arg_types = {
306        "this": True,
307        "expression": True,
308        "position": False,
309        "iterator": True,
310        "condition": False,
311    }
312
313
314class MergeTreeTTLAction(Expression):
315    arg_types = {
316        "this": True,
317        "delete": False,
318        "recompress": False,
319        "to_disk": False,
320        "to_volume": False,
321    }
322
323
324class MergeTreeTTL(Expression):
325    arg_types = {
326        "expressions": True,
327        "where": False,
328        "group": False,
329        "aggregates": False,
330    }
331
332
333class Drop(Expression):
334    arg_types = {
335        "this": False,
336        "kind": False,
337        "expressions": False,
338        "exists": False,
339        "temporary": False,
340        "materialized": False,
341        "cascade": False,
342        "restrict": False,
343        "constraints": False,
344        "purge": False,
345        "cluster": False,
346        "concurrently": False,
347        "sync": False,
348        "iceberg": False,
349    }
350
351    @property
352    def kind(self) -> str | None:
353        kind = self.args.get("kind")
354        return kind and kind.upper()
355
356
357class Command(Expression):
358    arg_types = {"this": True, "expression": False}
359
360
361class Transaction(Expression):
362    arg_types = {"this": False, "modes": False, "mark": False}
363
364
365class Commit(Expression):
366    arg_types = {"chain": False, "this": False, "durability": False}
367
368
369class Rollback(Expression):
370    arg_types = {"savepoint": False, "this": False}
371
372
373class Alter(Expression):
374    arg_types = {
375        "this": False,
376        "kind": True,
377        "actions": True,
378        "exists": False,
379        "only": False,
380        "options": False,
381        "cluster": False,
382        "not_valid": False,
383        "check": False,
384        "cascade": False,
385        "iceberg": False,
386    }
387
388    @property
389    def kind(self) -> str | None:
390        kind = self.args.get("kind")
391        return kind and kind.upper()
392
393    @property
394    def actions(self) -> list[Expr]:
395        return self.args.get("actions") or []
396
397
398class AlterSession(Expression):
399    arg_types = {"expressions": True, "unset": False}
400
401
402class Use(Expression):
403    arg_types = {"this": False, "expressions": False, "kind": False}
404
405
406class NextValueFor(Expression, Func):
407    arg_types = {"this": True, "order": False}
408
409
410class Execute(Expression):
411    arg_types = {"this": True, "expressions": False}
412
413    @property
414    def name(self) -> str:
415        return self.this.name
416
417
418class ExecuteSql(Execute):
419    pass
@trait
class DDL(sqlglot.expressions.query.Selectable):
16@trait
17class DDL(Selectable):
18    @property
19    def ctes(self) -> list[CTE]:
20        """Returns a list of all the CTEs attached to this statement."""
21        with_ = self.args.get("with_")
22        return with_.expressions if with_ else []
23
24    @property
25    def selects(self) -> list[Expr]:
26        """If this statement contains a query (e.g. a CTAS), this returns the query's projections."""
27        expression = self.expression
28        return expression.selects if isinstance(expression, Query) else []
29
30    @property
31    def named_selects(self) -> list[str]:
32        """
33        If this statement contains a query (e.g. a CTAS), this returns the output
34        names of the query's projections.
35        """
36        expression = self.expression
37        return expression.named_selects if isinstance(expression, Query) else []
ctes: list[sqlglot.expressions.query.CTE]
18    @property
19    def ctes(self) -> list[CTE]:
20        """Returns a list of all the CTEs attached to this statement."""
21        with_ = self.args.get("with_")
22        return with_.expressions if with_ else []

Returns a list of all the CTEs attached to this statement.

selects: list[sqlglot.expressions.core.Expr]
24    @property
25    def selects(self) -> list[Expr]:
26        """If this statement contains a query (e.g. a CTAS), this returns the query's projections."""
27        expression = self.expression
28        return expression.selects if isinstance(expression, Query) else []

If this statement contains a query (e.g. a CTAS), this returns the query's projections.

named_selects: list[str]
30    @property
31    def named_selects(self) -> list[str]:
32        """
33        If this statement contains a query (e.g. a CTAS), this returns the output
34        names of the query's projections.
35        """
36        expression = self.expression
37        return expression.named_selects if isinstance(expression, Query) else []

If this statement contains a query (e.g. a CTAS), this returns the output names of the query's projections.

key: ClassVar[str] = 'ddl'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Create(sqlglot.expressions.core.Expression, DDL):
40class Create(Expression, DDL):
41    arg_types = {
42        "with_": False,
43        "this": True,
44        "kind": True,
45        "expression": False,
46        "exists": False,
47        "properties": False,
48        "replace": False,
49        "refresh": False,
50        "unique": False,
51        "indexes": False,
52        "no_schema_binding": False,
53        "begin": False,
54        "clone": False,
55        "concurrently": False,
56        "clustered": False,
57    }
58
59    @property
60    def kind(self) -> str | None:
61        kind = self.args.get("kind")
62        return kind and kind.upper()
arg_types = {'with_': False, 'this': True, 'kind': True, 'expression': False, 'exists': False, 'properties': False, 'replace': False, 'refresh': False, 'unique': False, 'indexes': False, 'no_schema_binding': False, 'begin': False, 'clone': False, 'concurrently': False, 'clustered': False}
kind: str | None
59    @property
60    def kind(self) -> str | None:
61        kind = self.args.get("kind")
62        return kind and kind.upper()
key: ClassVar[str] = 'create'
required_args: 't.ClassVar[set[str]]' = {'kind', 'this'}
class SequenceProperties(sqlglot.expressions.core.Expression):
65class SequenceProperties(Expression):
66    arg_types = {
67        "increment": False,
68        "minvalue": False,
69        "maxvalue": False,
70        "cache": False,
71        "start": False,
72        "owned": False,
73        "options": False,
74    }
arg_types = {'increment': False, 'minvalue': False, 'maxvalue': False, 'cache': False, 'start': False, 'owned': False, 'options': False}
key: ClassVar[str] = 'sequenceproperties'
required_args: 't.ClassVar[set[str]]' = set()
class TriggerProperties(sqlglot.expressions.core.Expression):
77class TriggerProperties(Expression):
78    arg_types = {
79        "table": True,
80        "timing": True,
81        "events": True,
82        "execute": True,
83        "constraint": False,
84        "referenced_table": False,
85        "deferrable": False,
86        "initially": False,
87        "referencing": False,
88        "for_each": False,
89        "when": False,
90    }
arg_types = {'table': True, 'timing': True, 'events': True, 'execute': True, 'constraint': False, 'referenced_table': False, 'deferrable': False, 'initially': False, 'referencing': False, 'for_each': False, 'when': False}
key: ClassVar[str] = 'triggerproperties'
required_args: 't.ClassVar[set[str]]' = {'events', 'table', 'timing', 'execute'}
class TriggerExecute(sqlglot.expressions.core.Expression):
93class TriggerExecute(Expression):
94    pass
key: ClassVar[str] = 'triggerexecute'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TriggerEvent(sqlglot.expressions.core.Expression):
97class TriggerEvent(Expression):
98    arg_types = {"this": True, "columns": False}
arg_types = {'this': True, 'columns': False}
key: ClassVar[str] = 'triggerevent'
required_args: 't.ClassVar[set[str]]' = {'this'}
class TriggerReferencing(sqlglot.expressions.core.Expression):
101class TriggerReferencing(Expression):
102    arg_types = {"old": False, "new": False}
arg_types = {'old': False, 'new': False}
key: ClassVar[str] = 'triggerreferencing'
required_args: 't.ClassVar[set[str]]' = set()
class TruncateTable(sqlglot.expressions.core.Expression):
105class TruncateTable(Expression):
106    arg_types = {
107        "expressions": True,
108        "is_database": False,
109        "exists": False,
110        "only": False,
111        "cluster": False,
112        "identity": False,
113        "option": False,
114        "partition": False,
115    }
arg_types = {'expressions': True, 'is_database': False, 'exists': False, 'only': False, 'cluster': False, 'identity': False, 'option': False, 'partition': False}
key: ClassVar[str] = 'truncatetable'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class Clone(sqlglot.expressions.core.Expression):
118class Clone(Expression):
119    arg_types = {"this": True, "shallow": False, "copy": False}
arg_types = {'this': True, 'shallow': False, 'copy': False}
key: ClassVar[str] = 'clone'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Describe(sqlglot.expressions.core.Expression):
122class Describe(Expression):
123    arg_types = {
124        "this": True,
125        "style": False,
126        "kind": False,
127        "properties": False,
128        "expressions": False,
129        "partition": False,
130        "format": False,
131        "as_json": False,
132    }
arg_types = {'this': True, 'style': False, 'kind': False, 'properties': False, 'expressions': False, 'partition': False, 'format': False, 'as_json': False}
key: ClassVar[str] = 'describe'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Attach(sqlglot.expressions.core.Expression):
135class Attach(Expression):
136    arg_types = {"this": True, "exists": False, "expressions": False}
arg_types = {'this': True, 'exists': False, 'expressions': False}
key: ClassVar[str] = 'attach'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Detach(sqlglot.expressions.core.Expression):
139class Detach(Expression):
140    arg_types = {
141        "this": True,
142        "kind": False,
143        "exists": False,
144        "cluster": False,
145        "permanent": False,
146        "sync": False,
147    }
arg_types = {'this': True, 'kind': False, 'exists': False, 'cluster': False, 'permanent': False, 'sync': False}
key: ClassVar[str] = 'detach'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Install(sqlglot.expressions.core.Expression):
150class Install(Expression):
151    arg_types = {"this": True, "from_": False, "force": False}
arg_types = {'this': True, 'from_': False, 'force': False}
key: ClassVar[str] = 'install'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Summarize(sqlglot.expressions.core.Expression):
154class Summarize(Expression):
155    arg_types = {"this": True, "table": False}
arg_types = {'this': True, 'table': False}
key: ClassVar[str] = 'summarize'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Kill(sqlglot.expressions.core.Expression):
158class Kill(Expression):
159    arg_types = {"this": True, "kind": False}
arg_types = {'this': True, 'kind': False}
key: ClassVar[str] = 'kill'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Pragma(sqlglot.expressions.core.Expression):
162class Pragma(Expression):
163    pass
key: ClassVar[str] = 'pragma'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Declare(sqlglot.expressions.core.Expression):
166class Declare(Expression):
167    arg_types = {"expressions": True, "replace": False}
arg_types = {'expressions': True, 'replace': False}
key: ClassVar[str] = 'declare'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class DeclareItem(sqlglot.expressions.core.Expression):
170class DeclareItem(Expression):
171    arg_types = {"this": True, "kind": False, "default": False}
arg_types = {'this': True, 'kind': False, 'default': False}
key: ClassVar[str] = 'declareitem'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Set(sqlglot.expressions.core.Expression):
174class Set(Expression):
175    arg_types = {"expressions": False, "unset": False, "tag": False}
arg_types = {'expressions': False, 'unset': False, 'tag': False}
key: ClassVar[str] = 'set'
required_args: 't.ClassVar[set[str]]' = set()
class Heredoc(sqlglot.expressions.core.Expression):
178class Heredoc(Expression):
179    arg_types = {"this": True, "tag": False}
arg_types = {'this': True, 'tag': False}
key: ClassVar[str] = 'heredoc'
required_args: 't.ClassVar[set[str]]' = {'this'}
class SetItem(sqlglot.expressions.core.Expression):
182class SetItem(Expression):
183    arg_types = {
184        "this": False,
185        "expressions": False,
186        "kind": False,
187        "collate": False,  # MySQL SET NAMES statement
188        "global_": False,
189    }
arg_types = {'this': False, 'expressions': False, 'kind': False, 'collate': False, 'global_': False}
key: ClassVar[str] = 'setitem'
required_args: 't.ClassVar[set[str]]' = set()
class Show(sqlglot.expressions.core.Expression):
192class Show(Expression):
193    arg_types = {
194        "this": True,
195        "history": False,
196        "terse": False,
197        "target": False,
198        "offset": False,
199        "starts_with": False,
200        "limit": False,
201        "from_": False,
202        "like": False,
203        "where": False,
204        "db": False,
205        "scope": False,
206        "scope_kind": False,
207        "full": False,
208        "mutex": False,
209        "query": False,
210        "channel": False,
211        "global_": False,
212        "log": False,
213        "position": False,
214        "types": False,
215        "privileges": False,
216        "for_table": False,
217        "for_group": False,
218        "for_user": False,
219        "for_role": False,
220        "into_outfile": False,
221        "json": False,
222        "iceberg": False,
223    }
arg_types = {'this': True, 'history': False, 'terse': False, 'target': False, 'offset': False, 'starts_with': False, 'limit': False, 'from_': False, 'like': False, 'where': False, 'db': False, 'scope': False, 'scope_kind': False, 'full': False, 'mutex': False, 'query': False, 'channel': False, 'global_': False, 'log': False, 'position': False, 'types': False, 'privileges': False, 'for_table': False, 'for_group': False, 'for_user': False, 'for_role': False, 'into_outfile': False, 'json': False, 'iceberg': False}
key: ClassVar[str] = 'show'
required_args: 't.ClassVar[set[str]]' = {'this'}
class UserDefinedFunction(sqlglot.expressions.core.Expression):
226class UserDefinedFunction(Expression):
227    arg_types = {"this": True, "expressions": False, "wrapped": False}
arg_types = {'this': True, 'expressions': False, 'wrapped': False}
key: ClassVar[str] = 'userdefinedfunction'
required_args: 't.ClassVar[set[str]]' = {'this'}
class CharacterSet(sqlglot.expressions.core.Expression):
230class CharacterSet(Expression):
231    arg_types = {"this": True, "default": False}
arg_types = {'this': True, 'default': False}
key: ClassVar[str] = 'characterset'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterColumn(sqlglot.expressions.core.Expression):
234class AlterColumn(Expression):
235    arg_types = {
236        "this": True,
237        "dtype": False,
238        "collate": False,
239        "using": False,
240        "default": False,
241        "drop": False,
242        "comment": False,
243        "allow_null": False,
244        "visible": False,
245        "rename_to": False,
246    }
arg_types = {'this': True, 'dtype': False, 'collate': False, 'using': False, 'default': False, 'drop': False, 'comment': False, 'allow_null': False, 'visible': False, 'rename_to': False}
key: ClassVar[str] = 'altercolumn'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterIndex(sqlglot.expressions.core.Expression):
249class AlterIndex(Expression):
250    arg_types = {"this": True, "visible": True}
arg_types = {'this': True, 'visible': True}
key: ClassVar[str] = 'alterindex'
required_args: 't.ClassVar[set[str]]' = {'visible', 'this'}
class AlterDistStyle(sqlglot.expressions.core.Expression):
253class AlterDistStyle(Expression):
254    pass
key: ClassVar[str] = 'alterdiststyle'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterSortKey(sqlglot.expressions.core.Expression):
257class AlterSortKey(Expression):
258    arg_types = {"this": False, "expressions": False, "compound": False}
arg_types = {'this': False, 'expressions': False, 'compound': False}
key: ClassVar[str] = 'altersortkey'
required_args: 't.ClassVar[set[str]]' = set()
class AlterSet(sqlglot.expressions.core.Expression):
261class AlterSet(Expression):
262    arg_types = {
263        "expressions": False,
264        "option": False,
265        "tablespace": False,
266        "access_method": False,
267        "file_format": False,
268        "copy_options": False,
269        "tag": False,
270        "location": False,
271        "serde": False,
272    }
arg_types = {'expressions': False, 'option': False, 'tablespace': False, 'access_method': False, 'file_format': False, 'copy_options': False, 'tag': False, 'location': False, 'serde': False}
key: ClassVar[str] = 'alterset'
required_args: 't.ClassVar[set[str]]' = set()
class RenameColumn(sqlglot.expressions.core.Expression):
275class RenameColumn(Expression):
276    arg_types = {"this": True, "to": True, "exists": False}
arg_types = {'this': True, 'to': True, 'exists': False}
key: ClassVar[str] = 'renamecolumn'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
class AlterRename(sqlglot.expressions.core.Expression):
279class AlterRename(Expression):
280    pass
key: ClassVar[str] = 'alterrename'
required_args: 't.ClassVar[set[str]]' = {'this'}
class RenameIndex(sqlglot.expressions.core.Expression):
283class RenameIndex(Expression):
284    arg_types = {"this": True, "to": True}
arg_types = {'this': True, 'to': True}
key: ClassVar[str] = 'renameindex'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
class AlterModifySqlSecurity(sqlglot.expressions.core.Expression):
287class AlterModifySqlSecurity(Expression):
288    arg_types = {"expressions": True}
arg_types = {'expressions': True}
key: ClassVar[str] = 'altermodifysqlsecurity'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class SwapTable(sqlglot.expressions.core.Expression):
291class SwapTable(Expression):
292    pass
key: ClassVar[str] = 'swaptable'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Comment(sqlglot.expressions.core.Expression):
295class Comment(Expression):
296    arg_types = {
297        "this": True,
298        "kind": True,
299        "expression": True,
300        "exists": False,
301        "materialized": False,
302    }
arg_types = {'this': True, 'kind': True, 'expression': True, 'exists': False, 'materialized': False}
key: ClassVar[str] = 'comment'
required_args: 't.ClassVar[set[str]]' = {'kind', 'expression', 'this'}
class Comprehension(sqlglot.expressions.core.Expression):
305class Comprehension(Expression):
306    arg_types = {
307        "this": True,
308        "expression": True,
309        "position": False,
310        "iterator": True,
311        "condition": False,
312    }
arg_types = {'this': True, 'expression': True, 'position': False, 'iterator': True, 'condition': False}
key: ClassVar[str] = 'comprehension'
required_args: 't.ClassVar[set[str]]' = {'iterator', 'expression', 'this'}
class MergeTreeTTLAction(sqlglot.expressions.core.Expression):
315class MergeTreeTTLAction(Expression):
316    arg_types = {
317        "this": True,
318        "delete": False,
319        "recompress": False,
320        "to_disk": False,
321        "to_volume": False,
322    }
arg_types = {'this': True, 'delete': False, 'recompress': False, 'to_disk': False, 'to_volume': False}
key: ClassVar[str] = 'mergetreettlaction'
required_args: 't.ClassVar[set[str]]' = {'this'}
class MergeTreeTTL(sqlglot.expressions.core.Expression):
325class MergeTreeTTL(Expression):
326    arg_types = {
327        "expressions": True,
328        "where": False,
329        "group": False,
330        "aggregates": False,
331    }
arg_types = {'expressions': True, 'where': False, 'group': False, 'aggregates': False}
key: ClassVar[str] = 'mergetreettl'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class Drop(sqlglot.expressions.core.Expression):
334class Drop(Expression):
335    arg_types = {
336        "this": False,
337        "kind": False,
338        "expressions": False,
339        "exists": False,
340        "temporary": False,
341        "materialized": False,
342        "cascade": False,
343        "restrict": False,
344        "constraints": False,
345        "purge": False,
346        "cluster": False,
347        "concurrently": False,
348        "sync": False,
349        "iceberg": False,
350    }
351
352    @property
353    def kind(self) -> str | None:
354        kind = self.args.get("kind")
355        return kind and kind.upper()
arg_types = {'this': False, 'kind': False, 'expressions': False, 'exists': False, 'temporary': False, 'materialized': False, 'cascade': False, 'restrict': False, 'constraints': False, 'purge': False, 'cluster': False, 'concurrently': False, 'sync': False, 'iceberg': False}
kind: str | None
352    @property
353    def kind(self) -> str | None:
354        kind = self.args.get("kind")
355        return kind and kind.upper()
key: ClassVar[str] = 'drop'
required_args: 't.ClassVar[set[str]]' = set()
class Command(sqlglot.expressions.core.Expression):
358class Command(Expression):
359    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'command'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Transaction(sqlglot.expressions.core.Expression):
362class Transaction(Expression):
363    arg_types = {"this": False, "modes": False, "mark": False}
arg_types = {'this': False, 'modes': False, 'mark': False}
key: ClassVar[str] = 'transaction'
required_args: 't.ClassVar[set[str]]' = set()
class Commit(sqlglot.expressions.core.Expression):
366class Commit(Expression):
367    arg_types = {"chain": False, "this": False, "durability": False}
arg_types = {'chain': False, 'this': False, 'durability': False}
key: ClassVar[str] = 'commit'
required_args: 't.ClassVar[set[str]]' = set()
class Rollback(sqlglot.expressions.core.Expression):
370class Rollback(Expression):
371    arg_types = {"savepoint": False, "this": False}
arg_types = {'savepoint': False, 'this': False}
key: ClassVar[str] = 'rollback'
required_args: 't.ClassVar[set[str]]' = set()
class Alter(sqlglot.expressions.core.Expression):
374class Alter(Expression):
375    arg_types = {
376        "this": False,
377        "kind": True,
378        "actions": True,
379        "exists": False,
380        "only": False,
381        "options": False,
382        "cluster": False,
383        "not_valid": False,
384        "check": False,
385        "cascade": False,
386        "iceberg": False,
387    }
388
389    @property
390    def kind(self) -> str | None:
391        kind = self.args.get("kind")
392        return kind and kind.upper()
393
394    @property
395    def actions(self) -> list[Expr]:
396        return self.args.get("actions") or []
arg_types = {'this': False, 'kind': True, 'actions': True, 'exists': False, 'only': False, 'options': False, 'cluster': False, 'not_valid': False, 'check': False, 'cascade': False, 'iceberg': False}
kind: str | None
389    @property
390    def kind(self) -> str | None:
391        kind = self.args.get("kind")
392        return kind and kind.upper()
actions: list[sqlglot.expressions.core.Expr]
394    @property
395    def actions(self) -> list[Expr]:
396        return self.args.get("actions") or []
key: ClassVar[str] = 'alter'
required_args: 't.ClassVar[set[str]]' = {'actions', 'kind'}
class AlterSession(sqlglot.expressions.core.Expression):
399class AlterSession(Expression):
400    arg_types = {"expressions": True, "unset": False}
arg_types = {'expressions': True, 'unset': False}
key: ClassVar[str] = 'altersession'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class Use(sqlglot.expressions.core.Expression):
403class Use(Expression):
404    arg_types = {"this": False, "expressions": False, "kind": False}
arg_types = {'this': False, 'expressions': False, 'kind': False}
key: ClassVar[str] = 'use'
required_args: 't.ClassVar[set[str]]' = set()
407class NextValueFor(Expression, Func):
408    arg_types = {"this": True, "order": False}
arg_types = {'this': True, 'order': False}
key: ClassVar[str] = 'nextvaluefor'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Execute(sqlglot.expressions.core.Expression):
411class Execute(Expression):
412    arg_types = {"this": True, "expressions": False}
413
414    @property
415    def name(self) -> str:
416        return self.this.name
arg_types = {'this': True, 'expressions': False}
name: str
414    @property
415    def name(self) -> str:
416        return self.this.name
key: ClassVar[str] = 'execute'
required_args: 't.ClassVar[set[str]]' = {'this'}
class ExecuteSql(Execute):
419class ExecuteSql(Execute):
420    pass
key: ClassVar[str] = 'executesql'
required_args: 't.ClassVar[set[str]]' = {'this'}