Skip to content

GH-41605: [C++][Gandiva] Stabilize TestFromUtcTimestamp around DST boundary#49887

Closed
Reranko05 wants to merge 1 commit into
apache:mainfrom
Reranko05:41605-datetimetest
Closed

GH-41605: [C++][Gandiva] Stabilize TestFromUtcTimestamp around DST boundary#49887
Reranko05 wants to merge 1 commit into
apache:mainfrom
Reranko05:41605-datetimetest

Conversation

@Reranko05
Copy link
Copy Markdown
Contributor

@Reranko05 Reranko05 commented Apr 28, 2026

Rationale for this change

The existing test includes a timestamp that falls on a DST spring-forward boundary, which can make the expected result environment-dependent. This change avoids that boundary to make the test deterministic across environments.

What changes are included in this PR?

Adjusted the DST-sensitive test input in TestFromUtcTimestamp
Updated the corresponding expected output

Are these changes tested?

  • Reproduced the original failure locally
  • Re-ran the modified test successfully

Are there any user-facing changes?

No

@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #41605 has been automatically assigned in GitHub to PR creator.

@lriggs
Copy link
Copy Markdown
Contributor

lriggs commented Apr 30, 2026

I think this is ok, but I would consider adding a comment in the test code about the fragility around DST times.

An alternative my AI assistant proposed is using timegm instead of mktime and then you can also remove the Hack in Epoch(). The only trick is that windows needs a timegm definition, like this: #ifdef _WIN32 / #define timegm _mkgmtime

Apparently some implementations of mktime account for DST and others dont.

That approach might be worth trying out locally to see if it fixes the failing test. #49902

@Reranko05 Reranko05 force-pushed the 41605-datetimetest branch from b2219b7 to b027fcc Compare April 30, 2026 04:27
@Reranko05
Copy link
Copy Markdown
Contributor Author

@lriggs Added a comment in the test to highlight the DST-related fragility.

I will try timegm approach out locally and consider it as a follow-up if it proves to be a more robust fix.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels May 4, 2026
kou pushed a commit that referenced this pull request Jun 5, 2026
### Rationale for this change

As discussed in PR #49887, the Gandiva datetime test utilities currently use `mktime()`, which interprets timestamps as local time and can behave differently across platforms and DST boundaries.

This PR switches the test utilities to `timegm()` so timestamps are interpreted consistently as UTC. This also removes the existing workaround logic in `Epoch()` that was previously needed for `mktime()` behavior on Windows/MSVC.

### What changes are included in this PR?

* replaced `mktime()` with `timegm()` in `date_time_test.cc`
* added a small Windows compatibility mapping for `_mkgmtime`
* removed the existing DST/localtime workaround logic in `Epoch()`

### Are these changes tested?

* Re-ran `DateTimeTestProjector.TestFromUtcTimestamp` repeatedly locally
* Re-ran the full `gandiva-projector-test` suite successfully

### Are there any user-facing changes?

No.

* GitHub Issue: #49952

Authored-by: Aaditya Srinivasan <aadityasri03@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou
Copy link
Copy Markdown
Member

kou commented Jun 5, 2026

Can we close this in favor of #49953?
Or do we still need this?

@Reranko05
Copy link
Copy Markdown
Contributor Author

@kou I think #49953 supersedes this PR. The timegm() approach addresses the underlying DST/localtime issue more comprehensively, while this PR only avoids a specific DST boundary case.

I'm happy to close this PR in favor of #49953.

@kou
Copy link
Copy Markdown
Member

kou commented Jun 5, 2026

OK. Let's close this.

@kou kou closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants