diff options
Diffstat (limited to 'sqlglot/dialects/snowflake.py')
-rw-r--r-- | sqlglot/dialects/snowflake.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py index 07be65b..01f7512 100644 --- a/sqlglot/dialects/snowflake.py +++ b/sqlglot/dialects/snowflake.py @@ -32,7 +32,7 @@ def _check_int(s: str) -> bool: # from https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html -def _parse_to_timestamp(args: t.List) -> t.Union[exp.StrToTime, exp.UnixToTime]: +def _parse_to_timestamp(args: t.List) -> t.Union[exp.StrToTime, exp.UnixToTime, exp.TimeStrToTime]: if len(args) == 2: first_arg, second_arg = args if second_arg.is_string: @@ -60,8 +60,8 @@ def _parse_to_timestamp(args: t.List) -> t.Union[exp.StrToTime, exp.UnixToTime]: # reduce it using `simplify_literals` first and then check if it's a Literal. first_arg = seq_get(args, 0) if not isinstance(simplify_literals(first_arg, root=True), Literal): - # case: <variant_expr> - return format_time_lambda(exp.StrToTime, "snowflake", default=True)(args) + # case: <variant_expr> or other expressions such as columns + return exp.TimeStrToTime.from_arg_list(args) if first_arg.is_string: if _check_int(first_arg.this): @@ -560,7 +560,6 @@ class Snowflake(Dialect): offset = expression.args.get("offset") if offset: if unnest_alias: - expression = expression.copy() unnest_alias.append("columns", offset.pop()) selects.append("index") |