-
Notifications
You must be signed in to change notification settings - Fork 752
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
add toStartOfWeek #1942
add toStartOfWeek #1942
Conversation
Thanks for the contribution! Please review the labels and make any necessary changes. |
Codecov Report
@@ Coverage Diff @@
## master #1942 +/- ##
========================================
- Coverage 70% 69% -2%
========================================
Files 635 643 +8
Lines 38218 36125 -2093
========================================
- Hits 26865 25010 -1855
+ Misses 11353 11115 -238
Continue to review full report at Codecov.
|
/review @sundy-li |
Take the reviewer to sundy-li |
let week_mode = mode.unwrap_or(0); | ||
let mut weekday = value.weekday().number_from_monday(); | ||
if (week_mode & 1) == 0 { | ||
weekday = value.weekday().number_from_sunday(); |
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.
If week_mode is 1,should use monday first?
bool monday_first_mode = week_mode & static_cast<UInt8>(WeekModeFlag::MONDAY_FIRST);
if (monday_first_mode)
{
return toFirstDayNumOfWeek(v);
}
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.
my mistake
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 find clickhouse doc, if week_mode is 1,First day of week is Monday. https://clickhouse.com/docs/zh/sql-reference/functions/date-time-functions/#toweekdatemode
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.
So this should be like:
let mut weekday = value.weekday().number_from_sunday();
if week_mode & 1 {
weekday = value.weekday().number_from_monday();
}
?
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.
shouldn't I have 1 in the code? This is magic number?
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.
No, just a little weird.
Default weekday should be number_from_sunday
because of the week_mode defaults to 0.
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 understand.I will modify it right away
CI Passed |
17 similar comments
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
26 similar comments
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
CI Passed |
I hereby agree to the terms of the CLA available at: https://databend.rs/policies/cla/
Summary
Summary about this PR
Changelog
Related Issues
#853
Test Plan
Unit Tests ok
Stateless Tests ok