diff options
Diffstat (limited to '')
-rw-r--r-- | sqlglot/dialects/snowflake.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py index c50961c..34bc3bd 100644 --- a/sqlglot/dialects/snowflake.py +++ b/sqlglot/dialects/snowflake.py @@ -179,6 +179,10 @@ class Snowflake(Dialect): "ARRAYAGG": exp.ArrayAgg.from_arg_list, "ARRAY_CONSTRUCT": exp.Array.from_arg_list, "ARRAY_TO_STRING": exp.ArrayJoin.from_arg_list, + "CONVERT_TIMEZONE": lambda args: exp.AtTimeZone( + this=seq_get(args, 1), + zone=seq_get(args, 0), + ), "DATE_TRUNC": date_trunc_to_time, "DATEADD": lambda args: exp.DateAdd( this=seq_get(args, 2), @@ -190,7 +194,6 @@ class Snowflake(Dialect): expression=seq_get(args, 1), unit=seq_get(args, 0), ), - "DECODE": exp.Matches.from_arg_list, "DIV0": _div0_to_if, "IFF": exp.If.from_arg_list, "NULLIFZERO": _nullifzero_to_if, @@ -275,6 +278,9 @@ class Snowflake(Dialect): exp.Array: inline_array_sql, exp.ArrayConcat: rename_func("ARRAY_CAT"), exp.ArrayJoin: rename_func("ARRAY_TO_STRING"), + exp.AtTimeZone: lambda self, e: self.func( + "CONVERT_TIMEZONE", e.args.get("zone"), e.this + ), exp.DateAdd: lambda self, e: self.func("DATEADD", e.text("unit"), e.expression, e.this), exp.DateDiff: lambda self, e: self.func( "DATEDIFF", e.text("unit"), e.expression, e.this @@ -287,7 +293,6 @@ class Snowflake(Dialect): exp.LogicalAnd: rename_func("BOOLAND_AGG"), exp.VarMap: lambda self, e: var_map_sql(self, e, "OBJECT_CONSTRUCT"), exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}", - exp.Matches: rename_func("DECODE"), exp.StrPosition: lambda self, e: self.func( "POSITION", e.args.get("substr"), e.this, e.args.get("position") ), |