sqlglot 27.29.0__py3-none-any.whl → 28.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. sqlglot/__main__.py +6 -4
  2. sqlglot/_version.py +2 -2
  3. sqlglot/dialects/bigquery.py +116 -295
  4. sqlglot/dialects/clickhouse.py +67 -2
  5. sqlglot/dialects/databricks.py +38 -1
  6. sqlglot/dialects/dialect.py +327 -286
  7. sqlglot/dialects/dremio.py +4 -1
  8. sqlglot/dialects/duckdb.py +718 -22
  9. sqlglot/dialects/exasol.py +243 -10
  10. sqlglot/dialects/hive.py +8 -8
  11. sqlglot/dialects/mysql.py +11 -2
  12. sqlglot/dialects/oracle.py +29 -0
  13. sqlglot/dialects/postgres.py +46 -24
  14. sqlglot/dialects/presto.py +47 -16
  15. sqlglot/dialects/redshift.py +16 -0
  16. sqlglot/dialects/risingwave.py +3 -0
  17. sqlglot/dialects/singlestore.py +12 -3
  18. sqlglot/dialects/snowflake.py +199 -271
  19. sqlglot/dialects/spark.py +2 -2
  20. sqlglot/dialects/spark2.py +11 -48
  21. sqlglot/dialects/sqlite.py +9 -0
  22. sqlglot/dialects/teradata.py +5 -8
  23. sqlglot/dialects/trino.py +6 -0
  24. sqlglot/dialects/tsql.py +61 -25
  25. sqlglot/diff.py +4 -2
  26. sqlglot/errors.py +69 -0
  27. sqlglot/expressions.py +484 -84
  28. sqlglot/generator.py +143 -41
  29. sqlglot/helper.py +2 -2
  30. sqlglot/optimizer/annotate_types.py +247 -140
  31. sqlglot/optimizer/canonicalize.py +6 -1
  32. sqlglot/optimizer/eliminate_joins.py +1 -1
  33. sqlglot/optimizer/eliminate_subqueries.py +2 -2
  34. sqlglot/optimizer/merge_subqueries.py +5 -5
  35. sqlglot/optimizer/normalize.py +20 -13
  36. sqlglot/optimizer/normalize_identifiers.py +17 -3
  37. sqlglot/optimizer/optimizer.py +4 -0
  38. sqlglot/optimizer/pushdown_predicates.py +1 -1
  39. sqlglot/optimizer/qualify.py +14 -6
  40. sqlglot/optimizer/qualify_columns.py +113 -352
  41. sqlglot/optimizer/qualify_tables.py +112 -70
  42. sqlglot/optimizer/resolver.py +374 -0
  43. sqlglot/optimizer/scope.py +27 -16
  44. sqlglot/optimizer/simplify.py +1074 -964
  45. sqlglot/optimizer/unnest_subqueries.py +12 -2
  46. sqlglot/parser.py +276 -160
  47. sqlglot/planner.py +2 -2
  48. sqlglot/schema.py +15 -4
  49. sqlglot/tokens.py +42 -7
  50. sqlglot/transforms.py +77 -22
  51. sqlglot/typing/__init__.py +316 -0
  52. sqlglot/typing/bigquery.py +376 -0
  53. sqlglot/typing/hive.py +12 -0
  54. sqlglot/typing/presto.py +24 -0
  55. sqlglot/typing/snowflake.py +505 -0
  56. sqlglot/typing/spark2.py +58 -0
  57. sqlglot/typing/tsql.py +9 -0
  58. {sqlglot-27.29.0.dist-info → sqlglot-28.4.1.dist-info}/METADATA +2 -2
  59. sqlglot-28.4.1.dist-info/RECORD +92 -0
  60. sqlglot-27.29.0.dist-info/RECORD +0 -84
  61. {sqlglot-27.29.0.dist-info → sqlglot-28.4.1.dist-info}/WHEEL +0 -0
  62. {sqlglot-27.29.0.dist-info → sqlglot-28.4.1.dist-info}/licenses/LICENSE +0 -0
  63. {sqlglot-27.29.0.dist-info → sqlglot-28.4.1.dist-info}/top_level.txt +0 -0
sqlglot/expressions.py CHANGED
@@ -16,6 +16,7 @@ import datetime
16
16
  import math
17
17
  import numbers
18
18
  import re
19
+ import sys
19
20
  import textwrap
20
21
  import typing as t
21
22
  from collections import deque
@@ -54,6 +55,7 @@ class _Expression(type):
54
55
  # When an Expression class is created, its key is automatically set
55
56
  # to be the lowercase version of the class' name.
56
57
  klass.key = clsname.lower()
58
+ klass.required_args = {k for k, v in klass.arg_types.items() if v}
57
59
 
58
60
  # This is so that docstrings are not inherited in pdoc
59
61
  klass.__doc__ = klass.__doc__ or ""
@@ -66,6 +68,7 @@ SQLGLOT_ANONYMOUS = "sqlglot.anonymous"
66
68
  TABLE_PARTS = ("this", "db", "catalog")
67
69
  COLUMN_PARTS = ("this", "table", "db", "catalog")
68
70
  POSITION_META_KEYS = ("line", "col", "start", "end")
71
+ UNITTEST = "unittest" in sys.modules or "pytest" in sys.modules
69
72
 
70
73
 
71
74
  class Expression(metaclass=_Expression):
@@ -102,6 +105,7 @@ class Expression(metaclass=_Expression):
102
105
 
103
106
  key = "expression"
104
107
  arg_types = {"this": True}
108
+ required_args = {"this"}
105
109
  __slots__ = ("args", "parent", "arg_key", "index", "comments", "_type", "_meta", "_hash")
106
110
 
107
111
  def __init__(self, **args: t.Any):
@@ -768,12 +772,14 @@ class Expression(metaclass=_Expression):
768
772
  """
769
773
  errors: t.List[str] = []
770
774
 
771
- for k in self.args:
772
- if k not in self.arg_types:
773
- errors.append(f"Unexpected keyword: '{k}' for {self.__class__}")
774
- for k, mandatory in self.arg_types.items():
775
+ if UNITTEST:
776
+ for k in self.args:
777
+ if k not in self.arg_types:
778
+ raise TypeError(f"Unexpected keyword: '{k}' for {self.__class__}")
779
+
780
+ for k in self.required_args:
775
781
  v = self.args.get(k)
776
- if mandatory and (v is None or (isinstance(v, list) and not v)):
782
+ if v is None or (type(v) is list and not v):
777
783
  errors.append(f"Required keyword: '{k}' missing for {self.__class__}")
778
784
 
779
785
  if (
@@ -883,29 +889,39 @@ class Expression(metaclass=_Expression):
883
889
  return not_(self, copy=copy)
884
890
 
885
891
  def update_positions(
886
- self: E, other: t.Optional[Token | Expression] = None, **kwargs: t.Any
892
+ self: E,
893
+ other: t.Optional[Token | Expression] = None,
894
+ line: t.Optional[int] = None,
895
+ col: t.Optional[int] = None,
896
+ start: t.Optional[int] = None,
897
+ end: t.Optional[int] = None,
887
898
  ) -> E:
888
899
  """
889
900
  Update this expression with positions from a token or other expression.
890
901
 
891
902
  Args:
892
903
  other: a token or expression to update this expression with.
904
+ line: the line number to use if other is None
905
+ col: column number
906
+ start: start char index
907
+ end: end char index
893
908
 
894
909
  Returns:
895
910
  The updated expression.
896
911
  """
897
- if isinstance(other, Expression):
898
- self.meta.update({k: v for k, v in other.meta.items() if k in POSITION_META_KEYS})
899
- elif other is not None:
900
- self.meta.update(
901
- {
902
- "line": other.line,
903
- "col": other.col,
904
- "start": other.start,
905
- "end": other.end,
906
- }
907
- )
908
- self.meta.update({k: v for k, v in kwargs.items() if k in POSITION_META_KEYS})
912
+ if other is None:
913
+ self.meta["line"] = line
914
+ self.meta["col"] = col
915
+ self.meta["start"] = start
916
+ self.meta["end"] = end
917
+ elif hasattr(other, "meta"):
918
+ for k in POSITION_META_KEYS:
919
+ self.meta[k] = other.meta[k]
920
+ else:
921
+ self.meta["line"] = other.line
922
+ self.meta["col"] = other.col
923
+ self.meta["start"] = other.start
924
+ self.meta["end"] = other.end
909
925
  return self
910
926
 
911
927
  def as_(
@@ -1247,7 +1263,7 @@ class Query(Expression):
1247
1263
  @property
1248
1264
  def ctes(self) -> t.List[CTE]:
1249
1265
  """Returns a list of all the CTEs attached to this query."""
1250
- with_ = self.args.get("with")
1266
+ with_ = self.args.get("with_")
1251
1267
  return with_.expressions if with_ else []
1252
1268
 
1253
1269
  @property
@@ -1337,7 +1353,7 @@ class Query(Expression):
1337
1353
  append: bool = True,
1338
1354
  dialect: DialectType = None,
1339
1355
  copy: bool = True,
1340
- scalar: bool = False,
1356
+ scalar: t.Optional[bool] = None,
1341
1357
  **opts,
1342
1358
  ) -> Q:
1343
1359
  """
@@ -1468,14 +1484,14 @@ class Uncache(Expression):
1468
1484
 
1469
1485
 
1470
1486
  class Refresh(Expression):
1471
- pass
1487
+ arg_types = {"this": True, "kind": True}
1472
1488
 
1473
1489
 
1474
1490
  class DDL(Expression):
1475
1491
  @property
1476
1492
  def ctes(self) -> t.List[CTE]:
1477
1493
  """Returns a list of all the CTEs attached to this statement."""
1478
- with_ = self.args.get("with")
1494
+ with_ = self.args.get("with_")
1479
1495
  return with_.expressions if with_ else []
1480
1496
 
1481
1497
  @property
@@ -1536,7 +1552,7 @@ class DML(Expression):
1536
1552
 
1537
1553
  class Create(DDL):
1538
1554
  arg_types = {
1539
- "with": False,
1555
+ "with_": False,
1540
1556
  "this": True,
1541
1557
  "kind": True,
1542
1558
  "expression": False,
@@ -1615,7 +1631,7 @@ class Detach(Expression):
1615
1631
 
1616
1632
  # https://duckdb.org/docs/sql/statements/load_and_install.html
1617
1633
  class Install(Expression):
1618
- arg_types = {"this": True, "from": False, "force": False}
1634
+ arg_types = {"this": True, "from_": False, "force": False}
1619
1635
 
1620
1636
 
1621
1637
  # https://duckdb.org/docs/guides/meta/summarize.html
@@ -1653,7 +1669,7 @@ class SetItem(Expression):
1653
1669
  "expressions": False,
1654
1670
  "kind": False,
1655
1671
  "collate": False, # MySQL SET NAMES statement
1656
- "global": False,
1672
+ "global_": False,
1657
1673
  }
1658
1674
 
1659
1675
 
@@ -1670,7 +1686,7 @@ class Show(Expression):
1670
1686
  "offset": False,
1671
1687
  "starts_with": False,
1672
1688
  "limit": False,
1673
- "from": False,
1689
+ "from_": False,
1674
1690
  "like": False,
1675
1691
  "where": False,
1676
1692
  "db": False,
@@ -1680,7 +1696,7 @@ class Show(Expression):
1680
1696
  "mutex": False,
1681
1697
  "query": False,
1682
1698
  "channel": False,
1683
- "global": False,
1699
+ "global_": False,
1684
1700
  "log": False,
1685
1701
  "position": False,
1686
1702
  "types": False,
@@ -1751,7 +1767,7 @@ class HexString(Condition):
1751
1767
 
1752
1768
 
1753
1769
  class ByteString(Condition):
1754
- pass
1770
+ arg_types = {"this": True, "is_bytes": False}
1755
1771
 
1756
1772
 
1757
1773
  class RawString(Condition):
@@ -1803,6 +1819,10 @@ class Column(Condition):
1803
1819
  return Dot.build(deepcopy(parts)) if len(parts) > 1 else parts[0]
1804
1820
 
1805
1821
 
1822
+ class Pseudocolumn(Column):
1823
+ pass
1824
+
1825
+
1806
1826
  class ColumnPosition(Expression):
1807
1827
  arg_types = {"this": False, "position": True}
1808
1828
 
@@ -1952,6 +1972,10 @@ class AutoIncrementColumnConstraint(ColumnConstraintKind):
1952
1972
  pass
1953
1973
 
1954
1974
 
1975
+ class ZeroFillColumnConstraint(ColumnConstraint):
1976
+ arg_types = {}
1977
+
1978
+
1955
1979
  class PeriodForSystemTimeConstraint(ColumnConstraintKind):
1956
1980
  arg_types = {"this": True, "expression": True}
1957
1981
 
@@ -2116,11 +2140,12 @@ class Constraint(Expression):
2116
2140
 
2117
2141
  class Delete(DML):
2118
2142
  arg_types = {
2119
- "with": False,
2143
+ "with_": False,
2120
2144
  "this": False,
2121
2145
  "using": False,
2122
2146
  "where": False,
2123
2147
  "returning": False,
2148
+ "order": False,
2124
2149
  "limit": False,
2125
2150
  "tables": False, # Multiple-Table Syntax (MySQL)
2126
2151
  "cluster": False, # Clickhouse
@@ -2295,7 +2320,7 @@ class ColumnPrefix(Expression):
2295
2320
 
2296
2321
 
2297
2322
  class PrimaryKey(Expression):
2298
- arg_types = {"expressions": True, "options": False, "include": False}
2323
+ arg_types = {"this": False, "expressions": True, "options": False, "include": False}
2299
2324
 
2300
2325
 
2301
2326
  # https://www.postgresql.org/docs/9.1/sql-selectinto.html
@@ -2333,7 +2358,7 @@ class JoinHint(Expression):
2333
2358
 
2334
2359
 
2335
2360
  class Identifier(Expression):
2336
- arg_types = {"this": True, "quoted": False, "global": False, "temporary": False}
2361
+ arg_types = {"this": True, "quoted": False, "global_": False, "temporary": False}
2337
2362
 
2338
2363
  @property
2339
2364
  def quoted(self) -> bool:
@@ -2376,7 +2401,7 @@ class IndexParameters(Expression):
2376
2401
  class Insert(DDL, DML):
2377
2402
  arg_types = {
2378
2403
  "hint": False,
2379
- "with": False,
2404
+ "with_": False,
2380
2405
  "is_function": False,
2381
2406
  "this": False,
2382
2407
  "expression": False,
@@ -2603,7 +2628,7 @@ class Join(Expression):
2603
2628
  "kind": False,
2604
2629
  "using": False,
2605
2630
  "method": False,
2606
- "global": False,
2631
+ "global_": False,
2607
2632
  "hint": False,
2608
2633
  "match_condition": False, # Snowflake
2609
2634
  "expressions": False,
@@ -2782,7 +2807,7 @@ class Order(Expression):
2782
2807
  # https://clickhouse.com/docs/en/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier
2783
2808
  class WithFill(Expression):
2784
2809
  arg_types = {
2785
- "from": False,
2810
+ "from_": False,
2786
2811
  "to": False,
2787
2812
  "step": False,
2788
2813
  "interpolate": False,
@@ -2886,7 +2911,7 @@ class DataBlocksizeProperty(Property):
2886
2911
 
2887
2912
 
2888
2913
  class DataDeletionProperty(Property):
2889
- arg_types = {"on": True, "filter_col": False, "retention_period": False}
2914
+ arg_types = {"on": True, "filter_column": False, "retention_period": False}
2890
2915
 
2891
2916
 
2892
2917
  class DefinerProperty(Property):
@@ -3196,11 +3221,17 @@ class SchemaCommentProperty(Property):
3196
3221
 
3197
3222
 
3198
3223
  class SemanticView(Expression):
3199
- arg_types = {"this": True, "metrics": False, "dimensions": False, "where": False}
3224
+ arg_types = {
3225
+ "this": True,
3226
+ "metrics": False,
3227
+ "dimensions": False,
3228
+ "facts": False,
3229
+ "where": False,
3230
+ }
3200
3231
 
3201
3232
 
3202
3233
  class SerdeProperties(Property):
3203
- arg_types = {"expressions": True, "with": False}
3234
+ arg_types = {"expressions": True, "with_": False}
3204
3235
 
3205
3236
 
3206
3237
  class SetProperty(Property):
@@ -3228,7 +3259,7 @@ class SqlReadWriteProperty(Property):
3228
3259
 
3229
3260
 
3230
3261
  class SqlSecurityProperty(Property):
3231
- arg_types = {"definer": True}
3262
+ arg_types = {"this": True}
3232
3263
 
3233
3264
 
3234
3265
  class StabilityProperty(Property):
@@ -3296,7 +3327,7 @@ class WithSystemVersioningProperty(Property):
3296
3327
  "this": False,
3297
3328
  "data_consistency": False,
3298
3329
  "retention_period": False,
3299
- "with": True,
3330
+ "with_": True,
3300
3331
  }
3301
3332
 
3302
3333
 
@@ -3506,6 +3537,7 @@ class Table(Expression):
3506
3537
  "changes": False,
3507
3538
  "rows_from": False,
3508
3539
  "sample": False,
3540
+ "indexed": False,
3509
3541
  }
3510
3542
 
3511
3543
  @property
@@ -3564,7 +3596,7 @@ class Table(Expression):
3564
3596
 
3565
3597
  class SetOperation(Query):
3566
3598
  arg_types = {
3567
- "with": False,
3599
+ "with_": False,
3568
3600
  "this": True,
3569
3601
  "expression": True,
3570
3602
  "distinct": False,
@@ -3592,7 +3624,10 @@ class SetOperation(Query):
3592
3624
 
3593
3625
  @property
3594
3626
  def named_selects(self) -> t.List[str]:
3595
- return self.this.unnest().named_selects
3627
+ expression = self
3628
+ while isinstance(expression, SetOperation):
3629
+ expression = expression.this.unnest()
3630
+ return expression.named_selects
3596
3631
 
3597
3632
  @property
3598
3633
  def is_star(self) -> bool:
@@ -3600,7 +3635,10 @@ class SetOperation(Query):
3600
3635
 
3601
3636
  @property
3602
3637
  def selects(self) -> t.List[Expression]:
3603
- return self.this.unnest().selects
3638
+ expression = self
3639
+ while isinstance(expression, SetOperation):
3640
+ expression = expression.this.unnest()
3641
+ return expression.selects
3604
3642
 
3605
3643
  @property
3606
3644
  def left(self) -> Query:
@@ -3633,10 +3671,10 @@ class Intersect(SetOperation):
3633
3671
 
3634
3672
  class Update(DML):
3635
3673
  arg_types = {
3636
- "with": False,
3674
+ "with_": False,
3637
3675
  "this": False,
3638
- "expressions": True,
3639
- "from": False,
3676
+ "expressions": False,
3677
+ "from_": False,
3640
3678
  "where": False,
3641
3679
  "returning": False,
3642
3680
  "order": False,
@@ -3784,7 +3822,7 @@ class Update(DML):
3784
3822
  return _apply_builder(
3785
3823
  expression=expression,
3786
3824
  instance=self,
3787
- arg="from",
3825
+ arg="from_",
3788
3826
  into=From,
3789
3827
  prefix="FROM",
3790
3828
  dialect=dialect,
@@ -3880,13 +3918,13 @@ class Lock(Expression):
3880
3918
 
3881
3919
  class Select(Query):
3882
3920
  arg_types = {
3883
- "with": False,
3921
+ "with_": False,
3884
3922
  "kind": False,
3885
3923
  "expressions": False,
3886
3924
  "hint": False,
3887
3925
  "distinct": False,
3888
3926
  "into": False,
3889
- "from": False,
3927
+ "from_": False,
3890
3928
  "operation_modifiers": False,
3891
3929
  **QUERY_MODIFIERS,
3892
3930
  }
@@ -3915,7 +3953,7 @@ class Select(Query):
3915
3953
  return _apply_builder(
3916
3954
  expression=expression,
3917
3955
  instance=self,
3918
- arg="from",
3956
+ arg="from_",
3919
3957
  into=From,
3920
3958
  prefix="FROM",
3921
3959
  dialect=dialect,
@@ -4417,7 +4455,7 @@ class Subquery(DerivedTable, Query):
4417
4455
  arg_types = {
4418
4456
  "this": True,
4419
4457
  "alias": False,
4420
- "with": False,
4458
+ "with_": False,
4421
4459
  **QUERY_MODIFIERS,
4422
4460
  }
4423
4461
 
@@ -4505,6 +4543,7 @@ class Pivot(Expression):
4505
4543
  "include_nulls": False,
4506
4544
  "default_on_null": False,
4507
4545
  "into": False,
4546
+ "with_": False,
4508
4547
  }
4509
4548
 
4510
4549
  @property
@@ -4554,7 +4593,7 @@ class Where(Expression):
4554
4593
 
4555
4594
 
4556
4595
  class Star(Expression):
4557
- arg_types = {"except": False, "replace": False, "rename": False}
4596
+ arg_types = {"except_": False, "replace": False, "rename": False}
4558
4597
 
4559
4598
  @property
4560
4599
  def name(self) -> str:
@@ -4626,6 +4665,7 @@ class DataType(Expression):
4626
4665
  SIMPLEAGGREGATEFUNCTION = auto()
4627
4666
  BIGDECIMAL = auto()
4628
4667
  BIGINT = auto()
4668
+ BIGNUM = auto()
4629
4669
  BIGSERIAL = auto()
4630
4670
  BINARY = auto()
4631
4671
  BIT = auto()
@@ -4645,11 +4685,13 @@ class DataType(Expression):
4645
4685
  DECIMAL64 = auto()
4646
4686
  DECIMAL128 = auto()
4647
4687
  DECIMAL256 = auto()
4688
+ DECFLOAT = auto()
4648
4689
  DOUBLE = auto()
4649
4690
  DYNAMIC = auto()
4650
4691
  ENUM = auto()
4651
4692
  ENUM8 = auto()
4652
4693
  ENUM16 = auto()
4694
+ FILE = auto()
4653
4695
  FIXEDSTRING = auto()
4654
4696
  FLOAT = auto()
4655
4697
  GEOGRAPHY = auto()
@@ -4712,6 +4754,7 @@ class DataType(Expression):
4712
4754
  TINYTEXT = auto()
4713
4755
  TIME = auto()
4714
4756
  TIMETZ = auto()
4757
+ TIME_NS = auto()
4715
4758
  TIMESTAMP = auto()
4716
4759
  TIMESTAMPNTZ = auto()
4717
4760
  TIMESTAMPLTZ = auto()
@@ -4746,6 +4789,7 @@ class DataType(Expression):
4746
4789
  TDIGEST = auto()
4747
4790
 
4748
4791
  STRUCT_TYPES = {
4792
+ Type.FILE,
4749
4793
  Type.NESTED,
4750
4794
  Type.OBJECT,
4751
4795
  Type.STRUCT,
@@ -4811,6 +4855,7 @@ class DataType(Expression):
4811
4855
  Type.DECIMAL64,
4812
4856
  Type.DECIMAL128,
4813
4857
  Type.DECIMAL256,
4858
+ Type.DECFLOAT,
4814
4859
  Type.MONEY,
4815
4860
  Type.SMALLMONEY,
4816
4861
  Type.UDECIMAL,
@@ -5094,7 +5139,7 @@ class Connector(Binary):
5094
5139
 
5095
5140
 
5096
5141
  class BitwiseAnd(Binary):
5097
- pass
5142
+ arg_types = {"this": True, "expression": True, "padside": False}
5098
5143
 
5099
5144
 
5100
5145
  class BitwiseLeftShift(Binary):
@@ -5102,7 +5147,7 @@ class BitwiseLeftShift(Binary):
5102
5147
 
5103
5148
 
5104
5149
  class BitwiseOr(Binary):
5105
- pass
5150
+ arg_types = {"this": True, "expression": True, "padside": False}
5106
5151
 
5107
5152
 
5108
5153
  class BitwiseRightShift(Binary):
@@ -5110,7 +5155,7 @@ class BitwiseRightShift(Binary):
5110
5155
 
5111
5156
 
5112
5157
  class BitwiseXor(Binary):
5113
- pass
5158
+ arg_types = {"this": True, "expression": True, "padside": False}
5114
5159
 
5115
5160
 
5116
5161
  class Div(Binary):
@@ -5121,6 +5166,14 @@ class Overlaps(Binary):
5121
5166
  pass
5122
5167
 
5123
5168
 
5169
+ class ExtendsLeft(Binary):
5170
+ pass
5171
+
5172
+
5173
+ class ExtendsRight(Binary):
5174
+ pass
5175
+
5176
+
5124
5177
  class Dot(Binary):
5125
5178
  @property
5126
5179
  def is_star(self) -> bool:
@@ -5223,6 +5276,10 @@ class Like(Binary, Predicate):
5223
5276
  pass
5224
5277
 
5225
5278
 
5279
+ class Match(Binary, Predicate):
5280
+ pass
5281
+
5282
+
5226
5283
  class LT(Binary, Predicate):
5227
5284
  pass
5228
5285
 
@@ -5252,10 +5309,6 @@ class SimilarTo(Binary, Predicate):
5252
5309
  pass
5253
5310
 
5254
5311
 
5255
- class Slice(Binary):
5256
- arg_types = {"this": False, "expression": False}
5257
-
5258
-
5259
5312
  class Sub(Binary):
5260
5313
  pass
5261
5314
 
@@ -5590,10 +5643,18 @@ class CosineDistance(Func):
5590
5643
  arg_types = {"this": True, "expression": True}
5591
5644
 
5592
5645
 
5646
+ class DotProduct(Func):
5647
+ arg_types = {"this": True, "expression": True}
5648
+
5649
+
5593
5650
  class EuclideanDistance(Func):
5594
5651
  arg_types = {"this": True, "expression": True}
5595
5652
 
5596
5653
 
5654
+ class ManhattanDistance(Func):
5655
+ arg_types = {"this": True, "expression": True}
5656
+
5657
+
5597
5658
  class JarowinklerSimilarity(Func):
5598
5659
  arg_types = {"this": True, "expression": True}
5599
5660
 
@@ -5614,10 +5675,34 @@ class BitwiseXorAgg(AggFunc):
5614
5675
  pass
5615
5676
 
5616
5677
 
5678
+ class BoolxorAgg(AggFunc):
5679
+ pass
5680
+
5681
+
5617
5682
  class BitwiseCount(Func):
5618
5683
  pass
5619
5684
 
5620
5685
 
5686
+ class BitmapBucketNumber(Func):
5687
+ pass
5688
+
5689
+
5690
+ class BitmapCount(Func):
5691
+ pass
5692
+
5693
+
5694
+ class BitmapBitPosition(Func):
5695
+ pass
5696
+
5697
+
5698
+ class BitmapConstructAgg(AggFunc):
5699
+ pass
5700
+
5701
+
5702
+ class BitmapOrAgg(AggFunc):
5703
+ pass
5704
+
5705
+
5621
5706
  class ByteLength(Func):
5622
5707
  pass
5623
5708
 
@@ -5665,6 +5750,21 @@ class ApproxTopK(AggFunc):
5665
5750
  arg_types = {"this": True, "expression": False, "counters": False}
5666
5751
 
5667
5752
 
5753
+ # https://docs.snowflake.com/en/sql-reference/functions/approx_top_k_accumulate
5754
+ # https://spark.apache.org/docs/preview/api/sql/index.html#approx_top_k_accumulate
5755
+ class ApproxTopKAccumulate(AggFunc):
5756
+ arg_types = {"this": True, "expression": False}
5757
+
5758
+
5759
+ # https://docs.snowflake.com/en/sql-reference/functions/approx_top_k_combine
5760
+ class ApproxTopKCombine(AggFunc):
5761
+ arg_types = {"this": True, "expression": False}
5762
+
5763
+
5764
+ class ApproxTopKEstimate(Func):
5765
+ arg_types = {"this": True, "expression": False}
5766
+
5767
+
5668
5768
  class ApproxTopSum(AggFunc):
5669
5769
  arg_types = {"this": True, "expression": True, "count": True}
5670
5770
 
@@ -5673,6 +5773,27 @@ class ApproxQuantiles(AggFunc):
5673
5773
  arg_types = {"this": True, "expression": False}
5674
5774
 
5675
5775
 
5776
+ # https://docs.snowflake.com/en/sql-reference/functions/approx_percentile_combine
5777
+ class ApproxPercentileCombine(AggFunc):
5778
+ pass
5779
+
5780
+
5781
+ # https://docs.snowflake.com/en/sql-reference/functions/minhash
5782
+ class Minhash(AggFunc):
5783
+ arg_types = {"this": True, "expressions": True}
5784
+ is_var_len_args = True
5785
+
5786
+
5787
+ # https://docs.snowflake.com/en/sql-reference/functions/minhash_combine
5788
+ class MinhashCombine(AggFunc):
5789
+ pass
5790
+
5791
+
5792
+ # https://docs.snowflake.com/en/sql-reference/functions/approximate_similarity
5793
+ class ApproximateSimilarity(AggFunc):
5794
+ _sql_names = ["APPROXIMATE_SIMILARITY", "APPROXIMATE_JACCARD_INDEX"]
5795
+
5796
+
5676
5797
  class FarmFingerprint(Func):
5677
5798
  arg_types = {"expressions": True}
5678
5799
  is_var_len_args = True
@@ -5693,7 +5814,7 @@ class Transform(Func):
5693
5814
 
5694
5815
 
5695
5816
  class Translate(Func):
5696
- arg_types = {"this": True, "from": True, "to": True}
5817
+ arg_types = {"this": True, "from_": True, "to": True}
5697
5818
 
5698
5819
 
5699
5820
  class Grouping(AggFunc):
@@ -5701,6 +5822,11 @@ class Grouping(AggFunc):
5701
5822
  is_var_len_args = True
5702
5823
 
5703
5824
 
5825
+ class GroupingId(AggFunc):
5826
+ arg_types = {"expressions": True}
5827
+ is_var_len_args = True
5828
+
5829
+
5704
5830
  class Anonymous(Func):
5705
5831
  arg_types = {"this": True, "expressions": False}
5706
5832
  is_var_len_args = True
@@ -5724,6 +5850,12 @@ class CombinedParameterizedAgg(ParameterizedAgg):
5724
5850
  arg_types = {"this": True, "expressions": True, "params": True}
5725
5851
 
5726
5852
 
5853
+ # https://docs.snowflake.com/en/sql-reference/functions/hash_agg
5854
+ class HashAgg(AggFunc):
5855
+ arg_types = {"this": True, "expressions": False}
5856
+ is_var_len_args = True
5857
+
5858
+
5727
5859
  # https://docs.snowflake.com/en/sql-reference/functions/hll
5728
5860
  # https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html
5729
5861
  class Hll(AggFunc):
@@ -5741,7 +5873,11 @@ class Apply(Func):
5741
5873
 
5742
5874
 
5743
5875
  class Array(Func):
5744
- arg_types = {"expressions": False, "bracket_notation": False}
5876
+ arg_types = {
5877
+ "expressions": False,
5878
+ "bracket_notation": False,
5879
+ "struct_name_inheritance": False,
5880
+ }
5745
5881
  is_var_len_args = True
5746
5882
 
5747
5883
 
@@ -5754,6 +5890,10 @@ class ToArray(Func):
5754
5890
  pass
5755
5891
 
5756
5892
 
5893
+ class ToBoolean(Func):
5894
+ arg_types = {"this": True, "safe": False}
5895
+
5896
+
5757
5897
  # https://materialize.com/docs/sql/types/list/
5758
5898
  class List(Func):
5759
5899
  arg_types = {"expressions": False}
@@ -5789,17 +5929,45 @@ class ToNumber(Func):
5789
5929
  "nlsparam": False,
5790
5930
  "precision": False,
5791
5931
  "scale": False,
5932
+ "safe": False,
5933
+ "safe_name": False,
5792
5934
  }
5793
5935
 
5794
5936
 
5795
5937
  # https://docs.snowflake.com/en/sql-reference/functions/to_double
5796
5938
  class ToDouble(Func):
5939
+ arg_types = {
5940
+ "this": True,
5941
+ "format": False,
5942
+ "safe": False,
5943
+ }
5944
+
5945
+
5946
+ # https://docs.snowflake.com/en/sql-reference/functions/to_decfloat
5947
+ class ToDecfloat(Func):
5948
+ arg_types = {
5949
+ "this": True,
5950
+ "format": False,
5951
+ }
5952
+
5953
+
5954
+ # https://docs.snowflake.com/en/sql-reference/functions/try_to_decfloat
5955
+ class TryToDecfloat(Func):
5797
5956
  arg_types = {
5798
5957
  "this": True,
5799
5958
  "format": False,
5800
5959
  }
5801
5960
 
5802
5961
 
5962
+ # https://docs.snowflake.com/en/sql-reference/functions/to_file
5963
+ class ToFile(Func):
5964
+ arg_types = {
5965
+ "this": True,
5966
+ "path": False,
5967
+ "safe": False,
5968
+ }
5969
+
5970
+
5803
5971
  class CodePointsToBytes(Func):
5804
5972
  pass
5805
5973
 
@@ -5810,7 +5978,7 @@ class Columns(Func):
5810
5978
 
5811
5979
  # https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16#syntax
5812
5980
  class Convert(Func):
5813
- arg_types = {"this": True, "expression": True, "style": False}
5981
+ arg_types = {"this": True, "expression": True, "style": False, "safe": False}
5814
5982
 
5815
5983
 
5816
5984
  # https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CONVERT.html
@@ -5884,7 +6052,7 @@ class ArrayConcatAgg(AggFunc):
5884
6052
 
5885
6053
 
5886
6054
  class ArrayConstructCompact(Func):
5887
- arg_types = {"expressions": True}
6055
+ arg_types = {"expressions": False}
5888
6056
  is_var_len_args = True
5889
6057
 
5890
6058
 
@@ -6007,6 +6175,10 @@ class NthValue(AggFunc):
6007
6175
  arg_types = {"this": True, "offset": True}
6008
6176
 
6009
6177
 
6178
+ class ObjectAgg(AggFunc):
6179
+ arg_types = {"this": True, "expression": True}
6180
+
6181
+
6010
6182
  class Case(Func):
6011
6183
  arg_types = {"this": False, "ifs": True, "default": False}
6012
6184
 
@@ -6093,6 +6265,14 @@ class CastToStrType(Func):
6093
6265
  arg_types = {"this": True, "to": True}
6094
6266
 
6095
6267
 
6268
+ class CheckJson(Func):
6269
+ arg_types = {"this": True}
6270
+
6271
+
6272
+ class CheckXml(Func):
6273
+ arg_types = {"this": True, "disable_auto_convert": False}
6274
+
6275
+
6096
6276
  # https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Functions-Expressions-and-Predicates/String-Operators-and-Functions/TRANSLATE/TRANSLATE-Function-Syntax
6097
6277
  class TranslateCharacters(Expression):
6098
6278
  arg_types = {"this": True, "expression": True, "with_error": False}
@@ -6156,6 +6336,58 @@ class Cbrt(Func):
6156
6336
  pass
6157
6337
 
6158
6338
 
6339
+ class CurrentAccount(Func):
6340
+ arg_types = {}
6341
+
6342
+
6343
+ class CurrentAccountName(Func):
6344
+ arg_types = {}
6345
+
6346
+
6347
+ class CurrentAvailableRoles(Func):
6348
+ arg_types = {}
6349
+
6350
+
6351
+ class CurrentClient(Func):
6352
+ arg_types = {}
6353
+
6354
+
6355
+ class CurrentIpAddress(Func):
6356
+ arg_types = {}
6357
+
6358
+
6359
+ class CurrentDatabase(Func):
6360
+ arg_types = {}
6361
+
6362
+
6363
+ class CurrentSchemas(Func):
6364
+ arg_types = {"this": False}
6365
+
6366
+
6367
+ class CurrentSecondaryRoles(Func):
6368
+ arg_types = {}
6369
+
6370
+
6371
+ class CurrentSession(Func):
6372
+ arg_types = {}
6373
+
6374
+
6375
+ class CurrentStatement(Func):
6376
+ arg_types = {}
6377
+
6378
+
6379
+ class CurrentVersion(Func):
6380
+ arg_types = {}
6381
+
6382
+
6383
+ class CurrentTransaction(Func):
6384
+ arg_types = {}
6385
+
6386
+
6387
+ class CurrentWarehouse(Func):
6388
+ arg_types = {}
6389
+
6390
+
6159
6391
  class CurrentDate(Func):
6160
6392
  arg_types = {"this": False}
6161
6393
 
@@ -6168,6 +6400,16 @@ class CurrentTime(Func):
6168
6400
  arg_types = {"this": False}
6169
6401
 
6170
6402
 
6403
+ # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
6404
+ # In Postgres, the difference between CURRENT_TIME vs LOCALTIME etc is that the latter does not have tz
6405
+ class Localtime(Func):
6406
+ arg_types = {"this": False}
6407
+
6408
+
6409
+ class Localtimestamp(Func):
6410
+ arg_types = {"this": False}
6411
+
6412
+
6171
6413
  class CurrentTimestamp(Func):
6172
6414
  arg_types = {"this": False, "sysdate": False}
6173
6415
 
@@ -6176,6 +6418,18 @@ class CurrentTimestampLTZ(Func):
6176
6418
  arg_types = {}
6177
6419
 
6178
6420
 
6421
+ class CurrentTimezone(Func):
6422
+ arg_types = {}
6423
+
6424
+
6425
+ class Sysdate(Func):
6426
+ arg_types = {}
6427
+
6428
+
6429
+ class CurrentOrganizationName(Func):
6430
+ arg_types = {}
6431
+
6432
+
6179
6433
  class CurrentSchema(Func):
6180
6434
  arg_types = {"this": False}
6181
6435
 
@@ -6184,6 +6438,30 @@ class CurrentUser(Func):
6184
6438
  arg_types = {"this": False}
6185
6439
 
6186
6440
 
6441
+ class CurrentCatalog(Func):
6442
+ arg_types = {}
6443
+
6444
+
6445
+ class CurrentRegion(Func):
6446
+ arg_types = {}
6447
+
6448
+
6449
+ class CurrentRole(Func):
6450
+ arg_types = {}
6451
+
6452
+
6453
+ class CurrentRoleType(Func):
6454
+ arg_types = {}
6455
+
6456
+
6457
+ class CurrentOrganizationUser(Func):
6458
+ arg_types = {}
6459
+
6460
+
6461
+ class SessionUser(Func):
6462
+ arg_types = {}
6463
+
6464
+
6187
6465
  class UtcDate(Func):
6188
6466
  arg_types = {}
6189
6467
 
@@ -6210,7 +6488,14 @@ class DateSub(Func, IntervalOp):
6210
6488
 
6211
6489
  class DateDiff(Func, TimeUnit):
6212
6490
  _sql_names = ["DATEDIFF", "DATE_DIFF"]
6213
- arg_types = {"this": True, "expression": True, "unit": False, "zone": False}
6491
+ arg_types = {
6492
+ "this": True,
6493
+ "expression": True,
6494
+ "unit": False,
6495
+ "zone": False,
6496
+ "big_int": False,
6497
+ "date_part_boundary": False,
6498
+ }
6214
6499
 
6215
6500
 
6216
6501
  class DateTrunc(Func):
@@ -6346,8 +6631,13 @@ class Exists(Func, SubqueryPredicate):
6346
6631
  arg_types = {"this": True, "expression": False}
6347
6632
 
6348
6633
 
6634
+ class Elt(Func):
6635
+ arg_types = {"this": True, "expressions": True}
6636
+ is_var_len_args = True
6637
+
6638
+
6349
6639
  class Timestamp(Func):
6350
- arg_types = {"this": False, "zone": False, "with_tz": False}
6640
+ arg_types = {"this": False, "zone": False, "with_tz": False, "safe": False}
6351
6641
 
6352
6642
 
6353
6643
  class TimestampAdd(Func, TimeUnit):
@@ -6389,7 +6679,7 @@ class TimeTrunc(Func, TimeUnit):
6389
6679
 
6390
6680
  class DateFromParts(Func):
6391
6681
  _sql_names = ["DATE_FROM_PARTS", "DATEFROMPARTS"]
6392
- arg_types = {"year": True, "month": True, "day": True}
6682
+ arg_types = {"year": True, "month": False, "day": False}
6393
6683
 
6394
6684
 
6395
6685
  class TimeFromParts(Func):
@@ -6524,6 +6814,10 @@ class ToBase64(Func):
6524
6814
  pass
6525
6815
 
6526
6816
 
6817
+ class ToBinary(Func):
6818
+ arg_types = {"this": True, "format": False, "safe": False}
6819
+
6820
+
6527
6821
  # https://docs.snowflake.com/en/sql-reference/functions/base64_decode_binary
6528
6822
  class Base64DecodeBinary(Func):
6529
6823
  arg_types = {"this": True, "alphabet": False}
@@ -6591,8 +6885,12 @@ class GetExtract(Func):
6591
6885
  arg_types = {"this": True, "expression": True}
6592
6886
 
6593
6887
 
6888
+ class Getbit(Func):
6889
+ arg_types = {"this": True, "expression": True}
6890
+
6891
+
6594
6892
  class Greatest(Func):
6595
- arg_types = {"this": True, "expressions": False}
6893
+ arg_types = {"this": True, "expressions": False, "null_if_any_null": False}
6596
6894
  is_var_len_args = True
6597
6895
 
6598
6896
 
@@ -6710,7 +7008,7 @@ class IsNullValue(Func):
6710
7008
 
6711
7009
  # https://www.postgresql.org/docs/current/functions-json.html
6712
7010
  class JSON(Expression):
6713
- arg_types = {"this": False, "with": False, "unique": False}
7011
+ arg_types = {"this": False, "with_": False, "unique": False}
6714
7012
 
6715
7013
 
6716
7014
  class JSONPath(Expression):
@@ -6831,7 +7129,13 @@ class JSONArrayAgg(Func):
6831
7129
 
6832
7130
 
6833
7131
  class JSONExists(Func):
6834
- arg_types = {"this": True, "path": True, "passing": False, "on_condition": False}
7132
+ arg_types = {
7133
+ "this": True,
7134
+ "path": True,
7135
+ "passing": False,
7136
+ "on_condition": False,
7137
+ "from_dcolonqmark": False,
7138
+ }
6835
7139
 
6836
7140
 
6837
7141
  # https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_TABLE.html
@@ -6988,6 +7292,7 @@ class JSONExtractScalar(Binary, Func):
6988
7292
  "only_json_types": False,
6989
7293
  "expressions": False,
6990
7294
  "json_type": False,
7295
+ "scalar_only": False,
6991
7296
  }
6992
7297
  _sql_names = ["JSON_EXTRACT_SCALAR"]
6993
7298
  is_var_len_args = True
@@ -7063,7 +7368,7 @@ class ParseDatetime(Func):
7063
7368
 
7064
7369
 
7065
7370
  class Least(Func):
7066
- arg_types = {"this": True, "expressions": False}
7371
+ arg_types = {"this": True, "expressions": False, "null_if_any_null": False}
7067
7372
  is_var_len_args = True
7068
7373
 
7069
7374
 
@@ -7151,6 +7456,10 @@ class ScopeResolution(Expression):
7151
7456
  arg_types = {"this": False, "expression": True}
7152
7457
 
7153
7458
 
7459
+ class Slice(Expression):
7460
+ arg_types = {"this": False, "expression": False, "step": False}
7461
+
7462
+
7154
7463
  class Stream(Expression):
7155
7464
  pass
7156
7465
 
@@ -7205,6 +7514,10 @@ class Median(AggFunc):
7205
7514
  pass
7206
7515
 
7207
7516
 
7517
+ class Mode(AggFunc):
7518
+ arg_types = {"this": False, "deterministic": False}
7519
+
7520
+
7208
7521
  class Min(AggFunc):
7209
7522
  arg_types = {"this": True, "expressions": False}
7210
7523
  is_var_len_args = True
@@ -7234,8 +7547,17 @@ class Normalize(Func):
7234
7547
  arg_types = {"this": True, "form": False, "is_casefold": False}
7235
7548
 
7236
7549
 
7550
+ class Normal(Func):
7551
+ arg_types = {"this": True, "stddev": True, "gen": True}
7552
+
7553
+
7554
+ # https://cloud.google.com/bigquery/docs/reference/standard-sql/net_functions#nethost
7555
+ class NetHost(Func):
7556
+ _sql_names = ["NET.HOST"]
7557
+
7558
+
7237
7559
  class Overlay(Func):
7238
- arg_types = {"this": True, "expression": True, "from": True, "for": False}
7560
+ arg_types = {"this": True, "expression": True, "from_": True, "for_": False}
7239
7561
 
7240
7562
 
7241
7563
  # https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict#mlpredict_function
@@ -7316,6 +7638,16 @@ class ApproxQuantile(Quantile):
7316
7638
  }
7317
7639
 
7318
7640
 
7641
+ # https://docs.snowflake.com/en/sql-reference/functions/approx_percentile_accumulate
7642
+ class ApproxPercentileAccumulate(AggFunc):
7643
+ pass
7644
+
7645
+
7646
+ # https://docs.snowflake.com/en/sql-reference/functions/approx_percentile_estimate
7647
+ class ApproxPercentileEstimate(Func):
7648
+ arg_types = {"this": True, "percentile": True}
7649
+
7650
+
7319
7651
  class Quarter(Func):
7320
7652
  pass
7321
7653
 
@@ -7331,6 +7663,10 @@ class Randn(Func):
7331
7663
  arg_types = {"this": False}
7332
7664
 
7333
7665
 
7666
+ class Randstr(Func):
7667
+ arg_types = {"this": True, "generator": False}
7668
+
7669
+
7334
7670
  class RangeN(Func):
7335
7671
  arg_types = {"this": True, "expressions": True, "each": False}
7336
7672
 
@@ -7367,6 +7703,7 @@ class RegexpExtract(Func):
7367
7703
  "occurrence": False,
7368
7704
  "parameters": False,
7369
7705
  "group": False,
7706
+ "null_if_pos_overflow": False, # for transpilation target behavior
7370
7707
  }
7371
7708
 
7372
7709
 
@@ -7374,10 +7711,10 @@ class RegexpExtractAll(Func):
7374
7711
  arg_types = {
7375
7712
  "this": True,
7376
7713
  "expression": True,
7714
+ "group": False,
7715
+ "parameters": False,
7377
7716
  "position": False,
7378
7717
  "occurrence": False,
7379
- "parameters": False,
7380
- "group": False,
7381
7718
  }
7382
7719
 
7383
7720
 
@@ -7432,11 +7769,47 @@ class RegexpCount(Func):
7432
7769
  }
7433
7770
 
7434
7771
 
7435
- class RegrValx(Func):
7772
+ class RegrValx(AggFunc):
7773
+ arg_types = {"this": True, "expression": True}
7774
+
7775
+
7776
+ class RegrValy(AggFunc):
7777
+ arg_types = {"this": True, "expression": True}
7778
+
7779
+
7780
+ class RegrAvgy(AggFunc):
7781
+ arg_types = {"this": True, "expression": True}
7782
+
7783
+
7784
+ class RegrAvgx(AggFunc):
7785
+ arg_types = {"this": True, "expression": True}
7786
+
7787
+
7788
+ class RegrCount(AggFunc):
7789
+ arg_types = {"this": True, "expression": True}
7790
+
7791
+
7792
+ class RegrIntercept(AggFunc):
7793
+ arg_types = {"this": True, "expression": True}
7794
+
7795
+
7796
+ class RegrR2(AggFunc):
7797
+ arg_types = {"this": True, "expression": True}
7798
+
7799
+
7800
+ class RegrSxx(AggFunc):
7436
7801
  arg_types = {"this": True, "expression": True}
7437
7802
 
7438
7803
 
7439
- class RegrValy(Func):
7804
+ class RegrSxy(AggFunc):
7805
+ arg_types = {"this": True, "expression": True}
7806
+
7807
+
7808
+ class RegrSyy(AggFunc):
7809
+ arg_types = {"this": True, "expression": True}
7810
+
7811
+
7812
+ class RegrSlope(AggFunc):
7440
7813
  arg_types = {"this": True, "expression": True}
7441
7814
 
7442
7815
 
@@ -7456,7 +7829,12 @@ class Radians(Func):
7456
7829
  # https://learn.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-ver16
7457
7830
  # tsql third argument function == trunctaion if not 0
7458
7831
  class Round(Func):
7459
- arg_types = {"this": True, "decimals": False, "truncate": False}
7832
+ arg_types = {
7833
+ "this": True,
7834
+ "decimals": False,
7835
+ "truncate": False,
7836
+ "casts_non_integer_decimals": False,
7837
+ }
7460
7838
 
7461
7839
 
7462
7840
  class RowNumber(Func):
@@ -7588,6 +7966,11 @@ class Search(Func):
7588
7966
  }
7589
7967
 
7590
7968
 
7969
+ # Snowflake: https://docs.snowflake.com/en/sql-reference/functions/search_ip
7970
+ class SearchIp(Func):
7971
+ arg_types = {"this": True, "expression": True}
7972
+
7973
+
7591
7974
  class StrToDate(Func):
7592
7975
  arg_types = {"this": True, "format": False, "safe": False}
7593
7976
 
@@ -7748,6 +8131,10 @@ class Unicode(Func):
7748
8131
  pass
7749
8132
 
7750
8133
 
8134
+ class Uniform(Func):
8135
+ arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
8136
+
8137
+
7751
8138
  # https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#unix_date
7752
8139
  class UnixDate(Func):
7753
8140
  pass
@@ -7800,7 +8187,7 @@ class UnixMillis(Func):
7800
8187
  class Uuid(Func):
7801
8188
  _sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
7802
8189
 
7803
- arg_types = {"this": False, "name": False}
8190
+ arg_types = {"this": False, "name": False, "is_string": False}
7804
8191
 
7805
8192
 
7806
8193
  TIMESTAMP_PARTS = {
@@ -7860,6 +8247,10 @@ class VariancePop(AggFunc):
7860
8247
  _sql_names = ["VARIANCE_POP", "VAR_POP"]
7861
8248
 
7862
8249
 
8250
+ class Skewness(AggFunc):
8251
+ pass
8252
+
8253
+
7863
8254
  class WidthBucket(Func):
7864
8255
  arg_types = {"this": True, "min_value": True, "max_value": True, "num_buckets": True}
7865
8256
 
@@ -7889,6 +8280,11 @@ class XMLElement(Func):
7889
8280
  arg_types = {"this": True, "expressions": False}
7890
8281
 
7891
8282
 
8283
+ class XMLGet(Func):
8284
+ _sql_names = ["XMLGET"]
8285
+ arg_types = {"this": True, "expression": True, "instance": False}
8286
+
8287
+
7892
8288
  class XMLTable(Func):
7893
8289
  arg_types = {
7894
8290
  "this": True,
@@ -7912,6 +8308,10 @@ class Year(Func):
7912
8308
  pass
7913
8309
 
7914
8310
 
8311
+ class Zipf(Func):
8312
+ arg_types = {"this": True, "elementcount": True, "gen": True}
8313
+
8314
+
7915
8315
  class Use(Expression):
7916
8316
  arg_types = {"this": False, "expressions": False, "kind": False}
7917
8317
 
@@ -7923,7 +8323,7 @@ class Merge(DML):
7923
8323
  "on": False,
7924
8324
  "using_cond": False,
7925
8325
  "whens": True,
7926
- "with": False,
8326
+ "with_": False,
7927
8327
  "returning": False,
7928
8328
  }
7929
8329
 
@@ -7956,10 +8356,10 @@ class TableColumn(Expression):
7956
8356
  pass
7957
8357
 
7958
8358
 
7959
- ALL_FUNCTIONS = subclasses(__name__, Func, (AggFunc, Anonymous, Func))
8359
+ ALL_FUNCTIONS = subclasses(__name__, Func, {AggFunc, Anonymous, Func})
7960
8360
  FUNCTION_BY_NAME = {name: func for func in ALL_FUNCTIONS for name in func.sql_names()}
7961
8361
 
7962
- JSON_PATH_PARTS = subclasses(__name__, JSONPathPart, (JSONPathPart,))
8362
+ JSON_PATH_PARTS = subclasses(__name__, JSONPathPart, {JSONPathPart})
7963
8363
 
7964
8364
  PERCENTILES = (PercentileCont, PercentileDisc)
7965
8365
 
@@ -8232,7 +8632,7 @@ def _apply_cte_builder(
8232
8632
  append: bool = True,
8233
8633
  dialect: DialectType = None,
8234
8634
  copy: bool = True,
8235
- scalar: bool = False,
8635
+ scalar: t.Optional[bool] = None,
8236
8636
  **opts,
8237
8637
  ) -> E:
8238
8638
  alias_expression = maybe_parse(alias, dialect=dialect, into=TableAlias, **opts)
@@ -8244,11 +8644,11 @@ def _apply_cte_builder(
8244
8644
  return _apply_child_list_builder(
8245
8645
  cte,
8246
8646
  instance=instance,
8247
- arg="with",
8647
+ arg="with_",
8248
8648
  append=append,
8249
8649
  copy=copy,
8250
8650
  into=With,
8251
- properties={"recursive": recursive or False},
8651
+ properties={"recursive": recursive} if recursive else {},
8252
8652
  )
8253
8653
 
8254
8654
 
@@ -8477,7 +8877,7 @@ def update(
8477
8877
  )
8478
8878
  if from_:
8479
8879
  update_expr.set(
8480
- "from",
8880
+ "from_",
8481
8881
  maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts),
8482
8882
  )
8483
8883
  if isinstance(where, Condition):
@@ -8493,7 +8893,7 @@ def update(
8493
8893
  for alias, qry in with_.items()
8494
8894
  ]
8495
8895
  update_expr.set(
8496
- "with",
8896
+ "with_",
8497
8897
  With(expressions=cte_list),
8498
8898
  )
8499
8899
  return update_expr