summaryrefslogtreecommitdiffstats
path: root/sqlglot/parser.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:29:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-21 09:29:23 +0000
commitdab6ba29e8eb9a5c2890ac3be8eab6e994aeb10e (patch)
tree0d209cfc6f7b9c794c254601c29aa5d8b9414876 /sqlglot/parser.py
parentAdding upstream version 7.1.3. (diff)
downloadsqlglot-dab6ba29e8eb9a5c2890ac3be8eab6e994aeb10e.tar.xz
sqlglot-dab6ba29e8eb9a5c2890ac3be8eab6e994aeb10e.zip
Adding upstream version 9.0.1.upstream/9.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/parser.py')
-rw-r--r--sqlglot/parser.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/sqlglot/parser.py b/sqlglot/parser.py
index b378f12..47c1c1d 100644
--- a/sqlglot/parser.py
+++ b/sqlglot/parser.py
@@ -329,6 +329,7 @@ class Parser:
exp.DataType: lambda self: self._parse_types(),
exp.From: lambda self: self._parse_from(),
exp.Group: lambda self: self._parse_group(),
+ exp.Identifier: lambda self: self._parse_id_var(),
exp.Lateral: lambda self: self._parse_lateral(),
exp.Join: lambda self: self._parse_join(),
exp.Order: lambda self: self._parse_order(),
@@ -371,11 +372,8 @@ class Parser:
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(
- exp.Introducer,
- this=token.text,
- expression=self._parse_var_or_string(),
- ),
+ TokenType.BYTE_STRING: lambda _, token: exp.ByteString(this=token.text),
+ TokenType.INTRODUCER: lambda self, token: self._parse_introducer(token),
}
RANGE_PARSERS = {
@@ -500,7 +498,7 @@ class Parser:
max_errors=3,
null_ordering=None,
):
- self.error_level = error_level or ErrorLevel.RAISE
+ self.error_level = error_level or ErrorLevel.IMMEDIATE
self.error_message_context = error_message_context
self.index_offset = index_offset
self.unnest_column_only = unnest_column_only
@@ -928,6 +926,7 @@ class Parser:
return self.expression(
exp.Delete,
this=self._parse_table(schema=True),
+ using=self._parse_csv(lambda: self._match(TokenType.USING) and self._parse_table(schema=True)),
where=self._parse_where(),
)
@@ -1148,7 +1147,7 @@ class Parser:
def _parse_annotation(self, expression):
if self._match(TokenType.ANNOTATION):
- return self.expression(exp.Annotation, this=self._prev.text, expression=expression)
+ return self.expression(exp.Annotation, this=self._prev.text.strip(), expression=expression)
return expression
@@ -1277,7 +1276,7 @@ class Parser:
alias = self._parse_table_alias()
if alias:
- this = self.expression(exp.Alias, this=this, alias=alias)
+ this.set("alias", alias)
if not self.alias_post_tablesample:
table_sample = self._parse_table_sample()
@@ -1876,6 +1875,17 @@ class Parser:
self._match_r_paren()
return self.expression(exp.UserDefinedFunction, this=this, expressions=expressions)
+ def _parse_introducer(self, token):
+ literal = self._parse_primary()
+ if literal:
+ return self.expression(
+ exp.Introducer,
+ this=token.text,
+ expression=literal,
+ )
+
+ return self.expression(exp.Identifier, this=token.text)
+
def _parse_udf_kwarg(self):
this = self._parse_id_var()
kind = self._parse_types()