Merging upstream version 18.5.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ad94fdbf21
commit
11b24b93ea
67 changed files with 32690 additions and 32450 deletions
sqlglot/dialects
|
@ -153,6 +153,9 @@ class Dialect(metaclass=_Dialect):
|
|||
# Determines whether or not CONCAT's arguments must be strings
|
||||
STRICT_STRING_CONCAT = False
|
||||
|
||||
# Determines whether or not user-defined data types are supported
|
||||
SUPPORTS_USER_DEFINED_TYPES = True
|
||||
|
||||
# Determines how function names are going to be normalized
|
||||
NORMALIZE_FUNCTIONS: bool | str = "upper"
|
||||
|
||||
|
@ -546,6 +549,19 @@ def date_trunc_to_time(args: t.List) -> exp.DateTrunc | exp.TimestampTrunc:
|
|||
return exp.TimestampTrunc(this=this, unit=unit)
|
||||
|
||||
|
||||
def date_add_interval_sql(
|
||||
data_type: str, kind: str
|
||||
) -> t.Callable[[Generator, exp.Expression], str]:
|
||||
def func(self: Generator, expression: exp.Expression) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
unit = expression.args.get("unit")
|
||||
unit = exp.var(unit.name.upper() if unit else "DAY")
|
||||
interval = exp.Interval(this=expression.expression.copy(), unit=unit)
|
||||
return f"{data_type}_{kind}({this}, {self.sql(interval)})"
|
||||
|
||||
return func
|
||||
|
||||
|
||||
def timestamptrunc_sql(self: Generator, expression: exp.TimestampTrunc) -> str:
|
||||
return self.func(
|
||||
"DATE_TRUNC", exp.Literal.string(expression.text("unit") or "day"), expression.this
|
||||
|
@ -736,5 +752,15 @@ def any_value_to_max_sql(self: Generator, expression: exp.AnyValue) -> str:
|
|||
|
||||
|
||||
# Used to generate JSON_OBJECT with a comma in BigQuery and MySQL instead of colon
|
||||
def json_keyvalue_comma_sql(self, expression: exp.JSONKeyValue) -> str:
|
||||
def json_keyvalue_comma_sql(self: Generator, expression: exp.JSONKeyValue) -> str:
|
||||
return f"{self.sql(expression, 'this')}, {self.sql(expression, 'expression')}"
|
||||
|
||||
|
||||
def is_parse_json(expression: exp.Expression) -> bool:
|
||||
return isinstance(expression, exp.ParseJSON) or (
|
||||
isinstance(expression, exp.Cast) and expression.is_type("json")
|
||||
)
|
||||
|
||||
|
||||
def isnull_to_is_null(args: t.List) -> exp.Expression:
|
||||
return exp.Paren(this=exp.Is(this=seq_get(args, 0), expression=exp.null()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue