sqlglot 28.4.1__py3-none-any.whl → 28.8.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/_version.py +2 -2
- sqlglot/dialects/bigquery.py +20 -23
- sqlglot/dialects/clickhouse.py +2 -0
- sqlglot/dialects/dialect.py +355 -18
- sqlglot/dialects/doris.py +38 -90
- sqlglot/dialects/druid.py +1 -0
- sqlglot/dialects/duckdb.py +1739 -163
- sqlglot/dialects/exasol.py +17 -1
- sqlglot/dialects/hive.py +27 -2
- sqlglot/dialects/mysql.py +103 -11
- sqlglot/dialects/oracle.py +38 -1
- sqlglot/dialects/postgres.py +142 -33
- sqlglot/dialects/presto.py +6 -2
- sqlglot/dialects/redshift.py +7 -1
- sqlglot/dialects/singlestore.py +13 -3
- sqlglot/dialects/snowflake.py +271 -21
- sqlglot/dialects/spark.py +25 -0
- sqlglot/dialects/spark2.py +4 -3
- sqlglot/dialects/starrocks.py +152 -17
- sqlglot/dialects/trino.py +1 -0
- sqlglot/dialects/tsql.py +5 -0
- sqlglot/diff.py +1 -1
- sqlglot/expressions.py +239 -47
- sqlglot/generator.py +173 -44
- sqlglot/optimizer/annotate_types.py +129 -60
- sqlglot/optimizer/merge_subqueries.py +13 -2
- sqlglot/optimizer/qualify_columns.py +7 -0
- sqlglot/optimizer/resolver.py +19 -0
- sqlglot/optimizer/scope.py +12 -0
- sqlglot/optimizer/unnest_subqueries.py +7 -0
- sqlglot/parser.py +251 -58
- sqlglot/schema.py +186 -14
- sqlglot/tokens.py +36 -6
- sqlglot/transforms.py +6 -5
- sqlglot/typing/__init__.py +29 -10
- sqlglot/typing/bigquery.py +5 -10
- sqlglot/typing/duckdb.py +39 -0
- sqlglot/typing/hive.py +50 -1
- sqlglot/typing/mysql.py +32 -0
- sqlglot/typing/presto.py +0 -1
- sqlglot/typing/snowflake.py +80 -17
- sqlglot/typing/spark.py +29 -0
- sqlglot/typing/spark2.py +9 -1
- sqlglot/typing/tsql.py +21 -0
- {sqlglot-28.4.1.dist-info → sqlglot-28.8.0.dist-info}/METADATA +47 -2
- sqlglot-28.8.0.dist-info/RECORD +95 -0
- {sqlglot-28.4.1.dist-info → sqlglot-28.8.0.dist-info}/WHEEL +1 -1
- sqlglot-28.4.1.dist-info/RECORD +0 -92
- {sqlglot-28.4.1.dist-info → sqlglot-28.8.0.dist-info}/licenses/LICENSE +0 -0
- {sqlglot-28.4.1.dist-info → sqlglot-28.8.0.dist-info}/top_level.txt +0 -0
sqlglot/expressions.py
CHANGED
|
@@ -280,6 +280,8 @@ class Expression(metaclass=_Expression):
|
|
|
280
280
|
|
|
281
281
|
@property
|
|
282
282
|
def type(self) -> t.Optional[DataType]:
|
|
283
|
+
if isinstance(self, Cast):
|
|
284
|
+
return self._type or self.to
|
|
283
285
|
return self._type
|
|
284
286
|
|
|
285
287
|
@type.setter
|
|
@@ -1616,6 +1618,7 @@ class Describe(Expression):
|
|
|
1616
1618
|
"expressions": False,
|
|
1617
1619
|
"partition": False,
|
|
1618
1620
|
"format": False,
|
|
1621
|
+
"as_json": False,
|
|
1619
1622
|
}
|
|
1620
1623
|
|
|
1621
1624
|
|
|
@@ -2134,6 +2137,11 @@ class ComputedColumnConstraint(ColumnConstraintKind):
|
|
|
2134
2137
|
arg_types = {"this": True, "persisted": False, "not_null": False, "data_type": False}
|
|
2135
2138
|
|
|
2136
2139
|
|
|
2140
|
+
# https://docs.oracle.com/en/database/other-databases/timesten/22.1/plsql-developer/examples-using-input-and-output-parameters-and-bind-variables.html#GUID-4B20426E-F93F-4835-88CB-6A79829A8D7F
|
|
2141
|
+
class InOutColumnConstraint(ColumnConstraintKind):
|
|
2142
|
+
arg_types = {"input_": False, "output": False, "variadic": False}
|
|
2143
|
+
|
|
2144
|
+
|
|
2137
2145
|
class Constraint(Expression):
|
|
2138
2146
|
arg_types = {"this": True, "expressions": True}
|
|
2139
2147
|
|
|
@@ -2481,6 +2489,7 @@ class OnConflict(Expression):
|
|
|
2481
2489
|
"expressions": False,
|
|
2482
2490
|
"action": False,
|
|
2483
2491
|
"conflict_keys": False,
|
|
2492
|
+
"index_predicate": False,
|
|
2484
2493
|
"constraint": False,
|
|
2485
2494
|
"where": False,
|
|
2486
2495
|
}
|
|
@@ -2600,8 +2609,19 @@ class Literal(Condition):
|
|
|
2600
2609
|
arg_types = {"this": True, "is_string": True}
|
|
2601
2610
|
|
|
2602
2611
|
@classmethod
|
|
2603
|
-
def number(cls, number) -> Literal:
|
|
2604
|
-
|
|
2612
|
+
def number(cls, number) -> Literal | Neg:
|
|
2613
|
+
expr: Literal | Neg = cls(this=str(number), is_string=False)
|
|
2614
|
+
|
|
2615
|
+
try:
|
|
2616
|
+
to_py = expr.to_py()
|
|
2617
|
+
|
|
2618
|
+
if not isinstance(to_py, str) and to_py < 0:
|
|
2619
|
+
expr.set("this", str(abs(to_py)))
|
|
2620
|
+
expr = Neg(this=expr)
|
|
2621
|
+
except Exception:
|
|
2622
|
+
pass
|
|
2623
|
+
|
|
2624
|
+
return expr
|
|
2605
2625
|
|
|
2606
2626
|
@classmethod
|
|
2607
2627
|
def string(cls, string) -> Literal:
|
|
@@ -2631,6 +2651,7 @@ class Join(Expression):
|
|
|
2631
2651
|
"global_": False,
|
|
2632
2652
|
"hint": False,
|
|
2633
2653
|
"match_condition": False, # Snowflake
|
|
2654
|
+
"directed": False, # Snowflake
|
|
2634
2655
|
"expressions": False,
|
|
2635
2656
|
"pivots": False,
|
|
2636
2657
|
}
|
|
@@ -3115,6 +3136,16 @@ class PartitionByRangePropertyDynamic(Expression):
|
|
|
3115
3136
|
arg_types = {"this": False, "start": True, "end": True, "every": True}
|
|
3116
3137
|
|
|
3117
3138
|
|
|
3139
|
+
# https://docs.starrocks.io/docs/sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE/#rollup-index
|
|
3140
|
+
class RollupProperty(Property):
|
|
3141
|
+
arg_types = {"expressions": True}
|
|
3142
|
+
|
|
3143
|
+
|
|
3144
|
+
# https://docs.starrocks.io/docs/sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE/#rollup-index
|
|
3145
|
+
class RollupIndex(Expression):
|
|
3146
|
+
arg_types = {"this": True, "expressions": True, "from_index": False, "properties": False}
|
|
3147
|
+
|
|
3148
|
+
|
|
3118
3149
|
# https://doris.apache.org/docs/table-design/data-partitioning/manual-partitioning
|
|
3119
3150
|
class PartitionByListProperty(Property):
|
|
3120
3151
|
arg_types = {"partition_expressions": True, "create_expressions": True}
|
|
@@ -3128,7 +3159,7 @@ class PartitionList(Expression):
|
|
|
3128
3159
|
# https://doris.apache.org/docs/sql-manual/sql-statements/table-and-view/async-materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW
|
|
3129
3160
|
class RefreshTriggerProperty(Property):
|
|
3130
3161
|
arg_types = {
|
|
3131
|
-
"method":
|
|
3162
|
+
"method": False,
|
|
3132
3163
|
"kind": False,
|
|
3133
3164
|
"every": False,
|
|
3134
3165
|
"unit": False,
|
|
@@ -5143,7 +5174,7 @@ class BitwiseAnd(Binary):
|
|
|
5143
5174
|
|
|
5144
5175
|
|
|
5145
5176
|
class BitwiseLeftShift(Binary):
|
|
5146
|
-
|
|
5177
|
+
arg_types = {"this": True, "expression": True, "requires_int128": False}
|
|
5147
5178
|
|
|
5148
5179
|
|
|
5149
5180
|
class BitwiseOr(Binary):
|
|
@@ -5151,7 +5182,7 @@ class BitwiseOr(Binary):
|
|
|
5151
5182
|
|
|
5152
5183
|
|
|
5153
5184
|
class BitwiseRightShift(Binary):
|
|
5154
|
-
|
|
5185
|
+
arg_types = {"this": True, "expression": True, "requires_int128": False}
|
|
5155
5186
|
|
|
5156
5187
|
|
|
5157
5188
|
class BitwiseXor(Binary):
|
|
@@ -5313,6 +5344,12 @@ class Sub(Binary):
|
|
|
5313
5344
|
pass
|
|
5314
5345
|
|
|
5315
5346
|
|
|
5347
|
+
# https://www.postgresql.org/docs/current/functions-range.html
|
|
5348
|
+
# Represents range adjacency operator: -|-
|
|
5349
|
+
class Adjacent(Binary):
|
|
5350
|
+
pass
|
|
5351
|
+
|
|
5352
|
+
|
|
5316
5353
|
# Unary Expressions
|
|
5317
5354
|
# (NOT a)
|
|
5318
5355
|
class Unary(Condition):
|
|
@@ -5555,6 +5592,12 @@ class Func(Condition):
|
|
|
5555
5592
|
return {name: cls.from_arg_list for name in cls.sql_names()}
|
|
5556
5593
|
|
|
5557
5594
|
|
|
5595
|
+
# Function returns NULL instead of error
|
|
5596
|
+
# https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/functions-reference#safe_prefix
|
|
5597
|
+
class SafeFunc(Func):
|
|
5598
|
+
pass
|
|
5599
|
+
|
|
5600
|
+
|
|
5558
5601
|
class Typeof(Func):
|
|
5559
5602
|
pass
|
|
5560
5603
|
|
|
@@ -5708,15 +5751,15 @@ class ByteLength(Func):
|
|
|
5708
5751
|
|
|
5709
5752
|
|
|
5710
5753
|
class Boolnot(Func):
|
|
5711
|
-
|
|
5754
|
+
arg_types = {"this": True, "round_input": False}
|
|
5712
5755
|
|
|
5713
5756
|
|
|
5714
5757
|
class Booland(Func):
|
|
5715
|
-
arg_types = {"this": True, "expression": True}
|
|
5758
|
+
arg_types = {"this": True, "expression": True, "round_input": False}
|
|
5716
5759
|
|
|
5717
5760
|
|
|
5718
5761
|
class Boolor(Func):
|
|
5719
|
-
arg_types = {"this": True, "expression": True}
|
|
5762
|
+
arg_types = {"this": True, "expression": True, "round_input": False}
|
|
5720
5763
|
|
|
5721
5764
|
|
|
5722
5765
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#bool_for_json
|
|
@@ -5725,7 +5768,7 @@ class JSONBool(Func):
|
|
|
5725
5768
|
|
|
5726
5769
|
|
|
5727
5770
|
class ArrayRemove(Func):
|
|
5728
|
-
arg_types = {"this": True, "expression": True}
|
|
5771
|
+
arg_types = {"this": True, "expression": True, "null_propagation": False}
|
|
5729
5772
|
|
|
5730
5773
|
|
|
5731
5774
|
class ParameterizedAgg(AggFunc):
|
|
@@ -5823,7 +5866,7 @@ class Grouping(AggFunc):
|
|
|
5823
5866
|
|
|
5824
5867
|
|
|
5825
5868
|
class GroupingId(AggFunc):
|
|
5826
|
-
arg_types = {"expressions":
|
|
5869
|
+
arg_types = {"expressions": False}
|
|
5827
5870
|
is_var_len_args = True
|
|
5828
5871
|
|
|
5829
5872
|
|
|
@@ -6010,6 +6053,11 @@ class ExplodingGenerateSeries(GenerateSeries):
|
|
|
6010
6053
|
pass
|
|
6011
6054
|
|
|
6012
6055
|
|
|
6056
|
+
# https://docs.snowflake.com/en/sql-reference/functions/generator
|
|
6057
|
+
class Generator(Func, UDTF):
|
|
6058
|
+
arg_types = {"rowcount": False, "timelimit": False}
|
|
6059
|
+
|
|
6060
|
+
|
|
6013
6061
|
class ArrayAgg(AggFunc):
|
|
6014
6062
|
arg_types = {"this": True, "nulls_excluded": False}
|
|
6015
6063
|
|
|
@@ -6041,9 +6089,17 @@ class ArrayAny(Func):
|
|
|
6041
6089
|
arg_types = {"this": True, "expression": True}
|
|
6042
6090
|
|
|
6043
6091
|
|
|
6092
|
+
class ArrayAppend(Func):
|
|
6093
|
+
arg_types = {"this": True, "expression": True, "null_propagation": False}
|
|
6094
|
+
|
|
6095
|
+
|
|
6096
|
+
class ArrayPrepend(Func):
|
|
6097
|
+
arg_types = {"this": True, "expression": True, "null_propagation": False}
|
|
6098
|
+
|
|
6099
|
+
|
|
6044
6100
|
class ArrayConcat(Func):
|
|
6045
6101
|
_sql_names = ["ARRAY_CONCAT", "ARRAY_CAT"]
|
|
6046
|
-
arg_types = {"this": True, "expressions": False}
|
|
6102
|
+
arg_types = {"this": True, "expressions": False, "null_propagation": False}
|
|
6047
6103
|
is_var_len_args = True
|
|
6048
6104
|
|
|
6049
6105
|
|
|
@@ -6051,6 +6107,14 @@ class ArrayConcatAgg(AggFunc):
|
|
|
6051
6107
|
pass
|
|
6052
6108
|
|
|
6053
6109
|
|
|
6110
|
+
class ArrayCompact(Func):
|
|
6111
|
+
pass
|
|
6112
|
+
|
|
6113
|
+
|
|
6114
|
+
class ArrayInsert(Func):
|
|
6115
|
+
arg_types = {"this": True, "position": True, "expression": True, "offset": False}
|
|
6116
|
+
|
|
6117
|
+
|
|
6054
6118
|
class ArrayConstructCompact(Func):
|
|
6055
6119
|
arg_types = {"expressions": False}
|
|
6056
6120
|
is_var_len_args = True
|
|
@@ -6137,6 +6201,11 @@ class ArrayUnionAgg(AggFunc):
|
|
|
6137
6201
|
pass
|
|
6138
6202
|
|
|
6139
6203
|
|
|
6204
|
+
class ArraysZip(Func):
|
|
6205
|
+
arg_types = {"expressions": False}
|
|
6206
|
+
is_var_len_args = True
|
|
6207
|
+
|
|
6208
|
+
|
|
6140
6209
|
class Avg(AggFunc):
|
|
6141
6210
|
pass
|
|
6142
6211
|
|
|
@@ -6410,6 +6479,10 @@ class Localtimestamp(Func):
|
|
|
6410
6479
|
arg_types = {"this": False}
|
|
6411
6480
|
|
|
6412
6481
|
|
|
6482
|
+
class Systimestamp(Func):
|
|
6483
|
+
arg_types = {"this": False}
|
|
6484
|
+
|
|
6485
|
+
|
|
6413
6486
|
class CurrentTimestamp(Func):
|
|
6414
6487
|
arg_types = {"this": False, "sysdate": False}
|
|
6415
6488
|
|
|
@@ -6422,10 +6495,6 @@ class CurrentTimezone(Func):
|
|
|
6422
6495
|
arg_types = {}
|
|
6423
6496
|
|
|
6424
6497
|
|
|
6425
|
-
class Sysdate(Func):
|
|
6426
|
-
arg_types = {}
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
6498
|
class CurrentOrganizationName(Func):
|
|
6430
6499
|
arg_types = {}
|
|
6431
6500
|
|
|
@@ -6499,7 +6568,7 @@ class DateDiff(Func, TimeUnit):
|
|
|
6499
6568
|
|
|
6500
6569
|
|
|
6501
6570
|
class DateTrunc(Func):
|
|
6502
|
-
arg_types = {"unit": True, "this": True, "zone": False}
|
|
6571
|
+
arg_types = {"unit": True, "this": True, "zone": False, "input_type_preserved": False}
|
|
6503
6572
|
|
|
6504
6573
|
def __init__(self, **args):
|
|
6505
6574
|
# Across most dialects it's safe to unabbreviate the unit (e.g. 'Q' -> 'QUARTER') except Oracle
|
|
@@ -6567,6 +6636,10 @@ class DayOfYear(Func):
|
|
|
6567
6636
|
_sql_names = ["DAY_OF_YEAR", "DAYOFYEAR"]
|
|
6568
6637
|
|
|
6569
6638
|
|
|
6639
|
+
class Dayname(Func):
|
|
6640
|
+
arg_types = {"this": True, "abbreviated": False}
|
|
6641
|
+
|
|
6642
|
+
|
|
6570
6643
|
class ToDays(Func):
|
|
6571
6644
|
pass
|
|
6572
6645
|
|
|
@@ -6591,6 +6664,7 @@ class MakeInterval(Func):
|
|
|
6591
6664
|
arg_types = {
|
|
6592
6665
|
"year": False,
|
|
6593
6666
|
"month": False,
|
|
6667
|
+
"week": False,
|
|
6594
6668
|
"day": False,
|
|
6595
6669
|
"hour": False,
|
|
6596
6670
|
"minute": False,
|
|
@@ -6637,7 +6711,7 @@ class Elt(Func):
|
|
|
6637
6711
|
|
|
6638
6712
|
|
|
6639
6713
|
class Timestamp(Func):
|
|
6640
|
-
arg_types = {"this": False, "zone": False, "with_tz": False
|
|
6714
|
+
arg_types = {"this": False, "zone": False, "with_tz": False}
|
|
6641
6715
|
|
|
6642
6716
|
|
|
6643
6717
|
class TimestampAdd(Func, TimeUnit):
|
|
@@ -6654,7 +6728,7 @@ class TimestampDiff(Func, TimeUnit):
|
|
|
6654
6728
|
|
|
6655
6729
|
|
|
6656
6730
|
class TimestampTrunc(Func, TimeUnit):
|
|
6657
|
-
arg_types = {"this": True, "unit": True, "zone": False}
|
|
6731
|
+
arg_types = {"this": True, "unit": True, "zone": False, "input_type_preserved": False}
|
|
6658
6732
|
|
|
6659
6733
|
|
|
6660
6734
|
class TimeSlice(Func, TimeUnit):
|
|
@@ -6679,7 +6753,7 @@ class TimeTrunc(Func, TimeUnit):
|
|
|
6679
6753
|
|
|
6680
6754
|
class DateFromParts(Func):
|
|
6681
6755
|
_sql_names = ["DATE_FROM_PARTS", "DATEFROMPARTS"]
|
|
6682
|
-
arg_types = {"year": True, "month": False, "day": False}
|
|
6756
|
+
arg_types = {"year": True, "month": False, "day": False, "allow_overflow": False}
|
|
6683
6757
|
|
|
6684
6758
|
|
|
6685
6759
|
class TimeFromParts(Func):
|
|
@@ -6691,6 +6765,7 @@ class TimeFromParts(Func):
|
|
|
6691
6765
|
"nano": False,
|
|
6692
6766
|
"fractions": False,
|
|
6693
6767
|
"precision": False,
|
|
6768
|
+
"overflow": False,
|
|
6694
6769
|
}
|
|
6695
6770
|
|
|
6696
6771
|
|
|
@@ -6725,6 +6800,30 @@ class DecodeCase(Func):
|
|
|
6725
6800
|
is_var_len_args = True
|
|
6726
6801
|
|
|
6727
6802
|
|
|
6803
|
+
# https://docs.snowflake.com/en/sql-reference/functions/decrypt
|
|
6804
|
+
class Decrypt(Func):
|
|
6805
|
+
arg_types = {
|
|
6806
|
+
"this": True,
|
|
6807
|
+
"passphrase": True,
|
|
6808
|
+
"aad": False,
|
|
6809
|
+
"encryption_method": False,
|
|
6810
|
+
"safe": False,
|
|
6811
|
+
}
|
|
6812
|
+
|
|
6813
|
+
|
|
6814
|
+
# https://docs.snowflake.com/en/sql-reference/functions/decrypt_raw
|
|
6815
|
+
class DecryptRaw(Func):
|
|
6816
|
+
arg_types = {
|
|
6817
|
+
"this": True,
|
|
6818
|
+
"key": True,
|
|
6819
|
+
"iv": True,
|
|
6820
|
+
"aad": False,
|
|
6821
|
+
"encryption_method": False,
|
|
6822
|
+
"aead": False,
|
|
6823
|
+
"safe": False,
|
|
6824
|
+
}
|
|
6825
|
+
|
|
6826
|
+
|
|
6728
6827
|
class DenseRank(AggFunc):
|
|
6729
6828
|
arg_types = {"expressions": False}
|
|
6730
6829
|
is_var_len_args = True
|
|
@@ -6738,6 +6837,16 @@ class Encode(Func):
|
|
|
6738
6837
|
arg_types = {"this": True, "charset": True}
|
|
6739
6838
|
|
|
6740
6839
|
|
|
6840
|
+
# https://docs.snowflake.com/en/sql-reference/functions/encrypt
|
|
6841
|
+
class Encrypt(Func):
|
|
6842
|
+
arg_types = {"this": True, "passphrase": True, "aad": False, "encryption_method": False}
|
|
6843
|
+
|
|
6844
|
+
|
|
6845
|
+
# https://docs.snowflake.com/en/sql-reference/functions/encrypt_raw
|
|
6846
|
+
class EncryptRaw(Func):
|
|
6847
|
+
arg_types = {"this": True, "key": True, "iv": True, "aad": False, "encryption_method": False}
|
|
6848
|
+
|
|
6849
|
+
|
|
6741
6850
|
class EqualNull(Func):
|
|
6742
6851
|
arg_types = {"this": True, "expression": True}
|
|
6743
6852
|
|
|
@@ -6886,21 +6995,13 @@ class GetExtract(Func):
|
|
|
6886
6995
|
|
|
6887
6996
|
|
|
6888
6997
|
class Getbit(Func):
|
|
6889
|
-
|
|
6998
|
+
_sql_names = ["GETBIT", "GET_BIT"]
|
|
6999
|
+
# zero_is_msb means the most significant bit is indexed 0
|
|
7000
|
+
arg_types = {"this": True, "expression": True, "zero_is_msb": False}
|
|
6890
7001
|
|
|
6891
7002
|
|
|
6892
7003
|
class Greatest(Func):
|
|
6893
|
-
arg_types = {"this": True, "expressions": 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}
|
|
7004
|
+
arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
|
|
6904
7005
|
is_var_len_args = True
|
|
6905
7006
|
|
|
6906
7007
|
|
|
@@ -6969,7 +7070,8 @@ class Or(Connector, Func):
|
|
|
6969
7070
|
|
|
6970
7071
|
|
|
6971
7072
|
class Xor(Connector, Func):
|
|
6972
|
-
arg_types = {"this": False, "expression": False, "expressions": False}
|
|
7073
|
+
arg_types = {"this": False, "expression": False, "expressions": False, "round_input": False}
|
|
7074
|
+
is_var_len_args = True
|
|
6973
7075
|
|
|
6974
7076
|
|
|
6975
7077
|
class If(Func):
|
|
@@ -7006,6 +7108,10 @@ class IsNullValue(Func):
|
|
|
7006
7108
|
pass
|
|
7007
7109
|
|
|
7008
7110
|
|
|
7111
|
+
class IsArray(Func):
|
|
7112
|
+
pass
|
|
7113
|
+
|
|
7114
|
+
|
|
7009
7115
|
# https://www.postgresql.org/docs/current/functions-json.html
|
|
7010
7116
|
class JSON(Expression):
|
|
7011
7117
|
arg_types = {"this": False, "with_": False, "unique": False}
|
|
@@ -7073,6 +7179,12 @@ class Format(Func):
|
|
|
7073
7179
|
is_var_len_args = True
|
|
7074
7180
|
|
|
7075
7181
|
|
|
7182
|
+
class JSONKeys(Func):
|
|
7183
|
+
arg_types = {"this": True, "expression": False, "expressions": False}
|
|
7184
|
+
is_var_len_args = True
|
|
7185
|
+
_sql_names = ["JSON_KEYS"]
|
|
7186
|
+
|
|
7187
|
+
|
|
7076
7188
|
class JSONKeyValue(Expression):
|
|
7077
7189
|
arg_types = {"this": True, "expression": True}
|
|
7078
7190
|
|
|
@@ -7118,7 +7230,7 @@ class JSONArray(Func):
|
|
|
7118
7230
|
|
|
7119
7231
|
|
|
7120
7232
|
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_ARRAYAGG.html
|
|
7121
|
-
class JSONArrayAgg(
|
|
7233
|
+
class JSONArrayAgg(AggFunc):
|
|
7122
7234
|
arg_types = {
|
|
7123
7235
|
"this": True,
|
|
7124
7236
|
"order": False,
|
|
@@ -7368,7 +7480,7 @@ class ParseDatetime(Func):
|
|
|
7368
7480
|
|
|
7369
7481
|
|
|
7370
7482
|
class Least(Func):
|
|
7371
|
-
arg_types = {"this": True, "expressions": False, "
|
|
7483
|
+
arg_types = {"this": True, "expressions": False, "ignore_nulls": True}
|
|
7372
7484
|
is_var_len_args = True
|
|
7373
7485
|
|
|
7374
7486
|
|
|
@@ -7451,6 +7563,36 @@ class MapFromEntries(Func):
|
|
|
7451
7563
|
pass
|
|
7452
7564
|
|
|
7453
7565
|
|
|
7566
|
+
class MapCat(Func):
|
|
7567
|
+
arg_types = {"this": True, "expression": True}
|
|
7568
|
+
|
|
7569
|
+
|
|
7570
|
+
class MapContainsKey(Func):
|
|
7571
|
+
arg_types = {"this": True, "key": True}
|
|
7572
|
+
|
|
7573
|
+
|
|
7574
|
+
class MapDelete(Func):
|
|
7575
|
+
arg_types = {"this": True, "expressions": True}
|
|
7576
|
+
is_var_len_args = True
|
|
7577
|
+
|
|
7578
|
+
|
|
7579
|
+
class MapInsert(Func):
|
|
7580
|
+
arg_types = {"this": True, "key": False, "value": True, "update_flag": False}
|
|
7581
|
+
|
|
7582
|
+
|
|
7583
|
+
class MapKeys(Func):
|
|
7584
|
+
pass
|
|
7585
|
+
|
|
7586
|
+
|
|
7587
|
+
class MapPick(Func):
|
|
7588
|
+
arg_types = {"this": True, "expressions": True}
|
|
7589
|
+
is_var_len_args = True
|
|
7590
|
+
|
|
7591
|
+
|
|
7592
|
+
class MapSize(Func):
|
|
7593
|
+
pass
|
|
7594
|
+
|
|
7595
|
+
|
|
7454
7596
|
# https://learn.microsoft.com/en-us/sql/t-sql/language-elements/scope-resolution-operator-transact-sql?view=sql-server-ver16
|
|
7455
7597
|
class ScopeResolution(Expression):
|
|
7456
7598
|
arg_types = {"this": False, "expression": True}
|
|
@@ -7496,7 +7638,11 @@ class MD5(Func):
|
|
|
7496
7638
|
|
|
7497
7639
|
|
|
7498
7640
|
# Represents the variant of the MD5 function that returns a binary value
|
|
7641
|
+
# Var len args due to Exasol:
|
|
7642
|
+
# https://docs.exasol.com/db/latest/sql_references/functions/alphabeticallistfunctions/hashtype_md5.htm
|
|
7499
7643
|
class MD5Digest(Func):
|
|
7644
|
+
arg_types = {"this": True, "expressions": False}
|
|
7645
|
+
is_var_len_args = True
|
|
7500
7646
|
_sql_names = ["MD5_DIGEST"]
|
|
7501
7647
|
|
|
7502
7648
|
|
|
@@ -7528,11 +7674,11 @@ class Month(Func):
|
|
|
7528
7674
|
|
|
7529
7675
|
|
|
7530
7676
|
class Monthname(Func):
|
|
7531
|
-
|
|
7677
|
+
arg_types = {"this": True, "abbreviated": False}
|
|
7532
7678
|
|
|
7533
7679
|
|
|
7534
7680
|
class AddMonths(Func):
|
|
7535
|
-
arg_types = {"this": True, "expression": True}
|
|
7681
|
+
arg_types = {"this": True, "expression": True, "preserve_end_of_month": False}
|
|
7536
7682
|
|
|
7537
7683
|
|
|
7538
7684
|
class Nvl2(Func):
|
|
@@ -7551,9 +7697,19 @@ class Normal(Func):
|
|
|
7551
7697
|
arg_types = {"this": True, "stddev": True, "gen": True}
|
|
7552
7698
|
|
|
7553
7699
|
|
|
7700
|
+
# https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/net_functions
|
|
7701
|
+
class NetFunc(Func):
|
|
7702
|
+
pass
|
|
7703
|
+
|
|
7704
|
+
|
|
7554
7705
|
# https://cloud.google.com/bigquery/docs/reference/standard-sql/net_functions#nethost
|
|
7555
|
-
class
|
|
7556
|
-
|
|
7706
|
+
class Host(Func):
|
|
7707
|
+
pass
|
|
7708
|
+
|
|
7709
|
+
|
|
7710
|
+
# https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/net_functions#netreg_domain
|
|
7711
|
+
class RegDomain(Func):
|
|
7712
|
+
pass
|
|
7557
7713
|
|
|
7558
7714
|
|
|
7559
7715
|
class Overlay(Func):
|
|
@@ -7841,6 +7997,22 @@ class RowNumber(Func):
|
|
|
7841
7997
|
arg_types = {"this": False}
|
|
7842
7998
|
|
|
7843
7999
|
|
|
8000
|
+
class Seq1(Func):
|
|
8001
|
+
arg_types = {"this": False}
|
|
8002
|
+
|
|
8003
|
+
|
|
8004
|
+
class Seq2(Func):
|
|
8005
|
+
arg_types = {"this": False}
|
|
8006
|
+
|
|
8007
|
+
|
|
8008
|
+
class Seq4(Func):
|
|
8009
|
+
arg_types = {"this": False}
|
|
8010
|
+
|
|
8011
|
+
|
|
8012
|
+
class Seq8(Func):
|
|
8013
|
+
arg_types = {"this": False}
|
|
8014
|
+
|
|
8015
|
+
|
|
7844
8016
|
class SafeAdd(Func):
|
|
7845
8017
|
arg_types = {"this": True, "expression": True}
|
|
7846
8018
|
|
|
@@ -7976,11 +8148,11 @@ class StrToDate(Func):
|
|
|
7976
8148
|
|
|
7977
8149
|
|
|
7978
8150
|
class StrToTime(Func):
|
|
7979
|
-
arg_types = {"this": True, "format": True, "zone": False, "safe": False}
|
|
8151
|
+
arg_types = {"this": True, "format": True, "zone": False, "safe": False, "target_type": False}
|
|
7980
8152
|
|
|
7981
8153
|
|
|
7982
8154
|
# Spark allows unix_timestamp()
|
|
7983
|
-
# https://spark.apache.org/docs/
|
|
8155
|
+
# https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.unix_timestamp.html
|
|
7984
8156
|
class StrToUnix(Func):
|
|
7985
8157
|
arg_types = {"this": False, "format": False}
|
|
7986
8158
|
|
|
@@ -8154,6 +8326,7 @@ class UnixToTime(Func):
|
|
|
8154
8326
|
"hours": False,
|
|
8155
8327
|
"minutes": False,
|
|
8156
8328
|
"format": False,
|
|
8329
|
+
"target_type": False,
|
|
8157
8330
|
}
|
|
8158
8331
|
|
|
8159
8332
|
SECONDS = Literal.number(0)
|
|
@@ -8230,7 +8403,10 @@ class Upper(Func):
|
|
|
8230
8403
|
|
|
8231
8404
|
|
|
8232
8405
|
class Corr(Binary, AggFunc):
|
|
8233
|
-
|
|
8406
|
+
# Correlation divides by variance(column). If a column has 0 variance, the denominator
|
|
8407
|
+
# is 0 - some dialects return NaN (DuckDB) while others return NULL (Snowflake).
|
|
8408
|
+
# `null_on_zero_variance` is set to True at parse time for dialects that return NULL.
|
|
8409
|
+
arg_types = {"this": True, "expression": True, "null_on_zero_variance": False}
|
|
8234
8410
|
|
|
8235
8411
|
|
|
8236
8412
|
# https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CUME_DIST.html
|
|
@@ -8247,20 +8423,30 @@ class VariancePop(AggFunc):
|
|
|
8247
8423
|
_sql_names = ["VARIANCE_POP", "VAR_POP"]
|
|
8248
8424
|
|
|
8249
8425
|
|
|
8426
|
+
class Kurtosis(AggFunc):
|
|
8427
|
+
pass
|
|
8428
|
+
|
|
8429
|
+
|
|
8250
8430
|
class Skewness(AggFunc):
|
|
8251
8431
|
pass
|
|
8252
8432
|
|
|
8253
8433
|
|
|
8254
8434
|
class WidthBucket(Func):
|
|
8255
|
-
arg_types = {
|
|
8435
|
+
arg_types = {
|
|
8436
|
+
"this": True,
|
|
8437
|
+
"min_value": False,
|
|
8438
|
+
"max_value": False,
|
|
8439
|
+
"num_buckets": False,
|
|
8440
|
+
"threshold": False,
|
|
8441
|
+
}
|
|
8256
8442
|
|
|
8257
8443
|
|
|
8258
|
-
class CovarSamp(
|
|
8259
|
-
|
|
8444
|
+
class CovarSamp(AggFunc):
|
|
8445
|
+
arg_types = {"this": True, "expression": True}
|
|
8260
8446
|
|
|
8261
8447
|
|
|
8262
|
-
class CovarPop(
|
|
8263
|
-
|
|
8448
|
+
class CovarPop(AggFunc):
|
|
8449
|
+
arg_types = {"this": True, "expression": True}
|
|
8264
8450
|
|
|
8265
8451
|
|
|
8266
8452
|
class Week(Func):
|
|
@@ -8277,7 +8463,7 @@ class NextDay(Func):
|
|
|
8277
8463
|
|
|
8278
8464
|
class XMLElement(Func):
|
|
8279
8465
|
_sql_names = ["XMLELEMENT"]
|
|
8280
|
-
arg_types = {"this": True, "expressions": False}
|
|
8466
|
+
arg_types = {"this": True, "expressions": False, "evalname": False}
|
|
8281
8467
|
|
|
8282
8468
|
|
|
8283
8469
|
class XMLGet(Func):
|
|
@@ -8356,6 +8542,12 @@ class TableColumn(Expression):
|
|
|
8356
8542
|
pass
|
|
8357
8543
|
|
|
8358
8544
|
|
|
8545
|
+
# https://www.postgresql.org/docs/current/typeconv-func.html
|
|
8546
|
+
# https://www.postgresql.org/docs/current/xfunc-sql.html
|
|
8547
|
+
class Variadic(Expression):
|
|
8548
|
+
pass
|
|
8549
|
+
|
|
8550
|
+
|
|
8359
8551
|
ALL_FUNCTIONS = subclasses(__name__, Func, {AggFunc, Anonymous, Func})
|
|
8360
8552
|
FUNCTION_BY_NAME = {name: func for func in ALL_FUNCTIONS for name in func.sql_names()}
|
|
8361
8553
|
|