fengstack commented on PR #18726:
URL: 
https://github.com/apache/dolphinscheduler/pull/18726#issuecomment-6337203736

   Thanks for the thorough review @SbloodyS! Updated in commit d930c52a79 to 
address all three regressions:
   
   ### 1. Preserve existing four-digit day offsets
   
   `TIMEZONE_PATTERN` no longer classifies operands solely by digit count: it 
only matches operands that can be a valid timezone offset (hours <= 14, minutes 
<= 59, i.e. within UTC-12:00..UTC+14:00). Larger four-digit operands such as 
3650 keep the legacy numeric day-offset semantics:
   
   - `$[yyyyMMdd-3650]` => `20120828`, `$[yyyyMMdd+3650]` => `20320823` 
(four-digit positive and negative offsets covered)
   - `$[yyyyMMdd+1400]` => `20220826+1400` (still a valid timezone form, stays 
a format literal - added as a boundary case)
   
   ### 2. Do not split the offset at a unary arithmetic sign
   
   Replaced the scanner with `findOffsetOperatorIndex`, which mirrors the 
legacy precedence in a quote-aware way: when an unquoted `+` exists, the last 
`+` is the boundary between the date pattern and the offset expression; only 
when no `+` exists is the last `-` used. Signs inside the operand (unary or 
parenthesized) therefore stay part of the arithmetic expression:
   
   - `$[yyyyMMdd+7*-1]` => `20220819` (previously produced `20220825+7*`)
   - `$[yyyyMMdd+7*(-1)]` => `20220819` (parenthesized arithmetic)
   
   ### 3. Propagate arithmetic failures instead of formatting them as literals
   
   Removed the catch-all in `calcMinutes(String, Date)`: after an offset is 
recognized, exceptions propagate again and error handling is left to 
`formatTimeExpression()`:
   
   - strict mode: `$[yyyyMMdd+1/0]` throws `IllegalArgumentException`
   - ignore-invalid mode: the original placeholder `$[yyyyMMdd+1/0]` is 
preserved
   
   ### 4. Documentation
   
   Already updated in 7cb5b5f49b: both the English and Chinese docs 
consistently use `$[month_first_day(yyyy-MM-dd-1)]`.
   
   Regression tests were added for every case above 
(`timePlaceHolderWithFourDigitDayOffset`, 
`timePlaceHolderWithUnaryMinusInOffsetExpression`, 
`timePlaceHolderWithArithmeticFailure`). All 136 tests in 
`dolphinscheduler-task-api` pass and spotless is clean.


-- 
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