diff options
Diffstat (limited to '')
-rw-r--r-- | sqlglot/parser.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/sqlglot/parser.py b/sqlglot/parser.py index f46bafe..6ad6391 100644 --- a/sqlglot/parser.py +++ b/sqlglot/parser.py @@ -81,6 +81,7 @@ class Parser: TokenType.INTERVAL, TokenType.TIMESTAMP, TokenType.TIMESTAMPTZ, + TokenType.TIMESTAMPLTZ, TokenType.DATETIME, TokenType.DATE, TokenType.DECIMAL, @@ -92,6 +93,13 @@ class Parser: TokenType.SERIAL, TokenType.SMALLSERIAL, TokenType.BIGSERIAL, + TokenType.XML, + TokenType.UNIQUEIDENTIFIER, + TokenType.MONEY, + TokenType.SMALLMONEY, + TokenType.ROWVERSION, + TokenType.IMAGE, + TokenType.SQL_VARIANT, *NESTED_TYPE_TOKENS, } @@ -233,6 +241,7 @@ class Parser: TIMESTAMPS = { TokenType.TIMESTAMP, TokenType.TIMESTAMPTZ, + TokenType.TIMESTAMPLTZ, } SET_OPERATIONS = { @@ -315,6 +324,7 @@ class Parser: TokenType.TRUE: lambda *_: exp.Boolean(this=True), TokenType.FALSE: lambda *_: exp.Boolean(this=False), TokenType.PLACEHOLDER: lambda *_: exp.Placeholder(), + TokenType.PARAMETER: lambda self, _: exp.Parameter(this=self._parse_var() or self._parse_primary()), TokenType.BIT_STRING: lambda _, token: exp.BitString(this=token.text), TokenType.HEX_STRING: lambda _, token: exp.HexString(this=token.text), TokenType.INTRODUCER: lambda self, token: self.expression( @@ -1497,12 +1507,19 @@ class Parser: if type_token in self.TIMESTAMPS: tz = self._match(TokenType.WITH_TIME_ZONE) or type_token == TokenType.TIMESTAMPTZ - self._match(TokenType.WITHOUT_TIME_ZONE) if tz: return exp.DataType( this=exp.DataType.Type.TIMESTAMPTZ, expressions=expressions, ) + ltz = self._match(TokenType.WITH_LOCAL_TIME_ZONE) or type_token == TokenType.TIMESTAMPLTZ + if ltz: + return exp.DataType( + this=exp.DataType.Type.TIMESTAMPLTZ, + expressions=expressions, + ) + self._match(TokenType.WITHOUT_TIME_ZONE) + return exp.DataType( this=exp.DataType.Type.TIMESTAMP, expressions=expressions, @@ -1845,8 +1862,11 @@ class Parser: def _parse_extract(self): this = self._parse_var() or self._parse_type() - if not self._match(TokenType.FROM): - self.raise_error("Expected FROM after EXTRACT", self._prev) + if self._match(TokenType.FROM): + return self.expression(exp.Extract, this=this, expression=self._parse_bitwise()) + + if not self._match(TokenType.COMMA): + self.raise_error("Expected FROM or comma after EXTRACT", self._prev) return self.expression(exp.Extract, this=this, expression=self._parse_bitwise()) |