Merging upstream version 11.3.6.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
f5f7767f8d
commit
e33f287a97
46 changed files with 23416 additions and 22639 deletions
|
@ -2656,12 +2656,17 @@ class DataType(Expression):
|
|||
BINARY = auto()
|
||||
VARBINARY = auto()
|
||||
INT = auto()
|
||||
UINT = auto()
|
||||
TINYINT = auto()
|
||||
UTINYINT = auto()
|
||||
SMALLINT = auto()
|
||||
USMALLINT = auto()
|
||||
BIGINT = auto()
|
||||
UBIGINT = auto()
|
||||
FLOAT = auto()
|
||||
DOUBLE = auto()
|
||||
DECIMAL = auto()
|
||||
BIT = auto()
|
||||
BOOLEAN = auto()
|
||||
JSON = auto()
|
||||
JSONB = auto()
|
||||
|
@ -2861,10 +2866,6 @@ class Div(Binary):
|
|||
pass
|
||||
|
||||
|
||||
class FloatDiv(Binary):
|
||||
pass
|
||||
|
||||
|
||||
class Overlaps(Binary):
|
||||
pass
|
||||
|
||||
|
@ -2971,6 +2972,10 @@ class Sub(Binary):
|
|||
pass
|
||||
|
||||
|
||||
class ArrayOverlaps(Binary):
|
||||
pass
|
||||
|
||||
|
||||
# Unary Expressions
|
||||
# (NOT a)
|
||||
class Unary(Expression):
|
||||
|
@ -3135,6 +3140,11 @@ class Array(Func):
|
|||
is_var_len_args = True
|
||||
|
||||
|
||||
# https://docs.snowflake.com/en/sql-reference/functions/to_char
|
||||
class ToChar(Func):
|
||||
arg_types = {"this": True, "format": False}
|
||||
|
||||
|
||||
class GenerateSeries(Func):
|
||||
arg_types = {"start": True, "end": True, "step": False}
|
||||
|
||||
|
@ -3156,8 +3166,12 @@ class ArrayConcat(Func):
|
|||
is_var_len_args = True
|
||||
|
||||
|
||||
class ArrayContains(Func):
|
||||
arg_types = {"this": True, "expression": True}
|
||||
class ArrayContains(Binary, Func):
|
||||
pass
|
||||
|
||||
|
||||
class ArrayContained(Binary):
|
||||
pass
|
||||
|
||||
|
||||
class ArrayFilter(Func):
|
||||
|
@ -3272,6 +3286,7 @@ class DateSub(Func, TimeUnit):
|
|||
|
||||
|
||||
class DateDiff(Func, TimeUnit):
|
||||
_sql_names = ["DATEDIFF", "DATE_DIFF"]
|
||||
arg_types = {"this": True, "expression": True, "unit": False}
|
||||
|
||||
|
||||
|
@ -4861,19 +4876,19 @@ def func(name: str, *args, dialect: DialectType = None, **kwargs) -> Func:
|
|||
|
||||
from sqlglot.dialects.dialect import Dialect
|
||||
|
||||
args = tuple(convert(arg) for arg in args)
|
||||
converted = [convert(arg) for arg in args]
|
||||
kwargs = {key: convert(value) for key, value in kwargs.items()}
|
||||
|
||||
parser = Dialect.get_or_raise(dialect)().parser()
|
||||
from_args_list = parser.FUNCTIONS.get(name.upper())
|
||||
|
||||
if from_args_list:
|
||||
function = from_args_list(args) if args else from_args_list.__self__(**kwargs) # type: ignore
|
||||
function = from_args_list(converted) if converted else from_args_list.__self__(**kwargs) # type: ignore
|
||||
else:
|
||||
kwargs = kwargs or {"expressions": args}
|
||||
kwargs = kwargs or {"expressions": converted}
|
||||
function = Anonymous(this=name, **kwargs)
|
||||
|
||||
for error_message in function.error_messages(args):
|
||||
for error_message in function.error_messages(converted):
|
||||
raise ValueError(error_message)
|
||||
|
||||
return function
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue