summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/bigquery.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-10 09:23:46 +0000
commit5dde903f4f6659e384287a3e508b9f369c5a2ba3 (patch)
tree05cd2920d82f0023f6ac695dbb6eaeef64608401 /sqlglot/dialects/bigquery.py
parentAdding upstream version 17.9.1. (diff)
downloadsqlglot-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/bigquery.py')
-rw-r--r--sqlglot/dialects/bigquery.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py
index df9065f..71977dd 100644
--- a/sqlglot/dialects/bigquery.py
+++ b/sqlglot/dialects/bigquery.py
@@ -34,7 +34,7 @@ def _date_add_sql(
this = self.sql(expression, "this")
unit = expression.args.get("unit")
unit = exp.var(unit.name.upper() if unit else "DAY")
- interval = exp.Interval(this=expression.expression, unit=unit)
+ interval = exp.Interval(this=expression.expression.copy(), unit=unit)
return f"{data_type}_{kind}({this}, {self.sql(interval)})"
return func
@@ -76,16 +76,12 @@ def _returnsproperty_sql(self: generator.Generator, expression: exp.ReturnsPrope
def _create_sql(self: generator.Generator, expression: exp.Create) -> str:
kind = expression.args["kind"]
returns = expression.find(exp.ReturnsProperty)
+
if kind.upper() == "FUNCTION" and returns and returns.args.get("is_table"):
expression = expression.copy()
expression.set("kind", "TABLE FUNCTION")
- if isinstance(
- expression.expression,
- (
- exp.Subquery,
- exp.Literal,
- ),
- ):
+
+ if isinstance(expression.expression, (exp.Subquery, exp.Literal)):
expression.set("expression", expression.expression.this)
return self.create_sql(expression)