Merging upstream version 23.16.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d0f42f708a
commit
213191b8e3
93 changed files with 64106 additions and 59061 deletions
|
@ -248,6 +248,9 @@ class Dialect(metaclass=_Dialect):
|
|||
CONCAT_COALESCE = False
|
||||
"""A `NULL` arg in `CONCAT` yields `NULL` by default, but in some dialects it yields an empty string."""
|
||||
|
||||
HEX_LOWERCASE = False
|
||||
"""Whether the `HEX` function returns a lowercase hexadecimal string."""
|
||||
|
||||
DATE_FORMAT = "'%Y-%m-%d'"
|
||||
DATEINT_FORMAT = "'%Y%m%d'"
|
||||
TIME_FORMAT = "'%Y-%m-%d %H:%M:%S'"
|
||||
|
@ -769,8 +772,14 @@ def date_add_interval_sql(
|
|||
return func
|
||||
|
||||
|
||||
def timestamptrunc_sql(self: Generator, expression: exp.TimestampTrunc) -> str:
|
||||
return self.func("DATE_TRUNC", unit_to_str(expression), expression.this)
|
||||
def timestamptrunc_sql(zone: bool = False) -> t.Callable[[Generator, exp.TimestampTrunc], str]:
|
||||
def _timestamptrunc_sql(self: Generator, expression: exp.TimestampTrunc) -> str:
|
||||
args = [unit_to_str(expression), expression.this]
|
||||
if zone:
|
||||
args.append(expression.args.get("zone"))
|
||||
return self.func("DATE_TRUNC", *args)
|
||||
|
||||
return _timestamptrunc_sql
|
||||
|
||||
|
||||
def no_timestamp_sql(self: Generator, expression: exp.Timestamp) -> str:
|
||||
|
@ -1141,10 +1150,23 @@ def filter_array_using_unnest(self: Generator, expression: exp.ArrayFilter) -> s
|
|||
return self.sql(exp.Array(expressions=[filtered]))
|
||||
|
||||
|
||||
def to_number_with_nls_param(self, expression: exp.ToNumber) -> str:
|
||||
def to_number_with_nls_param(self: Generator, expression: exp.ToNumber) -> str:
|
||||
return self.func(
|
||||
"TO_NUMBER",
|
||||
expression.this,
|
||||
expression.args.get("format"),
|
||||
expression.args.get("nlsparam"),
|
||||
)
|
||||
|
||||
|
||||
def build_default_decimal_type(
|
||||
precision: t.Optional[int] = None, scale: t.Optional[int] = None
|
||||
) -> t.Callable[[exp.DataType], exp.DataType]:
|
||||
def _builder(dtype: exp.DataType) -> exp.DataType:
|
||||
if dtype.expressions or precision is None:
|
||||
return dtype
|
||||
|
||||
params = f"{precision}{f', {scale}' if scale is not None else ''}"
|
||||
return exp.DataType.build(f"DECIMAL({params})")
|
||||
|
||||
return _builder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue