This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 866f1e7fd18 branch-4.0: [Enhancement](func) Add fold constant for
PREVIOUS_DAY #60755 (#60762)
866f1e7fd18 is described below
commit 866f1e7fd1823034805e0b29317e67e6227cbe40
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Feb 14 20:23:07 2026 +0800
branch-4.0: [Enhancement](func) Add fold constant for PREVIOUS_DAY #60755
(#60762)
Cherry-picked from #60755
Co-authored-by: linrrarity <[email protected]>
---
.../functions/executable/DateTimeExtractAndTransform.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
index 607374753eb..a19617c43ef 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
@@ -1289,6 +1289,20 @@ public class DateTimeExtractAndTransform {
return date.plusDays(daysToAdd);
}
+ /**
+ * date arithmetic function previous_day
+ */
+ @ExecFunction(name = "previous_day")
+ public static Expression previousDay(DateV2Literal date, StringLiteral
day) {
+ int dayOfWeek = getDayOfWeek(day.getValue());
+ if (dayOfWeek == 0) {
+ throw new RuntimeException("Invalid day of week: " +
day.getValue());
+ }
+ int daysToSub = (date.getDayOfWeek() - dayOfWeek + 7) % 7;
+ daysToSub = daysToSub == 0 ? 7 : daysToSub;
+ return date.plusDays(-daysToSub);
+ }
+
/**
* date transform function sec_to_time
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]