|
7 | 7 | from collections import defaultdict
|
8 | 8 |
|
9 | 9 | from sqlglot import exp
|
10 |
| -from sqlglot.errors import ErrorLevel, ParseError, concat_messages, merge_errors |
| 10 | +from sqlglot.errors import ErrorLevel, ParseError, TokenError, concat_messages, merge_errors |
11 | 11 | from sqlglot.helper import apply_index_offset, ensure_list, seq_get
|
12 | 12 | from sqlglot.time import format_time
|
13 | 13 | from sqlglot.tokens import Token, Tokenizer, TokenType
|
@@ -5298,35 +5298,29 @@ def _parse_types(
|
5298 | 5298 | this: t.Optional[exp.Expression] = None
|
5299 | 5299 | prefix = self._match_text_seq("SYSUDTLIB", ".")
|
5300 | 5300 |
|
5301 |
| - if not self._match_set(self.TYPE_TOKENS): |
| 5301 | + if self._match_set(self.TYPE_TOKENS): |
| 5302 | + type_token = self._prev.token_type |
| 5303 | + else: |
| 5304 | + type_token = None |
5302 | 5305 | identifier = allow_identifiers and self._parse_id_var(
|
5303 | 5306 | any_token=False, tokens=(TokenType.VAR,)
|
5304 | 5307 | )
|
5305 | 5308 | if isinstance(identifier, exp.Identifier):
|
5306 |
| - tokens = self.dialect.tokenize(identifier.name) |
| 5309 | + try: |
| 5310 | + tokens = self.dialect.tokenize(identifier.name) |
| 5311 | + except TokenError: |
| 5312 | + tokens = None |
5307 | 5313 |
|
5308 |
| - if len(tokens) != 1: |
5309 |
| - self.raise_error("Unexpected identifier", self._prev) |
5310 |
| - |
5311 |
| - if tokens[0].token_type in self.TYPE_TOKENS: |
| 5314 | + if tokens and len(tokens) == 1 and tokens[0].token_type in self.TYPE_TOKENS: |
5312 | 5315 | type_token = tokens[0].token_type
|
5313 | 5316 | else:
|
5314 |
| - # retain quotes |
5315 |
| - tokens = self.dialect.tokenize(identifier.sql(dialect=self.dialect)) |
5316 |
| - |
5317 |
| - if len(tokens) != 1: |
5318 |
| - self.raise_error("Unexpected identifier", self._prev) |
5319 |
| - |
5320 | 5317 | if self.dialect.SUPPORTS_USER_DEFINED_TYPES:
|
5321 |
| - type_token = None |
5322 | 5318 | this = self._parse_user_defined_type(identifier)
|
5323 | 5319 | else:
|
5324 | 5320 | self._retreat(self._index - 1)
|
5325 | 5321 | return None
|
5326 | 5322 | else:
|
5327 | 5323 | return None
|
5328 |
| - else: |
5329 |
| - type_token = self._prev.token_type |
5330 | 5324 |
|
5331 | 5325 | if type_token == TokenType.PSEUDO_TYPE:
|
5332 | 5326 | return self.expression(exp.PseudoType, this=self._prev.text.upper())
|
|
0 commit comments