diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:46 +0000 |
commit | 5dde903f4f6659e384287a3e508b9f369c5a2ba3 (patch) | |
tree | 05cd2920d82f0023f6ac695dbb6eaeef64608401 /sqlglot/dialects/hive.py | |
parent | Adding upstream version 17.9.1. (diff) | |
download | sqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.tar.xz sqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.zip |
Adding upstream version 17.11.0.upstream/17.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/hive.py')
-rw-r--r-- | sqlglot/dialects/hive.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sqlglot/dialects/hive.py b/sqlglot/dialects/hive.py index 4e84085..aa4d845 100644 --- a/sqlglot/dialects/hive.py +++ b/sqlglot/dialects/hive.py @@ -59,7 +59,7 @@ def _add_date_sql(self: generator.Generator, expression: exp.DateAdd | exp.DateS if expression.expression.is_number: modified_increment = exp.Literal.number(int(expression.text("expression")) * multiplier) else: - modified_increment = expression.expression + modified_increment = expression.expression.copy() if multiplier != 1: modified_increment = exp.Mul( # type: ignore this=modified_increment, expression=exp.Literal.number(multiplier) @@ -272,8 +272,8 @@ class Hive(Dialect): "YEAR": lambda args: exp.Year(this=exp.TsOrDsToDate.from_arg_list(args)), } - FUNCTION_PARSERS = { - **parser.Parser.FUNCTION_PARSERS, + NO_PAREN_FUNCTION_PARSERS = { + **parser.Parser.NO_PAREN_FUNCTION_PARSERS, "TRANSFORM": lambda self: self._parse_transform(), } @@ -284,10 +284,12 @@ class Hive(Dialect): ), } - def _parse_transform(self) -> exp.Transform | exp.QueryTransform: - args = self._parse_csv(self._parse_lambda) - self._match_r_paren() + def _parse_transform(self) -> t.Optional[exp.Transform | exp.QueryTransform]: + if not self._match(TokenType.L_PAREN, advance=False): + self._retreat(self._index - 1) + return None + args = self._parse_wrapped_csv(self._parse_lambda) row_format_before = self._parse_row_format(match_row=True) record_writer = None |