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 ConnectTo(Expression):
135    pass
136
137
138class Disconnect(Expression):
139    arg_types = {}
140
141
142class Attach(Expression):
143    arg_types = {"this": True, "exists": False, "expressions": False}
144
145
146class Detach(Expression):
147    arg_types = {
148        "this": True,
149        "kind": False,
150        "exists": False,
151        "cluster": False,
152        "permanent": False,
153        "sync": False,
154    }
155
156
157class Install(Expression):
158    arg_types = {"this": True, "from_": False, "force": False}
159
160
161class Summarize(Expression):
162    arg_types = {"this": True, "table": False}
163
164
165class Kill(Expression):
166    arg_types = {"this": True, "kind": False}
167
168
169class Pragma(Expression):
170    pass
171
172
173class Declare(Expression):
174    arg_types = {"expressions": True, "replace": False}
175
176
177class DeclareItem(Expression):
178    arg_types = {"this": True, "kind": False, "default": False}
179
180
181class Set(Expression):
182    arg_types = {"expressions": False, "unset": False, "tag": False}
183
184
185class Heredoc(Expression):
186    arg_types = {"this": True, "tag": False}
187    _hash_raw_args = True
188
189
190class SetItem(Expression):
191    arg_types = {
192        "this": False,
193        "expressions": False,
194        "kind": False,
195        "collate": False,  # MySQL SET NAMES statement
196        "global_": False,
197    }
198
199
200class Show(Expression):
201    arg_types = {
202        "this": True,
203        "history": False,
204        "terse": False,
205        "target": False,
206        "offset": False,
207        "starts_with": False,
208        "limit": False,
209        "from_": False,
210        "like": False,
211        "where": False,
212        "db": False,
213        "scope": False,
214        "scope_kind": False,
215        "full": False,
216        "mutex": False,
217        "query": False,
218        "channel": False,
219        "global_": False,
220        "log": False,
221        "position": False,
222        "types": False,
223        "privileges": False,
224        "for_table": False,
225        "for_group": False,
226        "for_user": False,
227        "for_role": False,
228        "into_outfile": False,
229        "json": False,
230        "iceberg": False,
231    }
232
233
234class UserDefinedFunction(Expression):
235    arg_types = {"this": True, "expressions": False, "wrapped": False}
236
237
238class MacroOverloads(Expression):
239    arg_types = {"expressions": True}
240
241
242class MacroOverload(Expression):
243    arg_types = {"this": True, "expressions": False, "is_table": False}
244
245
246class CharacterSet(Expression):
247    arg_types = {"this": True, "default": False}
248
249
250class AlterColumn(Expression):
251    arg_types = {
252        "this": True,
253        "dtype": False,
254        "collate": False,
255        "using": False,
256        "default": False,
257        "drop": False,
258        "comment": False,
259        "allow_null": False,
260        "visible": False,
261        "rename_to": False,
262        "exists": False,
263    }
264
265
266class ModifyColumn(Expression):
267    arg_types = {"this": True, "rename_from": False}
268
269
270class AlterIndex(Expression):
271    arg_types = {"this": True, "visible": True}
272
273
274class AlterDistStyle(Expression):
275    pass
276
277
278class AlterSortKey(Expression):
279    arg_types = {"this": False, "expressions": False, "compound": False}
280
281
282class AlterSet(Expression):
283    arg_types = {
284        "expressions": False,
285        "option": False,
286        "tablespace": False,
287        "access_method": False,
288        "file_format": False,
289        "copy_options": False,
290        "tag": False,
291        "location": False,
292        "serde": False,
293    }
294
295
296class RenameColumn(Expression):
297    arg_types = {"this": True, "to": True, "exists": False}
298
299
300class AlterRename(Expression):
301    pass
302
303
304class RenameIndex(Expression):
305    arg_types = {"this": True, "to": True}
306
307
308class AlterModifySqlSecurity(Expression):
309    arg_types = {"expressions": True}
310
311
312class SwapTable(Expression):
313    pass
314
315
316class Comment(Expression):
317    arg_types = {
318        "this": True,
319        "kind": True,
320        "expression": True,
321        "exists": False,
322        "materialized": False,
323    }
324
325
326class Comprehension(Expression):
327    arg_types = {
328        "this": True,
329        "expression": True,
330        "position": False,
331        "iterator": True,
332        "condition": False,
333    }
334
335
336class MergeTreeTTLAction(Expression):
337    arg_types = {
338        "this": True,
339        "delete": False,
340        "recompress": False,
341        "to_disk": False,
342        "to_volume": False,
343    }
344
345
346class MergeTreeTTL(Expression):
347    arg_types = {
348        "expressions": True,
349        "where": False,
350        "group": False,
351        "aggregates": False,
352    }
353
354
355class Drop(Expression):
356    arg_types = {
357        "kind": False,
358        "tables": False,
359        "expressions": False,
360        "exists": False,
361        "temporary": False,
362        "materialized": False,
363        "cascade": False,
364        "restrict": False,
365        "constraints": False,
366        "purge": False,
367        "cluster": False,
368        "concurrently": False,
369        "sync": False,
370        "iceberg": False,
371        "force": False,
372    }
373
374    @property
375    def kind(self) -> str | None:
376        kind = self.args.get("kind")
377        return kind and kind.upper()
378
379
380class DropPrimaryKey(Expression):
381    arg_types = {}
382
383
384class Undrop(Expression):
385    arg_types = {"this": True, "kind": True, "rename": False}
386
387    @property
388    def kind(self) -> str:
389        return self.args["kind"].upper()
390
391
392class Command(Expression):
393    arg_types = {"this": True, "expression": False}
394    _hash_raw_args = True
395
396
397class Transaction(Expression):
398    arg_types = {"this": False, "modes": False, "mark": False}
399
400
401class Commit(Expression):
402    arg_types = {"chain": False, "this": False, "durability": False}
403
404
405class Rollback(Expression):
406    arg_types = {"savepoint": False, "this": False}
407
408
409class Alter(Expression):
410    arg_types = {
411        "this": False,
412        "kind": True,
413        "actions": False,
414        "exists": False,
415        "only": False,
416        "options": False,
417        "cluster": False,
418        "not_valid": False,
419        "check": False,
420        "cascade": False,
421        "iceberg": False,
422    }
423
424    @property
425    def kind(self) -> str | None:
426        kind = self.args.get("kind")
427        return kind and kind.upper()
428
429    @property
430    def actions(self) -> list[Expr]:
431        return self.args.get("actions") or []
432
433
434class AlterSession(Expression):
435    arg_types = {"expressions": True, "unset": False}
436
437
438class Use(Expression):
439    arg_types = {"this": False, "expressions": False, "kind": False}
440
441
442class NextValueFor(Expression, Func):
443    arg_types = {"this": True, "order": False}
444
445
446class Execute(Expression):
447    arg_types = {"this": True, "expressions": False, "return_status": False}
448
449    @property
450    def name(self) -> str:
451        return self.this.name
452
453
454class ExecuteSql(Execute):
455    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 ConnectTo(sqlglot.expressions.core.Expression):
135class ConnectTo(Expression):
136    pass
key: ClassVar[str] = 'connectto'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Disconnect(sqlglot.expressions.core.Expression):
139class Disconnect(Expression):
140    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'disconnect'
required_args: 't.ClassVar[set[str]]' = set()
class Attach(sqlglot.expressions.core.Expression):
143class Attach(Expression):
144    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):
147class Detach(Expression):
148    arg_types = {
149        "this": True,
150        "kind": False,
151        "exists": False,
152        "cluster": False,
153        "permanent": False,
154        "sync": False,
155    }
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):
158class Install(Expression):
159    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):
162class Summarize(Expression):
163    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):
166class Kill(Expression):
167    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):
170class Pragma(Expression):
171    pass
key: ClassVar[str] = 'pragma'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Declare(sqlglot.expressions.core.Expression):
174class Declare(Expression):
175    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):
178class DeclareItem(Expression):
179    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):
182class Set(Expression):
183    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):
186class Heredoc(Expression):
187    arg_types = {"this": True, "tag": False}
188    _hash_raw_args = True
arg_types = {'this': True, 'tag': False}
key: ClassVar[str] = 'heredoc'
required_args: 't.ClassVar[set[str]]' = {'this'}
class SetItem(sqlglot.expressions.core.Expression):
191class SetItem(Expression):
192    arg_types = {
193        "this": False,
194        "expressions": False,
195        "kind": False,
196        "collate": False,  # MySQL SET NAMES statement
197        "global_": False,
198    }
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):
201class Show(Expression):
202    arg_types = {
203        "this": True,
204        "history": False,
205        "terse": False,
206        "target": False,
207        "offset": False,
208        "starts_with": False,
209        "limit": False,
210        "from_": False,
211        "like": False,
212        "where": False,
213        "db": False,
214        "scope": False,
215        "scope_kind": False,
216        "full": False,
217        "mutex": False,
218        "query": False,
219        "channel": False,
220        "global_": False,
221        "log": False,
222        "position": False,
223        "types": False,
224        "privileges": False,
225        "for_table": False,
226        "for_group": False,
227        "for_user": False,
228        "for_role": False,
229        "into_outfile": False,
230        "json": False,
231        "iceberg": False,
232    }
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):
235class UserDefinedFunction(Expression):
236    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 MacroOverloads(sqlglot.expressions.core.Expression):
239class MacroOverloads(Expression):
240    arg_types = {"expressions": True}
arg_types = {'expressions': True}
key: ClassVar[str] = 'macrooverloads'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
class MacroOverload(sqlglot.expressions.core.Expression):
243class MacroOverload(Expression):
244    arg_types = {"this": True, "expressions": False, "is_table": False}
arg_types = {'this': True, 'expressions': False, 'is_table': False}
key: ClassVar[str] = 'macrooverload'
required_args: 't.ClassVar[set[str]]' = {'this'}
class CharacterSet(sqlglot.expressions.core.Expression):
247class CharacterSet(Expression):
248    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):
251class AlterColumn(Expression):
252    arg_types = {
253        "this": True,
254        "dtype": False,
255        "collate": False,
256        "using": False,
257        "default": False,
258        "drop": False,
259        "comment": False,
260        "allow_null": False,
261        "visible": False,
262        "rename_to": False,
263        "exists": False,
264    }
arg_types = {'this': True, 'dtype': False, 'collate': False, 'using': False, 'default': False, 'drop': False, 'comment': False, 'allow_null': False, 'visible': False, 'rename_to': False, 'exists': False}
key: ClassVar[str] = 'altercolumn'
required_args: 't.ClassVar[set[str]]' = {'this'}
class ModifyColumn(sqlglot.expressions.core.Expression):
267class ModifyColumn(Expression):
268    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):
271class AlterIndex(Expression):
272    arg_types = {"this": True, "visible": True}
arg_types = {'this': True, 'visible': True}
key: ClassVar[str] = 'alterindex'
required_args: 't.ClassVar[set[str]]' = {'this', 'visible'}
class AlterDistStyle(sqlglot.expressions.core.Expression):
275class AlterDistStyle(Expression):
276    pass
key: ClassVar[str] = 'alterdiststyle'
required_args: 't.ClassVar[set[str]]' = {'this'}
class AlterSortKey(sqlglot.expressions.core.Expression):
279class AlterSortKey(Expression):
280    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):
283class AlterSet(Expression):
284    arg_types = {
285        "expressions": False,
286        "option": False,
287        "tablespace": False,
288        "access_method": False,
289        "file_format": False,
290        "copy_options": False,
291        "tag": False,
292        "location": False,
293        "serde": False,
294    }
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):
297class RenameColumn(Expression):
298    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]]' = {'this', 'to'}
class AlterRename(sqlglot.expressions.core.Expression):
301class AlterRename(Expression):
302    pass
key: ClassVar[str] = 'alterrename'
required_args: 't.ClassVar[set[str]]' = {'this'}
class RenameIndex(sqlglot.expressions.core.Expression):
305class RenameIndex(Expression):
306    arg_types = {"this": True, "to": True}
arg_types = {'this': True, 'to': True}
key: ClassVar[str] = 'renameindex'
required_args: 't.ClassVar[set[str]]' = {'this', 'to'}
class AlterModifySqlSecurity(sqlglot.expressions.core.Expression):
309class AlterModifySqlSecurity(Expression):
310    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):
313class SwapTable(Expression):
314    pass
key: ClassVar[str] = 'swaptable'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Comment(sqlglot.expressions.core.Expression):
317class Comment(Expression):
318    arg_types = {
319        "this": True,
320        "kind": True,
321        "expression": True,
322        "exists": False,
323        "materialized": False,
324    }
arg_types = {'this': True, 'kind': True, 'expression': True, 'exists': False, 'materialized': False}
key: ClassVar[str] = 'comment'
required_args: 't.ClassVar[set[str]]' = {'kind', 'this', 'expression'}
class Comprehension(sqlglot.expressions.core.Expression):
327class Comprehension(Expression):
328    arg_types = {
329        "this": True,
330        "expression": True,
331        "position": False,
332        "iterator": True,
333        "condition": False,
334    }
arg_types = {'this': True, 'expression': True, 'position': False, 'iterator': True, 'condition': False}
key: ClassVar[str] = 'comprehension'
required_args: 't.ClassVar[set[str]]' = {'this', 'iterator', 'expression'}
class MergeTreeTTLAction(sqlglot.expressions.core.Expression):
337class MergeTreeTTLAction(Expression):
338    arg_types = {
339        "this": True,
340        "delete": False,
341        "recompress": False,
342        "to_disk": False,
343        "to_volume": False,
344    }
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):
347class MergeTreeTTL(Expression):
348    arg_types = {
349        "expressions": True,
350        "where": False,
351        "group": False,
352        "aggregates": False,
353    }
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):
356class Drop(Expression):
357    arg_types = {
358        "kind": False,
359        "tables": False,
360        "expressions": False,
361        "exists": False,
362        "temporary": False,
363        "materialized": False,
364        "cascade": False,
365        "restrict": False,
366        "constraints": False,
367        "purge": False,
368        "cluster": False,
369        "concurrently": False,
370        "sync": False,
371        "iceberg": False,
372        "force": False,
373    }
374
375    @property
376    def kind(self) -> str | None:
377        kind = self.args.get("kind")
378        return kind and kind.upper()
arg_types = {'kind': False, 'tables': 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, 'force': False}
kind: str | None
375    @property
376    def kind(self) -> str | None:
377        kind = self.args.get("kind")
378        return kind and kind.upper()
key: ClassVar[str] = 'drop'
required_args: 't.ClassVar[set[str]]' = set()
class DropPrimaryKey(sqlglot.expressions.core.Expression):
381class DropPrimaryKey(Expression):
382    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'dropprimarykey'
required_args: 't.ClassVar[set[str]]' = set()
class Undrop(sqlglot.expressions.core.Expression):
385class Undrop(Expression):
386    arg_types = {"this": True, "kind": True, "rename": False}
387
388    @property
389    def kind(self) -> str:
390        return self.args["kind"].upper()
arg_types = {'this': True, 'kind': True, 'rename': False}
kind: str
388    @property
389    def kind(self) -> str:
390        return self.args["kind"].upper()
key: ClassVar[str] = 'undrop'
required_args: 't.ClassVar[set[str]]' = {'kind', 'this'}
class Command(sqlglot.expressions.core.Expression):
393class Command(Expression):
394    arg_types = {"this": True, "expression": False}
395    _hash_raw_args = True
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'command'
required_args: 't.ClassVar[set[str]]' = {'this'}
class Transaction(sqlglot.expressions.core.Expression):
398class Transaction(Expression):
399    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):
402class Commit(Expression):
403    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):
406class Rollback(Expression):
407    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):
410class Alter(Expression):
411    arg_types = {
412        "this": False,
413        "kind": True,
414        "actions": False,
415        "exists": False,
416        "only": False,
417        "options": False,
418        "cluster": False,
419        "not_valid": False,
420        "check": False,
421        "cascade": False,
422        "iceberg": False,
423    }
424
425    @property
426    def kind(self) -> str | None:
427        kind = self.args.get("kind")
428        return kind and kind.upper()
429
430    @property
431    def actions(self) -> list[Expr]:
432        return self.args.get("actions") or []
arg_types = {'this': False, 'kind': True, 'actions': False, 'exists': False, 'only': False, 'options': False, 'cluster': False, 'not_valid': False, 'check': False, 'cascade': False, 'iceberg': False}
kind: str | None
425    @property
426    def kind(self) -> str | None:
427        kind = self.args.get("kind")
428        return kind and kind.upper()
actions: list[sqlglot.expressions.core.Expr]
430    @property
431    def actions(self) -> list[Expr]:
432        return self.args.get("actions") or []
key: ClassVar[str] = 'alter'
required_args: 't.ClassVar[set[str]]' = {'kind'}
class AlterSession(sqlglot.expressions.core.Expression):
435class AlterSession(Expression):
436    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):
439class Use(Expression):
440    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()
443class NextValueFor(Expression, Func):
444    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):
447class Execute(Expression):
448    arg_types = {"this": True, "expressions": False, "return_status": False}
449
450    @property
451    def name(self) -> str:
452        return self.this.name
arg_types = {'this': True, 'expressions': False, 'return_status': False}
name: str
450    @property
451    def name(self) -> str:
452        return self.this.name
key: ClassVar[str] = 'execute'
required_args: 't.ClassVar[set[str]]' = {'this'}
class ExecuteSql(Execute):
455class ExecuteSql(Execute):
456    pass
key: ClassVar[str] = 'executesql'
required_args: 't.ClassVar[set[str]]' = {'this'}