You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2026/02/14 12:23:14 UTC
(doris) branch branch-4.0 updated: branch-4.0: [Enhancement](func) Add fold constant for PREVIOUS_DAY #60755 (#60762)
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] <41...@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 <li...@selectdb.com>
---
.../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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org