diff options
Diffstat (limited to 'sqlglot/dialects/spark2.py')
-rw-r--r-- | sqlglot/dialects/spark2.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/sqlglot/dialects/spark2.py b/sqlglot/dialects/spark2.py index 069916f..5264f39 100644 --- a/sqlglot/dialects/spark2.py +++ b/sqlglot/dialects/spark2.py @@ -48,7 +48,7 @@ def _unix_to_time_sql(self: Spark2.Generator, expression: exp.UnixToTime) -> str timestamp = expression.this if scale is None: - return self.sql(exp.cast(exp.func("from_unixtime", timestamp), "timestamp")) + return self.sql(exp.cast(exp.func("from_unixtime", timestamp), exp.DataType.Type.TIMESTAMP)) if scale == exp.UnixToTime.SECONDS: return self.func("TIMESTAMP_SECONDS", timestamp) if scale == exp.UnixToTime.MILLIS: @@ -129,11 +129,7 @@ class Spark2(Hive): "DOUBLE": _build_as_cast("double"), "FLOAT": _build_as_cast("float"), "FROM_UTC_TIMESTAMP": lambda args: exp.AtTimeZone( - this=exp.cast_unless( - seq_get(args, 0) or exp.Var(this=""), - exp.DataType.build("timestamp"), - exp.DataType.build("timestamp"), - ), + this=exp.cast(seq_get(args, 0) or exp.Var(this=""), exp.DataType.Type.TIMESTAMP), zone=seq_get(args, 1), ), "INT": _build_as_cast("int"), @@ -150,11 +146,7 @@ class Spark2(Hive): ), "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"), - ), + this=exp.cast(seq_get(args, 0) or exp.Var(this=""), exp.DataType.Type.TIMESTAMP), zone=seq_get(args, 1), ), "TRUNC": lambda args: exp.DateTrunc(unit=seq_get(args, 1), this=seq_get(args, 0)), |