1
0
Fork 0

Merging upstream version 10.0.8.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 14:54:32 +01:00
parent 407314e8d2
commit efc1e37108
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
67 changed files with 2461 additions and 840 deletions

View file

@ -641,9 +641,11 @@ class Set(Expression):
class SetItem(Expression):
arg_types = {
"this": True,
"this": False,
"expressions": False,
"kind": False,
"collate": False, # MySQL SET NAMES statement
"global": False,
}
@ -787,6 +789,7 @@ class Drop(Expression):
"exists": False,
"temporary": False,
"materialized": False,
"cascade": False,
}
@ -1073,6 +1076,18 @@ class FileFormatProperty(Property):
pass
class DistKeyProperty(Property):
pass
class SortKeyProperty(Property):
pass
class DistStyleProperty(Property):
pass
class LocationProperty(Property):
pass
@ -1130,6 +1145,9 @@ class Properties(Expression):
"LOCATION": LocationProperty,
"PARTITIONED_BY": PartitionedByProperty,
"TABLE_FORMAT": TableFormatProperty,
"DISTKEY": DistKeyProperty,
"DISTSTYLE": DistStyleProperty,
"SORTKEY": SortKeyProperty,
}
@classmethod
@ -1356,7 +1374,7 @@ class Var(Expression):
class Schema(Expression):
arg_types = {"this": False, "expressions": True}
arg_types = {"this": False, "expressions": False}
class Select(Subqueryable):
@ -1741,7 +1759,7 @@ class Select(Subqueryable):
)
if join_alias:
join.set("this", alias_(join.args["this"], join_alias, table=True))
join.set("this", alias_(join.this, join_alias, table=True))
return _apply_list_builder(
join,
instance=self,
@ -1884,6 +1902,7 @@ class Subquery(DerivedTable, Unionable):
arg_types = {
"this": True,
"alias": False,
"with": False,
**QUERY_MODIFIERS,
}
@ -2025,6 +2044,31 @@ class DataType(Expression):
NULL = auto()
UNKNOWN = auto() # Sentinel value, useful for type annotation
TEXT_TYPES = {
Type.CHAR,
Type.NCHAR,
Type.VARCHAR,
Type.NVARCHAR,
Type.TEXT,
}
NUMERIC_TYPES = {
Type.INT,
Type.TINYINT,
Type.SMALLINT,
Type.BIGINT,
Type.FLOAT,
Type.DOUBLE,
}
TEMPORAL_TYPES = {
Type.TIMESTAMP,
Type.TIMESTAMPTZ,
Type.TIMESTAMPLTZ,
Type.DATE,
Type.DATETIME,
}
@classmethod
def build(cls, dtype, **kwargs) -> DataType:
return DataType(
@ -2054,16 +2098,25 @@ class Exists(SubqueryPredicate):
pass
# Commands to interact with the databases or engines
# These expressions don't truly parse the expression and consume
# whatever exists as a string until the end or a semicolon
# Commands to interact with the databases or engines. For most of the command
# expressions we parse whatever comes after the command's name as a string.
class Command(Expression):
arg_types = {"this": True, "expression": False}
# Binary Expressions
# (ADD a b)
# (FROM table selects)
class Transaction(Command):
arg_types = {"this": False, "modes": False}
class Commit(Command):
arg_types = {} # type: ignore
class Rollback(Command):
arg_types = {"savepoint": False}
# Binary expressions like (ADD a b)
class Binary(Expression):
arg_types = {"this": True, "expression": True}
@ -2215,7 +2268,7 @@ class Not(Unary, Condition):
class Paren(Unary, Condition):
pass
arg_types = {"this": True, "with": False}
class Neg(Unary):
@ -2428,6 +2481,10 @@ class Cast(Func):
return self.args["to"]
class Collate(Binary):
pass
class TryCast(Cast):
pass
@ -2442,13 +2499,17 @@ class Coalesce(Func):
is_var_len_args = True
class ConcatWs(Func):
arg_types = {"expressions": False}
class Concat(Func):
arg_types = {"expressions": True}
is_var_len_args = True
class ConcatWs(Concat):
_sql_names = ["CONCAT_WS"]
class Count(AggFunc):
pass
arg_types = {"this": False}
class CurrentDate(Func):
@ -2556,10 +2617,18 @@ class Day(Func):
pass
class Decode(Func):
arg_types = {"this": True, "charset": True}
class DiToDate(Func):
pass
class Encode(Func):
arg_types = {"this": True, "charset": True}
class Exp(Func):
pass
@ -2581,6 +2650,10 @@ class GroupConcat(Func):
arg_types = {"this": True, "separator": False}
class Hex(Func):
pass
class If(Func):
arg_types = {"this": True, "true": True, "false": False}
@ -2641,7 +2714,7 @@ class Log10(Func):
class Lower(Func):
pass
_sql_names = ["LOWER", "LCASE"]
class Map(Func):
@ -2686,6 +2759,12 @@ class ApproxQuantile(Quantile):
arg_types = {"this": True, "quantile": True, "accuracy": False}
class ReadCSV(Func):
_sql_names = ["READ_CSV"]
is_var_len_args = True
arg_types = {"this": True, "expressions": False}
class Reduce(Func):
arg_types = {"this": True, "initial": True, "merge": True, "finish": True}
@ -2804,8 +2883,8 @@ class TimeStrToUnix(Func):
class Trim(Func):
arg_types = {
"this": True,
"position": False,
"expression": False,
"position": False,
"collation": False,
}
@ -2826,6 +2905,10 @@ class TsOrDiToDi(Func):
pass
class Unhex(Func):
pass
class UnixToStr(Func):
arg_types = {"this": True, "format": False}
@ -2843,7 +2926,7 @@ class UnixToTimeStr(Func):
class Upper(Func):
pass
_sql_names = ["UPPER", "UCASE"]
class Variance(AggFunc):
@ -3701,6 +3784,19 @@ def replace_placeholders(expression, *args, **kwargs):
return expression.transform(_replace_placeholders, iter(args), **kwargs)
def true():
return Boolean(this=True)
def false():
return Boolean(this=False)
def null():
return Null()
# TODO: deprecate this
TRUE = Boolean(this=True)
FALSE = Boolean(this=False)
NULL = Null()