diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:06:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:06:28 +0000 |
commit | 918abde014f9e5c75dfbe21110c379f7f70435c9 (patch) | |
tree | 3419a01e34958bffbd917fa9e600eda126ea3a87 /sqlglot/dialects/duckdb.py | |
parent | Releasing debian version 10.6.3-1. (diff) | |
download | sqlglot-918abde014f9e5c75dfbe21110c379f7f70435c9.tar.xz sqlglot-918abde014f9e5c75dfbe21110c379f7f70435c9.zip |
Merging upstream version 11.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/duckdb.py')
-rw-r--r-- | sqlglot/dialects/duckdb.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sqlglot/dialects/duckdb.py b/sqlglot/dialects/duckdb.py index 95ff95c..959e5e2 100644 --- a/sqlglot/dialects/duckdb.py +++ b/sqlglot/dialects/duckdb.py @@ -25,10 +25,9 @@ def _str_to_time_sql(self, expression): def _ts_or_ds_add(self, expression): - this = self.sql(expression, "this") - e = self.sql(expression, "expression") + this = expression.args.get("this") unit = self.sql(expression, "unit").strip("'") or "DAY" - return f"CAST({this} AS DATE) + INTERVAL {e} {unit}" + return f"CAST({this} AS DATE) + {self.sql(exp.Interval(this=expression.expression, unit=unit))}" def _ts_or_ds_to_date_sql(self, expression): @@ -40,9 +39,8 @@ def _ts_or_ds_to_date_sql(self, expression): def _date_add(self, expression): this = self.sql(expression, "this") - e = self.sql(expression, "expression") unit = self.sql(expression, "unit").strip("'") or "DAY" - return f"{this} + INTERVAL {e} {unit}" + return f"{this} + {self.sql(exp.Interval(this=expression.expression, unit=unit))}" def _array_sort_sql(self, expression): |