We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
transpiling from snowflake to snowflake converts DAYOFWEEK to nonexistent DAY_OF_WEEK
works in snowflake: `select dayofweek( '2016-01-02T23:39:20.123-07:00'::timestamp)`

in sqlglot 11.0.0, python 3.10.4:

```python
import sqlglot

# converts dayofweek to nonexistent DAY_OF_WEEK
print(sqlglot.transpile("select dayofweek( '2016-01-02T23:39:20.123-07:00'::timestamp)", read='snowflake', write='snowflake'))
```



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sqlglot/dialects/snowflake.py`
Content:
```
1 from __future__ import annotations
2 
3 from sqlglot import exp, generator, parser, tokens
4 from sqlglot.dialects.dialect import (
5     Dialect,
6     datestrtodate_sql,
7     format_time_lambda,
8     inline_array_sql,
9     rename_func,
10     timestrtotime_sql,
11     var_map_sql,
12 )
13 from sqlglot.expressions import Literal
14 from sqlglot.helper import flatten, seq_get
15 from sqlglot.tokens import TokenType
16 
17 
18 def _check_int(s):
19     if s[0] in ("-", "+"):
20         return s[1:].isdigit()
21     return s.isdigit()
22 
23 
24 # from https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html
25 def _snowflake_to_timestamp(args):
26     if len(args) == 2:
27         first_arg, second_arg = args
28         if second_arg.is_string:
29             # case: <string_expr> [ , <format> ]
30             return format_time_lambda(exp.StrToTime, "snowflake")(args)
31 
32         # case: <numeric_expr> [ , <scale> ]
33         if second_arg.name not in ["0", "3", "9"]:
34             raise ValueError(
35                 f"Scale for snowflake numeric timestamp is {second_arg}, but should be 0, 3, or 9"
36             )
37 
38         if second_arg.name == "0":
39             timescale = exp.UnixToTime.SECONDS
40         elif second_arg.name == "3":
41             timescale = exp.UnixToTime.MILLIS
42         elif second_arg.name == "9":
43             timescale = exp.UnixToTime.MICROS
44 
45         return exp.UnixToTime(this=first_arg, scale=timescale)
46 
47     first_arg = seq_get(args, 0)
48     if not isinstance(first_arg, Literal):
49         # case: <variant_expr>
50         return format_time_lambda(exp.StrToTime, "snowflake", default=True)(args)
51 
52     if first_arg.is_string:
53         if _check_int(first_arg.this):
54             # case: <integer>
55             return exp.UnixToTime.from_arg_list(args)
56 
57         # case: <date_expr>
58         return format_time_lambda(exp.StrToTime, "snowflake", default=True)(args)
59 
60     # case: <numeric_expr>
61     return exp.UnixToTime.from_arg_list(args)
62 
63 
64 def _unix_to_time_sql(self, expression):
65     scale = expression.args.get("scale")
66     timestamp = self.sql(expression, "this")
67     if scale in [None, exp.UnixToTime.SECONDS]:
68         return f"TO_TIMESTAMP({timestamp})"
69     if scale == exp.UnixToTime.MILLIS:
70         return f"TO_TIMESTAMP({timestamp}, 3)"
71     if scale == exp.UnixToTime.MICROS:
72         return f"TO_TIMESTAMP({timestamp}, 9)"
73 
74     raise ValueError("Improper scale for timestamp")
75 
76 
77 # https://docs.snowflake.com/en/sql-reference/functions/date_part.html
78 # https://docs.snowflake.com/en/sql-reference/functions-date-time.html#label-supported-date-time-parts
79 def _parse_date_part(self):
80     this = self._parse_var() or self._parse_type()
81     self._match(TokenType.COMMA)
82     expression = self._parse_bitwise()
83 
84     name = this.name.upper()
85     if name.startswith("EPOCH"):
86         if name.startswith("EPOCH_MILLISECOND"):
87             scale = 10**3
88         elif name.startswith("EPOCH_MICROSECOND"):
89             scale = 10**6
90         elif name.startswith("EPOCH_NANOSECOND"):
91             scale = 10**9
92         else:
93             scale = None
94 
95         ts = self.expression(exp.Cast, this=expression, to=exp.DataType.build("TIMESTAMP"))
96         to_unix = self.expression(exp.TimeToUnix, this=ts)
97 
98         if scale:
99             to_unix = exp.Mul(this=to_unix, expression=exp.Literal.number(scale))
100 
101         return to_unix
102 
103     return self.expression(exp.Extract, this=this, expression=expression)
104 
105 
106 def _datatype_sql(self, expression):
107     if expression.this == exp.DataType.Type.ARRAY:
108         return "ARRAY"
109     elif expression.this == exp.DataType.Type.MAP:
110         return "OBJECT"
111     return self.datatype_sql(expression)
112 
113 
114 class Snowflake(Dialect):
115     null_ordering = "nulls_are_large"
116     time_format = "'yyyy-mm-dd hh24:mi:ss'"
117 
118     time_mapping = {
119         "YYYY": "%Y",
120         "yyyy": "%Y",
121         "YY": "%y",
122         "yy": "%y",
123         "MMMM": "%B",
124         "mmmm": "%B",
125         "MON": "%b",
126         "mon": "%b",
127         "MM": "%m",
128         "mm": "%m",
129         "DD": "%d",
130         "dd": "%d",
131         "d": "%-d",
132         "DY": "%w",
133         "dy": "%w",
134         "HH24": "%H",
135         "hh24": "%H",
136         "HH12": "%I",
137         "hh12": "%I",
138         "MI": "%M",
139         "mi": "%M",
140         "SS": "%S",
141         "ss": "%S",
142         "FF": "%f",
143         "ff": "%f",
144         "FF6": "%f",
145         "ff6": "%f",
146     }
147 
148     class Parser(parser.Parser):
149         FUNCTIONS = {
150             **parser.Parser.FUNCTIONS,
151             "ARRAYAGG": exp.ArrayAgg.from_arg_list,
152             "IFF": exp.If.from_arg_list,
153             "TO_TIMESTAMP": _snowflake_to_timestamp,
154             "ARRAY_CONSTRUCT": exp.Array.from_arg_list,
155             "RLIKE": exp.RegexpLike.from_arg_list,
156             "DECODE": exp.Matches.from_arg_list,
157             "OBJECT_CONSTRUCT": parser.parse_var_map,
158         }
159 
160         FUNCTION_PARSERS = {
161             **parser.Parser.FUNCTION_PARSERS,
162             "DATE_PART": _parse_date_part,
163         }
164         FUNCTION_PARSERS.pop("TRIM")
165 
166         FUNC_TOKENS = {
167             *parser.Parser.FUNC_TOKENS,
168             TokenType.RLIKE,
169             TokenType.TABLE,
170         }
171 
172         COLUMN_OPERATORS = {
173             **parser.Parser.COLUMN_OPERATORS,  # type: ignore
174             TokenType.COLON: lambda self, this, path: self.expression(
175                 exp.Bracket,
176                 this=this,
177                 expressions=[path],
178             ),
179         }
180 
181     class Tokenizer(tokens.Tokenizer):
182         QUOTES = ["'", "$$"]
183         STRING_ESCAPES = ["\\", "'"]
184 
185         SINGLE_TOKENS = {
186             **tokens.Tokenizer.SINGLE_TOKENS,
187             "$": TokenType.PARAMETER,
188         }
189 
190         KEYWORDS = {
191             **tokens.Tokenizer.KEYWORDS,
192             "EXCLUDE": TokenType.EXCEPT,
193             "MATCH_RECOGNIZE": TokenType.MATCH_RECOGNIZE,
194             "RENAME": TokenType.REPLACE,
195             "TIMESTAMP_LTZ": TokenType.TIMESTAMPLTZ,
196             "TIMESTAMP_NTZ": TokenType.TIMESTAMP,
197             "TIMESTAMP_TZ": TokenType.TIMESTAMPTZ,
198             "TIMESTAMPNTZ": TokenType.TIMESTAMP,
199             "MINUS": TokenType.EXCEPT,
200             "SAMPLE": TokenType.TABLE_SAMPLE,
201         }
202 
203     class Generator(generator.Generator):
204         CREATE_TRANSIENT = True
205 
206         TRANSFORMS = {
207             **generator.Generator.TRANSFORMS,  # type: ignore
208             exp.Array: inline_array_sql,
209             exp.ArrayConcat: rename_func("ARRAY_CAT"),
210             exp.DateAdd: rename_func("DATEADD"),
211             exp.DateStrToDate: datestrtodate_sql,
212             exp.DataType: _datatype_sql,
213             exp.If: rename_func("IFF"),
214             exp.Map: lambda self, e: var_map_sql(self, e, "OBJECT_CONSTRUCT"),
215             exp.VarMap: lambda self, e: var_map_sql(self, e, "OBJECT_CONSTRUCT"),
216             exp.Parameter: lambda self, e: f"${self.sql(e, 'this')}",
217             exp.PartitionedByProperty: lambda self, e: f"PARTITION BY {self.sql(e, 'this')}",
218             exp.Matches: rename_func("DECODE"),
219             exp.StrPosition: lambda self, e: f"{self.normalize_func('POSITION')}({self.format_args(e.args.get('substr'), e.this, e.args.get('position'))})",
220             exp.StrToTime: lambda self, e: f"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})",
221             exp.TimeStrToTime: timestrtotime_sql,
222             exp.TimeToUnix: lambda self, e: f"EXTRACT(epoch_second FROM {self.sql(e, 'this')})",
223             exp.Trim: lambda self, e: f"TRIM({self.format_args(e.this, e.expression)})",
224             exp.UnixToTime: _unix_to_time_sql,
225         }
226 
227         TYPE_MAPPING = {
228             **generator.Generator.TYPE_MAPPING,  # type: ignore
229             exp.DataType.Type.TIMESTAMP: "TIMESTAMPNTZ",
230         }
231 
232         STAR_MAPPING = {
233             "except": "EXCLUDE",
234             "replace": "RENAME",
235         }
236 
237         def except_op(self, expression):
238             if not expression.args.get("distinct", False):
239                 self.unsupported("EXCEPT with All is not supported in Snowflake")
240             return super().except_op(expression)
241 
242         def intersect_op(self, expression):
243             if not expression.args.get("distinct", False):
244                 self.unsupported("INTERSECT with All is not supported in Snowflake")
245             return super().intersect_op(expression)
246 
247         def values_sql(self, expression: exp.Values) -> str:
248             """Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted.
249 
250             We also want to make sure that after we find matches where we need to unquote a column that we prevent users
251             from adding quotes to the column by using the `identify` argument when generating the SQL.
252             """
253             alias = expression.args.get("alias")
254             if alias and alias.args.get("columns"):
255                 expression = expression.transform(
256                     lambda node: exp.Identifier(**{**node.args, "quoted": False})
257                     if isinstance(node, exp.Identifier)
258                     and isinstance(node.parent, exp.TableAlias)
259                     and node.arg_key == "columns"
260                     else node,
261                 )
262                 return self.no_identify(lambda: super(self.__class__, self).values_sql(expression))
263             return super().values_sql(expression)
264 
265         def select_sql(self, expression: exp.Select) -> str:
266             """Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted and also
267             that all columns in a SELECT are unquoted. We also want to make sure that after we find matches where we need
268             to unquote a column that we prevent users from adding quotes to the column by using the `identify` argument when
269             generating the SQL.
270 
271             Note: We make an assumption that any columns referenced in a VALUES expression should be unquoted throughout the
272             expression. This might not be true in a case where the same column name can be sourced from another table that can
273             properly quote but should be true in most cases.
274             """
275             values_expressions = expression.find_all(exp.Values)
276             values_identifiers = set(
277                 flatten(
278                     v.args.get("alias", exp.Alias()).args.get("columns", [])
279                     for v in values_expressions
280                 )
281             )
282             if values_identifiers:
283                 expression = expression.transform(
284                     lambda node: exp.Identifier(**{**node.args, "quoted": False})
285                     if isinstance(node, exp.Identifier) and node in values_identifiers
286                     else node,
287                 )
288                 return self.no_identify(lambda: super(self.__class__, self).select_sql(expression))
289             return super().select_sql(expression)
290 
291         def describe_sql(self, expression: exp.Describe) -> str:
292             # Default to table if kind is unknown
293             kind_value = expression.args.get("kind") or "TABLE"
294             kind = f" {kind_value}" if kind_value else ""
295             this = f" {self.sql(expression, 'this')}"
296             return f"DESCRIBE{kind}{this}"
297
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py
--- a/sqlglot/dialects/snowflake.py
+++ b/sqlglot/dialects/snowflake.py
@@ -222,6 +222,7 @@
             exp.TimeToUnix: lambda self, e: f"EXTRACT(epoch_second FROM {self.sql(e, 'this')})",
             exp.Trim: lambda self, e: f"TRIM({self.format_args(e.this, e.expression)})",
             exp.UnixToTime: _unix_to_time_sql,
+            exp.DayOfWeek: rename_func("DAYOFWEEK"),
         }
 
         TYPE_MAPPING = {

{"golden_diff": "diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py\n--- a/sqlglot/dialects/snowflake.py\n+++ b/sqlglot/dialects/snowflake.py\n@@ -222,6 +222,7 @@\n             exp.TimeToUnix: lambda self, e: f\"EXTRACT(epoch_second FROM {self.sql(e, 'this')})\",\n             exp.Trim: lambda self, e: f\"TRIM({self.format_args(e.this, e.expression)})\",\n             exp.UnixToTime: _unix_to_time_sql,\n+            exp.DayOfWeek: rename_func(\"DAYOFWEEK\"),\n         }\n \n         TYPE_MAPPING = {\n", "issue": "transpiling from snowflake to snowflake converts DAYOFWEEK to nonexistent DAY_OF_WEEK\nworks in snowflake: `select dayofweek( '2016-01-02T23:39:20.123-07:00'::timestamp)`\r\n\r\nin sqlglot 11.0.0, python 3.10.4:\r\n\r\n```python\r\nimport sqlglot\r\n\r\n# converts dayofweek to nonexistent DAY_OF_WEEK\r\nprint(sqlglot.transpile(\"select dayofweek( '2016-01-02T23:39:20.123-07:00'::timestamp)\", read='snowflake', write='snowflake'))\r\n```\r\n\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom sqlglot import exp, generator, parser, tokens\nfrom sqlglot.dialects.dialect import (\n    Dialect,\n    datestrtodate_sql,\n    format_time_lambda,\n    inline_array_sql,\n    rename_func,\n    timestrtotime_sql,\n    var_map_sql,\n)\nfrom sqlglot.expressions import Literal\nfrom sqlglot.helper import flatten, seq_get\nfrom sqlglot.tokens import TokenType\n\n\ndef _check_int(s):\n    if s[0] in (\"-\", \"+\"):\n        return s[1:].isdigit()\n    return s.isdigit()\n\n\n# from https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html\ndef _snowflake_to_timestamp(args):\n    if len(args) == 2:\n        first_arg, second_arg = args\n        if second_arg.is_string:\n            # case: <string_expr> [ , <format> ]\n            return format_time_lambda(exp.StrToTime, \"snowflake\")(args)\n\n        # case: <numeric_expr> [ , <scale> ]\n        if second_arg.name not in [\"0\", \"3\", \"9\"]:\n            raise ValueError(\n                f\"Scale for snowflake numeric timestamp is {second_arg}, but should be 0, 3, or 9\"\n            )\n\n        if second_arg.name == \"0\":\n            timescale = exp.UnixToTime.SECONDS\n        elif second_arg.name == \"3\":\n            timescale = exp.UnixToTime.MILLIS\n        elif second_arg.name == \"9\":\n            timescale = exp.UnixToTime.MICROS\n\n        return exp.UnixToTime(this=first_arg, scale=timescale)\n\n    first_arg = seq_get(args, 0)\n    if not isinstance(first_arg, Literal):\n        # case: <variant_expr>\n        return format_time_lambda(exp.StrToTime, \"snowflake\", default=True)(args)\n\n    if first_arg.is_string:\n        if _check_int(first_arg.this):\n            # case: <integer>\n            return exp.UnixToTime.from_arg_list(args)\n\n        # case: <date_expr>\n        return format_time_lambda(exp.StrToTime, \"snowflake\", default=True)(args)\n\n    # case: <numeric_expr>\n    return exp.UnixToTime.from_arg_list(args)\n\n\ndef _unix_to_time_sql(self, expression):\n    scale = expression.args.get(\"scale\")\n    timestamp = self.sql(expression, \"this\")\n    if scale in [None, exp.UnixToTime.SECONDS]:\n        return f\"TO_TIMESTAMP({timestamp})\"\n    if scale == exp.UnixToTime.MILLIS:\n        return f\"TO_TIMESTAMP({timestamp}, 3)\"\n    if scale == exp.UnixToTime.MICROS:\n        return f\"TO_TIMESTAMP({timestamp}, 9)\"\n\n    raise ValueError(\"Improper scale for timestamp\")\n\n\n# https://docs.snowflake.com/en/sql-reference/functions/date_part.html\n# https://docs.snowflake.com/en/sql-reference/functions-date-time.html#label-supported-date-time-parts\ndef _parse_date_part(self):\n    this = self._parse_var() or self._parse_type()\n    self._match(TokenType.COMMA)\n    expression = self._parse_bitwise()\n\n    name = this.name.upper()\n    if name.startswith(\"EPOCH\"):\n        if name.startswith(\"EPOCH_MILLISECOND\"):\n            scale = 10**3\n        elif name.startswith(\"EPOCH_MICROSECOND\"):\n            scale = 10**6\n        elif name.startswith(\"EPOCH_NANOSECOND\"):\n            scale = 10**9\n        else:\n            scale = None\n\n        ts = self.expression(exp.Cast, this=expression, to=exp.DataType.build(\"TIMESTAMP\"))\n        to_unix = self.expression(exp.TimeToUnix, this=ts)\n\n        if scale:\n            to_unix = exp.Mul(this=to_unix, expression=exp.Literal.number(scale))\n\n        return to_unix\n\n    return self.expression(exp.Extract, this=this, expression=expression)\n\n\ndef _datatype_sql(self, expression):\n    if expression.this == exp.DataType.Type.ARRAY:\n        return \"ARRAY\"\n    elif expression.this == exp.DataType.Type.MAP:\n        return \"OBJECT\"\n    return self.datatype_sql(expression)\n\n\nclass Snowflake(Dialect):\n    null_ordering = \"nulls_are_large\"\n    time_format = \"'yyyy-mm-dd hh24:mi:ss'\"\n\n    time_mapping = {\n        \"YYYY\": \"%Y\",\n        \"yyyy\": \"%Y\",\n        \"YY\": \"%y\",\n        \"yy\": \"%y\",\n        \"MMMM\": \"%B\",\n        \"mmmm\": \"%B\",\n        \"MON\": \"%b\",\n        \"mon\": \"%b\",\n        \"MM\": \"%m\",\n        \"mm\": \"%m\",\n        \"DD\": \"%d\",\n        \"dd\": \"%d\",\n        \"d\": \"%-d\",\n        \"DY\": \"%w\",\n        \"dy\": \"%w\",\n        \"HH24\": \"%H\",\n        \"hh24\": \"%H\",\n        \"HH12\": \"%I\",\n        \"hh12\": \"%I\",\n        \"MI\": \"%M\",\n        \"mi\": \"%M\",\n        \"SS\": \"%S\",\n        \"ss\": \"%S\",\n        \"FF\": \"%f\",\n        \"ff\": \"%f\",\n        \"FF6\": \"%f\",\n        \"ff6\": \"%f\",\n    }\n\n    class Parser(parser.Parser):\n        FUNCTIONS = {\n            **parser.Parser.FUNCTIONS,\n            \"ARRAYAGG\": exp.ArrayAgg.from_arg_list,\n            \"IFF\": exp.If.from_arg_list,\n            \"TO_TIMESTAMP\": _snowflake_to_timestamp,\n            \"ARRAY_CONSTRUCT\": exp.Array.from_arg_list,\n            \"RLIKE\": exp.RegexpLike.from_arg_list,\n            \"DECODE\": exp.Matches.from_arg_list,\n            \"OBJECT_CONSTRUCT\": parser.parse_var_map,\n        }\n\n        FUNCTION_PARSERS = {\n            **parser.Parser.FUNCTION_PARSERS,\n            \"DATE_PART\": _parse_date_part,\n        }\n        FUNCTION_PARSERS.pop(\"TRIM\")\n\n        FUNC_TOKENS = {\n            *parser.Parser.FUNC_TOKENS,\n            TokenType.RLIKE,\n            TokenType.TABLE,\n        }\n\n        COLUMN_OPERATORS = {\n            **parser.Parser.COLUMN_OPERATORS,  # type: ignore\n            TokenType.COLON: lambda self, this, path: self.expression(\n                exp.Bracket,\n                this=this,\n                expressions=[path],\n            ),\n        }\n\n    class Tokenizer(tokens.Tokenizer):\n        QUOTES = [\"'\", \"$$\"]\n        STRING_ESCAPES = [\"\\\\\", \"'\"]\n\n        SINGLE_TOKENS = {\n            **tokens.Tokenizer.SINGLE_TOKENS,\n            \"$\": TokenType.PARAMETER,\n        }\n\n        KEYWORDS = {\n            **tokens.Tokenizer.KEYWORDS,\n            \"EXCLUDE\": TokenType.EXCEPT,\n            \"MATCH_RECOGNIZE\": TokenType.MATCH_RECOGNIZE,\n            \"RENAME\": TokenType.REPLACE,\n            \"TIMESTAMP_LTZ\": TokenType.TIMESTAMPLTZ,\n            \"TIMESTAMP_NTZ\": TokenType.TIMESTAMP,\n            \"TIMESTAMP_TZ\": TokenType.TIMESTAMPTZ,\n            \"TIMESTAMPNTZ\": TokenType.TIMESTAMP,\n            \"MINUS\": TokenType.EXCEPT,\n            \"SAMPLE\": TokenType.TABLE_SAMPLE,\n        }\n\n    class Generator(generator.Generator):\n        CREATE_TRANSIENT = True\n\n        TRANSFORMS = {\n            **generator.Generator.TRANSFORMS,  # type: ignore\n            exp.Array: inline_array_sql,\n            exp.ArrayConcat: rename_func(\"ARRAY_CAT\"),\n            exp.DateAdd: rename_func(\"DATEADD\"),\n            exp.DateStrToDate: datestrtodate_sql,\n            exp.DataType: _datatype_sql,\n            exp.If: rename_func(\"IFF\"),\n            exp.Map: lambda self, e: var_map_sql(self, e, \"OBJECT_CONSTRUCT\"),\n            exp.VarMap: lambda self, e: var_map_sql(self, e, \"OBJECT_CONSTRUCT\"),\n            exp.Parameter: lambda self, e: f\"${self.sql(e, 'this')}\",\n            exp.PartitionedByProperty: lambda self, e: f\"PARTITION BY {self.sql(e, 'this')}\",\n            exp.Matches: rename_func(\"DECODE\"),\n            exp.StrPosition: lambda self, e: f\"{self.normalize_func('POSITION')}({self.format_args(e.args.get('substr'), e.this, e.args.get('position'))})\",\n            exp.StrToTime: lambda self, e: f\"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})\",\n            exp.TimeStrToTime: timestrtotime_sql,\n            exp.TimeToUnix: lambda self, e: f\"EXTRACT(epoch_second FROM {self.sql(e, 'this')})\",\n            exp.Trim: lambda self, e: f\"TRIM({self.format_args(e.this, e.expression)})\",\n            exp.UnixToTime: _unix_to_time_sql,\n        }\n\n        TYPE_MAPPING = {\n            **generator.Generator.TYPE_MAPPING,  # type: ignore\n            exp.DataType.Type.TIMESTAMP: \"TIMESTAMPNTZ\",\n        }\n\n        STAR_MAPPING = {\n            \"except\": \"EXCLUDE\",\n            \"replace\": \"RENAME\",\n        }\n\n        def except_op(self, expression):\n            if not expression.args.get(\"distinct\", False):\n                self.unsupported(\"EXCEPT with All is not supported in Snowflake\")\n            return super().except_op(expression)\n\n        def intersect_op(self, expression):\n            if not expression.args.get(\"distinct\", False):\n                self.unsupported(\"INTERSECT with All is not supported in Snowflake\")\n            return super().intersect_op(expression)\n\n        def values_sql(self, expression: exp.Values) -> str:\n            \"\"\"Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted.\n\n            We also want to make sure that after we find matches where we need to unquote a column that we prevent users\n            from adding quotes to the column by using the `identify` argument when generating the SQL.\n            \"\"\"\n            alias = expression.args.get(\"alias\")\n            if alias and alias.args.get(\"columns\"):\n                expression = expression.transform(\n                    lambda node: exp.Identifier(**{**node.args, \"quoted\": False})\n                    if isinstance(node, exp.Identifier)\n                    and isinstance(node.parent, exp.TableAlias)\n                    and node.arg_key == \"columns\"\n                    else node,\n                )\n                return self.no_identify(lambda: super(self.__class__, self).values_sql(expression))\n            return super().values_sql(expression)\n\n        def select_sql(self, expression: exp.Select) -> str:\n            \"\"\"Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted and also\n            that all columns in a SELECT are unquoted. We also want to make sure that after we find matches where we need\n            to unquote a column that we prevent users from adding quotes to the column by using the `identify` argument when\n            generating the SQL.\n\n            Note: We make an assumption that any columns referenced in a VALUES expression should be unquoted throughout the\n            expression. This might not be true in a case where the same column name can be sourced from another table that can\n            properly quote but should be true in most cases.\n            \"\"\"\n            values_expressions = expression.find_all(exp.Values)\n            values_identifiers = set(\n                flatten(\n                    v.args.get(\"alias\", exp.Alias()).args.get(\"columns\", [])\n                    for v in values_expressions\n                )\n            )\n            if values_identifiers:\n                expression = expression.transform(\n                    lambda node: exp.Identifier(**{**node.args, \"quoted\": False})\n                    if isinstance(node, exp.Identifier) and node in values_identifiers\n                    else node,\n                )\n                return self.no_identify(lambda: super(self.__class__, self).select_sql(expression))\n            return super().select_sql(expression)\n\n        def describe_sql(self, expression: exp.Describe) -> str:\n            # Default to table if kind is unknown\n            kind_value = expression.args.get(\"kind\") or \"TABLE\"\n            kind = f\" {kind_value}\" if kind_value else \"\"\n            this = f\" {self.sql(expression, 'this')}\"\n            return f\"DESCRIBE{kind}{this}\"\n", "path": "sqlglot/dialects/snowflake.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom sqlglot import exp, generator, parser, tokens\nfrom sqlglot.dialects.dialect import (\n    Dialect,\n    datestrtodate_sql,\n    format_time_lambda,\n    inline_array_sql,\n    rename_func,\n    timestrtotime_sql,\n    var_map_sql,\n)\nfrom sqlglot.expressions import Literal\nfrom sqlglot.helper import flatten, seq_get\nfrom sqlglot.tokens import TokenType\n\n\ndef _check_int(s):\n    if s[0] in (\"-\", \"+\"):\n        return s[1:].isdigit()\n    return s.isdigit()\n\n\n# from https://docs.snowflake.com/en/sql-reference/functions/to_timestamp.html\ndef _snowflake_to_timestamp(args):\n    if len(args) == 2:\n        first_arg, second_arg = args\n        if second_arg.is_string:\n            # case: <string_expr> [ , <format> ]\n            return format_time_lambda(exp.StrToTime, \"snowflake\")(args)\n\n        # case: <numeric_expr> [ , <scale> ]\n        if second_arg.name not in [\"0\", \"3\", \"9\"]:\n            raise ValueError(\n                f\"Scale for snowflake numeric timestamp is {second_arg}, but should be 0, 3, or 9\"\n            )\n\n        if second_arg.name == \"0\":\n            timescale = exp.UnixToTime.SECONDS\n        elif second_arg.name == \"3\":\n            timescale = exp.UnixToTime.MILLIS\n        elif second_arg.name == \"9\":\n            timescale = exp.UnixToTime.MICROS\n\n        return exp.UnixToTime(this=first_arg, scale=timescale)\n\n    first_arg = seq_get(args, 0)\n    if not isinstance(first_arg, Literal):\n        # case: <variant_expr>\n        return format_time_lambda(exp.StrToTime, \"snowflake\", default=True)(args)\n\n    if first_arg.is_string:\n        if _check_int(first_arg.this):\n            # case: <integer>\n            return exp.UnixToTime.from_arg_list(args)\n\n        # case: <date_expr>\n        return format_time_lambda(exp.StrToTime, \"snowflake\", default=True)(args)\n\n    # case: <numeric_expr>\n    return exp.UnixToTime.from_arg_list(args)\n\n\ndef _unix_to_time_sql(self, expression):\n    scale = expression.args.get(\"scale\")\n    timestamp = self.sql(expression, \"this\")\n    if scale in [None, exp.UnixToTime.SECONDS]:\n        return f\"TO_TIMESTAMP({timestamp})\"\n    if scale == exp.UnixToTime.MILLIS:\n        return f\"TO_TIMESTAMP({timestamp}, 3)\"\n    if scale == exp.UnixToTime.MICROS:\n        return f\"TO_TIMESTAMP({timestamp}, 9)\"\n\n    raise ValueError(\"Improper scale for timestamp\")\n\n\n# https://docs.snowflake.com/en/sql-reference/functions/date_part.html\n# https://docs.snowflake.com/en/sql-reference/functions-date-time.html#label-supported-date-time-parts\ndef _parse_date_part(self):\n    this = self._parse_var() or self._parse_type()\n    self._match(TokenType.COMMA)\n    expression = self._parse_bitwise()\n\n    name = this.name.upper()\n    if name.startswith(\"EPOCH\"):\n        if name.startswith(\"EPOCH_MILLISECOND\"):\n            scale = 10**3\n        elif name.startswith(\"EPOCH_MICROSECOND\"):\n            scale = 10**6\n        elif name.startswith(\"EPOCH_NANOSECOND\"):\n            scale = 10**9\n        else:\n            scale = None\n\n        ts = self.expression(exp.Cast, this=expression, to=exp.DataType.build(\"TIMESTAMP\"))\n        to_unix = self.expression(exp.TimeToUnix, this=ts)\n\n        if scale:\n            to_unix = exp.Mul(this=to_unix, expression=exp.Literal.number(scale))\n\n        return to_unix\n\n    return self.expression(exp.Extract, this=this, expression=expression)\n\n\ndef _datatype_sql(self, expression):\n    if expression.this == exp.DataType.Type.ARRAY:\n        return \"ARRAY\"\n    elif expression.this == exp.DataType.Type.MAP:\n        return \"OBJECT\"\n    return self.datatype_sql(expression)\n\n\nclass Snowflake(Dialect):\n    null_ordering = \"nulls_are_large\"\n    time_format = \"'yyyy-mm-dd hh24:mi:ss'\"\n\n    time_mapping = {\n        \"YYYY\": \"%Y\",\n        \"yyyy\": \"%Y\",\n        \"YY\": \"%y\",\n        \"yy\": \"%y\",\n        \"MMMM\": \"%B\",\n        \"mmmm\": \"%B\",\n        \"MON\": \"%b\",\n        \"mon\": \"%b\",\n        \"MM\": \"%m\",\n        \"mm\": \"%m\",\n        \"DD\": \"%d\",\n        \"dd\": \"%d\",\n        \"d\": \"%-d\",\n        \"DY\": \"%w\",\n        \"dy\": \"%w\",\n        \"HH24\": \"%H\",\n        \"hh24\": \"%H\",\n        \"HH12\": \"%I\",\n        \"hh12\": \"%I\",\n        \"MI\": \"%M\",\n        \"mi\": \"%M\",\n        \"SS\": \"%S\",\n        \"ss\": \"%S\",\n        \"FF\": \"%f\",\n        \"ff\": \"%f\",\n        \"FF6\": \"%f\",\n        \"ff6\": \"%f\",\n    }\n\n    class Parser(parser.Parser):\n        FUNCTIONS = {\n            **parser.Parser.FUNCTIONS,\n            \"ARRAYAGG\": exp.ArrayAgg.from_arg_list,\n            \"IFF\": exp.If.from_arg_list,\n            \"TO_TIMESTAMP\": _snowflake_to_timestamp,\n            \"ARRAY_CONSTRUCT\": exp.Array.from_arg_list,\n            \"RLIKE\": exp.RegexpLike.from_arg_list,\n            \"DECODE\": exp.Matches.from_arg_list,\n            \"OBJECT_CONSTRUCT\": parser.parse_var_map,\n        }\n\n        FUNCTION_PARSERS = {\n            **parser.Parser.FUNCTION_PARSERS,\n            \"DATE_PART\": _parse_date_part,\n        }\n        FUNCTION_PARSERS.pop(\"TRIM\")\n\n        FUNC_TOKENS = {\n            *parser.Parser.FUNC_TOKENS,\n            TokenType.RLIKE,\n            TokenType.TABLE,\n        }\n\n        COLUMN_OPERATORS = {\n            **parser.Parser.COLUMN_OPERATORS,  # type: ignore\n            TokenType.COLON: lambda self, this, path: self.expression(\n                exp.Bracket,\n                this=this,\n                expressions=[path],\n            ),\n        }\n\n    class Tokenizer(tokens.Tokenizer):\n        QUOTES = [\"'\", \"$$\"]\n        STRING_ESCAPES = [\"\\\\\", \"'\"]\n\n        SINGLE_TOKENS = {\n            **tokens.Tokenizer.SINGLE_TOKENS,\n            \"$\": TokenType.PARAMETER,\n        }\n\n        KEYWORDS = {\n            **tokens.Tokenizer.KEYWORDS,\n            \"EXCLUDE\": TokenType.EXCEPT,\n            \"MATCH_RECOGNIZE\": TokenType.MATCH_RECOGNIZE,\n            \"RENAME\": TokenType.REPLACE,\n            \"TIMESTAMP_LTZ\": TokenType.TIMESTAMPLTZ,\n            \"TIMESTAMP_NTZ\": TokenType.TIMESTAMP,\n            \"TIMESTAMP_TZ\": TokenType.TIMESTAMPTZ,\n            \"TIMESTAMPNTZ\": TokenType.TIMESTAMP,\n            \"MINUS\": TokenType.EXCEPT,\n            \"SAMPLE\": TokenType.TABLE_SAMPLE,\n        }\n\n    class Generator(generator.Generator):\n        CREATE_TRANSIENT = True\n\n        TRANSFORMS = {\n            **generator.Generator.TRANSFORMS,  # type: ignore\n            exp.Array: inline_array_sql,\n            exp.ArrayConcat: rename_func(\"ARRAY_CAT\"),\n            exp.DateAdd: rename_func(\"DATEADD\"),\n            exp.DateStrToDate: datestrtodate_sql,\n            exp.DataType: _datatype_sql,\n            exp.If: rename_func(\"IFF\"),\n            exp.Map: lambda self, e: var_map_sql(self, e, \"OBJECT_CONSTRUCT\"),\n            exp.VarMap: lambda self, e: var_map_sql(self, e, \"OBJECT_CONSTRUCT\"),\n            exp.Parameter: lambda self, e: f\"${self.sql(e, 'this')}\",\n            exp.PartitionedByProperty: lambda self, e: f\"PARTITION BY {self.sql(e, 'this')}\",\n            exp.Matches: rename_func(\"DECODE\"),\n            exp.StrPosition: lambda self, e: f\"{self.normalize_func('POSITION')}({self.format_args(e.args.get('substr'), e.this, e.args.get('position'))})\",\n            exp.StrToTime: lambda self, e: f\"TO_TIMESTAMP({self.sql(e, 'this')}, {self.format_time(e)})\",\n            exp.TimeStrToTime: timestrtotime_sql,\n            exp.TimeToUnix: lambda self, e: f\"EXTRACT(epoch_second FROM {self.sql(e, 'this')})\",\n            exp.Trim: lambda self, e: f\"TRIM({self.format_args(e.this, e.expression)})\",\n            exp.UnixToTime: _unix_to_time_sql,\n            exp.DayOfWeek: rename_func(\"DAYOFWEEK\"),\n        }\n\n        TYPE_MAPPING = {\n            **generator.Generator.TYPE_MAPPING,  # type: ignore\n            exp.DataType.Type.TIMESTAMP: \"TIMESTAMPNTZ\",\n        }\n\n        STAR_MAPPING = {\n            \"except\": \"EXCLUDE\",\n            \"replace\": \"RENAME\",\n        }\n\n        def except_op(self, expression):\n            if not expression.args.get(\"distinct\", False):\n                self.unsupported(\"EXCEPT with All is not supported in Snowflake\")\n            return super().except_op(expression)\n\n        def intersect_op(self, expression):\n            if not expression.args.get(\"distinct\", False):\n                self.unsupported(\"INTERSECT with All is not supported in Snowflake\")\n            return super().intersect_op(expression)\n\n        def values_sql(self, expression: exp.Values) -> str:\n            \"\"\"Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted.\n\n            We also want to make sure that after we find matches where we need to unquote a column that we prevent users\n            from adding quotes to the column by using the `identify` argument when generating the SQL.\n            \"\"\"\n            alias = expression.args.get(\"alias\")\n            if alias and alias.args.get(\"columns\"):\n                expression = expression.transform(\n                    lambda node: exp.Identifier(**{**node.args, \"quoted\": False})\n                    if isinstance(node, exp.Identifier)\n                    and isinstance(node.parent, exp.TableAlias)\n                    and node.arg_key == \"columns\"\n                    else node,\n                )\n                return self.no_identify(lambda: super(self.__class__, self).values_sql(expression))\n            return super().values_sql(expression)\n\n        def select_sql(self, expression: exp.Select) -> str:\n            \"\"\"Due to a bug in Snowflake we want to make sure that all columns in a VALUES table alias are unquoted and also\n            that all columns in a SELECT are unquoted. We also want to make sure that after we find matches where we need\n            to unquote a column that we prevent users from adding quotes to the column by using the `identify` argument when\n            generating the SQL.\n\n            Note: We make an assumption that any columns referenced in a VALUES expression should be unquoted throughout the\n            expression. This might not be true in a case where the same column name can be sourced from another table that can\n            properly quote but should be true in most cases.\n            \"\"\"\n            values_expressions = expression.find_all(exp.Values)\n            values_identifiers = set(\n                flatten(\n                    v.args.get(\"alias\", exp.Alias()).args.get(\"columns\", [])\n                    for v in values_expressions\n                )\n            )\n            if values_identifiers:\n                expression = expression.transform(\n                    lambda node: exp.Identifier(**{**node.args, \"quoted\": False})\n                    if isinstance(node, exp.Identifier) and node in values_identifiers\n                    else node,\n                )\n                return self.no_identify(lambda: super(self.__class__, self).select_sql(expression))\n            return super().select_sql(expression)\n\n        def describe_sql(self, expression: exp.Describe) -> str:\n            # Default to table if kind is unknown\n            kind_value = expression.args.get(\"kind\") or \"TABLE\"\n            kind = f\" {kind_value}\" if kind_value else \"\"\n            this = f\" {self.sql(expression, 'this')}\"\n            return f\"DESCRIBE{kind}{this}\"\n", "path": "sqlglot/dialects/snowflake.py"}]}