Adding upstream version 25.30.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c61927f460
commit
44a4f87ffd
69 changed files with 48139 additions and 46098 deletions
|
@ -436,9 +436,21 @@ class Generator(metaclass=_Generator):
|
|||
# Whether MEDIAN(expr) is supported; if not, it will be generated as PERCENTILE_CONT(expr, 0.5)
|
||||
SUPPORTS_MEDIAN = True
|
||||
|
||||
# Whether UNIX_SECONDS(timestamp) is supported
|
||||
SUPPORTS_UNIX_SECONDS = False
|
||||
|
||||
# The name to generate for the JSONPath expression. If `None`, only `this` will be generated
|
||||
PARSE_JSON_NAME: t.Optional[str] = "PARSE_JSON"
|
||||
|
||||
# The function name of the exp.ArraySize expression
|
||||
ARRAY_SIZE_NAME: str = "ARRAY_LENGTH"
|
||||
|
||||
# Whether exp.ArraySize should generate the dimension arg too (valid for Postgres & DuckDB)
|
||||
# None -> Doesn't support it at all
|
||||
# False (DuckDB) -> Has backwards-compatible support, but preferably generated without
|
||||
# True (Postgres) -> Explicitly requires it
|
||||
ARRAY_SIZE_DIM_REQUIRED: t.Optional[bool] = None
|
||||
|
||||
TYPE_MAPPING = {
|
||||
exp.DataType.Type.NCHAR: "CHAR",
|
||||
exp.DataType.Type.NVARCHAR: "VARCHAR",
|
||||
|
@ -4472,3 +4484,30 @@ class Generator(metaclass=_Generator):
|
|||
filler = f" {filler}" if filler else ""
|
||||
with_count = "WITH COUNT" if expression.args.get("with_count") else "WITHOUT COUNT"
|
||||
return f"TRUNCATE{filler} {with_count}"
|
||||
|
||||
def unixseconds_sql(self, expression: exp.UnixSeconds) -> str:
|
||||
if self.SUPPORTS_UNIX_SECONDS:
|
||||
return self.function_fallback_sql(expression)
|
||||
|
||||
start_ts = exp.cast(
|
||||
exp.Literal.string("1970-01-01 00:00:00+00"), to=exp.DataType.Type.TIMESTAMPTZ
|
||||
)
|
||||
|
||||
return self.sql(
|
||||
exp.TimestampDiff(this=expression.this, expression=start_ts, unit=exp.var("SECONDS"))
|
||||
)
|
||||
|
||||
def arraysize_sql(self, expression: exp.ArraySize) -> str:
|
||||
dim = expression.expression
|
||||
|
||||
# For dialects that don't support the dimension arg, we can safely transpile it's default value (1st dimension)
|
||||
if dim and self.ARRAY_SIZE_DIM_REQUIRED is None:
|
||||
if not (dim.is_int and dim.name == "1"):
|
||||
self.unsupported("Cannot transpile dimension argument for ARRAY_LENGTH")
|
||||
dim = None
|
||||
|
||||
# If dimension is required but not specified, default initialize it
|
||||
if self.ARRAY_SIZE_DIM_REQUIRED and not dim:
|
||||
dim = exp.Literal.number(1)
|
||||
|
||||
return self.func(self.ARRAY_SIZE_NAME, expression.this, dim)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue