sqlglot 27.27.0__py3-none-any.whl → 28.4.0__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.
- sqlglot/__init__.py +1 -0
- sqlglot/__main__.py +6 -4
- sqlglot/_version.py +2 -2
- sqlglot/dialects/bigquery.py +118 -279
- sqlglot/dialects/clickhouse.py +73 -5
- sqlglot/dialects/databricks.py +38 -1
- sqlglot/dialects/dialect.py +354 -275
- sqlglot/dialects/dremio.py +4 -1
- sqlglot/dialects/duckdb.py +754 -25
- sqlglot/dialects/exasol.py +243 -10
- sqlglot/dialects/hive.py +8 -8
- sqlglot/dialects/mysql.py +14 -4
- sqlglot/dialects/oracle.py +29 -0
- sqlglot/dialects/postgres.py +60 -26
- sqlglot/dialects/presto.py +47 -16
- sqlglot/dialects/redshift.py +16 -0
- sqlglot/dialects/risingwave.py +3 -0
- sqlglot/dialects/singlestore.py +12 -3
- sqlglot/dialects/snowflake.py +239 -218
- sqlglot/dialects/spark.py +15 -4
- sqlglot/dialects/spark2.py +11 -48
- sqlglot/dialects/sqlite.py +10 -0
- sqlglot/dialects/starrocks.py +3 -0
- sqlglot/dialects/teradata.py +5 -8
- sqlglot/dialects/trino.py +6 -0
- sqlglot/dialects/tsql.py +61 -22
- sqlglot/diff.py +4 -2
- sqlglot/errors.py +69 -0
- sqlglot/executor/__init__.py +5 -10
- sqlglot/executor/python.py +1 -29
- sqlglot/expressions.py +637 -100
- sqlglot/generator.py +160 -43
- sqlglot/helper.py +2 -44
- sqlglot/lineage.py +10 -4
- sqlglot/optimizer/annotate_types.py +247 -140
- sqlglot/optimizer/canonicalize.py +6 -1
- sqlglot/optimizer/eliminate_joins.py +1 -1
- sqlglot/optimizer/eliminate_subqueries.py +2 -2
- sqlglot/optimizer/merge_subqueries.py +5 -5
- sqlglot/optimizer/normalize.py +20 -13
- sqlglot/optimizer/normalize_identifiers.py +17 -3
- sqlglot/optimizer/optimizer.py +4 -0
- sqlglot/optimizer/pushdown_predicates.py +1 -1
- sqlglot/optimizer/qualify.py +18 -10
- sqlglot/optimizer/qualify_columns.py +122 -275
- sqlglot/optimizer/qualify_tables.py +128 -76
- sqlglot/optimizer/resolver.py +374 -0
- sqlglot/optimizer/scope.py +27 -16
- sqlglot/optimizer/simplify.py +1075 -959
- sqlglot/optimizer/unnest_subqueries.py +12 -2
- sqlglot/parser.py +296 -170
- sqlglot/planner.py +2 -2
- sqlglot/schema.py +15 -4
- sqlglot/tokens.py +42 -7
- sqlglot/transforms.py +77 -22
- sqlglot/typing/__init__.py +316 -0
- sqlglot/typing/bigquery.py +376 -0
- sqlglot/typing/hive.py +12 -0
- sqlglot/typing/presto.py +24 -0
- sqlglot/typing/snowflake.py +505 -0
- sqlglot/typing/spark2.py +58 -0
- sqlglot/typing/tsql.py +9 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/METADATA +2 -2
- sqlglot-28.4.0.dist-info/RECORD +92 -0
- sqlglot-27.27.0.dist-info/RECORD +0 -84
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/WHEEL +0 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.dist-info}/licenses/LICENSE +0 -0
- {sqlglot-27.27.0.dist-info → sqlglot-28.4.0.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):
|
|
@@ -118,7 +122,7 @@ class Expression(metaclass=_Expression):
|
|
|
118
122
|
self._set_parent(arg_key, value)
|
|
119
123
|
|
|
120
124
|
def __eq__(self, other) -> bool:
|
|
121
|
-
return type(self) is type(other) and hash(self) == hash(other)
|
|
125
|
+
return self is other or (type(self) is type(other) and hash(self) == hash(other))
|
|
122
126
|
|
|
123
127
|
def __hash__(self) -> int:
|
|
124
128
|
if self._hash is None:
|
|
@@ -454,9 +458,8 @@ class Expression(metaclass=_Expression):
|
|
|
454
458
|
for v in reversed(vs) if reverse else vs: # type: ignore
|
|
455
459
|
if hasattr(v, "parent"):
|
|
456
460
|
yield v
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
yield vs
|
|
461
|
+
elif hasattr(vs, "parent"):
|
|
462
|
+
yield vs
|
|
460
463
|
|
|
461
464
|
def find(self, *expression_types: t.Type[E], bfs: bool = True) -> t.Optional[E]:
|
|
462
465
|
"""
|
|
@@ -769,12 +772,14 @@ class Expression(metaclass=_Expression):
|
|
|
769
772
|
"""
|
|
770
773
|
errors: t.List[str] = []
|
|
771
774
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
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:
|
|
776
781
|
v = self.args.get(k)
|
|
777
|
-
if
|
|
782
|
+
if v is None or (type(v) is list and not v):
|
|
778
783
|
errors.append(f"Required keyword: '{k}' missing for {self.__class__}")
|
|
779
784
|
|
|
780
785
|
if (
|
|
@@ -884,29 +889,39 @@ class Expression(metaclass=_Expression):
|
|
|
884
889
|
return not_(self, copy=copy)
|
|
885
890
|
|
|
886
891
|
def update_positions(
|
|
887
|
-
self: E,
|
|
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,
|
|
888
898
|
) -> E:
|
|
889
899
|
"""
|
|
890
900
|
Update this expression with positions from a token or other expression.
|
|
891
901
|
|
|
892
902
|
Args:
|
|
893
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
|
|
894
908
|
|
|
895
909
|
Returns:
|
|
896
910
|
The updated expression.
|
|
897
911
|
"""
|
|
898
|
-
if
|
|
899
|
-
self.meta
|
|
900
|
-
|
|
901
|
-
self.meta
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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
|
|
910
925
|
return self
|
|
911
926
|
|
|
912
927
|
def as_(
|
|
@@ -1248,7 +1263,7 @@ class Query(Expression):
|
|
|
1248
1263
|
@property
|
|
1249
1264
|
def ctes(self) -> t.List[CTE]:
|
|
1250
1265
|
"""Returns a list of all the CTEs attached to this query."""
|
|
1251
|
-
with_ = self.args.get("
|
|
1266
|
+
with_ = self.args.get("with_")
|
|
1252
1267
|
return with_.expressions if with_ else []
|
|
1253
1268
|
|
|
1254
1269
|
@property
|
|
@@ -1338,7 +1353,7 @@ class Query(Expression):
|
|
|
1338
1353
|
append: bool = True,
|
|
1339
1354
|
dialect: DialectType = None,
|
|
1340
1355
|
copy: bool = True,
|
|
1341
|
-
scalar: bool =
|
|
1356
|
+
scalar: t.Optional[bool] = None,
|
|
1342
1357
|
**opts,
|
|
1343
1358
|
) -> Q:
|
|
1344
1359
|
"""
|
|
@@ -1469,14 +1484,14 @@ class Uncache(Expression):
|
|
|
1469
1484
|
|
|
1470
1485
|
|
|
1471
1486
|
class Refresh(Expression):
|
|
1472
|
-
|
|
1487
|
+
arg_types = {"this": True, "kind": True}
|
|
1473
1488
|
|
|
1474
1489
|
|
|
1475
1490
|
class DDL(Expression):
|
|
1476
1491
|
@property
|
|
1477
1492
|
def ctes(self) -> t.List[CTE]:
|
|
1478
1493
|
"""Returns a list of all the CTEs attached to this statement."""
|
|
1479
|
-
with_ = self.args.get("
|
|
1494
|
+
with_ = self.args.get("with_")
|
|
1480
1495
|
return with_.expressions if with_ else []
|
|
1481
1496
|
|
|
1482
1497
|
@property
|
|
@@ -1537,7 +1552,7 @@ class DML(Expression):
|
|
|
1537
1552
|
|
|
1538
1553
|
class Create(DDL):
|
|
1539
1554
|
arg_types = {
|
|
1540
|
-
"
|
|
1555
|
+
"with_": False,
|
|
1541
1556
|
"this": True,
|
|
1542
1557
|
"kind": True,
|
|
1543
1558
|
"expression": False,
|
|
@@ -1616,7 +1631,7 @@ class Detach(Expression):
|
|
|
1616
1631
|
|
|
1617
1632
|
# https://duckdb.org/docs/sql/statements/load_and_install.html
|
|
1618
1633
|
class Install(Expression):
|
|
1619
|
-
arg_types = {"this": True, "
|
|
1634
|
+
arg_types = {"this": True, "from_": False, "force": False}
|
|
1620
1635
|
|
|
1621
1636
|
|
|
1622
1637
|
# https://duckdb.org/docs/guides/meta/summarize.html
|
|
@@ -1654,7 +1669,7 @@ class SetItem(Expression):
|
|
|
1654
1669
|
"expressions": False,
|
|
1655
1670
|
"kind": False,
|
|
1656
1671
|
"collate": False, # MySQL SET NAMES statement
|
|
1657
|
-
"
|
|
1672
|
+
"global_": False,
|
|
1658
1673
|
}
|
|
1659
1674
|
|
|
1660
1675
|
|
|
@@ -1671,7 +1686,7 @@ class Show(Expression):
|
|
|
1671
1686
|
"offset": False,
|
|
1672
1687
|
"starts_with": False,
|
|
1673
1688
|
"limit": False,
|
|
1674
|
-
"
|
|
1689
|
+
"from_": False,
|
|
1675
1690
|
"like": False,
|
|
1676
1691
|
"where": False,
|
|
1677
1692
|
"db": False,
|
|
@@ -1681,7 +1696,7 @@ class Show(Expression):
|
|
|
1681
1696
|
"mutex": False,
|
|
1682
1697
|
"query": False,
|
|
1683
1698
|
"channel": False,
|
|
1684
|
-
"
|
|
1699
|
+
"global_": False,
|
|
1685
1700
|
"log": False,
|
|
1686
1701
|
"position": False,
|
|
1687
1702
|
"types": False,
|
|
@@ -1752,7 +1767,7 @@ class HexString(Condition):
|
|
|
1752
1767
|
|
|
1753
1768
|
|
|
1754
1769
|
class ByteString(Condition):
|
|
1755
|
-
|
|
1770
|
+
arg_types = {"this": True, "is_bytes": False}
|
|
1756
1771
|
|
|
1757
1772
|
|
|
1758
1773
|
class RawString(Condition):
|
|
@@ -1804,6 +1819,10 @@ class Column(Condition):
|
|
|
1804
1819
|
return Dot.build(deepcopy(parts)) if len(parts) > 1 else parts[0]
|
|
1805
1820
|
|
|
1806
1821
|
|
|
1822
|
+
class Pseudocolumn(Column):
|
|
1823
|
+
pass
|
|
1824
|
+
|
|
1825
|
+
|
|
1807
1826
|
class ColumnPosition(Expression):
|
|
1808
1827
|
arg_types = {"this": False, "position": True}
|
|
1809
1828
|
|
|
@@ -1894,7 +1913,13 @@ class Comment(Expression):
|
|
|
1894
1913
|
|
|
1895
1914
|
|
|
1896
1915
|
class Comprehension(Expression):
|
|
1897
|
-
arg_types = {
|
|
1916
|
+
arg_types = {
|
|
1917
|
+
"this": True,
|
|
1918
|
+
"expression": True,
|
|
1919
|
+
"position": False,
|
|
1920
|
+
"iterator": True,
|
|
1921
|
+
"condition": False,
|
|
1922
|
+
}
|
|
1898
1923
|
|
|
1899
1924
|
|
|
1900
1925
|
# https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree#mergetree-table-ttl
|
|
@@ -1947,6 +1972,10 @@ class AutoIncrementColumnConstraint(ColumnConstraintKind):
|
|
|
1947
1972
|
pass
|
|
1948
1973
|
|
|
1949
1974
|
|
|
1975
|
+
class ZeroFillColumnConstraint(ColumnConstraint):
|
|
1976
|
+
arg_types = {}
|
|
1977
|
+
|
|
1978
|
+
|
|
1950
1979
|
class PeriodForSystemTimeConstraint(ColumnConstraintKind):
|
|
1951
1980
|
arg_types = {"this": True, "expression": True}
|
|
1952
1981
|
|
|
@@ -2111,11 +2140,12 @@ class Constraint(Expression):
|
|
|
2111
2140
|
|
|
2112
2141
|
class Delete(DML):
|
|
2113
2142
|
arg_types = {
|
|
2114
|
-
"
|
|
2143
|
+
"with_": False,
|
|
2115
2144
|
"this": False,
|
|
2116
2145
|
"using": False,
|
|
2117
2146
|
"where": False,
|
|
2118
2147
|
"returning": False,
|
|
2148
|
+
"order": False,
|
|
2119
2149
|
"limit": False,
|
|
2120
2150
|
"tables": False, # Multiple-Table Syntax (MySQL)
|
|
2121
2151
|
"cluster": False, # Clickhouse
|
|
@@ -2290,7 +2320,7 @@ class ColumnPrefix(Expression):
|
|
|
2290
2320
|
|
|
2291
2321
|
|
|
2292
2322
|
class PrimaryKey(Expression):
|
|
2293
|
-
arg_types = {"expressions": True, "options": False, "include": False}
|
|
2323
|
+
arg_types = {"this": False, "expressions": True, "options": False, "include": False}
|
|
2294
2324
|
|
|
2295
2325
|
|
|
2296
2326
|
# https://www.postgresql.org/docs/9.1/sql-selectinto.html
|
|
@@ -2328,7 +2358,7 @@ class JoinHint(Expression):
|
|
|
2328
2358
|
|
|
2329
2359
|
|
|
2330
2360
|
class Identifier(Expression):
|
|
2331
|
-
arg_types = {"this": True, "quoted": False, "
|
|
2361
|
+
arg_types = {"this": True, "quoted": False, "global_": False, "temporary": False}
|
|
2332
2362
|
|
|
2333
2363
|
@property
|
|
2334
2364
|
def quoted(self) -> bool:
|
|
@@ -2371,7 +2401,7 @@ class IndexParameters(Expression):
|
|
|
2371
2401
|
class Insert(DDL, DML):
|
|
2372
2402
|
arg_types = {
|
|
2373
2403
|
"hint": False,
|
|
2374
|
-
"
|
|
2404
|
+
"with_": False,
|
|
2375
2405
|
"is_function": False,
|
|
2376
2406
|
"this": False,
|
|
2377
2407
|
"expression": False,
|
|
@@ -2598,7 +2628,7 @@ class Join(Expression):
|
|
|
2598
2628
|
"kind": False,
|
|
2599
2629
|
"using": False,
|
|
2600
2630
|
"method": False,
|
|
2601
|
-
"
|
|
2631
|
+
"global_": False,
|
|
2602
2632
|
"hint": False,
|
|
2603
2633
|
"match_condition": False, # Snowflake
|
|
2604
2634
|
"expressions": False,
|
|
@@ -2777,7 +2807,7 @@ class Order(Expression):
|
|
|
2777
2807
|
# https://clickhouse.com/docs/en/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier
|
|
2778
2808
|
class WithFill(Expression):
|
|
2779
2809
|
arg_types = {
|
|
2780
|
-
"
|
|
2810
|
+
"from_": False,
|
|
2781
2811
|
"to": False,
|
|
2782
2812
|
"step": False,
|
|
2783
2813
|
"interpolate": False,
|
|
@@ -2881,7 +2911,7 @@ class DataBlocksizeProperty(Property):
|
|
|
2881
2911
|
|
|
2882
2912
|
|
|
2883
2913
|
class DataDeletionProperty(Property):
|
|
2884
|
-
arg_types = {"on": True, "
|
|
2914
|
+
arg_types = {"on": True, "filter_column": False, "retention_period": False}
|
|
2885
2915
|
|
|
2886
2916
|
|
|
2887
2917
|
class DefinerProperty(Property):
|
|
@@ -3191,11 +3221,17 @@ class SchemaCommentProperty(Property):
|
|
|
3191
3221
|
|
|
3192
3222
|
|
|
3193
3223
|
class SemanticView(Expression):
|
|
3194
|
-
arg_types = {
|
|
3224
|
+
arg_types = {
|
|
3225
|
+
"this": True,
|
|
3226
|
+
"metrics": False,
|
|
3227
|
+
"dimensions": False,
|
|
3228
|
+
"facts": False,
|
|
3229
|
+
"where": False,
|
|
3230
|
+
}
|
|
3195
3231
|
|
|
3196
3232
|
|
|
3197
3233
|
class SerdeProperties(Property):
|
|
3198
|
-
arg_types = {"expressions": True, "
|
|
3234
|
+
arg_types = {"expressions": True, "with_": False}
|
|
3199
3235
|
|
|
3200
3236
|
|
|
3201
3237
|
class SetProperty(Property):
|
|
@@ -3223,7 +3259,7 @@ class SqlReadWriteProperty(Property):
|
|
|
3223
3259
|
|
|
3224
3260
|
|
|
3225
3261
|
class SqlSecurityProperty(Property):
|
|
3226
|
-
arg_types = {"
|
|
3262
|
+
arg_types = {"this": True}
|
|
3227
3263
|
|
|
3228
3264
|
|
|
3229
3265
|
class StabilityProperty(Property):
|
|
@@ -3291,7 +3327,7 @@ class WithSystemVersioningProperty(Property):
|
|
|
3291
3327
|
"this": False,
|
|
3292
3328
|
"data_consistency": False,
|
|
3293
3329
|
"retention_period": False,
|
|
3294
|
-
"
|
|
3330
|
+
"with_": True,
|
|
3295
3331
|
}
|
|
3296
3332
|
|
|
3297
3333
|
|
|
@@ -3501,6 +3537,7 @@ class Table(Expression):
|
|
|
3501
3537
|
"changes": False,
|
|
3502
3538
|
"rows_from": False,
|
|
3503
3539
|
"sample": False,
|
|
3540
|
+
"indexed": False,
|
|
3504
3541
|
}
|
|
3505
3542
|
|
|
3506
3543
|
@property
|
|
@@ -3559,7 +3596,7 @@ class Table(Expression):
|
|
|
3559
3596
|
|
|
3560
3597
|
class SetOperation(Query):
|
|
3561
3598
|
arg_types = {
|
|
3562
|
-
"
|
|
3599
|
+
"with_": False,
|
|
3563
3600
|
"this": True,
|
|
3564
3601
|
"expression": True,
|
|
3565
3602
|
"distinct": False,
|
|
@@ -3587,7 +3624,10 @@ class SetOperation(Query):
|
|
|
3587
3624
|
|
|
3588
3625
|
@property
|
|
3589
3626
|
def named_selects(self) -> t.List[str]:
|
|
3590
|
-
|
|
3627
|
+
expression = self
|
|
3628
|
+
while isinstance(expression, SetOperation):
|
|
3629
|
+
expression = expression.this.unnest()
|
|
3630
|
+
return expression.named_selects
|
|
3591
3631
|
|
|
3592
3632
|
@property
|
|
3593
3633
|
def is_star(self) -> bool:
|
|
@@ -3595,7 +3635,10 @@ class SetOperation(Query):
|
|
|
3595
3635
|
|
|
3596
3636
|
@property
|
|
3597
3637
|
def selects(self) -> t.List[Expression]:
|
|
3598
|
-
|
|
3638
|
+
expression = self
|
|
3639
|
+
while isinstance(expression, SetOperation):
|
|
3640
|
+
expression = expression.this.unnest()
|
|
3641
|
+
return expression.selects
|
|
3599
3642
|
|
|
3600
3643
|
@property
|
|
3601
3644
|
def left(self) -> Query:
|
|
@@ -3628,10 +3671,10 @@ class Intersect(SetOperation):
|
|
|
3628
3671
|
|
|
3629
3672
|
class Update(DML):
|
|
3630
3673
|
arg_types = {
|
|
3631
|
-
"
|
|
3674
|
+
"with_": False,
|
|
3632
3675
|
"this": False,
|
|
3633
|
-
"expressions":
|
|
3634
|
-
"
|
|
3676
|
+
"expressions": False,
|
|
3677
|
+
"from_": False,
|
|
3635
3678
|
"where": False,
|
|
3636
3679
|
"returning": False,
|
|
3637
3680
|
"order": False,
|
|
@@ -3779,7 +3822,7 @@ class Update(DML):
|
|
|
3779
3822
|
return _apply_builder(
|
|
3780
3823
|
expression=expression,
|
|
3781
3824
|
instance=self,
|
|
3782
|
-
arg="
|
|
3825
|
+
arg="from_",
|
|
3783
3826
|
into=From,
|
|
3784
3827
|
prefix="FROM",
|
|
3785
3828
|
dialect=dialect,
|
|
@@ -3834,8 +3877,15 @@ class Update(DML):
|
|
|
3834
3877
|
)
|
|
3835
3878
|
|
|
3836
3879
|
|
|
3880
|
+
# DuckDB supports VALUES followed by https://duckdb.org/docs/stable/sql/query_syntax/limit
|
|
3837
3881
|
class Values(UDTF):
|
|
3838
|
-
arg_types = {
|
|
3882
|
+
arg_types = {
|
|
3883
|
+
"expressions": True,
|
|
3884
|
+
"alias": False,
|
|
3885
|
+
"order": False,
|
|
3886
|
+
"limit": False,
|
|
3887
|
+
"offset": False,
|
|
3888
|
+
}
|
|
3839
3889
|
|
|
3840
3890
|
|
|
3841
3891
|
class Var(Expression):
|
|
@@ -3868,13 +3918,13 @@ class Lock(Expression):
|
|
|
3868
3918
|
|
|
3869
3919
|
class Select(Query):
|
|
3870
3920
|
arg_types = {
|
|
3871
|
-
"
|
|
3921
|
+
"with_": False,
|
|
3872
3922
|
"kind": False,
|
|
3873
3923
|
"expressions": False,
|
|
3874
3924
|
"hint": False,
|
|
3875
3925
|
"distinct": False,
|
|
3876
3926
|
"into": False,
|
|
3877
|
-
"
|
|
3927
|
+
"from_": False,
|
|
3878
3928
|
"operation_modifiers": False,
|
|
3879
3929
|
**QUERY_MODIFIERS,
|
|
3880
3930
|
}
|
|
@@ -3903,7 +3953,7 @@ class Select(Query):
|
|
|
3903
3953
|
return _apply_builder(
|
|
3904
3954
|
expression=expression,
|
|
3905
3955
|
instance=self,
|
|
3906
|
-
arg="
|
|
3956
|
+
arg="from_",
|
|
3907
3957
|
into=From,
|
|
3908
3958
|
prefix="FROM",
|
|
3909
3959
|
dialect=dialect,
|
|
@@ -4405,7 +4455,7 @@ class Subquery(DerivedTable, Query):
|
|
|
4405
4455
|
arg_types = {
|
|
4406
4456
|
"this": True,
|
|
4407
4457
|
"alias": False,
|
|
4408
|
-
"
|
|
4458
|
+
"with_": False,
|
|
4409
4459
|
**QUERY_MODIFIERS,
|
|
4410
4460
|
}
|
|
4411
4461
|
|
|
@@ -4493,6 +4543,7 @@ class Pivot(Expression):
|
|
|
4493
4543
|
"include_nulls": False,
|
|
4494
4544
|
"default_on_null": False,
|
|
4495
4545
|
"into": False,
|
|
4546
|
+
"with_": False,
|
|
4496
4547
|
}
|
|
4497
4548
|
|
|
4498
4549
|
@property
|
|
@@ -4542,7 +4593,7 @@ class Where(Expression):
|
|
|
4542
4593
|
|
|
4543
4594
|
|
|
4544
4595
|
class Star(Expression):
|
|
4545
|
-
arg_types = {"
|
|
4596
|
+
arg_types = {"except_": False, "replace": False, "rename": False}
|
|
4546
4597
|
|
|
4547
4598
|
@property
|
|
4548
4599
|
def name(self) -> str:
|
|
@@ -4614,6 +4665,7 @@ class DataType(Expression):
|
|
|
4614
4665
|
SIMPLEAGGREGATEFUNCTION = auto()
|
|
4615
4666
|
BIGDECIMAL = auto()
|
|
4616
4667
|
BIGINT = auto()
|
|
4668
|
+
BIGNUM = auto()
|
|
4617
4669
|
BIGSERIAL = auto()
|
|
4618
4670
|
BINARY = auto()
|
|
4619
4671
|
BIT = auto()
|
|
@@ -4633,11 +4685,13 @@ class DataType(Expression):
|
|
|
4633
4685
|
DECIMAL64 = auto()
|
|
4634
4686
|
DECIMAL128 = auto()
|
|
4635
4687
|
DECIMAL256 = auto()
|
|
4688
|
+
DECFLOAT = auto()
|
|
4636
4689
|
DOUBLE = auto()
|
|
4637
4690
|
DYNAMIC = auto()
|
|
4638
4691
|
ENUM = auto()
|
|
4639
4692
|
ENUM8 = auto()
|
|
4640
4693
|
ENUM16 = auto()
|
|
4694
|
+
FILE = auto()
|
|
4641
4695
|
FIXEDSTRING = auto()
|
|
4642
4696
|
FLOAT = auto()
|
|
4643
4697
|
GEOGRAPHY = auto()
|
|
@@ -4700,6 +4754,7 @@ class DataType(Expression):
|
|
|
4700
4754
|
TINYTEXT = auto()
|
|
4701
4755
|
TIME = auto()
|
|
4702
4756
|
TIMETZ = auto()
|
|
4757
|
+
TIME_NS = auto()
|
|
4703
4758
|
TIMESTAMP = auto()
|
|
4704
4759
|
TIMESTAMPNTZ = auto()
|
|
4705
4760
|
TIMESTAMPLTZ = auto()
|
|
@@ -4734,6 +4789,7 @@ class DataType(Expression):
|
|
|
4734
4789
|
TDIGEST = auto()
|
|
4735
4790
|
|
|
4736
4791
|
STRUCT_TYPES = {
|
|
4792
|
+
Type.FILE,
|
|
4737
4793
|
Type.NESTED,
|
|
4738
4794
|
Type.OBJECT,
|
|
4739
4795
|
Type.STRUCT,
|
|
@@ -4799,6 +4855,7 @@ class DataType(Expression):
|
|
|
4799
4855
|
Type.DECIMAL64,
|
|
4800
4856
|
Type.DECIMAL128,
|
|
4801
4857
|
Type.DECIMAL256,
|
|
4858
|
+
Type.DECFLOAT,
|
|
4802
4859
|
Type.MONEY,
|
|
4803
4860
|
Type.SMALLMONEY,
|
|
4804
4861
|
Type.UDECIMAL,
|
|
@@ -5082,7 +5139,7 @@ class Connector(Binary):
|
|
|
5082
5139
|
|
|
5083
5140
|
|
|
5084
5141
|
class BitwiseAnd(Binary):
|
|
5085
|
-
|
|
5142
|
+
arg_types = {"this": True, "expression": True, "padside": False}
|
|
5086
5143
|
|
|
5087
5144
|
|
|
5088
5145
|
class BitwiseLeftShift(Binary):
|
|
@@ -5090,7 +5147,7 @@ class BitwiseLeftShift(Binary):
|
|
|
5090
5147
|
|
|
5091
5148
|
|
|
5092
5149
|
class BitwiseOr(Binary):
|
|
5093
|
-
|
|
5150
|
+
arg_types = {"this": True, "expression": True, "padside": False}
|
|
5094
5151
|
|
|
5095
5152
|
|
|
5096
5153
|
class BitwiseRightShift(Binary):
|
|
@@ -5098,7 +5155,7 @@ class BitwiseRightShift(Binary):
|
|
|
5098
5155
|
|
|
5099
5156
|
|
|
5100
5157
|
class BitwiseXor(Binary):
|
|
5101
|
-
|
|
5158
|
+
arg_types = {"this": True, "expression": True, "padside": False}
|
|
5102
5159
|
|
|
5103
5160
|
|
|
5104
5161
|
class Div(Binary):
|
|
@@ -5109,6 +5166,14 @@ class Overlaps(Binary):
|
|
|
5109
5166
|
pass
|
|
5110
5167
|
|
|
5111
5168
|
|
|
5169
|
+
class ExtendsLeft(Binary):
|
|
5170
|
+
pass
|
|
5171
|
+
|
|
5172
|
+
|
|
5173
|
+
class ExtendsRight(Binary):
|
|
5174
|
+
pass
|
|
5175
|
+
|
|
5176
|
+
|
|
5112
5177
|
class Dot(Binary):
|
|
5113
5178
|
@property
|
|
5114
5179
|
def is_star(self) -> bool:
|
|
@@ -5211,6 +5276,10 @@ class Like(Binary, Predicate):
|
|
|
5211
5276
|
pass
|
|
5212
5277
|
|
|
5213
5278
|
|
|
5279
|
+
class Match(Binary, Predicate):
|
|
5280
|
+
pass
|
|
5281
|
+
|
|
5282
|
+
|
|
5214
5283
|
class LT(Binary, Predicate):
|
|
5215
5284
|
pass
|
|
5216
5285
|
|
|
@@ -5240,10 +5309,6 @@ class SimilarTo(Binary, Predicate):
|
|
|
5240
5309
|
pass
|
|
5241
5310
|
|
|
5242
5311
|
|
|
5243
|
-
class Slice(Binary):
|
|
5244
|
-
arg_types = {"this": False, "expression": False}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
5312
|
class Sub(Binary):
|
|
5248
5313
|
pass
|
|
5249
5314
|
|
|
@@ -5578,10 +5643,18 @@ class CosineDistance(Func):
|
|
|
5578
5643
|
arg_types = {"this": True, "expression": True}
|
|
5579
5644
|
|
|
5580
5645
|
|
|
5646
|
+
class DotProduct(Func):
|
|
5647
|
+
arg_types = {"this": True, "expression": True}
|
|
5648
|
+
|
|
5649
|
+
|
|
5581
5650
|
class EuclideanDistance(Func):
|
|
5582
5651
|
arg_types = {"this": True, "expression": True}
|
|
5583
5652
|
|
|
5584
5653
|
|
|
5654
|
+
class ManhattanDistance(Func):
|
|
5655
|
+
arg_types = {"this": True, "expression": True}
|
|
5656
|
+
|
|
5657
|
+
|
|
5585
5658
|
class JarowinklerSimilarity(Func):
|
|
5586
5659
|
arg_types = {"this": True, "expression": True}
|
|
5587
5660
|
|
|
@@ -5602,7 +5675,31 @@ class BitwiseXorAgg(AggFunc):
|
|
|
5602
5675
|
pass
|
|
5603
5676
|
|
|
5604
5677
|
|
|
5605
|
-
class
|
|
5678
|
+
class BoolxorAgg(AggFunc):
|
|
5679
|
+
pass
|
|
5680
|
+
|
|
5681
|
+
|
|
5682
|
+
class BitwiseCount(Func):
|
|
5683
|
+
pass
|
|
5684
|
+
|
|
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):
|
|
5606
5703
|
pass
|
|
5607
5704
|
|
|
5608
5705
|
|
|
@@ -5610,6 +5707,18 @@ class ByteLength(Func):
|
|
|
5610
5707
|
pass
|
|
5611
5708
|
|
|
5612
5709
|
|
|
5710
|
+
class Boolnot(Func):
|
|
5711
|
+
pass
|
|
5712
|
+
|
|
5713
|
+
|
|
5714
|
+
class Booland(Func):
|
|
5715
|
+
arg_types = {"this": True, "expression": True}
|
|
5716
|
+
|
|
5717
|
+
|
|
5718
|
+
class Boolor(Func):
|
|
5719
|
+
arg_types = {"this": True, "expression": True}
|
|
5720
|
+
|
|
5721
|
+
|
|
5613
5722
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#bool_for_json
|
|
5614
5723
|
class JSONBool(Func):
|
|
5615
5724
|
pass
|
|
@@ -5641,6 +5750,21 @@ class ApproxTopK(AggFunc):
|
|
|
5641
5750
|
arg_types = {"this": True, "expression": False, "counters": False}
|
|
5642
5751
|
|
|
5643
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
|
+
|
|
5644
5768
|
class ApproxTopSum(AggFunc):
|
|
5645
5769
|
arg_types = {"this": True, "expression": True, "count": True}
|
|
5646
5770
|
|
|
@@ -5649,6 +5773,27 @@ class ApproxQuantiles(AggFunc):
|
|
|
5649
5773
|
arg_types = {"this": True, "expression": False}
|
|
5650
5774
|
|
|
5651
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
|
+
|
|
5652
5797
|
class FarmFingerprint(Func):
|
|
5653
5798
|
arg_types = {"expressions": True}
|
|
5654
5799
|
is_var_len_args = True
|
|
@@ -5669,7 +5814,7 @@ class Transform(Func):
|
|
|
5669
5814
|
|
|
5670
5815
|
|
|
5671
5816
|
class Translate(Func):
|
|
5672
|
-
arg_types = {"this": True, "
|
|
5817
|
+
arg_types = {"this": True, "from_": True, "to": True}
|
|
5673
5818
|
|
|
5674
5819
|
|
|
5675
5820
|
class Grouping(AggFunc):
|
|
@@ -5677,6 +5822,11 @@ class Grouping(AggFunc):
|
|
|
5677
5822
|
is_var_len_args = True
|
|
5678
5823
|
|
|
5679
5824
|
|
|
5825
|
+
class GroupingId(AggFunc):
|
|
5826
|
+
arg_types = {"expressions": True}
|
|
5827
|
+
is_var_len_args = True
|
|
5828
|
+
|
|
5829
|
+
|
|
5680
5830
|
class Anonymous(Func):
|
|
5681
5831
|
arg_types = {"this": True, "expressions": False}
|
|
5682
5832
|
is_var_len_args = True
|
|
@@ -5700,6 +5850,12 @@ class CombinedParameterizedAgg(ParameterizedAgg):
|
|
|
5700
5850
|
arg_types = {"this": True, "expressions": True, "params": True}
|
|
5701
5851
|
|
|
5702
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
|
+
|
|
5703
5859
|
# https://docs.snowflake.com/en/sql-reference/functions/hll
|
|
5704
5860
|
# https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html
|
|
5705
5861
|
class Hll(AggFunc):
|
|
@@ -5717,7 +5873,11 @@ class Apply(Func):
|
|
|
5717
5873
|
|
|
5718
5874
|
|
|
5719
5875
|
class Array(Func):
|
|
5720
|
-
arg_types = {
|
|
5876
|
+
arg_types = {
|
|
5877
|
+
"expressions": False,
|
|
5878
|
+
"bracket_notation": False,
|
|
5879
|
+
"struct_name_inheritance": False,
|
|
5880
|
+
}
|
|
5721
5881
|
is_var_len_args = True
|
|
5722
5882
|
|
|
5723
5883
|
|
|
@@ -5730,6 +5890,10 @@ class ToArray(Func):
|
|
|
5730
5890
|
pass
|
|
5731
5891
|
|
|
5732
5892
|
|
|
5893
|
+
class ToBoolean(Func):
|
|
5894
|
+
arg_types = {"this": True, "safe": False}
|
|
5895
|
+
|
|
5896
|
+
|
|
5733
5897
|
# https://materialize.com/docs/sql/types/list/
|
|
5734
5898
|
class List(Func):
|
|
5735
5899
|
arg_types = {"expressions": False}
|
|
@@ -5765,6 +5929,8 @@ class ToNumber(Func):
|
|
|
5765
5929
|
"nlsparam": False,
|
|
5766
5930
|
"precision": False,
|
|
5767
5931
|
"scale": False,
|
|
5932
|
+
"safe": False,
|
|
5933
|
+
"safe_name": False,
|
|
5768
5934
|
}
|
|
5769
5935
|
|
|
5770
5936
|
|
|
@@ -5773,6 +5939,32 @@ class ToDouble(Func):
|
|
|
5773
5939
|
arg_types = {
|
|
5774
5940
|
"this": True,
|
|
5775
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):
|
|
5956
|
+
arg_types = {
|
|
5957
|
+
"this": True,
|
|
5958
|
+
"format": False,
|
|
5959
|
+
}
|
|
5960
|
+
|
|
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,
|
|
5776
5968
|
}
|
|
5777
5969
|
|
|
5778
5970
|
|
|
@@ -5786,7 +5978,7 @@ class Columns(Func):
|
|
|
5786
5978
|
|
|
5787
5979
|
# https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16#syntax
|
|
5788
5980
|
class Convert(Func):
|
|
5789
|
-
arg_types = {"this": True, "expression": True, "style": False}
|
|
5981
|
+
arg_types = {"this": True, "expression": True, "style": False, "safe": False}
|
|
5790
5982
|
|
|
5791
5983
|
|
|
5792
5984
|
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CONVERT.html
|
|
@@ -5860,7 +6052,7 @@ class ArrayConcatAgg(AggFunc):
|
|
|
5860
6052
|
|
|
5861
6053
|
|
|
5862
6054
|
class ArrayConstructCompact(Func):
|
|
5863
|
-
arg_types = {"expressions":
|
|
6055
|
+
arg_types = {"expressions": False}
|
|
5864
6056
|
is_var_len_args = True
|
|
5865
6057
|
|
|
5866
6058
|
|
|
@@ -5964,11 +6156,11 @@ class Lead(AggFunc):
|
|
|
5964
6156
|
# some dialects have a distinction between first and first_value, usually first is an aggregate func
|
|
5965
6157
|
# and first_value is a window func
|
|
5966
6158
|
class First(AggFunc):
|
|
5967
|
-
|
|
6159
|
+
arg_types = {"this": True, "expression": False}
|
|
5968
6160
|
|
|
5969
6161
|
|
|
5970
6162
|
class Last(AggFunc):
|
|
5971
|
-
|
|
6163
|
+
arg_types = {"this": True, "expression": False}
|
|
5972
6164
|
|
|
5973
6165
|
|
|
5974
6166
|
class FirstValue(AggFunc):
|
|
@@ -5983,6 +6175,10 @@ class NthValue(AggFunc):
|
|
|
5983
6175
|
arg_types = {"this": True, "offset": True}
|
|
5984
6176
|
|
|
5985
6177
|
|
|
6178
|
+
class ObjectAgg(AggFunc):
|
|
6179
|
+
arg_types = {"this": True, "expression": True}
|
|
6180
|
+
|
|
6181
|
+
|
|
5986
6182
|
class Case(Func):
|
|
5987
6183
|
arg_types = {"this": False, "ifs": True, "default": False}
|
|
5988
6184
|
|
|
@@ -6069,6 +6265,14 @@ class CastToStrType(Func):
|
|
|
6069
6265
|
arg_types = {"this": True, "to": True}
|
|
6070
6266
|
|
|
6071
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
|
+
|
|
6072
6276
|
# https://docs.teradata.com/r/Enterprise_IntelliFlex_VMware/SQL-Functions-Expressions-and-Predicates/String-Operators-and-Functions/TRANSLATE/TRANSLATE-Function-Syntax
|
|
6073
6277
|
class TranslateCharacters(Expression):
|
|
6074
6278
|
arg_types = {"this": True, "expression": True, "with_error": False}
|
|
@@ -6132,6 +6336,58 @@ class Cbrt(Func):
|
|
|
6132
6336
|
pass
|
|
6133
6337
|
|
|
6134
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
|
+
|
|
6135
6391
|
class CurrentDate(Func):
|
|
6136
6392
|
arg_types = {"this": False}
|
|
6137
6393
|
|
|
@@ -6144,6 +6400,16 @@ class CurrentTime(Func):
|
|
|
6144
6400
|
arg_types = {"this": False}
|
|
6145
6401
|
|
|
6146
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
|
+
|
|
6147
6413
|
class CurrentTimestamp(Func):
|
|
6148
6414
|
arg_types = {"this": False, "sysdate": False}
|
|
6149
6415
|
|
|
@@ -6152,6 +6418,18 @@ class CurrentTimestampLTZ(Func):
|
|
|
6152
6418
|
arg_types = {}
|
|
6153
6419
|
|
|
6154
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
|
+
|
|
6155
6433
|
class CurrentSchema(Func):
|
|
6156
6434
|
arg_types = {"this": False}
|
|
6157
6435
|
|
|
@@ -6160,6 +6438,30 @@ class CurrentUser(Func):
|
|
|
6160
6438
|
arg_types = {"this": False}
|
|
6161
6439
|
|
|
6162
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
|
+
|
|
6163
6465
|
class UtcDate(Func):
|
|
6164
6466
|
arg_types = {}
|
|
6165
6467
|
|
|
@@ -6186,7 +6488,14 @@ class DateSub(Func, IntervalOp):
|
|
|
6186
6488
|
|
|
6187
6489
|
class DateDiff(Func, TimeUnit):
|
|
6188
6490
|
_sql_names = ["DATEDIFF", "DATE_DIFF"]
|
|
6189
|
-
arg_types = {
|
|
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
|
+
}
|
|
6190
6499
|
|
|
6191
6500
|
|
|
6192
6501
|
class DateTrunc(Func):
|
|
@@ -6266,6 +6575,14 @@ class WeekOfYear(Func):
|
|
|
6266
6575
|
_sql_names = ["WEEK_OF_YEAR", "WEEKOFYEAR"]
|
|
6267
6576
|
|
|
6268
6577
|
|
|
6578
|
+
class YearOfWeek(Func):
|
|
6579
|
+
_sql_names = ["YEAR_OF_WEEK", "YEAROFWEEK"]
|
|
6580
|
+
|
|
6581
|
+
|
|
6582
|
+
class YearOfWeekIso(Func):
|
|
6583
|
+
_sql_names = ["YEAR_OF_WEEK_ISO", "YEAROFWEEKISO"]
|
|
6584
|
+
|
|
6585
|
+
|
|
6269
6586
|
class MonthsBetween(Func):
|
|
6270
6587
|
arg_types = {"this": True, "expression": True, "roundoff": False}
|
|
6271
6588
|
|
|
@@ -6286,6 +6603,10 @@ class LastDay(Func, TimeUnit):
|
|
|
6286
6603
|
arg_types = {"this": True, "unit": False}
|
|
6287
6604
|
|
|
6288
6605
|
|
|
6606
|
+
class PreviousDay(Func):
|
|
6607
|
+
arg_types = {"this": True, "expression": True}
|
|
6608
|
+
|
|
6609
|
+
|
|
6289
6610
|
class LaxBool(Func):
|
|
6290
6611
|
pass
|
|
6291
6612
|
|
|
@@ -6310,8 +6631,13 @@ class Exists(Func, SubqueryPredicate):
|
|
|
6310
6631
|
arg_types = {"this": True, "expression": False}
|
|
6311
6632
|
|
|
6312
6633
|
|
|
6634
|
+
class Elt(Func):
|
|
6635
|
+
arg_types = {"this": True, "expressions": True}
|
|
6636
|
+
is_var_len_args = True
|
|
6637
|
+
|
|
6638
|
+
|
|
6313
6639
|
class Timestamp(Func):
|
|
6314
|
-
arg_types = {"this": False, "zone": False, "with_tz": False}
|
|
6640
|
+
arg_types = {"this": False, "zone": False, "with_tz": False, "safe": False}
|
|
6315
6641
|
|
|
6316
6642
|
|
|
6317
6643
|
class TimestampAdd(Func, TimeUnit):
|
|
@@ -6331,6 +6657,10 @@ class TimestampTrunc(Func, TimeUnit):
|
|
|
6331
6657
|
arg_types = {"this": True, "unit": True, "zone": False}
|
|
6332
6658
|
|
|
6333
6659
|
|
|
6660
|
+
class TimeSlice(Func, TimeUnit):
|
|
6661
|
+
arg_types = {"this": True, "expression": True, "unit": True, "kind": False}
|
|
6662
|
+
|
|
6663
|
+
|
|
6334
6664
|
class TimeAdd(Func, TimeUnit):
|
|
6335
6665
|
arg_types = {"this": True, "expression": True, "unit": False}
|
|
6336
6666
|
|
|
@@ -6349,7 +6679,7 @@ class TimeTrunc(Func, TimeUnit):
|
|
|
6349
6679
|
|
|
6350
6680
|
class DateFromParts(Func):
|
|
6351
6681
|
_sql_names = ["DATE_FROM_PARTS", "DATEFROMPARTS"]
|
|
6352
|
-
arg_types = {"year": True, "month":
|
|
6682
|
+
arg_types = {"year": True, "month": False, "day": False}
|
|
6353
6683
|
|
|
6354
6684
|
|
|
6355
6685
|
class TimeFromParts(Func):
|
|
@@ -6408,6 +6738,10 @@ class Encode(Func):
|
|
|
6408
6738
|
arg_types = {"this": True, "charset": True}
|
|
6409
6739
|
|
|
6410
6740
|
|
|
6741
|
+
class EqualNull(Func):
|
|
6742
|
+
arg_types = {"this": True, "expression": True}
|
|
6743
|
+
|
|
6744
|
+
|
|
6411
6745
|
class Exp(Func):
|
|
6412
6746
|
pass
|
|
6413
6747
|
|
|
@@ -6480,6 +6814,10 @@ class ToBase64(Func):
|
|
|
6480
6814
|
pass
|
|
6481
6815
|
|
|
6482
6816
|
|
|
6817
|
+
class ToBinary(Func):
|
|
6818
|
+
arg_types = {"this": True, "format": False, "safe": False}
|
|
6819
|
+
|
|
6820
|
+
|
|
6483
6821
|
# https://docs.snowflake.com/en/sql-reference/functions/base64_decode_binary
|
|
6484
6822
|
class Base64DecodeBinary(Func):
|
|
6485
6823
|
arg_types = {"this": True, "alphabet": False}
|
|
@@ -6547,8 +6885,22 @@ class GetExtract(Func):
|
|
|
6547
6885
|
arg_types = {"this": True, "expression": True}
|
|
6548
6886
|
|
|
6549
6887
|
|
|
6888
|
+
class Getbit(Func):
|
|
6889
|
+
arg_types = {"this": True, "expression": True}
|
|
6890
|
+
|
|
6891
|
+
|
|
6550
6892
|
class Greatest(Func):
|
|
6551
|
-
arg_types = {"this": True, "expressions": False}
|
|
6893
|
+
arg_types = {"this": True, "expressions": False, "null_if_any_null": False}
|
|
6894
|
+
is_var_len_args = True
|
|
6895
|
+
|
|
6896
|
+
|
|
6897
|
+
class GreatestIgnoreNulls(Func):
|
|
6898
|
+
arg_types = {"expressions": True}
|
|
6899
|
+
is_var_len_args = True
|
|
6900
|
+
|
|
6901
|
+
|
|
6902
|
+
class LeastIgnoreNulls(Func):
|
|
6903
|
+
arg_types = {"expressions": True}
|
|
6552
6904
|
is_var_len_args = True
|
|
6553
6905
|
|
|
6554
6906
|
|
|
@@ -6576,6 +6928,18 @@ class HexEncode(Func):
|
|
|
6576
6928
|
arg_types = {"this": True, "case": False}
|
|
6577
6929
|
|
|
6578
6930
|
|
|
6931
|
+
class Hour(Func):
|
|
6932
|
+
pass
|
|
6933
|
+
|
|
6934
|
+
|
|
6935
|
+
class Minute(Func):
|
|
6936
|
+
pass
|
|
6937
|
+
|
|
6938
|
+
|
|
6939
|
+
class Second(Func):
|
|
6940
|
+
pass
|
|
6941
|
+
|
|
6942
|
+
|
|
6579
6943
|
# T-SQL: https://learn.microsoft.com/en-us/sql/t-sql/functions/compress-transact-sql?view=sql-server-ver17
|
|
6580
6944
|
# Snowflake: https://docs.snowflake.com/en/sql-reference/functions/compress
|
|
6581
6945
|
class Compress(Func):
|
|
@@ -6638,9 +7002,13 @@ class IsInf(Func):
|
|
|
6638
7002
|
_sql_names = ["IS_INF", "ISINF"]
|
|
6639
7003
|
|
|
6640
7004
|
|
|
7005
|
+
class IsNullValue(Func):
|
|
7006
|
+
pass
|
|
7007
|
+
|
|
7008
|
+
|
|
6641
7009
|
# https://www.postgresql.org/docs/current/functions-json.html
|
|
6642
7010
|
class JSON(Expression):
|
|
6643
|
-
arg_types = {"this": False, "
|
|
7011
|
+
arg_types = {"this": False, "with_": False, "unique": False}
|
|
6644
7012
|
|
|
6645
7013
|
|
|
6646
7014
|
class JSONPath(Expression):
|
|
@@ -6701,7 +7069,7 @@ class FormatJson(Expression):
|
|
|
6701
7069
|
|
|
6702
7070
|
|
|
6703
7071
|
class Format(Func):
|
|
6704
|
-
arg_types = {"this": True, "expressions":
|
|
7072
|
+
arg_types = {"this": True, "expressions": False}
|
|
6705
7073
|
is_var_len_args = True
|
|
6706
7074
|
|
|
6707
7075
|
|
|
@@ -6761,7 +7129,13 @@ class JSONArrayAgg(Func):
|
|
|
6761
7129
|
|
|
6762
7130
|
|
|
6763
7131
|
class JSONExists(Func):
|
|
6764
|
-
arg_types = {
|
|
7132
|
+
arg_types = {
|
|
7133
|
+
"this": True,
|
|
7134
|
+
"path": True,
|
|
7135
|
+
"passing": False,
|
|
7136
|
+
"on_condition": False,
|
|
7137
|
+
"from_dcolonqmark": False,
|
|
7138
|
+
}
|
|
6765
7139
|
|
|
6766
7140
|
|
|
6767
7141
|
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_TABLE.html
|
|
@@ -6918,6 +7292,7 @@ class JSONExtractScalar(Binary, Func):
|
|
|
6918
7292
|
"only_json_types": False,
|
|
6919
7293
|
"expressions": False,
|
|
6920
7294
|
"json_type": False,
|
|
7295
|
+
"scalar_only": False,
|
|
6921
7296
|
}
|
|
6922
7297
|
_sql_names = ["JSON_EXTRACT_SCALAR"]
|
|
6923
7298
|
is_var_len_args = True
|
|
@@ -6993,7 +7368,7 @@ class ParseDatetime(Func):
|
|
|
6993
7368
|
|
|
6994
7369
|
|
|
6995
7370
|
class Least(Func):
|
|
6996
|
-
arg_types = {"this": True, "expressions": False}
|
|
7371
|
+
arg_types = {"this": True, "expressions": False, "null_if_any_null": False}
|
|
6997
7372
|
is_var_len_args = True
|
|
6998
7373
|
|
|
6999
7374
|
|
|
@@ -7081,6 +7456,10 @@ class ScopeResolution(Expression):
|
|
|
7081
7456
|
arg_types = {"this": False, "expression": True}
|
|
7082
7457
|
|
|
7083
7458
|
|
|
7459
|
+
class Slice(Expression):
|
|
7460
|
+
arg_types = {"this": False, "expression": False, "step": False}
|
|
7461
|
+
|
|
7462
|
+
|
|
7084
7463
|
class Stream(Expression):
|
|
7085
7464
|
pass
|
|
7086
7465
|
|
|
@@ -7135,6 +7514,10 @@ class Median(AggFunc):
|
|
|
7135
7514
|
pass
|
|
7136
7515
|
|
|
7137
7516
|
|
|
7517
|
+
class Mode(AggFunc):
|
|
7518
|
+
arg_types = {"this": False, "deterministic": False}
|
|
7519
|
+
|
|
7520
|
+
|
|
7138
7521
|
class Min(AggFunc):
|
|
7139
7522
|
arg_types = {"this": True, "expressions": False}
|
|
7140
7523
|
is_var_len_args = True
|
|
@@ -7144,6 +7527,10 @@ class Month(Func):
|
|
|
7144
7527
|
pass
|
|
7145
7528
|
|
|
7146
7529
|
|
|
7530
|
+
class Monthname(Func):
|
|
7531
|
+
pass
|
|
7532
|
+
|
|
7533
|
+
|
|
7147
7534
|
class AddMonths(Func):
|
|
7148
7535
|
arg_types = {"this": True, "expression": True}
|
|
7149
7536
|
|
|
@@ -7160,8 +7547,17 @@ class Normalize(Func):
|
|
|
7160
7547
|
arg_types = {"this": True, "form": False, "is_casefold": False}
|
|
7161
7548
|
|
|
7162
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
|
+
|
|
7163
7559
|
class Overlay(Func):
|
|
7164
|
-
arg_types = {"this": True, "expression": True, "
|
|
7560
|
+
arg_types = {"this": True, "expression": True, "from_": True, "for_": False}
|
|
7165
7561
|
|
|
7166
7562
|
|
|
7167
7563
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-predict#mlpredict_function
|
|
@@ -7242,6 +7638,16 @@ class ApproxQuantile(Quantile):
|
|
|
7242
7638
|
}
|
|
7243
7639
|
|
|
7244
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
|
+
|
|
7245
7651
|
class Quarter(Func):
|
|
7246
7652
|
pass
|
|
7247
7653
|
|
|
@@ -7257,6 +7663,10 @@ class Randn(Func):
|
|
|
7257
7663
|
arg_types = {"this": False}
|
|
7258
7664
|
|
|
7259
7665
|
|
|
7666
|
+
class Randstr(Func):
|
|
7667
|
+
arg_types = {"this": True, "generator": False}
|
|
7668
|
+
|
|
7669
|
+
|
|
7260
7670
|
class RangeN(Func):
|
|
7261
7671
|
arg_types = {"this": True, "expressions": True, "each": False}
|
|
7262
7672
|
|
|
@@ -7276,6 +7686,11 @@ class ReadCSV(Func):
|
|
|
7276
7686
|
arg_types = {"this": True, "expressions": False}
|
|
7277
7687
|
|
|
7278
7688
|
|
|
7689
|
+
class ReadParquet(Func):
|
|
7690
|
+
is_var_len_args = True
|
|
7691
|
+
arg_types = {"expressions": True}
|
|
7692
|
+
|
|
7693
|
+
|
|
7279
7694
|
class Reduce(Func):
|
|
7280
7695
|
arg_types = {"this": True, "initial": True, "merge": True, "finish": False}
|
|
7281
7696
|
|
|
@@ -7288,6 +7703,7 @@ class RegexpExtract(Func):
|
|
|
7288
7703
|
"occurrence": False,
|
|
7289
7704
|
"parameters": False,
|
|
7290
7705
|
"group": False,
|
|
7706
|
+
"null_if_pos_overflow": False, # for transpilation target behavior
|
|
7291
7707
|
}
|
|
7292
7708
|
|
|
7293
7709
|
|
|
@@ -7295,10 +7711,10 @@ class RegexpExtractAll(Func):
|
|
|
7295
7711
|
arg_types = {
|
|
7296
7712
|
"this": True,
|
|
7297
7713
|
"expression": True,
|
|
7714
|
+
"group": False,
|
|
7715
|
+
"parameters": False,
|
|
7298
7716
|
"position": False,
|
|
7299
7717
|
"occurrence": False,
|
|
7300
|
-
"parameters": False,
|
|
7301
|
-
"group": False,
|
|
7302
7718
|
}
|
|
7303
7719
|
|
|
7304
7720
|
|
|
@@ -7310,6 +7726,7 @@ class RegexpReplace(Func):
|
|
|
7310
7726
|
"position": False,
|
|
7311
7727
|
"occurrence": False,
|
|
7312
7728
|
"modifiers": False,
|
|
7729
|
+
"single_replace": False,
|
|
7313
7730
|
}
|
|
7314
7731
|
|
|
7315
7732
|
|
|
@@ -7352,6 +7769,50 @@ class RegexpCount(Func):
|
|
|
7352
7769
|
}
|
|
7353
7770
|
|
|
7354
7771
|
|
|
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):
|
|
7801
|
+
arg_types = {"this": True, "expression": True}
|
|
7802
|
+
|
|
7803
|
+
|
|
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):
|
|
7813
|
+
arg_types = {"this": True, "expression": True}
|
|
7814
|
+
|
|
7815
|
+
|
|
7355
7816
|
class Repeat(Func):
|
|
7356
7817
|
arg_types = {"this": True, "times": True}
|
|
7357
7818
|
|
|
@@ -7368,7 +7829,12 @@ class Radians(Func):
|
|
|
7368
7829
|
# https://learn.microsoft.com/en-us/sql/t-sql/functions/round-transact-sql?view=sql-server-ver16
|
|
7369
7830
|
# tsql third argument function == trunctaion if not 0
|
|
7370
7831
|
class Round(Func):
|
|
7371
|
-
arg_types = {
|
|
7832
|
+
arg_types = {
|
|
7833
|
+
"this": True,
|
|
7834
|
+
"decimals": False,
|
|
7835
|
+
"truncate": False,
|
|
7836
|
+
"casts_non_integer_decimals": False,
|
|
7837
|
+
}
|
|
7372
7838
|
|
|
7373
7839
|
|
|
7374
7840
|
class RowNumber(Func):
|
|
@@ -7500,6 +7966,11 @@ class Search(Func):
|
|
|
7500
7966
|
}
|
|
7501
7967
|
|
|
7502
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
|
+
|
|
7503
7974
|
class StrToDate(Func):
|
|
7504
7975
|
arg_types = {"this": True, "format": False, "safe": False}
|
|
7505
7976
|
|
|
@@ -7660,6 +8131,10 @@ class Unicode(Func):
|
|
|
7660
8131
|
pass
|
|
7661
8132
|
|
|
7662
8133
|
|
|
8134
|
+
class Uniform(Func):
|
|
8135
|
+
arg_types = {"this": True, "expression": True, "gen": False, "seed": False}
|
|
8136
|
+
|
|
8137
|
+
|
|
7663
8138
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#unix_date
|
|
7664
8139
|
class UnixDate(Func):
|
|
7665
8140
|
pass
|
|
@@ -7712,21 +8187,41 @@ class UnixMillis(Func):
|
|
|
7712
8187
|
class Uuid(Func):
|
|
7713
8188
|
_sql_names = ["UUID", "GEN_RANDOM_UUID", "GENERATE_UUID", "UUID_STRING"]
|
|
7714
8189
|
|
|
7715
|
-
arg_types = {"this": False, "name": False}
|
|
8190
|
+
arg_types = {"this": False, "name": False, "is_string": False}
|
|
8191
|
+
|
|
8192
|
+
|
|
8193
|
+
TIMESTAMP_PARTS = {
|
|
8194
|
+
"year": False,
|
|
8195
|
+
"month": False,
|
|
8196
|
+
"day": False,
|
|
8197
|
+
"hour": False,
|
|
8198
|
+
"min": False,
|
|
8199
|
+
"sec": False,
|
|
8200
|
+
"nano": False,
|
|
8201
|
+
}
|
|
7716
8202
|
|
|
7717
8203
|
|
|
7718
8204
|
class TimestampFromParts(Func):
|
|
7719
8205
|
_sql_names = ["TIMESTAMP_FROM_PARTS", "TIMESTAMPFROMPARTS"]
|
|
7720
8206
|
arg_types = {
|
|
7721
|
-
|
|
7722
|
-
"month": True,
|
|
7723
|
-
"day": True,
|
|
7724
|
-
"hour": True,
|
|
7725
|
-
"min": True,
|
|
7726
|
-
"sec": True,
|
|
7727
|
-
"nano": False,
|
|
8207
|
+
**TIMESTAMP_PARTS,
|
|
7728
8208
|
"zone": False,
|
|
7729
8209
|
"milli": False,
|
|
8210
|
+
"this": False,
|
|
8211
|
+
"expression": False,
|
|
8212
|
+
}
|
|
8213
|
+
|
|
8214
|
+
|
|
8215
|
+
class TimestampLtzFromParts(Func):
|
|
8216
|
+
_sql_names = ["TIMESTAMP_LTZ_FROM_PARTS", "TIMESTAMPLTZFROMPARTS"]
|
|
8217
|
+
arg_types = TIMESTAMP_PARTS.copy()
|
|
8218
|
+
|
|
8219
|
+
|
|
8220
|
+
class TimestampTzFromParts(Func):
|
|
8221
|
+
_sql_names = ["TIMESTAMP_TZ_FROM_PARTS", "TIMESTAMPTZFROMPARTS"]
|
|
8222
|
+
arg_types = {
|
|
8223
|
+
**TIMESTAMP_PARTS,
|
|
8224
|
+
"zone": False,
|
|
7730
8225
|
}
|
|
7731
8226
|
|
|
7732
8227
|
|
|
@@ -7752,6 +8247,14 @@ class VariancePop(AggFunc):
|
|
|
7752
8247
|
_sql_names = ["VARIANCE_POP", "VAR_POP"]
|
|
7753
8248
|
|
|
7754
8249
|
|
|
8250
|
+
class Skewness(AggFunc):
|
|
8251
|
+
pass
|
|
8252
|
+
|
|
8253
|
+
|
|
8254
|
+
class WidthBucket(Func):
|
|
8255
|
+
arg_types = {"this": True, "min_value": True, "max_value": True, "num_buckets": True}
|
|
8256
|
+
|
|
8257
|
+
|
|
7755
8258
|
class CovarSamp(Binary, AggFunc):
|
|
7756
8259
|
pass
|
|
7757
8260
|
|
|
@@ -7768,11 +8271,20 @@ class WeekStart(Expression):
|
|
|
7768
8271
|
pass
|
|
7769
8272
|
|
|
7770
8273
|
|
|
8274
|
+
class NextDay(Func):
|
|
8275
|
+
arg_types = {"this": True, "expression": True}
|
|
8276
|
+
|
|
8277
|
+
|
|
7771
8278
|
class XMLElement(Func):
|
|
7772
8279
|
_sql_names = ["XMLELEMENT"]
|
|
7773
8280
|
arg_types = {"this": True, "expressions": False}
|
|
7774
8281
|
|
|
7775
8282
|
|
|
8283
|
+
class XMLGet(Func):
|
|
8284
|
+
_sql_names = ["XMLGET"]
|
|
8285
|
+
arg_types = {"this": True, "expression": True, "instance": False}
|
|
8286
|
+
|
|
8287
|
+
|
|
7776
8288
|
class XMLTable(Func):
|
|
7777
8289
|
arg_types = {
|
|
7778
8290
|
"this": True,
|
|
@@ -7796,6 +8308,10 @@ class Year(Func):
|
|
|
7796
8308
|
pass
|
|
7797
8309
|
|
|
7798
8310
|
|
|
8311
|
+
class Zipf(Func):
|
|
8312
|
+
arg_types = {"this": True, "elementcount": True, "gen": True}
|
|
8313
|
+
|
|
8314
|
+
|
|
7799
8315
|
class Use(Expression):
|
|
7800
8316
|
arg_types = {"this": False, "expressions": False, "kind": False}
|
|
7801
8317
|
|
|
@@ -7804,9 +8320,10 @@ class Merge(DML):
|
|
|
7804
8320
|
arg_types = {
|
|
7805
8321
|
"this": True,
|
|
7806
8322
|
"using": True,
|
|
7807
|
-
"on":
|
|
8323
|
+
"on": False,
|
|
8324
|
+
"using_cond": False,
|
|
7808
8325
|
"whens": True,
|
|
7809
|
-
"
|
|
8326
|
+
"with_": False,
|
|
7810
8327
|
"returning": False,
|
|
7811
8328
|
}
|
|
7812
8329
|
|
|
@@ -7839,10 +8356,10 @@ class TableColumn(Expression):
|
|
|
7839
8356
|
pass
|
|
7840
8357
|
|
|
7841
8358
|
|
|
7842
|
-
ALL_FUNCTIONS = subclasses(__name__, Func,
|
|
8359
|
+
ALL_FUNCTIONS = subclasses(__name__, Func, {AggFunc, Anonymous, Func})
|
|
7843
8360
|
FUNCTION_BY_NAME = {name: func for func in ALL_FUNCTIONS for name in func.sql_names()}
|
|
7844
8361
|
|
|
7845
|
-
JSON_PATH_PARTS = subclasses(__name__, JSONPathPart,
|
|
8362
|
+
JSON_PATH_PARTS = subclasses(__name__, JSONPathPart, {JSONPathPart})
|
|
7846
8363
|
|
|
7847
8364
|
PERCENTILES = (PercentileCont, PercentileDisc)
|
|
7848
8365
|
|
|
@@ -8115,7 +8632,7 @@ def _apply_cte_builder(
|
|
|
8115
8632
|
append: bool = True,
|
|
8116
8633
|
dialect: DialectType = None,
|
|
8117
8634
|
copy: bool = True,
|
|
8118
|
-
scalar: bool =
|
|
8635
|
+
scalar: t.Optional[bool] = None,
|
|
8119
8636
|
**opts,
|
|
8120
8637
|
) -> E:
|
|
8121
8638
|
alias_expression = maybe_parse(alias, dialect=dialect, into=TableAlias, **opts)
|
|
@@ -8127,11 +8644,11 @@ def _apply_cte_builder(
|
|
|
8127
8644
|
return _apply_child_list_builder(
|
|
8128
8645
|
cte,
|
|
8129
8646
|
instance=instance,
|
|
8130
|
-
arg="
|
|
8647
|
+
arg="with_",
|
|
8131
8648
|
append=append,
|
|
8132
8649
|
copy=copy,
|
|
8133
8650
|
into=With,
|
|
8134
|
-
properties={"recursive": recursive
|
|
8651
|
+
properties={"recursive": recursive} if recursive else {},
|
|
8135
8652
|
)
|
|
8136
8653
|
|
|
8137
8654
|
|
|
@@ -8360,7 +8877,7 @@ def update(
|
|
|
8360
8877
|
)
|
|
8361
8878
|
if from_:
|
|
8362
8879
|
update_expr.set(
|
|
8363
|
-
"
|
|
8880
|
+
"from_",
|
|
8364
8881
|
maybe_parse(from_, into=From, dialect=dialect, prefix="FROM", **opts),
|
|
8365
8882
|
)
|
|
8366
8883
|
if isinstance(where, Condition):
|
|
@@ -8376,7 +8893,7 @@ def update(
|
|
|
8376
8893
|
for alias, qry in with_.items()
|
|
8377
8894
|
]
|
|
8378
8895
|
update_expr.set(
|
|
8379
|
-
"
|
|
8896
|
+
"with_",
|
|
8380
8897
|
With(expressions=cte_list),
|
|
8381
8898
|
)
|
|
8382
8899
|
return update_expr
|
|
@@ -9308,6 +9825,26 @@ def replace_tree(
|
|
|
9308
9825
|
return new_node
|
|
9309
9826
|
|
|
9310
9827
|
|
|
9828
|
+
def find_tables(expression: Expression) -> t.Set[Table]:
|
|
9829
|
+
"""
|
|
9830
|
+
Find all tables referenced in a query.
|
|
9831
|
+
|
|
9832
|
+
Args:
|
|
9833
|
+
expressions: The query to find the tables in.
|
|
9834
|
+
|
|
9835
|
+
Returns:
|
|
9836
|
+
A set of all the tables.
|
|
9837
|
+
"""
|
|
9838
|
+
from sqlglot.optimizer.scope import traverse_scope
|
|
9839
|
+
|
|
9840
|
+
return {
|
|
9841
|
+
table
|
|
9842
|
+
for scope in traverse_scope(expression)
|
|
9843
|
+
for table in scope.tables
|
|
9844
|
+
if table.name and table.name not in scope.cte_sources
|
|
9845
|
+
}
|
|
9846
|
+
|
|
9847
|
+
|
|
9311
9848
|
def column_table_names(expression: Expression, exclude: str = "") -> t.Set[str]:
|
|
9312
9849
|
"""
|
|
9313
9850
|
Return all table names referenced through columns in an expression.
|