Repository: tobymao/sqlglot

Issue:
[spark dialect] Parser still doesn't work when column name/alias starts with digits AND contains underscore
hi, struggling with spark sql scripts, I found https://github.com/tobymao/sqlglot/pull/930 still not fix bugs with name/alias startswith digits and conatain underscore. as exsample below 

```python
>>> sql="select 1a_1a from test_a"
>>> parse_one(sql, read='spark')
(SELECT expressions: 
  (ALIAS this: 
    (COLUMN this: 
      (IDENTIFIER this: 1a_, quoted: False)), alias: 
    (IDENTIFIER this: 1a, quoted: False)), from: 
  (FROM expressions: 
    (TABLE this: 
      (IDENTIFIER this: test_a, quoted: False))))

>>> sql="select 1a as 1a_1a from test_a"
>>> parse_one(sql, read='spark')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.8/site-packages/sqlglot/__init__.py", line 84, in parse_one
    result = dialect.parse(sql, **opts)
  File "/opt/homebrew/lib/python3.8/site-packages/sqlglot/dialects/dialect.py", line 150, in parse
    return self.parser(**opts).parse(self.tokenizer.tokenize(sql), sql)
  File "/opt/homebrew/lib/python3.8/site-packages/sqlglot/parser.py", line 670, in parse
    return self._parse(
  File "/opt/homebrew/lib/python3.8/site-packages/sqlglot/parser.py", line 735, in _parse
    self.raise_error("Invalid expression / Unexpected token")
  File "/opt/homebrew/lib/python3.8/site-packages/sqlglot/parser.py", line 778, in raise_error
    raise error
sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 17.
  select 1a as 1a_1a from test_a
```

which are both valid in spark sql: 
```python
>>> spark.sql("create table test_table (1a string)")
DataFrame[]
>>> spark.sql("select 1a as 1a_1a from test_table")
DataFrame[1a_1a: string]
>>> spark.sql("create table test_table2 (1a_1a string)")
DataFrame[]
>>> spark.sql("select 1a_1a from test_table2")
DataFrame[1a_1a: string]
```


Discussion:
Seems like I messed up, fixing this right now. Thanks for the reports.

Resolving patch:
diff --git a/sqlglot/tokens.py b/sqlglot/tokens.py
--- a/sqlglot/tokens.py
+++ b/sqlglot/tokens.py
@@ -947,7 +947,8 @@ def _scan_number(self) -> None:
             elif self._peek.isidentifier():  # type: ignore
                 number_text = self._text
                 literal = []
-                while self._peek.isidentifier():  # type: ignore
+
+                while self._peek.strip() and self._peek not in self.SINGLE_TOKENS:  # type: ignore
                     literal.append(self._peek.upper())  # type: ignore
                     self._advance()
 


Test patch:
diff --git a/tests/dialects/test_hive.py b/tests/dialects/test_hive.py
--- a/tests/dialects/test_hive.py
+++ b/tests/dialects/test_hive.py
@@ -356,6 +356,30 @@ def test_hive(self):
                 "spark": "SELECT a_b AS 1_a FROM test_table",
             },
         )
+        self.validate_all(
+            "SELECT 1a_1a FROM test_a",
+            write={
+                "spark": "SELECT 1a_1a FROM test_a",
+            },
+        )
+        self.validate_all(
+            "SELECT 1a AS 1a_1a FROM test_a",
+            write={
+                "spark": "SELECT 1a AS 1a_1a FROM test_a",
+            },
+        )
+        self.validate_all(
+            "CREATE TABLE test_table (1a STRING)",
+            write={
+                "spark": "CREATE TABLE test_table (1a STRING)",
+            },
+        )
+        self.validate_all(
+            "CREATE TABLE test_table2 (1a_1a STRING)",
+            write={
+                "spark": "CREATE TABLE test_table2 (1a_1a STRING)",
+            },
+        )
         self.validate_all(
             "PERCENTILE(x, 0.5)",
             write={