-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Feat: Make current_date aware of execution timezone. #18034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ); | ||
|
|
||
| // Get timezone from config and convert to local time | ||
| let days = if let Some(config) = info.execution_props().config_options() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can rewrite this into something more idiomatic
let days = info
.execution_props()
.config_options()
.and_then(|config| config.execution.time_zone.parse::<Tz>().ok())
.map_or_else(
|| datetime_to_days(&now_ts),
|tz| {
let local_now = tz.from_utc_datetime(&now_ts.naive_utc());
datetime_to_days(&local_now)
},
);
comphead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @codetyri0n it looks good to me
|
|
||
| #Test 4: Verify current_date matches cast(now() as date) in the same timezone | ||
| query B | ||
| SELECT current_date() = cast(now() as date); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, this test appears to be failing on main:
## Which issue does this PR close? - Relates #18062 - Relates #18065 ## Rationale for this change We disabled these tests because CI was failing on main. The test: `current_date() = cast(now() as date)` was added in #18034 requires `now` to use configured timezone, but it is only available after #18017. Since #18017 has been merged, these tests should be enable. ## What changes are included in this PR? This reverts commit a65a2cb. ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
* Feat: Make current_date aware of execution timezone. * CI Fixes: Rectify assertion error of slt and update scalar_functions.md * CI Fixes: Comment out flaky test involving now(). * CI Fixes: Resolve slt error. * Feat: Add helper function to calculate current_date and fix tests. * Chore: Refactor timezone conversion logic.
## Which issue does this PR close? - Relates apache#18062 - Relates apache#18065 ## Rationale for this change We disabled these tests because CI was failing on main. The test: `current_date() = cast(now() as date)` was added in apache#18034 requires `now` to use configured timezone, but it is only available after apache#18017. Since apache#18017 has been merged, these tests should be enable. ## What changes are included in this PR? This reverts commit a65a2cb. ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
## Which issue does this PR close? - Relates apache#18062 - Relates apache#18065 ## Rationale for this change We disabled these tests because CI was failing on main. The test: `current_date() = cast(now() as date)` was added in apache#18034 requires `now` to use configured timezone, but it is only available after apache#18017. Since apache#18017 has been merged, these tests should be enable. ## What changes are included in this PR? This reverts commit a65a2cb. ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
Are these changes tested?