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

[Feature] Support function next_day #21024

Closed
wants to merge 16 commits into from
Closed

Conversation

mlimwxxnn
Copy link
Contributor

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Which issues of this PR fixes :

Fixes #19553

Problem Summary(Required) :

NEW FUNCTION: next_day

Test sql:

CREATE TABLE IF NOT EXISTS `next_day_test` (
  `d1` DATE,
  `d2` DATETIME
) 
DISTRIBUTED BY HASH(`d1`) 
PROPERTIES(
  "replication_num" = "1"
);

INSERT INTO `next_day_test`(d1, d2)
VALUES ('2023-04-01', '2023-04-01 20:13:14'),
       ('2023-04-02', '2023-04-02 20:13:14'),
       ('2023-04-03', '2023-04-03 20:13:14'),
       ('2023-04-04', '2023-04-04 20:13:14'),
       ('2023-04-05', '2023-04-05 20:13:14'),
       ('2023-04-06', '2023-04-06 20:13:14'),
       ('2023-04-07', '2023-04-07 20:13:14');

SELECT next_day('2023-04-05', 'Mo');
SELECT next_day('2023-04-05', 'Tue');
SELECT next_day('2023-04-05', 'Wednesday');
SELECT next_day('2023-04-05 20:13:14', 'Thursday');


SELECT d1, next_day(d1, 'Fr'), d2, next_day(d2, 'Fr') FROM next_day_test;
SELECT d1, next_day(d1, 'Sat'), d2, next_day(d2,'Sat') FROM next_day_test;
SELECT d1, next_day(d1, 'Sunday'), d2, next_day(d2, 'Sunday') FROM next_day_test;

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr will affect users' behaviors
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto backported to target branch
    • 3.0
    • 2.5
    • 2.4
    • 2.3

@CLAassistant
Copy link

CLAassistant commented Apr 5, 2023

CLA assistant check
All committers have signed the CLA.

@mlimwxxnn mlimwxxnn changed the title [Feature] Support function next_day #19553 [Feature] Support function next_day Apr 5, 2023
@imay
Copy link
Contributor

imay commented Apr 6, 2023

you also need to sign off this PR by git commit -s

@mlimwxxnn
Copy link
Contributor Author

I have commit with sign but DCO check also failed.

@imay
Copy link
Contributor

imay commented Apr 6, 2023

  1. you need to run build-support/clang-format.sh to format the cpp source files.
  2. If the last commit has sign-off, DCO will be happy then.

Comment on lines 21 to 27
SELECT next_day('2023-04-05', 'Mo');
SELECT next_day('2023-04-05', 'Tue');
SELECT next_day('2023-04-05', 'Wednesday');
SELECT next_day('2023-04-05 20:13:14', 'Thursday');
SELECT d1, next_day(d1, 'Fr'), d2, next_day(d2, 'Fr') FROM next_day_test order by d1;
SELECT d1, next_day(d1, 'Sat'), d2, next_day(d2,'Sat') FROM next_day_test order by d1;
SELECT d1, next_day(d1, 'Sunday'), d2, next_day(d2, 'Sunday') FROM next_day_test order by d1;
Copy link
Contributor

Choose a reason for hiding this comment

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

please add more tests:

  1. abnormal tests, for example the data fromat or dow format is not right;
  2. some special tests, like 2/29 or 2/28 in LEAP year or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. inputs with null

Copy link
Contributor

Choose a reason for hiding this comment

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

And add some test cases, where the second parameter DOW is from table not a constant value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1.abnormal tests
2.special tests (LEAP year, LEAP month)
3.null
4.DOW is from table (date and dow from same/different table)
I have added the above cases to the test.

Copy link
Contributor

@fzhedu fzhedu left a comment

Choose a reason for hiding this comment

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

pleas add doc

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 6, 2023
gengjun-git and others added 14 commits April 7, 2023 11:34
Signed-off-by: gengjun-git <gengjun@starrocks.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
…bution (StarRocks#20901)

If FeConstants.AUTO_DISTRIBUTION_UNIT is not evenly divided by the data size,
we should round up the result to an integer.

Signed-off-by: mlimwxxnn <534370904@qq.com>
…les of the materialized view (StarRocks#20926)

Signed-off-by: Astralidea <astralidea@163.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
* [Doc] update ANALYZE TABLE manual collection

Signed-off-by: evelynzhaojie <everlyn.zhaojie@gmail.com>

* Update resource_group.md

* [Doc] update ANALYZE TABLE manual collection

Signed-off-by: evelynzhaojie <everlyn.zhaojie@gmail.com>

* Update resource_group.md

* [Doc] 3.0 privilege

* [Doc] 3.0 privilege

* Update TOC.md

* minor fixes

* [Doc] update 3.0 doc - privilege

* add commands

---------

Signed-off-by: evelynzhaojie <everlyn.zhaojie@gmail.com>

Signed-off-by: mlimwxxnn <534370904@qq.com>
fix demo sql-tester cases
Signed-off-by: AndyZiYe <yeziyu@starrocks.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: amber-create <yangyanping@starrocks.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: hellolilyliuyi <hellolilyliuyi123@163.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>
Signed-off-by: mlimwxxnn <534370904@qq.com>

Date:      Thu Apr 6 21:42:35 2023 +0800
Signed-off-by: mlimwxxnn <534370904@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[function]next_day/previous_day need to be supported.