Skip to content
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

Merged
merged 2 commits into from
Sep 24, 2021
Merged

add toStartOfWeek #1942

merged 2 commits into from
Sep 24, 2021

Conversation

dust1
Copy link
Contributor

@dust1 dust1 commented Sep 23, 2021

I hereby agree to the terms of the CLA available at: https://databend.rs/policies/cla/

Summary

Summary about this PR

Changelog

  • Improvement

Related Issues

#853

Test Plan

Unit Tests ok

Stateless Tests ok

@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2021

Codecov Report

Merging #1942 (c9deea5) into master (3df848d) will decrease coverage by 1%.
The diff coverage is 1%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1942     +/-   ##
========================================
- Coverage      70%     69%     -2%     
========================================
  Files         635     643      +8     
  Lines       38218   36125   -2093     
========================================
- Hits        26865   25010   -1855     
+ Misses      11353   11115    -238     
Impacted Files Coverage Δ
common/functions/src/scalars/dates/week_date.rs 0% <0%> (ø)
common/functions/src/scalars/dates/date.rs 61% <100%> (+<1%) ⬆️
common/functions/src/scalars/dates/date_test.rs 91% <100%> (ø)
store/src/configs/config.rs 87% <0%> (-4%) ⬇️
common/datavalues/src/macros.rs 30% <0%> (-3%) ⬇️
common/management/src/user/utils.rs 68% <0%> (-3%) ⬇️
common/datavalues/src/data_field.rs 55% <0%> (-2%) ⬇️
common/runtime/src/runtime_test.rs 98% <0%> (-2%) ⬇️
query/src/sql/plan_parser.rs 73% <0%> (-1%) ⬇️
common/management/src/user/user_mgr_test.rs 97% <0%> (-1%) ⬇️
... and 227 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3df848d...c9deea5. Read the comment docs.

@dust1 dust1 marked this pull request as ready for review September 23, 2021 14:15
@BohuTANG
Copy link
Member

/review @sundy-li

@databend-bot
Copy link
Member

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();
Copy link
Member

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);
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my mistake

Copy link
Contributor Author

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

Copy link
Member

@sundy-li sundy-li Sep 24, 2021

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();
       }

?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

@BohuTANG BohuTANG requested a review from sundy-li September 24, 2021 05:57
@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

17 similar comments
@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

26 similar comments
@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@dantengsky dantengsky merged commit 0fa1c83 into databendlabs:master Sep 24, 2021
@dust1 dust1 deleted the dust1/issues853 branch September 26, 2021 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants