Repository: tobymao/sqlglot

Issue:
rows as a keyword not be execute in mysql or doris , The others are range/else 
**Before you file an issue**
- Make sure you specify the "read" dialect eg. `parse_one(sql, read="postgres")`
- Make sure you specify the "write" dialect eg. `ast.sql(dialect="doris")`
- Check if the issue still exists on main:Couldn't find anything related

**Fully reproducible code snippet**
```python
import sqlglot

sql = """SELECT ROW_NUMBER() OVER (ORDER BY 1) AS rows"""

print(sqlglot.transpile(sql ,read="postgres" , write="doris")[0]);
``` 

output
```
SELECT ROW_NUMBER() OVER (ORDER BY 1 NULLS LAST) AS rows
```

Expected output
```
SELECT ROW_NUMBER() OVER (ORDER BY 1 NULLS LAST) AS 'rows'

```
or
```
SELECT ROW_NUMBER() OVER (ORDER BY 1 NULLS LAST) AS "rows"

```

or
```
SELECT ROW_NUMBER() OVER (ORDER BY 1 NULLS LAST) AS `rows`

```







Discussion:

Patch:
diff --git a/sqlglot/dialects/mysql.py b/sqlglot/dialects/mysql.py
index d707cde0..5cc34b61 100644
--- a/sqlglot/dialects/mysql.py
+++ b/sqlglot/dialects/mysql.py
@@ -597,13 +597,13 @@ class MySQL(Dialect):
             return offset, limit
 
         def _parse_set_item_charset(self, kind: str) -> exp.Expression:
-            this = self._parse_string() or self._parse_id_var()
+            this = self._parse_string() or self._parse_unquoted_field()
             return self.expression(exp.SetItem, this=this, kind=kind)
 
         def _parse_set_item_names(self) -> exp.Expression:
-            charset = self._parse_string() or self._parse_id_var()
+            charset = self._parse_string() or self._parse_unquoted_field()
             if self._match_text_seq("COLLATE"):
-                collate = self._parse_string() or self._parse_id_var()
+                collate = self._parse_string() or self._parse_unquoted_field()
             else:
                 collate = None
 
@@ -823,6 +823,295 @@ class MySQL(Dialect):
             exp.DataType.Type.TIMESTAMPLTZ,
         }
 
+        # https://dev.mysql.com/doc/refman/8.0/en/keywords.html
+        RESERVED_KEYWORDS = {
+            "accessible",
+            "add",
+            "all",
+            "alter",
+            "analyze",
+            "and",
+            "as",
+            "asc",
+            "asensitive",
+            "before",
+            "between",
+            "bigint",
+            "binary",
+            "blob",
+            "both",
+            "by",
+            "call",
+            "cascade",
+            "case",
+            "change",
+            "char",
+            "character",
+            "check",
+            "collate",
+            "column",
+            "condition",
+            "constraint",
+            "continue",
+            "convert",
+            "create",
+            "cross",
+            "cube",
+            "cume_dist",
+            "current_date",
+            "current_time",
+            "current_timestamp",
+            "current_user",
+            "cursor",
+            "database",
+            "databases",
+            "day_hour",
+            "day_microsecond",
+            "day_minute",
+            "day_second",
+            "dec",
+            "decimal",
+            "declare",
+            "default",
+            "delayed",
+            "delete",
+            "dense_rank",
+            "desc",
+            "describe",
+            "deterministic",
+            "distinct",
+            "distinctrow",
+            "div",
+            "double",
+            "drop",
+            "dual",
+            "each",
+            "else",
+            "elseif",
+            "empty",
+            "enclosed",
+            "escaped",
+            "except",
+            "exists",
+            "exit",
+            "explain",
+            "false",
+            "fetch",
+            "first_value",
+            "float",
+            "float4",
+            "float8",
+            "for",
+            "force",
+            "foreign",
+            "from",
+            "fulltext",
+            "function",
+            "generated",
+            "get",
+            "grant",
+            "group",
+            "grouping",
+            "groups",
+            "having",
+            "high_priority",
+            "hour_microsecond",
+            "hour_minute",
+            "hour_second",
+            "if",
+            "ignore",
+            "in",
+            "index",
+            "infile",
+            "inner",
+            "inout",
+            "insensitive",
+            "insert",
+            "int",
+            "int1",
+            "int2",
+            "int3",
+            "int4",
+            "int8",
+            "integer",
+            "intersect",
+            "interval",
+            "into",
+            "io_after_gtids",
+            "io_before_gtids",
+            "is",
+            "iterate",
+            "join",
+            "json_table",
+            "key",
+            "keys",
+            "kill",
+            "lag",
+            "last_value",
+            "lateral",
+            "lead",
+            "leading",
+            "leave",
+            "left",
+            "like",
+            "limit",
+            "linear",
+            "lines",
+            "load",
+            "localtime",
+            "localtimestamp",
+            "lock",
+            "long",
+            "longblob",
+            "longtext",
+            "loop",
+            "low_priority",
+            "master_bind",
+            "master_ssl_verify_server_cert",
+            "match",
+            "maxvalue",
+            "mediumblob",
+            "mediumint",
+            "mediumtext",
+            "middleint",
+            "minute_microsecond",
+            "minute_second",
+            "mod",
+            "modifies",
+            "natural",
+            "not",
+            "no_write_to_binlog",
+            "nth_value",
+            "ntile",
+            "null",
+            "numeric",
+            "of",
+            "on",
+            "optimize",
+            "optimizer_costs",
+            "option",
+            "optionally",
+            "or",
+            "order",
+            "out",
+            "outer",
+            "outfile",
+            "over",
+            "partition",
+            "percent_rank",
+            "precision",
+            "primary",
+            "procedure",
+            "purge",
+            "range",
+            "rank",
+            "read",
+            "reads",
+            "read_write",
+            "real",
+            "recursive",
+            "references",
+            "regexp",
+            "release",
+            "rename",
+            "repeat",
+            "replace",
+            "require",
+            "resignal",
+            "restrict",
+            "return",
+            "revoke",
+            "right",
+            "rlike",
+            "row",
+            "rows",
+            "row_number",
+            "schema",
+            "schemas",
+            "second_microsecond",
+            "select",
+            "sensitive",
+            "separator",
+            "set",
+            "show",
+            "signal",
+            "smallint",
+            "spatial",
+            "specific",
+            "sql",
+            "sqlexception",
+            "sqlstate",
+            "sqlwarning",
+            "sql_big_result",
+            "sql_calc_found_rows",
+            "sql_small_result",
+            "ssl",
+            "starting",
+            "stored",
+            "straight_join",
+            "system",
+            "table",
+            "terminated",
+            "then",
+            "tinyblob",
+            "tinyint",
+            "tinytext",
+            "to",
+            "trailing",
+            "trigger",
+            "true",
+            "undo",
+            "union",
+            "unique",
+            "unlock",
+            "unsigned",
+            "update",
+            "usage",
+            "use",
+            "using",
+            "utc_date",
+            "utc_time",
+            "utc_timestamp",
+            "values",
+            "varbinary",
+            "varchar",
+            "varcharacter",
+            "varying",
+            "virtual",
+            "when",
+            "where",
+            "while",
+            "window",
+            "with",
+            "write",
+            "xor",
+            "year_month",
+            "zerofill",
+            "cume_dist",
+            "dense_rank",
+            "empty",
+            "except",
+            "first_value",
+            "grouping",
+            "groups",
+            "intersect",
+            "json_table",
+            "lag",
+            "last_value",
+            "lateral",
+            "lead",
+            "nth_value",
+            "ntile",
+            "of",
+            "over",
+            "percent_rank",
+            "rank",
+            "recursive",
+            "row_number",
+            "system",
+            "window",
+        }
+
         def array_sql(self, expression: exp.Array) -> str:
             self.unsupported("Arrays are not supported by MySQL")
             return self.function_fallback_sql(expression)
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py
index 01a611a3..0de4a80e 100644
--- a/sqlglot/dialects/snowflake.py
+++ b/sqlglot/dialects/snowflake.py
@@ -483,7 +483,7 @@ class Snowflake(Dialect):
 
         SCHEMA_KINDS = {"OBJECTS", "TABLES", "VIEWS", "SEQUENCES", "UNIQUE KEYS", "IMPORTED KEYS"}
 
-        NON_TABLE_CREATABLES = {"STORAGE INTEGRATION", "TAG", "WAREHOUSE"}
+        NON_TABLE_CREATABLES = {"STORAGE INTEGRATION", "TAG", "WAREHOUSE", "STREAMLIT"}
 
         LAMBDAS = {
             **parser.Parser.LAMBDAS,
@@ -743,6 +743,7 @@ class Snowflake(Dialect):
             "TIMESTAMP_TZ": TokenType.TIMESTAMPTZ,
             "TOP": TokenType.TOP,
             "WAREHOUSE": TokenType.WAREHOUSE,
+            "STREAMLIT": TokenType.STREAMLIT,
         }
 
         SINGLE_TOKENS = {
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 43b150ad..3237cd1c 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -342,6 +342,7 @@ class Parser(metaclass=_Parser):
         TokenType.TAG,
         TokenType.VIEW,
         TokenType.WAREHOUSE,
+        TokenType.STREAMLIT,
     }
 
     CREATABLES = {
@@ -1642,6 +1643,7 @@ class Parser(metaclass=_Parser):
             extend_props(self._parse_properties())
 
             expression = self._match(TokenType.ALIAS) and self._parse_heredoc()
+            extend_props(self._parse_properties())
 
             if not expression:
                 if self._match(TokenType.COMMAND):
@@ -6246,8 +6248,10 @@ class Parser(metaclass=_Parser):
             return None
 
         right = self._parse_statement() or self._parse_id_var()
-        this = self.expression(exp.EQ, this=left, expression=right)
+        if isinstance(right, (exp.Column, exp.Identifier)):
+            right = exp.var(right.name)
 
+        this = self.expression(exp.EQ, this=left, expression=right)
         return self.expression(exp.SetItem, this=this, kind=kind)
 
     def _parse_set_transaction(self, global_: bool = False) -> exp.Expression:
diff --git a/sqlglot/tokens.py b/sqlglot/tokens.py
index 8ae090e0..6586667f 100644
--- a/sqlglot/tokens.py
+++ b/sqlglot/tokens.py
@@ -93,6 +93,7 @@ class TokenType(AutoName):
     SCHEMA = auto()
     TABLE = auto()
     WAREHOUSE = auto()
+    STREAMLIT = auto()
     VAR = auto()
     BIT_STRING = auto()
     HEX_STRING = auto()


Test patch:
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index b2b2ecc6..591b5dd5 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -155,6 +155,10 @@ class TestMySQL(Validator):
             """SELECT * FROM foo WHERE 3 MEMBER OF(info->'$.value')""",
             """SELECT * FROM foo WHERE 3 MEMBER OF(JSON_EXTRACT(info, '$.value'))""",
         )
+        self.validate_identity(
+            "SELECT 1 AS row",
+            "SELECT 1 AS `row`",
+        )
 
         # Index hints
         self.validate_identity(
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py
index 12af0d35..8ba4e967 100644
--- a/tests/dialects/test_postgres.py
+++ b/tests/dialects/test_postgres.py
@@ -753,6 +753,9 @@ class TestPostgres(Validator):
         self.validate_identity("ALTER TABLE t1 SET ACCESS METHOD method")
         self.validate_identity("ALTER TABLE t1 SET TABLESPACE tablespace")
         self.validate_identity("ALTER TABLE t1 SET (fillfactor = 5, autovacuum_enabled = TRUE)")
+        self.validate_identity(
+            "CREATE FUNCTION pymax(a INT, b INT) RETURNS INT LANGUAGE plpython3u AS $$\n  if a > b:\n    return a\n  return b\n$$",
+        )
         self.validate_identity(
             "CREATE TABLE t (vid INT NOT NULL, CONSTRAINT ht_vid_nid_fid_idx EXCLUDE (INT4RANGE(vid, nid) WITH &&, INT4RANGE(fid, fid, '[]') WITH &&))"
         )
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index d02c7165..f8c2ea16 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -1206,6 +1206,7 @@ WHERE
         self.validate_identity("CREATE TABLE IDENTIFIER($foo) (col1 VARCHAR, col2 VARCHAR)")
         self.validate_identity("CREATE TAG cost_center ALLOWED_VALUES 'a', 'b'")
         self.validate_identity("CREATE WAREHOUSE x").this.assert_is(exp.Identifier)
+        self.validate_identity("CREATE STREAMLIT x").this.assert_is(exp.Identifier)
         self.validate_identity(
             "CREATE OR REPLACE TAG IF NOT EXISTS cost_center COMMENT='cost_center tag'"
         ).this.assert_is(exp.Identifier)
diff --git a/tests/dialects/test_teradata.py b/tests/dialects/test_teradata.py
index 010b683c..74d5f88a 100644
--- a/tests/dialects/test_teradata.py
+++ b/tests/dialects/test_teradata.py
@@ -38,7 +38,7 @@ class TestTeradata(Validator):
             "UPDATE A FROM schema.tableA AS A, (SELECT col1 FROM schema.tableA GROUP BY col1) AS B SET col2 = '' WHERE A.col1 = B.col1",
             write={
                 "teradata": "UPDATE A FROM schema.tableA AS A, (SELECT col1 FROM schema.tableA GROUP BY col1) AS B SET col2 = '' WHERE A.col1 = B.col1",
-                "mysql": "UPDATE A SET col2 = '' FROM schema.tableA AS A, (SELECT col1 FROM schema.tableA GROUP BY col1) AS B WHERE A.col1 = B.col1",
+                "mysql": "UPDATE A SET col2 = '' FROM `schema`.tableA AS A, (SELECT col1 FROM `schema`.tableA GROUP BY col1) AS B WHERE A.col1 = B.col1",
             },
         )