Adding upstream version 20.11.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
8a068da99c
commit
07f4660f31
141 changed files with 66644 additions and 54334 deletions
|
@ -129,10 +129,20 @@ class Spark2(Hive):
|
|||
"SHIFTRIGHT": binary_from_function(exp.BitwiseRightShift),
|
||||
"STRING": _parse_as_cast("string"),
|
||||
"TIMESTAMP": _parse_as_cast("timestamp"),
|
||||
"TO_TIMESTAMP": lambda args: _parse_as_cast("timestamp")(args)
|
||||
if len(args) == 1
|
||||
else format_time_lambda(exp.StrToTime, "spark")(args),
|
||||
"TO_TIMESTAMP": lambda args: (
|
||||
_parse_as_cast("timestamp")(args)
|
||||
if len(args) == 1
|
||||
else format_time_lambda(exp.StrToTime, "spark")(args)
|
||||
),
|
||||
"TO_UNIX_TIMESTAMP": exp.StrToUnix.from_arg_list,
|
||||
"TO_UTC_TIMESTAMP": lambda args: exp.FromTimeZone(
|
||||
this=exp.cast_unless(
|
||||
seq_get(args, 0) or exp.Var(this=""),
|
||||
exp.DataType.build("timestamp"),
|
||||
exp.DataType.build("timestamp"),
|
||||
),
|
||||
zone=seq_get(args, 1),
|
||||
),
|
||||
"TRUNC": lambda args: exp.DateTrunc(unit=seq_get(args, 1), this=seq_get(args, 0)),
|
||||
"WEEKOFYEAR": lambda args: exp.WeekOfYear(this=exp.TsOrDsToDate(this=seq_get(args, 0))),
|
||||
}
|
||||
|
@ -188,6 +198,7 @@ class Spark2(Hive):
|
|||
exp.DayOfYear: rename_func("DAYOFYEAR"),
|
||||
exp.FileFormatProperty: lambda self, e: f"USING {e.name.upper()}",
|
||||
exp.From: transforms.preprocess([_unalias_pivot]),
|
||||
exp.FromTimeZone: lambda self, e: f"TO_UTC_TIMESTAMP({self.sql(e, 'this')}, {self.sql(e, 'zone')})",
|
||||
exp.LogicalAnd: rename_func("BOOL_AND"),
|
||||
exp.LogicalOr: rename_func("BOOL_OR"),
|
||||
exp.Map: _map_sql,
|
||||
|
@ -255,10 +266,12 @@ class Spark2(Hive):
|
|||
def columndef_sql(self, expression: exp.ColumnDef, sep: str = " ") -> str:
|
||||
return super().columndef_sql(
|
||||
expression,
|
||||
sep=": "
|
||||
if isinstance(expression.parent, exp.DataType)
|
||||
and expression.parent.is_type("struct")
|
||||
else sep,
|
||||
sep=(
|
||||
": "
|
||||
if isinstance(expression.parent, exp.DataType)
|
||||
and expression.parent.is_type("struct")
|
||||
else sep
|
||||
),
|
||||
)
|
||||
|
||||
class Tokenizer(Hive.Tokenizer):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue