diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-25 16:01:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-25 16:01:43 +0000 |
commit | 29f9a15cce138301cd5a84a1fd4060494a3a65b6 (patch) | |
tree | c593be2f0b0fdc60a43983aa547b34a441170e59 /sqlglot/parser.py | |
parent | Adding upstream version 9.0.1. (diff) | |
download | sqlglot-29f9a15cce138301cd5a84a1fd4060494a3a65b6.tar.xz sqlglot-29f9a15cce138301cd5a84a1fd4060494a3a65b6.zip |
Adding upstream version 9.0.3.upstream/9.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/parser.py')
-rw-r--r-- | sqlglot/parser.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sqlglot/parser.py b/sqlglot/parser.py index 47c1c1d..b94313a 100644 --- a/sqlglot/parser.py +++ b/sqlglot/parser.py @@ -433,7 +433,8 @@ class Parser: } FUNCTION_PARSERS = { - "CONVERT": lambda self: self._parse_convert(), + "CONVERT": lambda self: self._parse_convert(self.STRICT_CAST), + "TRY_CONVERT": lambda self: self._parse_convert(False), "EXTRACT": lambda self: self._parse_extract(), "POSITION": lambda self: self._parse_position(), "SUBSTRING": lambda self: self._parse_substring(), @@ -1512,7 +1513,7 @@ class Parser: return this def _parse_offset(self, this=None): - if not self._match(TokenType.OFFSET): + if not self._match_set((TokenType.OFFSET, TokenType.COMMA)): return this count = self._parse_number() self._match_set((TokenType.ROW, TokenType.ROWS)) @@ -2134,7 +2135,7 @@ class Parser: return self.expression(exp.Cast if strict else exp.TryCast, this=this, to=to) - def _parse_convert(self): + def _parse_convert(self, strict): this = self._parse_field() if self._match(TokenType.USING): to = self.expression(exp.CharacterSet, this=self._parse_var()) @@ -2142,7 +2143,7 @@ class Parser: to = self._parse_types() else: to = None - return self.expression(exp.Cast, this=this, to=to) + return self.expression(exp.Cast if strict else exp.TryCast, this=this, to=to) def _parse_position(self): args = self._parse_csv(self._parse_bitwise) |