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 = {
 74        **Cast.arg_types,
 75        "requires_string": False,
 76        "null_on_text_overflow": False,
 77        "probe_date_format": False,
 78    }
 79
 80
 81class JSONCast(Cast):
 82    pass
 83
 84
 85class CastToStrType(Expression, Func):
 86    arg_types = {"this": True, "to": True}
 87
 88
 89class Convert(Expression, Func):
 90    arg_types = {"this": True, "expression": True, "style": False, "safe": False}
 91
 92
 93# Conditional
 94
 95
 96class If(Expression, Func):
 97    arg_types = {"this": True, "true": True, "false": False}
 98    _sql_names = ["IF", "IIF"]
 99
100
101class Case(Expression, Func):
102    arg_types = {"this": False, "ifs": True, "default": False}
103
104    def when(
105        self,
106        condition: ExpOrStr,
107        then: ExpOrStr,
108        copy: bool = True,
109        **opts: Unpack[ParserArgs],
110    ) -> Case:
111        instance = maybe_copy(self, copy)
112        instance.append(
113            "ifs",
114            If(
115                this=maybe_parse(condition, copy=copy, **opts),
116                true=maybe_parse(then, copy=copy, **opts),
117            ),
118        )
119        return instance
120
121    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
122        instance = maybe_copy(self, copy)
123        instance.set("default", maybe_parse(condition, copy=copy, **opts))
124        return instance
125
126
127class Coalesce(Expression, Func):
128    arg_types = {"this": True, "expressions": False, "is_nvl": False, "is_null": False}
129    is_var_len_args = True
130    _sql_names = ["COALESCE", "IFNULL", "NVL"]
131
132
133class DecodeCase(Expression, Func):
134    arg_types = {"expressions": True}
135    is_var_len_args = True
136
137
138class EqualNull(Expression, Func):
139    arg_types = {"this": True, "expression": True}
140
141
142class Greatest(Expression, Func):
143    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
144    is_var_len_args = True
145
146
147class Least(Expression, Func):
148    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
149    is_var_len_args = True
150
151
152class Nullif(Expression, Func):
153    arg_types = {"this": True, "expression": True}
154
155
156class ObjectTransform(Expression, Func):
157    arg_types = {"this": True, "keep": False, "set_": False}
158
159
160class Nvl2(Expression, Func):
161    arg_types = {"this": True, "true": True, "false": False}
162
163
164class Try(Expression, Func):
165    pass
166
167
168# Predicates / misc functions
169
170
171class Collate(Expression, Binary, Func):
172    pass
173
174
175class Collation(Expression, Func):
176    pass
177
178
179class ConnectByRoot(Expression, Func):
180    pass
181
182
183class CheckXml(Expression, Func):
184    arg_types = {"this": True, "disable_auto_convert": False}
185
186
187class Exists(Expression, Func, SubqueryPredicate):
188    arg_types = {"this": True, "expression": False}
189
190
191# Type coercions / lax types
192
193
194class Float64(Expression, Func):
195    arg_types = {"this": True, "expression": False}
196
197
198class Int64(Expression, Func):
199    pass
200
201
202class IsArray(Expression, Func):
203    pass
204
205
206class IsNullValue(Expression, Func):
207    pass
208
209
210class LaxBool(Expression, Func):
211    pass
212
213
214class LaxFloat64(Expression, Func):
215    pass
216
217
218class LaxInt64(Expression, Func):
219    pass
220
221
222class LaxString(Expression, Func):
223    pass
224
225
226class ToBoolean(Expression, Func):
227    arg_types = {"this": True, "safe": False}
228
229
230class ToVariant(Expression, Func):
231    pass
232
233
234# Session / context functions
235
236
237class CurrentAccount(Expression, Func):
238    arg_types = {}
239
240
241class CurrentAccountName(Expression, Func):
242    arg_types = {}
243
244
245class CurrentAvailableRoles(Expression, Func):
246    arg_types = {}
247
248
249class CurrentCatalog(Expression, Func):
250    arg_types = {}
251
252
253class CurrentClient(Expression, Func):
254    arg_types = {}
255
256
257class CurrentDatabase(Expression, Func):
258    arg_types = {}
259
260
261class CurrentIpAddress(Expression, Func):
262    arg_types = {}
263
264
265class CurrentOrganizationName(Expression, Func):
266    arg_types = {}
267
268
269class CurrentOrganizationUser(Expression, Func):
270    arg_types = {}
271
272
273class CurrentRegion(Expression, Func):
274    arg_types = {}
275
276
277class CurrentRole(Expression, Func):
278    arg_types = {}
279
280
281class CurrentRoleType(Expression, Func):
282    arg_types = {}
283
284
285class CurrentSchema(Expression, Func):
286    arg_types = {"this": False}
287
288
289class CurrentSchemas(Expression, Func):
290    arg_types = {"this": False}
291
292
293class CurrentSecondaryRoles(Expression, Func):
294    arg_types = {}
295
296
297class CurrentSession(Expression, Func):
298    arg_types = {}
299
300
301class CurrentStatement(Expression, Func):
302    arg_types = {}
303
304
305class CurrentTransaction(Expression, Func):
306    arg_types = {}
307
308
309class CurrentUser(Expression, Func):
310    arg_types = {"this": False}
311
312
313class CurrentUserId(Expression, Func):
314    arg_types = {}
315
316
317class CurrentVersion(Expression, Func):
318    arg_types = {}
319
320
321class CurrentWarehouse(Expression, Func):
322    arg_types = {}
323
324
325class SessionUser(Expression, Func):
326    arg_types = {}
327
328
329# ML / AI
330
331
332class AIClassify(Expression, Func):
333    arg_types = {"this": True, "categories": True, "config": False}
334    _sql_names = ["AI_CLASSIFY"]
335
336
337class AIEmbed(Expression, Func):
338    arg_types = {"expressions": True}
339    is_var_len_args = True
340    _sql_names = ["AI_EMBED"]
341
342
343class AISimilarity(Expression, Func):
344    arg_types = {"expressions": True}
345    is_var_len_args = True
346    _sql_names = ["AI_SIMILARITY"]
347
348
349class AIGenerate(Expression, Func):
350    arg_types = {"expressions": True}
351    is_var_len_args = True
352    _sql_names = ["AI_GENERATE"]
353
354
355class FeaturesAtTime(Expression, Func):
356    arg_types = {"this": True, "time": False, "num_rows": False, "ignore_feature_nulls": False}
357
358
359class GenerateEmbedding(Expression, Func):
360    arg_types = {"this": True, "expression": True, "params_struct": False, "is_text": False}
361
362
363class GenerateText(Expression, Func):
364    arg_types = {"this": True, "expression": False, "params_struct": False}
365
366
367class GenerateTable(Expression, Func):
368    arg_types = {"this": True, "expression": False, "params_struct": False}
369
370
371class GenerateBool(Expression, Func):
372    arg_types = {"this": True, "expression": False, "params_struct": False}
373
374
375class GenerateInt(Expression, Func):
376    arg_types = {"this": True, "expression": False, "params_struct": False}
377
378
379class GenerateDouble(Expression, Func):
380    arg_types = {"this": True, "expression": False, "params_struct": False}
381
382
383class MLForecast(Expression, Func):
384    arg_types = {"this": True, "expression": False, "params_struct": False}
385
386
387class AIForecast(Expression, Func):
388    arg_types = {
389        "this": True,
390        "data_col": False,
391        "timestamp_col": False,
392        "model": False,
393        "id_cols": False,
394        "horizon": False,
395        "forecast_end_timestamp": False,
396        "confidence_level": False,
397        "output_historical_time_series": False,
398        "context_window": False,
399    }
400
401
402class MLTranslate(Expression, Func):
403    arg_types = {"this": True, "expression": True, "params_struct": True}
404
405
406class Predict(Expression, Func):
407    arg_types = {"this": True, "expression": True, "params_struct": False}
408
409
410class VectorSearch(Expression, Func):
411    arg_types = {
412        "this": True,
413        "column_to_search": True,
414        "query_table": True,
415        "query_column_to_search": False,
416        "top_k": False,
417        "distance_type": False,
418        "options": False,
419    }
420
421
422# Data reading
423
424
425class ReadCSV(Expression, Func):
426    _sql_names = ["READ_CSV"]
427    is_var_len_args = True
428    arg_types = {"this": True, "expressions": False}
429
430
431class ReadParquet(Expression, Func):
432    is_var_len_args = True
433    arg_types = {"expressions": True}
434
435
436# XML
437
438
439class XMLElement(Expression, Func):
440    _sql_names = ["XMLELEMENT"]
441    arg_types = {"this": True, "expressions": False, "evalname": False}
442
443
444class GetIgnoreCase(Expression, Func):
445    arg_types = {"this": True, "expression": True}
446
447
448class XMLGet(Expression, Func):
449    _sql_names = ["XMLGET"]
450    arg_types = {"this": True, "expression": True, "instance": False}
451
452
453class XMLTable(Expression, Func):
454    arg_types = {
455        "this": True,
456        "namespaces": False,
457        "passing": False,
458        "columns": False,
459        "by_ref": False,
460    }
461
462
463# Network / domain
464
465
466class Host(Expression, Func):
467    pass
468
469
470class NetFunc(Expression, Func):
471    pass
472
473
474class ParseIp(Expression, Func):
475    arg_types = {"this": True, "type": True, "permissive": False}
476
477
478class RegDomain(Expression, Func):
479    pass
480
481
482# Misc utility
483
484
485class Columns(Expression, Func):
486    arg_types = {"this": True, "unpack": False}
487
488
489class Normal(Expression, Func):
490    arg_types = {"this": True, "stddev": True, "gen": True}
491
492
493class Rand(Expression, Func):
494    _sql_names = ["RAND", "RANDOM"]
495    arg_types = {"this": False, "lower": False, "upper": False}
496
497
498class Randn(Expression, Func):
499    arg_types = {"this": False}
500
501
502class Randstr(Expression, Func):
503    arg_types = {"this": True, "generator": False}
504
505
506class RangeBucket(Expression, Func):
507    arg_types = {"this": True, "expression": True}
508
509
510class RangeN(Expression, Func):
511    arg_types = {"this": True, "expressions": True, "each": False}
512
513
514class Seq1(Expression, Func):
515    arg_types = {"this": False}
516
517
518class Seq2(Expression, Func):
519    arg_types = {"this": False}
520
521
522class Seq4(Expression, Func):
523    arg_types = {"this": False}
524
525
526class Seq8(Expression, Func):
527    arg_types = {"this": False}
528
529
530class Uniform(Expression, Func):
531    arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
532
533
534class Uuid(Expression, Func):
535    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
536
537    arg_types = {"this": False, "name": False, "is_string": False}
538
539
540class WeekStart(Expression, Func):
541    pass
542
543
544class WidthBucket(Expression, Func):
545    arg_types = {
546        "this": True,
547        "min_value": False,
548        "max_value": False,
549        "num_buckets": False,
550        "threshold": False,
551    }
552
553
554class Zipf(Expression, Func):
555    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]]' = {'this', 'to'}
class TryCast(Cast):
73class TryCast(Cast):
74    arg_types = {
75        **Cast.arg_types,
76        "requires_string": False,
77        "null_on_text_overflow": False,
78        "probe_date_format": False,
79    }
arg_types = {'this': True, 'to': True, 'format': False, 'safe': False, 'action': False, 'default': False, 'requires_string': False, 'null_on_text_overflow': False, 'probe_date_format': False}
key: ClassVar[str] = 'trycast'
required_args: 't.ClassVar[set[str]]' = {'this', 'to'}
class JSONCast(Cast):
82class JSONCast(Cast):
83    pass
key: ClassVar[str] = 'jsoncast'
required_args: 't.ClassVar[set[str]]' = {'this', 'to'}
86class CastToStrType(Expression, Func):
87    arg_types = {"this": True, "to": True}
arg_types = {'this': True, 'to': True}
key: ClassVar[str] = 'casttostrtype'
required_args: 't.ClassVar[set[str]]' = {'this', 'to'}
90class Convert(Expression, Func):
91    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]]' = {'this', 'expression'}
97class If(Expression, Func):
98    arg_types = {"this": True, "true": True, "false": False}
99    _sql_names = ["IF", "IIF"]
arg_types = {'this': True, 'true': True, 'false': False}
key: ClassVar[str] = 'if'
required_args: 't.ClassVar[set[str]]' = {'this', 'true'}
102class Case(Expression, Func):
103    arg_types = {"this": False, "ifs": True, "default": False}
104
105    def when(
106        self,
107        condition: ExpOrStr,
108        then: ExpOrStr,
109        copy: bool = True,
110        **opts: Unpack[ParserArgs],
111    ) -> Case:
112        instance = maybe_copy(self, copy)
113        instance.append(
114            "ifs",
115            If(
116                this=maybe_parse(condition, copy=copy, **opts),
117                true=maybe_parse(then, copy=copy, **opts),
118            ),
119        )
120        return instance
121
122    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
123        instance = maybe_copy(self, copy)
124        instance.set("default", maybe_parse(condition, copy=copy, **opts))
125        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:
105    def when(
106        self,
107        condition: ExpOrStr,
108        then: ExpOrStr,
109        copy: bool = True,
110        **opts: Unpack[ParserArgs],
111    ) -> Case:
112        instance = maybe_copy(self, copy)
113        instance.append(
114            "ifs",
115            If(
116                this=maybe_parse(condition, copy=copy, **opts),
117                true=maybe_parse(then, copy=copy, **opts),
118            ),
119        )
120        return instance
def else_( self, condition: Union[int, str, sqlglot.expressions.core.Expr], copy: bool = True, **opts: typing_extensions.Unpack[sqlglot._typing.ParserArgs]) -> Case:
122    def else_(self, condition: ExpOrStr, copy: bool = True, **opts: Unpack[ParserArgs]) -> Case:
123        instance = maybe_copy(self, copy)
124        instance.set("default", maybe_parse(condition, copy=copy, **opts))
125        return instance
key: ClassVar[str] = 'case'
required_args: 't.ClassVar[set[str]]' = {'ifs'}
128class Coalesce(Expression, Func):
129    arg_types = {"this": True, "expressions": False, "is_nvl": False, "is_null": False}
130    is_var_len_args = True
131    _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'}
134class DecodeCase(Expression, Func):
135    arg_types = {"expressions": True}
136    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'}
139class EqualNull(Expression, Func):
140    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'equalnull'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
143class Greatest(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] = 'greatest'
required_args: 't.ClassVar[set[str]]' = {'ignore_nulls', 'this'}
148class Least(Expression, Func):
149    arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
150    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'}
153class Nullif(Expression, Func):
154    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'nullif'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
157class ObjectTransform(Expression, Func):
158    arg_types = {"this": True, "keep": False, "set_": False}
arg_types = {'this': True, 'keep': False, 'set_': False}
key: ClassVar[str] = 'objecttransform'
required_args: 't.ClassVar[set[str]]' = {'this'}
161class Nvl2(Expression, Func):
162    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]]' = {'this', 'true'}
165class Try(Expression, Func):
166    pass
key: ClassVar[str] = 'try'
required_args: 't.ClassVar[set[str]]' = {'this'}
172class Collate(Expression, Binary, Func):
173    pass
key: ClassVar[str] = 'collate'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
176class Collation(Expression, Func):
177    pass
key: ClassVar[str] = 'collation'
required_args: 't.ClassVar[set[str]]' = {'this'}
180class ConnectByRoot(Expression, Func):
181    pass
key: ClassVar[str] = 'connectbyroot'
required_args: 't.ClassVar[set[str]]' = {'this'}
184class CheckXml(Expression, Func):
185    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'}
188class Exists(Expression, Func, SubqueryPredicate):
189    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'exists'
required_args: 't.ClassVar[set[str]]' = {'this'}
195class Float64(Expression, Func):
196    arg_types = {"this": True, "expression": False}
arg_types = {'this': True, 'expression': False}
key: ClassVar[str] = 'float64'
required_args: 't.ClassVar[set[str]]' = {'this'}
199class Int64(Expression, Func):
200    pass
key: ClassVar[str] = 'int64'
required_args: 't.ClassVar[set[str]]' = {'this'}
203class IsArray(Expression, Func):
204    pass
key: ClassVar[str] = 'isarray'
required_args: 't.ClassVar[set[str]]' = {'this'}
207class IsNullValue(Expression, Func):
208    pass
key: ClassVar[str] = 'isnullvalue'
required_args: 't.ClassVar[set[str]]' = {'this'}
211class LaxBool(Expression, Func):
212    pass
key: ClassVar[str] = 'laxbool'
required_args: 't.ClassVar[set[str]]' = {'this'}
215class LaxFloat64(Expression, Func):
216    pass
key: ClassVar[str] = 'laxfloat64'
required_args: 't.ClassVar[set[str]]' = {'this'}
219class LaxInt64(Expression, Func):
220    pass
key: ClassVar[str] = 'laxint64'
required_args: 't.ClassVar[set[str]]' = {'this'}
223class LaxString(Expression, Func):
224    pass
key: ClassVar[str] = 'laxstring'
required_args: 't.ClassVar[set[str]]' = {'this'}
227class ToBoolean(Expression, Func):
228    arg_types = {"this": True, "safe": False}
arg_types = {'this': True, 'safe': False}
key: ClassVar[str] = 'toboolean'
required_args: 't.ClassVar[set[str]]' = {'this'}
231class ToVariant(Expression, Func):
232    pass
key: ClassVar[str] = 'tovariant'
required_args: 't.ClassVar[set[str]]' = {'this'}
238class CurrentAccount(Expression, Func):
239    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):
242class CurrentAccountName(Expression, Func):
243    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):
246class CurrentAvailableRoles(Expression, Func):
247    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentavailableroles'
required_args: 't.ClassVar[set[str]]' = set()
250class CurrentCatalog(Expression, Func):
251    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentcatalog'
required_args: 't.ClassVar[set[str]]' = set()
254class CurrentClient(Expression, Func):
255    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentclient'
required_args: 't.ClassVar[set[str]]' = set()
258class CurrentDatabase(Expression, Func):
259    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentdatabase'
required_args: 't.ClassVar[set[str]]' = set()
262class CurrentIpAddress(Expression, Func):
263    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):
266class CurrentOrganizationName(Expression, Func):
267    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):
270class CurrentOrganizationUser(Expression, Func):
271    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentorganizationuser'
required_args: 't.ClassVar[set[str]]' = set()
274class CurrentRegion(Expression, Func):
275    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentregion'
required_args: 't.ClassVar[set[str]]' = set()
278class CurrentRole(Expression, Func):
279    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentrole'
required_args: 't.ClassVar[set[str]]' = set()
282class CurrentRoleType(Expression, Func):
283    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentroletype'
required_args: 't.ClassVar[set[str]]' = set()
286class CurrentSchema(Expression, Func):
287    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentschema'
required_args: 't.ClassVar[set[str]]' = set()
290class CurrentSchemas(Expression, Func):
291    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):
294class CurrentSecondaryRoles(Expression, Func):
295    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsecondaryroles'
required_args: 't.ClassVar[set[str]]' = set()
298class CurrentSession(Expression, Func):
299    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsession'
required_args: 't.ClassVar[set[str]]' = set()
302class CurrentStatement(Expression, Func):
303    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):
306class CurrentTransaction(Expression, Func):
307    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currenttransaction'
required_args: 't.ClassVar[set[str]]' = set()
310class CurrentUser(Expression, Func):
311    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentuser'
required_args: 't.ClassVar[set[str]]' = set()
314class CurrentUserId(Expression, Func):
315    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentuserid'
required_args: 't.ClassVar[set[str]]' = set()
318class CurrentVersion(Expression, Func):
319    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentversion'
required_args: 't.ClassVar[set[str]]' = set()
322class CurrentWarehouse(Expression, Func):
323    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentwarehouse'
required_args: 't.ClassVar[set[str]]' = set()
326class SessionUser(Expression, Func):
327    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'sessionuser'
required_args: 't.ClassVar[set[str]]' = set()
333class AIClassify(Expression, Func):
334    arg_types = {"this": True, "categories": True, "config": False}
335    _sql_names = ["AI_CLASSIFY"]
arg_types = {'this': True, 'categories': True, 'config': False}
key: ClassVar[str] = 'aiclassify'
required_args: 't.ClassVar[set[str]]' = {'categories', 'this'}
338class AIEmbed(Expression, Func):
339    arg_types = {"expressions": True}
340    is_var_len_args = True
341    _sql_names = ["AI_EMBED"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aiembed'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
344class AISimilarity(Expression, Func):
345    arg_types = {"expressions": True}
346    is_var_len_args = True
347    _sql_names = ["AI_SIMILARITY"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aisimilarity'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
350class AIGenerate(Expression, Func):
351    arg_types = {"expressions": True}
352    is_var_len_args = True
353    _sql_names = ["AI_GENERATE"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aigenerate'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
356class FeaturesAtTime(Expression, Func):
357    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'}
360class GenerateEmbedding(Expression, Func):
361    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]]' = {'this', 'expression'}
364class GenerateText(Expression, Func):
365    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'}
368class GenerateTable(Expression, Func):
369    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'}
372class GenerateBool(Expression, Func):
373    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'}
376class GenerateInt(Expression, Func):
377    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'}
380class GenerateDouble(Expression, Func):
381    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'}
384class MLForecast(Expression, Func):
385    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'}
388class AIForecast(Expression, Func):
389    arg_types = {
390        "this": True,
391        "data_col": False,
392        "timestamp_col": False,
393        "model": False,
394        "id_cols": False,
395        "horizon": False,
396        "forecast_end_timestamp": False,
397        "confidence_level": False,
398        "output_historical_time_series": False,
399        "context_window": False,
400    }
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'}
403class MLTranslate(Expression, Func):
404    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', 'this', 'expression'}
407class Predict(Expression, Func):
408    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]]' = {'this', 'expression'}
411class VectorSearch(Expression, Func):
412    arg_types = {
413        "this": True,
414        "column_to_search": True,
415        "query_table": True,
416        "query_column_to_search": False,
417        "top_k": False,
418        "distance_type": False,
419        "options": False,
420    }
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'}
426class ReadCSV(Expression, Func):
427    _sql_names = ["READ_CSV"]
428    is_var_len_args = True
429    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'}
432class ReadParquet(Expression, Func):
433    is_var_len_args = True
434    arg_types = {"expressions": True}
is_var_len_args = True
arg_types = {'expressions': True}
key: ClassVar[str] = 'readparquet'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
440class XMLElement(Expression, Func):
441    _sql_names = ["XMLELEMENT"]
442    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'}
445class GetIgnoreCase(Expression, Func):
446    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'getignorecase'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
449class XMLGet(Expression, Func):
450    _sql_names = ["XMLGET"]
451    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]]' = {'this', 'expression'}
454class XMLTable(Expression, Func):
455    arg_types = {
456        "this": True,
457        "namespaces": False,
458        "passing": False,
459        "columns": False,
460        "by_ref": False,
461    }
arg_types = {'this': True, 'namespaces': False, 'passing': False, 'columns': False, 'by_ref': False}
key: ClassVar[str] = 'xmltable'
required_args: 't.ClassVar[set[str]]' = {'this'}
467class Host(Expression, Func):
468    pass
key: ClassVar[str] = 'host'
required_args: 't.ClassVar[set[str]]' = {'this'}
471class NetFunc(Expression, Func):
472    pass
key: ClassVar[str] = 'netfunc'
required_args: 't.ClassVar[set[str]]' = {'this'}
475class ParseIp(Expression, Func):
476    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'}
479class RegDomain(Expression, Func):
480    pass
key: ClassVar[str] = 'regdomain'
required_args: 't.ClassVar[set[str]]' = {'this'}
486class Columns(Expression, Func):
487    arg_types = {"this": True, "unpack": False}
arg_types = {'this': True, 'unpack': False}
key: ClassVar[str] = 'columns'
required_args: 't.ClassVar[set[str]]' = {'this'}
490class Normal(Expression, Func):
491    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', 'gen', 'this'}
494class Rand(Expression, Func):
495    _sql_names = ["RAND", "RANDOM"]
496    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()
499class Randn(Expression, Func):
500    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'randn'
required_args: 't.ClassVar[set[str]]' = set()
503class Randstr(Expression, Func):
504    arg_types = {"this": True, "generator": False}
arg_types = {'this': True, 'generator': False}
key: ClassVar[str] = 'randstr'
required_args: 't.ClassVar[set[str]]' = {'this'}
507class RangeBucket(Expression, Func):
508    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'rangebucket'
required_args: 't.ClassVar[set[str]]' = {'this', 'expression'}
511class RangeN(Expression, Func):
512    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]]' = {'this', 'expressions'}
515class Seq1(Expression, Func):
516    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq1'
required_args: 't.ClassVar[set[str]]' = set()
519class Seq2(Expression, Func):
520    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq2'
required_args: 't.ClassVar[set[str]]' = set()
523class Seq4(Expression, Func):
524    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq4'
required_args: 't.ClassVar[set[str]]' = set()
527class Seq8(Expression, Func):
528    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq8'
required_args: 't.ClassVar[set[str]]' = set()
531class Uniform(Expression, Func):
532    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]]' = {'this', 'expression'}
535class Uuid(Expression, Func):
536    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
537
538    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()
541class WeekStart(Expression, Func):
542    pass
key: ClassVar[str] = 'weekstart'
required_args: 't.ClassVar[set[str]]' = {'this'}
545class WidthBucket(Expression, Func):
546    arg_types = {
547        "this": True,
548        "min_value": False,
549        "max_value": False,
550        "num_buckets": False,
551        "threshold": False,
552    }
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'}
555class Zipf(Expression, Func):
556    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', 'gen', 'this'}