fengstack opened a new pull request, #18726:
URL: https://github.com/apache/dolphinscheduler/pull/18726

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are 
happy that you want to help us improve DolphinScheduler! -->
   
   ## Was this PR generated or assisted by AI?
   YES, the unit tests, implementation logic for date offset parsing, and 
documentation updates were assisted by AI.
   
   ## Purpose of the pull request
   
   Close #16510.
   
   Currently, built-in parameter placeholders for month and week boundaries 
(`month_first_day`, `month_last_day`, `month_begin`, `month_end`, 
`week_first_day`, `week_last_day`, `week_begin`, `week_end`, and `add_months`) 
only parse format strings directly without supporting date offsets inside the 
format parameter (such as `$[month_first_day(yyyy-MM-dd-1)]`).
   This prevents expressing the month/week start or end of "yesterday" or "n-1 
days" relative to business time (for example, on September 1st, getting August 
1st instead of September 1st).
   
   This PR adds support for date offsets inside the format argument (via 
`calcMinutes`), making expressions like `$[month_first_day(yyyy-MM-dd-1)]` and 
`$[month_begin(yyyy-MM-dd-1, 0)]` calculate boundaries relative to the offset 
base date, with 100% backward compatibility for existing formats without date 
offsets.
   
   ## Brief change log
   
   - In `TimePlaceholderUtils.java`, parse date offsets in format parameters 
for `calcCustomDay`, `calcMonthBegin`, `calcMonthEnd`, `calcWeekStart`, 
`calcWeekEnd`, `calcMonths`, and `calculateYearWeek`.
   - Add comprehensive test cases in `TimePlaceholderUtilsTest.java` covering 
month/week boundaries across month transitions (e.g. 2022-09-01 -> yesterday 
2022-08-31 -> month start 2022-08-01).
   - Update documentation in `docs/docs/en/guide/parameter/built-in.md` and 
`docs/docs/zh/guide/parameter/built-in.md`.
   
   ## Verify this pull request
   
   This change added tests and can be verified as follows:
   
   - Added `timePlaceHolderForMonthFirstDayWithDateOffset` in 
`TimePlaceholderUtilsTest` to verify month and week boundary calculations with 
date offsets.
   - Ran `./mvnw verify -pl 
dolphinscheduler-task-plugin/dolphinscheduler-task-api 
-Dtest=TimePlaceholderUtilsTest` and all tests passed.
   - Spotless formatting verified via `./mvnw spotless:check -pl 
dolphinscheduler-task-plugin/dolphinscheduler-task-api`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to