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 CurrentPath(Expression, Func):
274    arg_types = {}
275
276
277class CurrentRegion(Expression, Func):
278    arg_types = {}
279
280
281class CurrentRole(Expression, Func):
282    arg_types = {}
283
284
285class CurrentRoleType(Expression, Func):
286    arg_types = {}
287
288
289class CurrentSchema(Expression, Func):
290    arg_types = {"this": False}
291
292
293class CurrentSchemas(Expression, Func):
294    arg_types = {"this": False}
295
296
297class CurrentSecondaryRoles(Expression, Func):
298    arg_types = {}
299
300
301class CurrentSession(Expression, Func):
302    arg_types = {}
303
304
305class CurrentStatement(Expression, Func):
306    arg_types = {}
307
308
309class CurrentTransaction(Expression, Func):
310    arg_types = {}
311
312
313class CurrentUser(Expression, Func):
314    arg_types = {"this": False}
315
316
317class CurrentUserId(Expression, Func):
318    arg_types = {}
319
320
321class CurrentVersion(Expression, Func):
322    arg_types = {}
323
324
325class CurrentWarehouse(Expression, Func):
326    arg_types = {}
327
328
329class SessionUser(Expression, Func):
330    arg_types = {}
331
332
333# ML / AI
334
335
336class AIClassify(Expression, Func):
337    arg_types = {"this": True, "categories": True, "config": False}
338    _sql_names = ["AI_CLASSIFY"]
339
340
341class AIEmbed(Expression, Func):
342    arg_types = {"expressions": True}
343    is_var_len_args = True
344    _sql_names = ["AI_EMBED"]
345
346
347class AISimilarity(Expression, Func):
348    arg_types = {"expressions": True}
349    is_var_len_args = True
350    _sql_names = ["AI_SIMILARITY"]
351
352
353class AIGenerate(Expression, Func):
354    arg_types = {"expressions": True}
355    is_var_len_args = True
356    _sql_names = ["AI_GENERATE"]
357
358
359class FeaturesAtTime(Expression, Func):
360    arg_types = {"this": True, "time": False, "num_rows": False, "ignore_feature_nulls": False}
361
362
363class GenerateEmbedding(Expression, Func):
364    arg_types = {"this": True, "expression": True, "params_struct": False, "is_text": False}
365
366
367class GenerateText(Expression, Func):
368    arg_types = {"this": True, "expression": False, "params_struct": False}
369
370
371class GenerateTable(Expression, Func):
372    arg_types = {"this": True, "expression": False, "params_struct": False}
373
374
375class GenerateBool(Expression, Func):
376    arg_types = {"this": True, "expression": False, "params_struct": False}
377
378
379class GenerateInt(Expression, Func):
380    arg_types = {"this": True, "expression": False, "params_struct": False}
381
382
383class GenerateDouble(Expression, Func):
384    arg_types = {"this": True, "expression": False, "params_struct": False}
385
386
387class MLForecast(Expression, Func):
388    arg_types = {"this": True, "expression": False, "params_struct": False}
389
390
391class AIForecast(Expression, Func):
392    arg_types = {
393        "this": True,
394        "data_col": False,
395        "timestamp_col": False,
396        "model": False,
397        "id_cols": False,
398        "horizon": False,
399        "forecast_end_timestamp": False,
400        "confidence_level": False,
401        "output_historical_time_series": False,
402        "context_window": False,
403    }
404
405
406class MLTranslate(Expression, Func):
407    arg_types = {"this": True, "expression": True, "params_struct": True}
408
409
410class Predict(Expression, Func):
411    arg_types = {"this": True, "expression": True, "params_struct": False}
412
413
414class VectorSearch(Expression, Func):
415    arg_types = {
416        "this": True,
417        "column_to_search": True,
418        "query_table": True,
419        "query_column_to_search": False,
420        "top_k": False,
421        "distance_type": False,
422        "options": False,
423    }
424
425
426# Data reading
427
428
429class ReadCSV(Expression, Func):
430    _sql_names = ["READ_CSV"]
431    is_var_len_args = True
432    arg_types = {"this": True, "expressions": False}
433
434
435class ReadParquet(Expression, Func):
436    is_var_len_args = True
437    arg_types = {"expressions": True}
438
439
440# XML
441
442
443class XMLElement(Expression, Func):
444    _sql_names = ["XMLELEMENT"]
445    arg_types = {"this": True, "expressions": False, "evalname": False}
446
447
448class GetIgnoreCase(Expression, Func):
449    arg_types = {"this": True, "expression": True}
450
451
452class XMLGet(Expression, Func):
453    _sql_names = ["XMLGET"]
454    arg_types = {"this": True, "expression": True, "instance": False}
455
456
457class XMLTable(Expression, Func):
458    arg_types = {
459        "this": True,
460        "namespaces": False,
461        "passing": False,
462        "columns": False,
463        "by_ref": False,
464    }
465
466
467# Network / domain
468
469
470class Host(Expression, Func):
471    pass
472
473
474class NetFunc(Expression, Func):
475    pass
476
477
478class ParseIp(Expression, Func):
479    arg_types = {"this": True, "type": True, "permissive": False}
480
481
482class RegDomain(Expression, Func):
483    pass
484
485
486# Misc utility
487
488
489class Columns(Expression, Func):
490    arg_types = {"this": True, "unpack": False}
491
492
493class Normal(Expression, Func):
494    arg_types = {"this": True, "stddev": True, "gen": True}
495
496
497class Rand(Expression, Func):
498    _sql_names = ["RAND", "RANDOM"]
499    arg_types = {"this": False, "lower": False, "upper": False}
500
501
502class Randn(Expression, Func):
503    arg_types = {"this": False}
504
505
506class Randstr(Expression, Func):
507    arg_types = {"this": True, "generator": False}
508
509
510class RangeBucket(Expression, Func):
511    arg_types = {"this": True, "expression": True}
512
513
514class RangeN(Expression, Func):
515    arg_types = {"this": True, "expressions": True, "each": False}
516
517
518class Seq1(Expression, Func):
519    arg_types = {"this": False}
520
521
522class Seq2(Expression, Func):
523    arg_types = {"this": False}
524
525
526class Seq4(Expression, Func):
527    arg_types = {"this": False}
528
529
530class Seq8(Expression, Func):
531    arg_types = {"this": False}
532
533
534class Uniform(Expression, Func):
535    arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
536
537
538class Uuid(Expression, Func):
539    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
540
541    arg_types = {"this": False, "name": False, "is_string": False}
542
543
544class WeekStart(Expression, Func):
545    pass
546
547
548class WidthBucket(Expression, Func):
549    arg_types = {
550        "this": True,
551        "min_value": False,
552        "max_value": False,
553        "num_buckets": False,
554        "threshold": False,
555    }
556
557
558class Zipf(Expression, Func):
559    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 = {
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]]' = {'to', 'this'}
class JSONCast(Cast):
82class JSONCast(Cast):
83    pass
key: ClassVar[str] = 'jsoncast'
required_args: 't.ClassVar[set[str]]' = {'to', 'this'}
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]]' = {'to', 'this'}
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]]' = {'expression', 'this'}
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]]' = {'true', 'this'}
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]]' = {'expression', 'this'}
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]]' = {'expression', 'this'}
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]]' = {'true', 'this'}
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]]' = {'expression', 'this'}
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 CurrentPath(Expression, Func):
275    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentpath'
required_args: 't.ClassVar[set[str]]' = set()
278class CurrentRegion(Expression, Func):
279    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentregion'
required_args: 't.ClassVar[set[str]]' = set()
282class CurrentRole(Expression, Func):
283    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentrole'
required_args: 't.ClassVar[set[str]]' = set()
286class CurrentRoleType(Expression, Func):
287    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentroletype'
required_args: 't.ClassVar[set[str]]' = set()
290class CurrentSchema(Expression, Func):
291    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentschema'
required_args: 't.ClassVar[set[str]]' = set()
294class CurrentSchemas(Expression, Func):
295    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):
298class CurrentSecondaryRoles(Expression, Func):
299    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsecondaryroles'
required_args: 't.ClassVar[set[str]]' = set()
302class CurrentSession(Expression, Func):
303    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentsession'
required_args: 't.ClassVar[set[str]]' = set()
306class CurrentStatement(Expression, Func):
307    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):
310class CurrentTransaction(Expression, Func):
311    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currenttransaction'
required_args: 't.ClassVar[set[str]]' = set()
314class CurrentUser(Expression, Func):
315    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'currentuser'
required_args: 't.ClassVar[set[str]]' = set()
318class CurrentUserId(Expression, Func):
319    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentuserid'
required_args: 't.ClassVar[set[str]]' = set()
322class CurrentVersion(Expression, Func):
323    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentversion'
required_args: 't.ClassVar[set[str]]' = set()
326class CurrentWarehouse(Expression, Func):
327    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'currentwarehouse'
required_args: 't.ClassVar[set[str]]' = set()
330class SessionUser(Expression, Func):
331    arg_types = {}
arg_types = {}
key: ClassVar[str] = 'sessionuser'
required_args: 't.ClassVar[set[str]]' = set()
337class AIClassify(Expression, Func):
338    arg_types = {"this": True, "categories": True, "config": False}
339    _sql_names = ["AI_CLASSIFY"]
arg_types = {'this': True, 'categories': True, 'config': False}
key: ClassVar[str] = 'aiclassify'
required_args: 't.ClassVar[set[str]]' = {'categories', 'this'}
342class AIEmbed(Expression, Func):
343    arg_types = {"expressions": True}
344    is_var_len_args = True
345    _sql_names = ["AI_EMBED"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aiembed'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
348class AISimilarity(Expression, Func):
349    arg_types = {"expressions": True}
350    is_var_len_args = True
351    _sql_names = ["AI_SIMILARITY"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aisimilarity'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
354class AIGenerate(Expression, Func):
355    arg_types = {"expressions": True}
356    is_var_len_args = True
357    _sql_names = ["AI_GENERATE"]
arg_types = {'expressions': True}
is_var_len_args = True
key: ClassVar[str] = 'aigenerate'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
360class FeaturesAtTime(Expression, Func):
361    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'}
364class GenerateEmbedding(Expression, Func):
365    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'}
368class GenerateText(Expression, Func):
369    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'}
372class GenerateTable(Expression, Func):
373    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'}
376class GenerateBool(Expression, Func):
377    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'}
380class GenerateInt(Expression, Func):
381    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'}
384class GenerateDouble(Expression, Func):
385    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'}
388class MLForecast(Expression, Func):
389    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'}
392class AIForecast(Expression, Func):
393    arg_types = {
394        "this": True,
395        "data_col": False,
396        "timestamp_col": False,
397        "model": False,
398        "id_cols": False,
399        "horizon": False,
400        "forecast_end_timestamp": False,
401        "confidence_level": False,
402        "output_historical_time_series": False,
403        "context_window": False,
404    }
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'}
407class MLTranslate(Expression, Func):
408    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'}
411class Predict(Expression, Func):
412    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'}
415class VectorSearch(Expression, Func):
416    arg_types = {
417        "this": True,
418        "column_to_search": True,
419        "query_table": True,
420        "query_column_to_search": False,
421        "top_k": False,
422        "distance_type": False,
423        "options": False,
424    }
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]]' = {'column_to_search', 'query_table', 'this'}
430class ReadCSV(Expression, Func):
431    _sql_names = ["READ_CSV"]
432    is_var_len_args = True
433    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'}
436class ReadParquet(Expression, Func):
437    is_var_len_args = True
438    arg_types = {"expressions": True}
is_var_len_args = True
arg_types = {'expressions': True}
key: ClassVar[str] = 'readparquet'
required_args: 't.ClassVar[set[str]]' = {'expressions'}
444class XMLElement(Expression, Func):
445    _sql_names = ["XMLELEMENT"]
446    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'}
449class GetIgnoreCase(Expression, Func):
450    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'getignorecase'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
453class XMLGet(Expression, Func):
454    _sql_names = ["XMLGET"]
455    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'}
458class XMLTable(Expression, Func):
459    arg_types = {
460        "this": True,
461        "namespaces": False,
462        "passing": False,
463        "columns": False,
464        "by_ref": False,
465    }
arg_types = {'this': True, 'namespaces': False, 'passing': False, 'columns': False, 'by_ref': False}
key: ClassVar[str] = 'xmltable'
required_args: 't.ClassVar[set[str]]' = {'this'}
471class Host(Expression, Func):
472    pass
key: ClassVar[str] = 'host'
required_args: 't.ClassVar[set[str]]' = {'this'}
475class NetFunc(Expression, Func):
476    pass
key: ClassVar[str] = 'netfunc'
required_args: 't.ClassVar[set[str]]' = {'this'}
479class ParseIp(Expression, Func):
480    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'}
483class RegDomain(Expression, Func):
484    pass
key: ClassVar[str] = 'regdomain'
required_args: 't.ClassVar[set[str]]' = {'this'}
490class Columns(Expression, Func):
491    arg_types = {"this": True, "unpack": False}
arg_types = {'this': True, 'unpack': False}
key: ClassVar[str] = 'columns'
required_args: 't.ClassVar[set[str]]' = {'this'}
494class Normal(Expression, Func):
495    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'}
498class Rand(Expression, Func):
499    _sql_names = ["RAND", "RANDOM"]
500    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()
503class Randn(Expression, Func):
504    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'randn'
required_args: 't.ClassVar[set[str]]' = set()
507class Randstr(Expression, Func):
508    arg_types = {"this": True, "generator": False}
arg_types = {'this': True, 'generator': False}
key: ClassVar[str] = 'randstr'
required_args: 't.ClassVar[set[str]]' = {'this'}
511class RangeBucket(Expression, Func):
512    arg_types = {"this": True, "expression": True}
arg_types = {'this': True, 'expression': True}
key: ClassVar[str] = 'rangebucket'
required_args: 't.ClassVar[set[str]]' = {'expression', 'this'}
515class RangeN(Expression, Func):
516    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'}
519class Seq1(Expression, Func):
520    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq1'
required_args: 't.ClassVar[set[str]]' = set()
523class Seq2(Expression, Func):
524    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq2'
required_args: 't.ClassVar[set[str]]' = set()
527class Seq4(Expression, Func):
528    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq4'
required_args: 't.ClassVar[set[str]]' = set()
531class Seq8(Expression, Func):
532    arg_types = {"this": False}
arg_types = {'this': False}
key: ClassVar[str] = 'seq8'
required_args: 't.ClassVar[set[str]]' = set()
535class Uniform(Expression, Func):
536    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'}
539class Uuid(Expression, Func):
540    _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
541
542    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()
545class WeekStart(Expression, Func):
546    pass
key: ClassVar[str] = 'weekstart'
required_args: 't.ClassVar[set[str]]' = {'this'}
549class WidthBucket(Expression, Func):
550    arg_types = {
551        "this": True,
552        "min_value": False,
553        "max_value": False,
554        "num_buckets": False,
555        "threshold": False,
556    }
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'}
559class Zipf(Expression, Func):
560    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]]' = {'gen', 'elementcount', 'this'}