AHeise opened a new pull request, #29030:
URL: https://github.com/apache/flink/pull/29030

   ```sql
   CREATE MATERIALIZED TABLE mt
   START_MODE = FROM_NOW(INTERVAL '3' MINUTE)
   AS SELECT ...;
   ```
   ```sql
   SHOW CREATE TABLE mt;
   -- START_MODE = FROM_NOW(INTERVAL '3' MINUTE) /* Evaluated to 
FROM_TIMESTAMP(TIMESTAMP '2026-08-27 09:43:12') at execution */
   ```
   Statement created at `2026-08-27 09:40:12`. The comment claims resolution to 
`09:43:12` — three minutes in the *future*. `FROM_NOW(<interval>)` actually 
resolves three minutes into the *past* (the documented, correct runtime 
behavior); only the `SHOW CREATE` annotation is wrong.
   
   `ShowCreateUtil.extractStartMode` builds the comment with:
   ```java
   LocalDateTime.now().plus(amount).toInstant(ZoneOffset.UTC)
   ```
   which should subtract the interval, not add it. Introduced in FLINK-39323.
   
   There's a second, related bug in the same expression: `LocalDateTime.now()` 
uses the JVM's default time zone, but the result is then reinterpreted with 
`.toInstant(ZoneOffset.UTC)` — mislabeling local wall-clock time as UTC. On a 
non-UTC host this shifts the annotated timestamp by the zone offset on top of 
the sign error.
   
   ### Fix
   Thread a `Clock` through `extractStartMode` (production passes 
`Clock.systemUTC()`) and compute `LocalDateTime.now(clock).minus(amount)`. This 
fixes both the sign and the zone-mislabeling in one change, and makes the sign 
directly testable: `ShowCreateUtilTest` now has a dedicated test using 
`Clock.fixed(...)` that asserts the exact resolved timestamp.
   
   ### Note for reviewers
   The existing parameterized `showCreateMaterializedTable` test can't catch a 
sign flip on its own — it normalizes the `Evaluated to FROM_TIMESTAMP(...)` 
comment via regex on both actual and expected before comparing 
(`setFixedTimestamp`), since the real value is wall-clock and 
non-deterministic. I left that normalization in place (it's still needed for 
the full-row equality checks against the real clock) and added the new 
`extractStartModeFromNowEvaluatesToPastTimestamp` test as a targeted, 
deterministic check via the injected `Clock` instead of widening the public 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