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 ModifyColumn(Expression):
249    arg_types = {"this": True, "rename_from": False}
250
251
252class AlterIndex(Expression):
253    arg_types = {"this": True, "visible": True}
254
255
256class AlterDistStyle(Expression):
257    pass
258
259
260class AlterSortKey(Expression):
261    arg_types = {"this": False, "expressions": False, "compound": False}
262
263
264class AlterSet(Expression):
265    arg_types = {
266        "expressions": False,
267        "option": False,
268        "tablespace": False,
269        "access_method": False,
270        "file_format": False,
271        "copy_options": False,
272        "tag": False,
273        "location": False,
274        "serde": False,
275    }
276
277
278class RenameColumn(Expression):
279    arg_types = {"this": True, "to": True, "exists": False}
280
281
282class AlterRename(Expression):
283    pass
284
285
286class RenameIndex(Expression):
287    arg_types = {"this": True, "to": True}
288
289
290class AlterModifySqlSecurity(Expression):
291    arg_types = {"expressions": True}
292
293
294class SwapTable(Expression):
295    pass
296
297
298class Comment(Expression):
299    arg_types = {
300        "this": True,
301        "kind": True,
302        "expression": True,
303        "exists": False,
304        "materialized": False,
305    }
306
307
308class Comprehension(Expression):
309    arg_types = {
310        "this": True,
311        "expression": True,
312        "position": False,
313        "iterator": True,
314        "condition": False,
315    }
316
317
318class MergeTreeTTLAction(Expression):
319    arg_types = {
320        "this": True,
321        "delete": False,
322        "recompress": False,
323        "to_disk": False,
324        "to_volume": False,
325    }
326
327
328class MergeTreeTTL(Expression):
329    arg_types = {
330        "expressions": True,
331        "where": False,
332        "group": False,
333        "aggregates": False,
334    }
335
336
337class Drop(Expression):
338    arg_types = {
339        "this": False,
340        "kind": False,
341        "expressions": False,
342        "exists": False,
343        "temporary": False,
344        "materialized": False,
345        "cascade": False,
346        "restrict": False,
347        "constraints": False,
348        "purge": False,
349        "cluster": False,
350        "concurrently": False,
351        "sync": False,
352        "iceberg": False,
353    }
354
355    @property
356    def kind(self) -> str | None:
357        kind = self.args.get("kind")
358        return kind and kind.upper()
359
360
361class DropPrimaryKey(Expression):
362    arg_types = {}
363
364
365class Command(Expression):
366    arg_types = {"this": True, "expression": False}
367
368
369class Transaction(Expression):
370    arg_types = {"this": False, "modes": False, "mark": False}
371
372
373class Commit(Expression):
374    arg_types = {"chain": False, "this": False, "durability": False}
375
376
377class Rollback(Expression):
378    arg_types = {"savepoint": False, "this": False}
379
380
381class Alter(Expression):
382    arg_types = {
383        "this": False,
384        "kind": True,
385        "actions": True,
386        "exists": False,
387        "only": False,
388        "options": False,
389        "cluster": False,
390        "not_valid": False,
391        "check": False,
392        "cascade": False,
393        "iceberg": False,
394    }
395
396    @property
397    def kind(self) -> str | None:
398        kind = self.args.get("kind")
399        return kind and kind.upper()
400
401    @property
402    def actions(self) -> list[Expr]:
403        return self.args.get("actions") or []
404
405
406class AlterSession(Expression):
407    arg_types = {"expressions": True, "unset": False}
408
409
410class Use(Expression):
411    arg_types = {"this": False, "expressions": False, "kind": False}
412
413
414class NextValueFor(Expression, Func):
415    arg_types = {"this": True, "order": False}
416
417
418class Execute(Expression):
419    arg_types = {"this": True, "expressions": False}
420
421    @property
422    def name(self) -> str:
423        return self.this.name
424
425
426class ExecuteSql(Execute):
427    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', 'execute', 'timing'}
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 ModifyColumn(sqlglot.expressions.core.Expression):
249class ModifyColumn(Expression):
250    arg_types = {"this": True, "rename_from": False}
arg_types = {'this': True, 'rename_from': False}
key: ClassVar[str] = 'modifycolumn'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterIndex(sqlglot.expressions.core.Expression):
253class AlterIndex(Expression):
254    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):
257class AlterDistStyle(Expression):
258    pass
key: ClassVar[str] = 'alterdiststyle'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterSortKey(sqlglot.expressions.core.Expression):
261class AlterSortKey(Expression):
262    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):
265class AlterSet(Expression):
266    arg_types = {
267        "expressions": False,
268        "option": False,
269        "tablespace": False,
270        "access_method": False,
271        "file_format": False,
272        "copy_options": False,
273        "tag": False,
274        "location": False,
275        "serde": False,
276    }
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):
279class RenameColumn(Expression):
280    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):
283class AlterRename(Expression):
284    pass
key: ClassVar[str] = 'alterrename'
required_args: 't.ClassVar[set[str]]' = {'this'}
class RenameIndex(sqlglot.expressions.core.Expression):
287class RenameIndex(Expression):
288    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):
291class AlterModifySqlSecurity(Expression):
292    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):
295class SwapTable(Expression):
296    pass
key: ClassVar[str] = 'swaptable'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Comment(sqlglot.expressions.core.Expression):
299class Comment(Expression):
300    arg_types = {
301        "this": True,
302        "kind": True,
303        "expression": True,
304        "exists": False,
305        "materialized": False,
306    }
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):
309class Comprehension(Expression):
310    arg_types = {
311        "this": True,
312        "expression": True,
313        "position": False,
314        "iterator": True,
315        "condition": False,
316    }
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):
319class MergeTreeTTLAction(Expression):
320    arg_types = {
321        "this": True,
322        "delete": False,
323        "recompress": False,
324        "to_disk": False,
325        "to_volume": False,
326    }
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):
329class MergeTreeTTL(Expression):
330    arg_types = {
331        "expressions": True,
332        "where": False,
333        "group": False,
334        "aggregates": False,
335    }
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):
338class Drop(Expression):
339    arg_types = {
340        "this": False,
341        "kind": False,
342        "expressions": False,
343        "exists": False,
344        "temporary": False,
345        "materialized": False,
346        "cascade": False,
347        "restrict": False,
348        "constraints": False,
349        "purge": False,
350        "cluster": False,
351        "concurrently": False,
352        "sync": False,
353        "iceberg": False,
354    }
355
356    @property
357    def kind(self) -> str | None:
358        kind = self.args.get("kind")
359        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
356    @property
357    def kind(self) -> str | None:
358        kind = self.args.get("kind")
359        return kind and kind.upper()
key: ClassVar[str] = 'drop'
required_args: 't.ClassVar[set[str]]' = set()
class DropPrimaryKey(sqlglot.expressions.core.Expression):
362class DropPrimaryKey(Expression):
363    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'dropprimarykey'
required_args: 't.ClassVar[set[str]]' = set()
class Command(sqlglot.expressions.core.Expression):
366class Command(Expression):
367    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):
370class Transaction(Expression):
371    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):
374class Commit(Expression):
375    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):
378class Rollback(Expression):
379    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):
382class Alter(Expression):
383    arg_types = {
384        "this": False,
385        "kind": True,
386        "actions": True,
387        "exists": False,
388        "only": False,
389        "options": False,
390        "cluster": False,
391        "not_valid": False,
392        "check": False,
393        "cascade": False,
394        "iceberg": False,
395    }
396
397    @property
398    def kind(self) -> str | None:
399        kind = self.args.get("kind")
400        return kind and kind.upper()
401
402    @property
403    def actions(self) -> list[Expr]:
404        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
397    @property
398    def kind(self) -> str | None:
399        kind = self.args.get("kind")
400        return kind and kind.upper()
actions: list[sqlglot.expressions.core.Expr]
402    @property
403    def actions(self) -> list[Expr]:
404        return self.args.get("actions") or []
key: ClassVar[str] = 'alter'
required_args: 't.ClassVar[set[str]]' = {'kind', 'actions'}
class AlterSession(sqlglot.expressions.core.Expression):
407class AlterSession(Expression):
408    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):
411class Use(Expression):
412    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()
415class NextValueFor(Expression, Func):
416    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):
419class Execute(Expression):
420    arg_types = {"this": True, "expressions": False}
421
422    @property
423    def name(self) -> str:
424        return self.this.name
arg_types = {'this': True, 'expressions': False}
name: str
422    @property
423    def name(self) -> str:
424        return self.this.name
key: ClassVar[str] = 'execute'
required_args: 't.ClassVar[set[str]]' = {'this'}
class ExecuteSql(Execute):
427class ExecuteSql(Execute):
428    pass
key: ClassVar[str] = 'executesql'
required_args: 't.ClassVar[set[str]]' = {'this'}