fix(pinot): DATE_SUB function (#35426)

This commit is contained in:
Beto Dealmeida
2025-10-02 10:12:19 -04:00
committed by GitHub
parent 449a89c214
commit f3349388d0
2 changed files with 55 additions and 0 deletions

View File

@@ -59,6 +59,11 @@ class Pinot(MySQL):
expression=seq_get(args, 1),
unit=seq_get(args, 0),
),
"DATE_SUB": lambda args: exp.DateSub(
this=seq_get(args, 2),
expression=seq_get(args, 1),
unit=seq_get(args, 0),
),
}
class Generator(MySQL.Generator):
@@ -97,6 +102,12 @@ class Pinot(MySQL):
e.args.get("expression"),
e.this,
),
exp.DateSub: lambda self, e: self.func(
"DATE_SUB",
exp.Literal.string(str(e.args.get("unit").name)),
e.args.get("expression"),
e.this,
),
}
# Remove DATE_TRUNC transformation - Pinot supports standard SQL DATE_TRUNC
TRANSFORMS.pop(exp.DateTrunc, None)