Merging upstream version 17.9.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
2bf6699c56
commit
9777880e00
87 changed files with 45907 additions and 42511 deletions
|
@ -17,6 +17,7 @@ from sqlglot.dialects.dialect import (
|
|||
no_tablesample_sql,
|
||||
no_trycast_sql,
|
||||
rename_func,
|
||||
simplify_literal,
|
||||
str_position_sql,
|
||||
timestamptrunc_sql,
|
||||
timestrtotime_sql,
|
||||
|
@ -39,16 +40,13 @@ DATE_DIFF_FACTOR = {
|
|||
|
||||
def _date_add_sql(kind: str) -> t.Callable[[generator.Generator, exp.DateAdd | exp.DateSub], str]:
|
||||
def func(self: generator.Generator, expression: exp.DateAdd | exp.DateSub) -> str:
|
||||
from sqlglot.optimizer.simplify import simplify
|
||||
|
||||
this = self.sql(expression, "this")
|
||||
unit = expression.args.get("unit")
|
||||
expression = simplify(expression.args["expression"])
|
||||
|
||||
expression = simplify_literal(expression.copy(), copy=False).expression
|
||||
if not isinstance(expression, exp.Literal):
|
||||
self.unsupported("Cannot add non literal")
|
||||
|
||||
expression = expression.copy()
|
||||
expression.args["is_string"] = True
|
||||
return f"{this} {kind} {self.sql(exp.Interval(this=expression, unit=unit))}"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue