Edit on GitHub

sqlglot expressions functions.

  1"""sqlglot expressions functions."""
  2
  3from __future__ import annotations
  4
  5import typing as t
  6
  7from sqlglot.expressions.core import (
  8    Expression,
  9    Func,
 10    Binary,
 11    SubqueryPredicate,
 12    ExpOrStr,
 13    maybe_parse,
 14    maybe_copy,
 15)
 16
 17# Re-export from focused submodules (backward compatibility)
 18from sqlglot.expressions.math import *  # noqa: F401,F403
 19from sqlglot.expressions.string import *  # noqa: F401,F403
 20from sqlglot.expressions.temporal import *  # noqa: F401,F403
 21from sqlglot.expressions.aggregate import *  # noqa: F401,F403
 22from sqlglot.expressions.array import *  # noqa: F401,F403
 23from sqlglot.expressions.json import *  # noqa: F401,F403
 24
 25if t.TYPE_CHECKING:
 26    from sqlglot.expressions.datatypes import DataType, DATA_TYPE
 27    from typing_extensions import Unpack
 28    from sqlglot._typing import ParserArgs
 29
 30
 31# Cast / type conversion
 32
 33
 34class Cast(Expression, Func):
 35    is_cast: t.ClassVar[bool] = True
 36    arg_types = {
 37        "this": True,
 38        "to": True,
 39        "format": False,
 40        "safe": False,
 41        "action": False,
 42        "default": False,
 43    }
 44
 45    @property
 46    def name(self) -> str:
 47        return self.this.name
 48
 49    @property
 50    def to(self) -> DataType:
 51        return self.args["to"]
 52
 53    @property
 54    def output_name(self) -> str:
 55        return self.name
 56
 57    def is_type(self, *dtypes: DATA_TYPE) -> bool:
 58        """
 59        Checks whether this Cast's DataType matches one of the provided data types. Nested types
 60        like arrays or structs will be compared using "structural equivalence" semantics, so e.g.
 61        array<int> != array<float>.
 62
 63        Args:
 64            dtypes: the data types to compare this Cast's DataType to.
 65
 66        Returns:
 67            True, if and only if there is a type in `dtypes` which is equal to this Cast's DataType.
 68        """
 69        return self.to.is_type(*dtypes)
 70
 71
 72class TryCast(Cast):
 73    arg_types = {**Cast.arg_types, "requires_string": False}
 74
 75
 76class JSONCast(Cast):
 77    pass
 78
 79
 80class CastToStrType(Expression, Func):
 81    arg_types = {"this": True, "to": True}
 82
 83
 84class Convert(Expression, Func):
 85    arg_types = {"this": True, "expression": True, "style": False, "safe": False}
 86
 87
 88# Conditional
 89
 90
 91class If(Expression, Func):
 92    arg_types = {"this": True, "true": True, "false": False}
 93    _sql_names = ["IF", "IIF"]
 94
 95
 96class Case(Expression, Func):
 97    arg_types = {"this": False, "ifs": True, "default": False}
 98
 99    def when(
100        self,
101        condition: ExpOrStr,
102        then: ExpOrStr,
103        copy: bool = True,
104        **opts: Unpack[ParserArgs],
105    ) -> Case:
106        instance = maybe_copy(self, copy)
107        instance.append(
108            "ifs",
109            If(
110                this=maybe_parse(condition, copy=copy, **opts),
111                true=maybe_parse(then, copy=copy, **opts),
112            ),
113        )
114        return instance
115
116    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
117        instance = maybe_copy(self, copy)
118        instance.set("default", maybe_parse(condition, copy=copy, **opts))
119        return instance
120
121
122class Coalesce(Expression, Func):
123    arg_types = {"this": True, "expressions": False, "is_nvl": False, "is_null": False}
124    is_var_len_args = True
125    _sql_names = ["COALESCE", "IFNULL", "NVL"]
126
127
128class DecodeCase(Expression, Func):
129    arg_types = {"expressions": True}
130    is_var_len_args = True
131
132
133class EqualNull(Expression, Func):
134    arg_types = {"this": True, "expression": True}
135
136
137class Greatest(Expression, Func):
138    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
139    is_var_len_args = True
140
141
142class Least(Expression, Func):
143    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
144    is_var_len_args = True
145
146
147class Nullif(Expression, Func):
148    arg_types = {"this": True, "expression": True}
149
150
151class Nvl2(Expression, Func):
152    arg_types = {"this": True, "true": True, "false": False}
153
154
155class Try(Expression, Func):
156    pass
157
158
159# Predicates / misc functions
160
161
162class Collate(Expression, Binary, Func):
163    pass
164
165
166class Collation(Expression, Func):
167    pass
168
169
170class ConnectByRoot(Expression, Func):
171    pass
172
173
174class CheckXml(Expression, Func):
175    arg_types = {"this": True, "disable_auto_convert": False}
176
177
178class Exists(Expression, Func, SubqueryPredicate):
179    arg_types = {"this": True, "expression": False}
180
181
182# Type coercions / lax types
183
184
185class Float64(Expression, Func):
186    arg_types = {"this": True, "expression": False}
187
188
189class Int64(Expression, Func):
190    pass
191
192
193class IsArray(Expression, Func):
194    pass
195
196
197class IsNullValue(Expression, Func):
198    pass
199
200
201class LaxBool(Expression, Func):
202    pass
203
204
205class LaxFloat64(Expression, Func):
206    pass
207
208
209class LaxInt64(Expression, Func):
210    pass
211
212
213class LaxString(Expression, Func):
214    pass
215
216
217class ToBoolean(Expression, Func):
218    arg_types = {"this": True, "safe": False}
219
220
221class ToVariant(Expression, Func):
222    pass
223
224
225# Session / context functions
226
227
228class CurrentAccount(Expression, Func):
229    arg_types = {}
230
231
232class CurrentAccountName(Expression, Func):
233    arg_types = {}
234
235
236class CurrentAvailableRoles(Expression, Func):
237    arg_types = {}
238
239
240class CurrentCatalog(Expression, Func):
241    arg_types = {}
242
243
244class CurrentClient(Expression, Func):
245    arg_types = {}
246
247
248class CurrentDatabase(Expression, Func):
249    arg_types = {}
250
251
252class CurrentIpAddress(Expression, Func):
253    arg_types = {}
254
255
256class CurrentOrganizationName(Expression, Func):
257    arg_types = {}
258
259
260class CurrentOrganizationUser(Expression, Func):
261    arg_types = {}
262
263
264class CurrentRegion(Expression, Func):
265    arg_types = {}
266
267
268class CurrentRole(Expression, Func):
269    arg_types = {}
270
271
272class CurrentRoleType(Expression, Func):
273    arg_types = {}
274
275
276class CurrentSchema(Expression, Func):
277    arg_types = {"this": False}
278
279
280class CurrentSchemas(Expression, Func):
281    arg_types = {"this": False}
282
283
284class CurrentSecondaryRoles(Expression, Func):
285    arg_types = {}
286
287
288class CurrentSession(Expression, Func):
289    arg_types = {}
290
291
292class CurrentStatement(Expression, Func):
293    arg_types = {}
294
295
296class CurrentTransaction(Expression, Func):
297    arg_types = {}
298
299
300class CurrentUser(Expression, Func):
301    arg_types = {"this": False}
302
303
304class CurrentVersion(Expression, Func):
305    arg_types = {}
306
307
308class CurrentWarehouse(Expression, Func):
309    arg_types = {}
310
311
312class SessionUser(Expression, Func):
313    arg_types = {}
314
315
316# ML / AI
317
318
319class AIClassify(Expression, Func):
320    arg_types = {"this": True, "categories": True, "config": False}
321    _sql_names = ["AI_CLASSIFY"]
322
323
324class AIEmbed(Expression, Func):
325    arg_types = {"expressions": True}
326    is_var_len_args = True
327    _sql_names = ["AI_EMBED"]
328
329
330class AISimilarity(Expression, Func):
331    arg_types = {"expressions": True}
332    is_var_len_args = True
333    _sql_names = ["AI_SIMILARITY"]
334
335
336class AIGenerate(Expression, Func):
337    arg_types = {"expressions": True}
338    is_var_len_args = True
339    _sql_names = ["AI_GENERATE"]
340
341
342class FeaturesAtTime(Expression, Func):
343    arg_types = {"this": True, "time": False, "num_rows": False, "ignore_feature_nulls": False}
344
345
346class GenerateEmbedding(Expression, Func):
347    arg_types = {"this": True, "expression": True, "params_struct": False, "is_text": False}
348
349
350class GenerateText(Expression, Func):
351    arg_types = {"this": True, "expression": False, "params_struct": False}
352
353
354class GenerateTable(Expression, Func):
355    arg_types = {"this": True, "expression": False, "params_struct": False}
356
357
358class GenerateBool(Expression, Func):
359    arg_types = {"this": True, "expression": False, "params_struct": False}
360
361
362class GenerateInt(Expression, Func):
363    arg_types = {"this": True, "expression": False, "params_struct": False}
364
365
366class GenerateDouble(Expression, Func):
367    arg_types = {"this": True, "expression": False, "params_struct": False}
368
369
370class MLForecast(Expression, Func):
371    arg_types = {"this": True, "expression": False, "params_struct": False}
372
373
374class AIForecast(Expression, Func):
375    arg_types = {
376        "this": True,
377        "data_col": False,
378        "timestamp_col": False,
379        "model": False,
380        "id_cols": False,
381        "horizon": False,
382        "forecast_end_timestamp": False,
383        "confidence_level": False,
384        "output_historical_time_series": False,
385        "context_window": False,
386    }
387
388
389class MLTranslate(Expression, Func):
390    arg_types = {"this": True, "expression": True, "params_struct": True}
391
392
393class Predict(Expression, Func):
394    arg_types = {"this": True, "expression": True, "params_struct": False}
395
396
397class VectorSearch(Expression, Func):
398    arg_types = {
399        "this": True,
400        "column_to_search": True,
401        "query_table": True,
402        "query_column_to_search": False,
403        "top_k": False,
404        "distance_type": False,
405        "options": False,
406    }
407
408
409# Data reading
410
411
412class ReadCSV(Expression, Func):
413    _sql_names = ["READ_CSV"]
414    is_var_len_args = True
415    arg_types = {"this": True, "expressions": False}
416
417
418class ReadParquet(Expression, Func):
419    is_var_len_args = True
420    arg_types = {"expressions": True}
421
422
423# XML
424
425
426class XMLElement(Expression, Func):
427    _sql_names = ["XMLELEMENT"]
428    arg_types = {"this": True, "expressions": False, "evalname": False}
429
430
431class XMLGet(Expression, Func):
432    _sql_names = ["XMLGET"]
433    arg_types = {"this": True, "expression": True, "instance": False}
434
435
436class XMLTable(Expression, Func):
437    arg_types = {
438        "this": True,
439        "namespaces": False,
440        "passing": False,
441        "columns": False,
442        "by_ref": False,
443    }
444
445
446# Network / domain
447
448
449class Host(Expression, Func):
450    pass
451
452
453class NetFunc(Expression, Func):
454    pass
455
456
457class ParseIp(Expression, Func):
458    arg_types = {"this": True, "type": True, "permissive": False}
459
460
461class RegDomain(Expression, Func):
462    pass
463
464
465# Misc utility
466
467
468class Columns(Expression, Func):
469    arg_types = {"this": True, "unpack": False}
470
471
472class Normal(Expression, Func):
473    arg_types = {"this": True, "stddev": True, "gen": True}
474
475
476class Rand(Expression, Func):
477    _sql_names = ["RAND", "RANDOM"]
478    arg_types = {"this": False, "lower": False, "upper": False}
479
480
481class Randn(Expression, Func):
482    arg_types = {"this": False}
483
484
485class Randstr(Expression, Func):
486    arg_types = {"this": True, "generator": False}
487
488
489class RangeBucket(Expression, Func):
490    arg_types = {"this": True, "expression": True}
491
492
493class RangeN(Expression, Func):
494    arg_types = {"this": True, "expressions": True, "each": False}
495
496
497class Seq1(Expression, Func):
498    arg_types = {"this": False}
499
500
501class Seq2(Expression, Func):
502    arg_types = {"this": False}
503
504
505class Seq4(Expression, Func):
506    arg_types = {"this": False}
507
508
509class Seq8(Expression, Func):
510    arg_types = {"this": False}
511
512
513class Uniform(Expression, Func):
514    arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
515
516
517class Uuid(Expression, Func):
518    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
519
520    arg_types = {"this": False, "name": False, "is_string": False}
521
522
523class WeekStart(Expression, Func):
524    pass
525
526
527class WidthBucket(Expression, Func):
528    arg_types = {
529        "this": True,
530        "min_value": False,
531        "max_value": False,
532        "num_buckets": False,
533        "threshold": False,
534    }
535
536
537class Zipf(Expression, Func):
538    arg_types = {"this": True, "elementcount": True, "gen": True}
35class Cast(Expression, Func):
36    is_cast: t.ClassVar[bool] = True
37    arg_types = {
38        "this": True,
39        "to": True,
40        "format": False,
41        "safe": False,
42        "action": False,
43        "default": False,
44    }
45
46    @property
47    def name(self) -> str:
48        return self.this.name
49
50    @property
51    def to(self) -> DataType:
52        return self.args["to"]
53
54    @property
55    def output_name(self) -> str:
56        return self.name
57
58    def is_type(self, *dtypes: DATA_TYPE) -> bool:
59        """
60        Checks whether this Cast's DataType matches one of the provided data types. Nested types
61        like arrays or structs will be compared using "structural equivalence" semantics, so e.g.
62        array<int> != array<float>.
63
64        Args:
65            dtypes: the data types to compare this Cast's DataType to.
66
67        Returns:
68            True, if and only if there is a type in `dtypes` which is equal to this Cast's DataType.
69        """
70        return self.to.is_type(*dtypes)
is_cast: ClassVar[bool] = True
arg_types = {'this': True, 'to': True, 'format': False, 'safe': False, 'action': False, 'default': False}
name: str
46    @property
47    def name(self) -> str:
48        return self.this.name
50    @property
51    def to(self) -> DataType:
52        return self.args["to"]
output_name: str
54    @property
55    def output_name(self) -> str:
56        return self.name

Name of the output column if this expression is a selection.

If the Expr has no output name, an empty string is returned.

Example:
>>> from sqlglot import parse_one
>>> parse_one("SELECT a").expressions[0].output_name
'a'
>>> parse_one("SELECT b AS c").expressions[0].output_name
'c'
>>> parse_one("SELECT 1 + 2").expressions[0].output_name
''
58    def is_type(self, *dtypes: DATA_TYPE) -> bool:
59        """
60        Checks whether this Cast's DataType matches one of the provided data types. Nested types
61        like arrays or structs will be compared using "structural equivalence" semantics, so e.g.
62        array<int> != array<float>.
63
64        Args:
65            dtypes: the data types to compare this Cast's DataType to.
66
67        Returns:
68            True, if and only if there is a type in `dtypes` which is equal to this Cast's DataType.
69        """
70        return self.to.is_type(*dtypes)

Checks whether this Cast's DataType matches one of the provided data types. Nested types like arrays or structs will be compared using "structural equivalence" semantics, so e.g. array != array.

Arguments:
  • dtypes: the data types to compare this Cast's DataType to.
Returns:

True, if and only if there is a type in dtypes which is equal to this Cast's DataType.

key: ClassVar[str] = 'cast'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
class TryCast(Cast):
73class TryCast(Cast):
74    arg_types = {**Cast.arg_types, "requires_string": False}
arg_types = {'this': True, 'to': True, 'format': False, 'safe': False, 'action': False, 'default': False, 'requires_string': False}
key: ClassVar[str] = 'trycast'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
class JSONCast(Cast):
77class JSONCast(Cast):
78    pass
key: ClassVar[str] = 'jsoncast'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
81class CastToStrType(Expression, Func):
82    arg_types = {"this": True, "to": True}
arg_types = {'this': True, 'to': True}
key: ClassVar[str] = 'casttostrtype'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
85class Convert(Expression, Func):
86    arg_types = {"this": True, "expression": True, "style": False, "safe": False}
arg_types = {'this': True, 'expression': True, 'style': False, 'safe': False}
key: ClassVar[str] = 'convert'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
92class If(Expression, Func):
93    arg_types = {"this": True, "true": True, "false": False}
94    _sql_names = ["IF", "IIF"]
arg_types = {'this': True, 'true': True, 'false': False}
key: ClassVar[str] = 'if'
required_args: 't.ClassVar[set[str]]' = {'true', 'this'}
 97class Case(Expression, Func):
 98    arg_types = {"this": False, "ifs": True, "default": False}
 99
100    def when(
101        self,
102        condition: ExpOrStr,
103        then: ExpOrStr,
104        copy: bool = True,
105        **opts: Unpack[ParserArgs],
106    ) -> Case:
107        instance = maybe_copy(self, copy)
108        instance.append(
109            "ifs",
110            If(
111                this=maybe_parse(condition, copy=copy, **opts),
112                true=maybe_parse(then, copy=copy, **opts),
113            ),
114        )
115        return instance
116
117    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
118        instance = maybe_copy(self, copy)
119        instance.set("default", maybe_parse(condition, copy=copy, **opts))
120        return instance
arg_types = {'this': False, 'ifs': True, 'default': False}
def when( self, condition: Union[int, str, sqlglot.expressions.core.Expr], then: Union[int, str, sqlglot.expressions.core.Expr], copy: bool = True, **opts: typing_extensions.Unpack[sqlglot._typing.ParserArgs]) -> Case:
100    def when(
101        self,
102        condition: ExpOrStr,
103        then: ExpOrStr,
104        copy: bool = True,
105        **opts: Unpack[ParserArgs],
106    ) -> Case:
107        instance = maybe_copy(self, copy)
108        instance.append(
109            "ifs",
110            If(
111                this=maybe_parse(condition, copy=copy, **opts),
112                true=maybe_parse(then, copy=copy, **opts),
113            ),
114        )
115        return instance
def else_( self, condition: Union[int, str, sqlglot.expressions.core.Expr], copy: bool = True, **opts: typing_extensions.Unpack[sqlglot._typing.ParserArgs]) -> Case:
117    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
118        instance = maybe_copy(self, copy)
119        instance.set("default", maybe_parse(condition, copy=copy, **opts))
120        return instance
key: ClassVar[str] = 'case'
required_args: 't.ClassVar[set[str]]' = {'ifs'}
123class Coalesce(Expression, Func):
124    arg_types = {"this": True, "expressions": False, "is_nvl": False, "is_null": False}
125    is_var_len_args = True
126    _sql_names = ["COALESCE", "IFNULL", "NVL"]
arg_types = {'this': True, 'expressions': False, 'is_nvl': False, 'is_null': False}
is_var_len_args = True
key: ClassVar[str] = 'coalesce'
required_args: 't.ClassVar[set[str]]' = {'this'}
129class DecodeCase(Expression, Func):
130    arg_types = {"expressions": True}
131    is_var_len_args = True
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'decodecase'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
134class EqualNull(Expression, Func):
135    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'equalnull'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
138class Greatest(Expression, Func):
139    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
140    is_var_len_args = True
arg_types = {'this': True, 'expressions': False, 'ignore_nulls': True}
is_var_len_args = True
key: ClassVar[str] = 'greatest'
required_args: 't.ClassVar[set[str]]' = {'ignore_nulls', 'this'}
143class Least(Expression, Func):
144    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
145    is_var_len_args = True
arg_types = {'this': True, 'expressions': False, 'ignore_nulls': True}
is_var_len_args = True
key: ClassVar[str] = 'least'
required_args: 't.ClassVar[set[str]]' = {'ignore_nulls', 'this'}
148class Nullif(Expression, Func):
149    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'nullif'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
152class Nvl2(Expression, Func):
153    arg_types = {"this": True, "true": True, "false": False}
arg_types = {'this': True, 'true': True, 'false': False}
key: ClassVar[str] = 'nvl2'
required_args: 't.ClassVar[set[str]]' = {'true', 'this'}
156class Try(Expression, Func):
157    pass
key: ClassVar[str] = 'try'
required_args: 't.ClassVar[set[str]]' = {'this'}
163class Collate(Expression, Binary, Func):
164    pass
key: ClassVar[str] = 'collate'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
167class Collation(Expression, Func):
168    pass
key: ClassVar[str] = 'collation'
required_args: 't.ClassVar[set[str]]' = {'this'}
171class ConnectByRoot(Expression, Func):
172    pass
key: ClassVar[str] = 'connectbyroot'
required_args: 't.ClassVar[set[str]]' = {'this'}
175class CheckXml(Expression, Func):
176    arg_types = {"this": True, "disable_auto_convert": False}
arg_types = {'this': True, 'disable_auto_convert': False}
key: ClassVar[str] = 'checkxml'
required_args: 't.ClassVar[set[str]]' = {'this'}
179class Exists(Expression, Func, SubqueryPredicate):
180    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'exists'
required_args: 't.ClassVar[set[str]]' = {'this'}
186class Float64(Expression, Func):
187    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'float64'
required_args: 't.ClassVar[set[str]]' = {'this'}
190class Int64(Expression, Func):
191    pass
key: ClassVar[str] = 'int64'
required_args: 't.ClassVar[set[str]]' = {'this'}
194class IsArray(Expression, Func):
195    pass
key: ClassVar[str] = 'isarray'
required_args: 't.ClassVar[set[str]]' = {'this'}
198class IsNullValue(Expression, Func):
199    pass
key: ClassVar[str] = 'isnullvalue'
required_args: 't.ClassVar[set[str]]' = {'this'}
202class LaxBool(Expression, Func):
203    pass
key: ClassVar[str] = 'laxbool'
required_args: 't.ClassVar[set[str]]' = {'this'}
206class LaxFloat64(Expression, Func):
207    pass
key: ClassVar[str] = 'laxfloat64'
required_args: 't.ClassVar[set[str]]' = {'this'}
210class LaxInt64(Expression, Func):
211    pass
key: ClassVar[str] = 'laxint64'
required_args: 't.ClassVar[set[str]]' = {'this'}
214class LaxString(Expression, Func):
215    pass
key: ClassVar[str] = 'laxstring'
required_args: 't.ClassVar[set[str]]' = {'this'}
218class ToBoolean(Expression, Func):
219    arg_types = {"this": True, "safe": False}
arg_types = {'this': True, 'safe': False}
key: ClassVar[str] = 'toboolean'
required_args: 't.ClassVar[set[str]]' = {'this'}
222class ToVariant(Expression, Func):
223    pass
key: ClassVar[str] = 'tovariant'
required_args: 't.ClassVar[set[str]]' = {'this'}
229class CurrentAccount(Expression, Func):
230    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentaccount'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentAccountName(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
233class CurrentAccountName(Expression, Func):
234    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentaccountname'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentAvailableRoles(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
237class CurrentAvailableRoles(Expression, Func):
238    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentavailableroles'
required_args: 't.ClassVar[set[str]]' = set()
241class CurrentCatalog(Expression, Func):
242    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentcatalog'
required_args: 't.ClassVar[set[str]]' = set()
245class CurrentClient(Expression, Func):
246    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentclient'
required_args: 't.ClassVar[set[str]]' = set()
249class CurrentDatabase(Expression, Func):
250    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentdatabase'
required_args: 't.ClassVar[set[str]]' = set()
253class CurrentIpAddress(Expression, Func):
254    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentipaddress'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentOrganizationName(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
257class CurrentOrganizationName(Expression, Func):
258    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentorganizationname'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentOrganizationUser(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
261class CurrentOrganizationUser(Expression, Func):
262    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentorganizationuser'
required_args: 't.ClassVar[set[str]]' = set()
265class CurrentRegion(Expression, Func):
266    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentregion'
required_args: 't.ClassVar[set[str]]' = set()
269class CurrentRole(Expression, Func):
270    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentrole'
required_args: 't.ClassVar[set[str]]' = set()
273class CurrentRoleType(Expression, Func):
274    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentroletype'
required_args: 't.ClassVar[set[str]]' = set()
277class CurrentSchema(Expression, Func):
278    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentschema'
required_args: 't.ClassVar[set[str]]' = set()
281class CurrentSchemas(Expression, Func):
282    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentschemas'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentSecondaryRoles(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
285class CurrentSecondaryRoles(Expression, Func):
286    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsecondaryroles'
required_args: 't.ClassVar[set[str]]' = set()
289class CurrentSession(Expression, Func):
290    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsession'
required_args: 't.ClassVar[set[str]]' = set()
293class CurrentStatement(Expression, Func):
294    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentstatement'
required_args: 't.ClassVar[set[str]]' = set()
class CurrentTransaction(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Func):
297class CurrentTransaction(Expression, Func):
298    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currenttransaction'
required_args: 't.ClassVar[set[str]]' = set()
301class CurrentUser(Expression, Func):
302    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentuser'
required_args: 't.ClassVar[set[str]]' = set()
305class CurrentVersion(Expression, Func):
306    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentversion'
required_args: 't.ClassVar[set[str]]' = set()
309class CurrentWarehouse(Expression, Func):
310    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentwarehouse'
required_args: 't.ClassVar[set[str]]' = set()
313class SessionUser(Expression, Func):
314    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'sessionuser'
required_args: 't.ClassVar[set[str]]' = set()
320class AIClassify(Expression, Func):
321    arg_types = {"this": True, "categories": True, "config": False}
322    _sql_names = ["AI_CLASSIFY"]
arg_types = {'this': True, 'categories': True, 'config': False}
key: ClassVar[str] = 'aiclassify'
required_args: 't.ClassVar[set[str]]' = {'categories', 'this'}
325class AIEmbed(Expression, Func):
326    arg_types = {"expressions": True}
327    is_var_len_args = True
328    _sql_names = ["AI_EMBED"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aiembed'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
331class AISimilarity(Expression, Func):
332    arg_types = {"expressions": True}
333    is_var_len_args = True
334    _sql_names = ["AI_SIMILARITY"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aisimilarity'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
337class AIGenerate(Expression, Func):
338    arg_types = {"expressions": True}
339    is_var_len_args = True
340    _sql_names = ["AI_GENERATE"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aigenerate'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
343class FeaturesAtTime(Expression, Func):
344    arg_types = {"this": True, "time": False, "num_rows": False, "ignore_feature_nulls": False}
arg_types = {'this': True, 'time': False, 'num_rows': False, 'ignore_feature_nulls': False}
key: ClassVar[str] = 'featuresattime'
required_args: 't.ClassVar[set[str]]' = {'this'}
347class GenerateEmbedding(Expression, Func):
348    arg_types = {"this": True, "expression": True, "params_struct": False, "is_text": False}
arg_types = {'this': True, 'expression': True, 'params_struct': False, 'is_text': False}
key: ClassVar[str] = 'generateembedding'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
351class GenerateText(Expression, Func):
352    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'generatetext'
required_args: 't.ClassVar[set[str]]' = {'this'}
355class GenerateTable(Expression, Func):
356    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'generatetable'
required_args: 't.ClassVar[set[str]]' = {'this'}
359class GenerateBool(Expression, Func):
360    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'generatebool'
required_args: 't.ClassVar[set[str]]' = {'this'}
363class GenerateInt(Expression, Func):
364    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'generateint'
required_args: 't.ClassVar[set[str]]' = {'this'}
367class GenerateDouble(Expression, Func):
368    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'generatedouble'
required_args: 't.ClassVar[set[str]]' = {'this'}
371class MLForecast(Expression, Func):
372    arg_types = {"this": True, "expression": False, "params_struct": False}
arg_types = {'this': True, 'expression': False, 'params_struct': False}
key: ClassVar[str] = 'mlforecast'
required_args: 't.ClassVar[set[str]]' = {'this'}
375class AIForecast(Expression, Func):
376    arg_types = {
377        "this": True,
378        "data_col": False,
379        "timestamp_col": False,
380        "model": False,
381        "id_cols": False,
382        "horizon": False,
383        "forecast_end_timestamp": False,
384        "confidence_level": False,
385        "output_historical_time_series": False,
386        "context_window": False,
387    }
arg_types = {'this': True, 'data_col': False, 'timestamp_col': False, 'model': False, 'id_cols': False, 'horizon': False, 'forecast_end_timestamp': False, 'confidence_level': False, 'output_historical_time_series': False, 'context_window': False}
key: ClassVar[str] = 'aiforecast'
required_args: 't.ClassVar[set[str]]' = {'this'}
390class MLTranslate(Expression, Func):
391    arg_types = {"this": True, "expression": True, "params_struct": True}
arg_types = {'this': True, 'expression': True, 'params_struct': True}
key: ClassVar[str] = 'mltranslate'
required_args: 't.ClassVar[set[str]]' = {'params_struct', 'expression', 'this'}
394class Predict(Expression, Func):
395    arg_types = {"this": True, "expression": True, "params_struct": False}
arg_types = {'this': True, 'expression': True, 'params_struct': False}
key: ClassVar[str] = 'predict'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
398class VectorSearch(Expression, Func):
399    arg_types = {
400        "this": True,
401        "column_to_search": True,
402        "query_table": True,
403        "query_column_to_search": False,
404        "top_k": False,
405        "distance_type": False,
406        "options": False,
407    }
arg_types = {'this': True, 'column_to_search': True, 'query_table': True, 'query_column_to_search': False, 'top_k': False, 'distance_type': False, 'options': False}
key: ClassVar[str] = 'vectorsearch'
required_args: 't.ClassVar[set[str]]' = {'query_table', 'column_to_search', 'this'}
413class ReadCSV(Expression, Func):
414    _sql_names = ["READ_CSV"]
415    is_var_len_args = True
416    arg_types = {"this": True, "expressions": False}
is_var_len_args = True
arg_types = {'this': True, 'expressions': False}
key: ClassVar[str] = 'readcsv'
required_args: 't.ClassVar[set[str]]' = {'this'}
419class ReadParquet(Expression, Func):
420    is_var_len_args = True
421    arg_types = {"expressions": True}
is_var_len_args = True
arg_types = {'expressions': True}
key: ClassVar[str] = 'readparquet'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
427class XMLElement(Expression, Func):
428    _sql_names = ["XMLELEMENT"]
429    arg_types = {"this": True, "expressions": False, "evalname": False}
arg_types = {'this': True, 'expressions': False, 'evalname': False}
key: ClassVar[str] = 'xmlelement'
required_args: 't.ClassVar[set[str]]' = {'this'}
432class XMLGet(Expression, Func):
433    _sql_names = ["XMLGET"]
434    arg_types = {"this": True, "expression": True, "instance": False}
arg_types = {'this': True, 'expression': True, 'instance': False}
key: ClassVar[str] = 'xmlget'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
437class XMLTable(Expression, Func):
438    arg_types = {
439        "this": True,
440        "namespaces": False,
441        "passing": False,
442        "columns": False,
443        "by_ref": False,
444    }
arg_types = {'this': True, 'namespaces': False, 'passing': False, 'columns': False, 'by_ref': False}
key: ClassVar[str] = 'xmltable'
required_args: 't.ClassVar[set[str]]' = {'this'}
450class Host(Expression, Func):
451    pass
key: ClassVar[str] = 'host'
required_args: 't.ClassVar[set[str]]' = {'this'}
454class NetFunc(Expression, Func):
455    pass
key: ClassVar[str] = 'netfunc'
required_args: 't.ClassVar[set[str]]' = {'this'}
458class ParseIp(Expression, Func):
459    arg_types = {"this": True, "type": True, "permissive": False}
arg_types = {'this': True, 'type': True, 'permissive': False}
key: ClassVar[str] = 'parseip'
required_args: 't.ClassVar[set[str]]' = {'type', 'this'}
462class RegDomain(Expression, Func):
463    pass
key: ClassVar[str] = 'regdomain'
required_args: 't.ClassVar[set[str]]' = {'this'}
469class Columns(Expression, Func):
470    arg_types = {"this": True, "unpack": False}
arg_types = {'this': True, 'unpack': False}
key: ClassVar[str] = 'columns'
required_args: 't.ClassVar[set[str]]' = {'this'}
473class Normal(Expression, Func):
474    arg_types = {"this": True, "stddev": True, "gen": True}
arg_types = {'this': True, 'stddev': True, 'gen': True}
key: ClassVar[str] = 'normal'
required_args: 't.ClassVar[set[str]]' = {'stddev', 'this', 'gen'}
477class Rand(Expression, Func):
478    _sql_names = ["RAND", "RANDOM"]
479    arg_types = {"this": False, "lower": False, "upper": False}
arg_types = {'this': False, 'lower': False, 'upper': False}
key: ClassVar[str] = 'rand'
required_args: 't.ClassVar[set[str]]' = set()
482class Randn(Expression, Func):
483    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'randn'
required_args: 't.ClassVar[set[str]]' = set()
486class Randstr(Expression, Func):
487    arg_types = {"this": True, "generator": False}
arg_types = {'this': True, 'generator': False}
key: ClassVar[str] = 'randstr'
required_args: 't.ClassVar[set[str]]' = {'this'}
490class RangeBucket(Expression, Func):
491    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'rangebucket'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
494class RangeN(Expression, Func):
495    arg_types = {"this": True, "expressions": True, "each": False}
arg_types = {'this': True, 'expressions': True, 'each': False}
key: ClassVar[str] = 'rangen'
required_args: 't.ClassVar[set[str]]' = {'expressions', 'this'}
498class Seq1(Expression, Func):
499    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq1'
required_args: 't.ClassVar[set[str]]' = set()
502class Seq2(Expression, Func):
503    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq2'
required_args: 't.ClassVar[set[str]]' = set()
506class Seq4(Expression, Func):
507    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq4'
required_args: 't.ClassVar[set[str]]' = set()
510class Seq8(Expression, Func):
511    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq8'
required_args: 't.ClassVar[set[str]]' = set()
514class Uniform(Expression, Func):
515    arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
arg_types = {'this': True, 'expression': True, 'gen': False, 'seed': False}
key: ClassVar[str] = 'uniform'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
518class Uuid(Expression, Func):
519    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
520
521    arg_types = {"this": False, "name": False, "is_string": False}
arg_types = {'this': False, 'name': False, 'is_string': False}
key: ClassVar[str] = 'uuid'
required_args: 't.ClassVar[set[str]]' = set()
524class WeekStart(Expression, Func):
525    pass
key: ClassVar[str] = 'weekstart'
required_args: 't.ClassVar[set[str]]' = {'this'}
528class WidthBucket(Expression, Func):
529    arg_types = {
530        "this": True,
531        "min_value": False,
532        "max_value": False,
533        "num_buckets": False,
534        "threshold": False,
535    }
arg_types = {'this': True, 'min_value': False, 'max_value': False, 'num_buckets': False, 'threshold': False}
key: ClassVar[str] = 'widthbucket'
required_args: 't.ClassVar[set[str]]' = {'this'}
538class Zipf(Expression, Func):
539    arg_types = {"this": True, "elementcount": True, "gen": True}
arg_types = {'this': True, 'elementcount': True, 'gen': True}
key: ClassVar[str] = 'zipf'
required_args: 't.ClassVar[set[str]]' = {'elementcount', 'this', 'gen'}