summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/hive.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:50 +0000
commit4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53 (patch)
tree1084b1a2dd9f2782031b4aa79608db08968a5837 /sqlglot/dialects/hive.py
parentReleasing debian version 17.9.1-1. (diff)
downloadsqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.tar.xz
sqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.zip
Merging upstream version 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.py14
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