Repository: tobymao/sqlglot

Issue:
parse SQL with CAST FUNCTION exception under MySQL dialect
When I parse the flowing sql using MySQL dialect , it encountered an exception  like 
`’sqlglot.errors.ParseError: Required keyword: 'this' missing for <class 'sqlglot.expressions.CharacterSet'>. Line 1, Col: 61.’`

the SQL is 
`
SELECT CAST(IFNULL(`id`, 'NULL') AS CHAR CHARACTER SET binary) from test`

Discussion:

Patch:
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index 0aae2e40..2ba64aa2 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -5960,7 +5960,7 @@ class Parser(metaclass=_Parser):
         return None
 
     def _parse_var_or_string(self) -> t.Optional[exp.Expression]:
-        return self._parse_var() or self._parse_string()
+        return self._parse_string() or self._parse_var(any_token=True)
 
     def _parse_primary_or_var(self) -> t.Optional[exp.Expression]:
         return self._parse_primary() or self._parse_var(any_token=True)


Test patch:
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index 280ebbf2..bfdb2a68 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -117,6 +117,7 @@ class TestMySQL(Validator):
         )
 
     def test_identity(self):
+        self.validate_identity("SELECT CAST(COALESCE(`id`, 'NULL') AS CHAR CHARACTER SET binary)")
         self.validate_identity("SELECT e.* FROM e STRAIGHT_JOIN p ON e.x = p.y")
         self.validate_identity("ALTER TABLE test_table ALTER COLUMN test_column SET DEFAULT 1")
         self.validate_identity("SELECT DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:00.0000')")