hubgeter opened a new pull request, #70612:
URL: https://github.com/apache/doris/pull/70612

   ### Background
   
   `ALTER TABLE ... EXECUTE expire_snapshots` accepts `older_than` as an ISO 
local datetime or epoch milliseconds. It converts that argument into an 
absolute cutoff before handing expiration to Iceberg, which also applies 
snapshot and reference retention rules.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #59979 (introduced the original timestamp parsing)
   PR Type: Bugfix
   
   Problem Summary:
   
   When the FE JVM default time zone differs from the SQL session time zone, an 
ISO `older_than` cutoff is interpreted at the wrong instant and can expire 
additional historical snapshots or retain snapshots that should expire. For 
example, `2026-11-10T10:00:00` in an Asia/Shanghai session means `02:00 UTC`, 
but a UTC JVM currently interprets it as `10:00 UTC`. Resolve the session zone 
through the existing helper and pass it explicitly to the local datetime 
parser; numeric epoch-millisecond input and argument validation remain 
unchanged. Most of this diff adds action tests that compare exact surviving 
snapshot IDs.
   
   ### Details
   
   - **Frequency:** Requires an ISO local datetime cutoff and different 
effective offsets between the JVM and session at that datetime; the retention 
outcome changes when eligible history lies between the two cutoff instants.
   - **Root cause:** `IcebergExpireSnapshotsAction` receives `ConnectorSession` 
but parses the cutoff with `ZoneId.systemDefault()`.
   - **Why existing tests missed it:** Existing expiration tests use epoch 
cutoffs or matching time zones, so they do not expose the shifted instant.
   - **Fix:** Reuse `IcebergTimeUtils.resolveSessionZone(session)` and pass the 
resulting `ZoneId` into the private parser. Retain the ISO input grammar, epoch 
branch, errors, and SDK retention/commit behavior. Update stale comments about 
which actions consume the session zone.
   - **Other paths and branches:** Rollback already uses the session-zone 
helper. Apache `branch-4.2` at `0a24ed86fb8da943e43facf653b5a3016470177a` has 
the same bug in the legacy `fe-core` action. A backport is recommended, but 
needs adaptation to the legacy `TimeUtils.getDorisZoneId()` path and FE test 
fixtures rather than a direct cherry-pick of connector code.
   - **Behavior change:** ISO `older_than` values use the session time zone 
instead of the JVM default. Epoch input remains an explicit instant.
   
   ### Testing
   
   Local testing through `run-fe-ut.sh --run`, with the local reactor selection 
restricted to the Iceberg connector and its upstream dependencies (21 modules); 
the runner modification was restored and is not part of the PR:
   
   - Before the fix, the new `IcebergExpireSnapshotsTimeZoneTest` reports 15 
failures out of 29 cases, including both over-expiration and under-expiration. 
Independent epoch controls pass.
   - After the fix, all 29 new cases pass. The tests cover both offset 
directions, matching zones, aliases and fixed offsets, cutoff equality, exact 
retained snapshot IDs, UTC fallback, and invalid/overflow input.
   - Six related test classes report 86 passing cases, zero failures/errors, 
and two pre-existing disabled stale-file-classification cases skipped: 
`IcebergExpireSnapshotsTimeZoneTest`, `IcebergExpireSnapshotsActionTest`, 
`IcebergSnapshotMaintenanceCoverageTest`, 
`IcebergRollbackToTimestampActionTest`, `IcebergTimeUtilsTest`, and 
`IcebergProcedureOpsTest`. The enabled maintenance tests include tag/branch 
protection.
   - Module-scoped Maven `validate`, Checkstyle (zero violations), and the 
connector import gate pass.
   
   These checks ran on master `714816b4c68` plus the fix. The commit was 
rebased onto `0e8b56e0dc95` with identical Iceberg module contents. 
SQL/external-catalog end-to-end testing and two-session concurrency testing 
were not run.
   
   ### Release note
   
   Iceberg `expire_snapshots` now interprets ISO `older_than` values in the 
session time zone instead of the FE JVM default time zone. Numeric 
epoch-millisecond values are unchanged.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details).
   - Does this need documentation: No.
   - Pre-submission status: Not ready: draft pending author review and 
SQL/external-catalog end-to-end verification; local action tests and style 
checks pass.
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6).
   - Generated: Production changes, unit tests, and this description.
   - Human review: Pending author review.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to