diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-30 08:03:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-30 08:03:55 +0000 |
commit | 5510bab2f2724b1785efb5e4be0e4fa1e0afbf9e (patch) | |
tree | 8f11dc162604c83298116ce6ac23d64492e2c189 /sqlglot/parser.py | |
parent | Adding upstream version 16.7.3. (diff) | |
download | sqlglot-5510bab2f2724b1785efb5e4be0e4fa1e0afbf9e.tar.xz sqlglot-5510bab2f2724b1785efb5e4be0e4fa1e0afbf9e.zip |
Adding upstream version 16.7.7.upstream/16.7.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/parser.py')
-rw-r--r-- | sqlglot/parser.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sqlglot/parser.py b/sqlglot/parser.py index e5bd4ae..79e7cac 100644 --- a/sqlglot/parser.py +++ b/sqlglot/parser.py @@ -717,6 +717,7 @@ class Parser(metaclass=_Parser): FUNCTIONS_WITH_ALIASED_ARGS = {"STRUCT"} FUNCTION_PARSERS: t.Dict[str, t.Callable] = { + "ANY_VALUE": lambda self: self._parse_any_value(), "CAST": lambda self: self._parse_cast(self.STRICT_CAST), "CONCAT": lambda self: self._parse_concat(), "CONVERT": lambda self: self._parse_convert(self.STRICT_CAST), @@ -3321,11 +3322,6 @@ class Parser(metaclass=_Parser): else: this = self._parse_select_or_expression(alias=alias) - if isinstance(this, exp.EQ): - left = this.this - if isinstance(left, exp.Column): - left.replace(exp.var(left.text("this"))) - return self._parse_limit(self._parse_order(self._parse_respect_or_ignore_nulls(this))) def _parse_schema(self, this: t.Optional[exp.Expression] = None) -> t.Optional[exp.Expression]: @@ -3678,6 +3674,18 @@ class Parser(metaclass=_Parser): return self.expression(exp.Extract, this=this, expression=self._parse_bitwise()) + def _parse_any_value(self) -> exp.AnyValue: + this = self._parse_lambda() + is_max = None + having = None + + if self._match(TokenType.HAVING): + self._match_texts(("MAX", "MIN")) + is_max = self._prev.text == "MAX" + having = self._parse_column() + + return self.expression(exp.AnyValue, this=this, having=having, max=is_max) + def _parse_cast(self, strict: bool) -> exp.Expression: this = self._parse_conjunction() |