Repository: tobymao/sqlglot

Issue:
MySQL dialect fails to parse PRIMARY KEY USING BTREE syntax
**Before you file an issue**
- Make sure you specify the "read" dialect eg. `parse_one(sql, read="spark")`
- Make sure you specify the "write" dialect eg. `ast.sql(dialect="duckdb")`
- Check if the issue still exists on main
yes, the issue still exists. I'v tried the latest version.
**Fully reproducible code snippet**
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.
mysql:
`CREATE TABLE test_table (
	id INT AUTO_INCREMENT,
	alarm_category VARCHAR ( 255 ),
	alarm_rule VARCHAR ( 255 ),
PRIMARY KEY(id) USING BTREE 
)`

**Official Documentation**
Please include links to official SQL documentation related to your issue.
https://sqlglot.com/sqlglot.html#parse_one

Discussion:
@Gohoy: ```python
sql = "CREATE TABLE test_table ( id INT AUTO_INCREMENT, alarm_category VARCHAR ( 255 ), alarm_rule VARCHAR ( 255 ), PRIMARY KEY(id) USING BTREE )"
sqlglot.parse_one(sql,read='mysql')

# result

# sqlglot.errors.ParseError: Expecting ). Line 1, Col: 130.
#   id INT AUTO_INCREMENT, alarm_category VARCHAR ( 255 ), alarm_rule VARCHAR ( 255 ), PRIMARY KEY(id) USING BTREE )
```
this is the reproducible python code




Solution patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 24bf1492f7..f5ed3a8923 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -1291,6 +1291,10 @@ class Parser(metaclass=_Parser):
             "SIMPLE",
         ),
         "INITIALLY": ("DEFERRED", "IMMEDIATE"),
+        "USING": (
+            "BTREE",
+            "HASH",
+        ),
         **dict.fromkeys(("DEFERRABLE", "NORELY"), tuple()),
     }
 


Test patch:
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index 06638f16c5..4a28176ccf 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -83,6 +83,12 @@ def test_ddl(self):
         self.validate_identity(
             "CREATE OR REPLACE VIEW my_view AS SELECT column1 AS `boo`, column2 AS `foo` FROM my_table WHERE column3 = 'some_value' UNION SELECT q.* FROM fruits_table, JSON_TABLE(Fruits, '$[*]' COLUMNS(id VARCHAR(255) PATH '$.$id', value VARCHAR(255) PATH '$.value')) AS q",
         )
+        self.validate_identity(
+            "CREATE TABLE test_table (id INT AUTO_INCREMENT, PRIMARY KEY (id) USING BTREE)"
+        )
+        self.validate_identity(
+            "CREATE TABLE test_table (id INT AUTO_INCREMENT, PRIMARY KEY (id) USING HASH)"
+        )
         self.validate_identity(
             "/*left*/ EXPLAIN SELECT /*hint*/ col FROM t1 /*right*/",
             "/* left */ DESCRIBE /* hint */ SELECT col FROM t1 /* right */",