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] add function of date_diff in multi actions #26415

Merged
merged 21 commits into from
Jul 6, 2023

Conversation

xuzifu666
Copy link
Contributor

@xuzifu666 xuzifu666 commented Jul 3, 2023

Fixes #23420

What type of PR is this:

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

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 the target branch
    • 3.1
    • 3.0
    • 2.5
    • 2.4

@xuzifu666 xuzifu666 requested a review from a team as a code owner July 3, 2023 10:16
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 3, 2023
@xuzifu666 xuzifu666 force-pushed the date_diff branch 2 times, most recently from 8a88b5d to e5a646e Compare July 3, 2023 12:15
@xuzifu666
Copy link
Contributor Author

cc @silverbullet233 have a review plz

@xuzifu666 xuzifu666 force-pushed the date_diff branch 3 times, most recently from cae0641 to 2ef2c47 Compare July 4, 2023 01:35
@packy92 packy92 dismissed their stale review July 4, 2023 02:13

need change

select date_diff("2010-11-30 23:59:59", "2010-11-30 20:58:59", "hour");
select date_diff("2010-11-30 23:59:59", "2010-11-30 20:58:59", "minute");
select date_diff("2010-11-30 23:59:59", "2010-11-30 20:59:59", "second");

Copy link
Contributor

Choose a reason for hiding this comment

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

need more stronger test cases, such as parameters with more precision and some corner cases, such as SELECT date_diff('2020-03-01 00:00:05.000001','2020-03-02 00:00:05',day');

Copy link
Contributor Author

@xuzifu666 xuzifu666 Jul 4, 2023

Choose a reason for hiding this comment

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

ok,had add more precision cases

@xuzifu666 xuzifu666 force-pushed the date_diff branch 5 times, most recently from 92cee60 to ff98036 Compare July 5, 2023 01:26
Comment on lines 2423 to 2424
TimestampValue l = (TimestampValue)lv_column.value(row);
TimestampValue r = (TimestampValue)rv_column.value(row);
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the value is NULL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the value is NULL,would return NULL

@@ -197,6 +197,29 @@ select dayofweek_iso("2023-01-03");
select dayofweek_iso("");
select dayofweek_iso(NULL);

-- name: test_date_diff
Copy link
Contributor

Choose a reason for hiding this comment

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

plz add some test cases that the parameters contain NULL and the third paramter is not invalid

Copy link
Contributor Author

@xuzifu666 xuzifu666 Jul 5, 2023

Choose a reason for hiding this comment

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

i had add testcase contained NULL,and if third paramter is valid would report a error like the picture:
mysql> select date_diff("2010-11-30 23:59:59", "2010-11-30 20:59:59", "aaa");
ERROR 1064 (HY000): Expr evaluate meet error: type column should be one of day/hour/minute/second/millisecond

Copy link
Contributor

Choose a reason for hiding this comment

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

i had add testcase contained NULL,and if third paramter is valid would report a error like the picture: mysql> select date_diff("2010-11-30 23:59:59", "2010-11-30 20:59:59", "aaa"); ERROR 1064 (HY000): Expr evaluate meet error: type column should be one of day/hour/minute/second/millisecond

should be added in test cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get,had add this to testcases

@xuzifu666 xuzifu666 force-pushed the date_diff branch 7 times, most recently from 2a6a0bf to ea00d17 Compare July 6, 2023 06:06
}
ColumnPtr column = context->get_constant_column(2);
auto type_str = ColumnHelper::get_const_value<TYPE_VARCHAR>(column);
if (type_str != "day" && type_str != "hour" && type_str != "minute" && type_str != "second" &&
Copy link
Contributor

Choose a reason for hiding this comment

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

compare ignore case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wanpengfei-git
Copy link
Collaborator

[FE PR Coverage Check]

😍 pass : 0 / 0 (0%)

@murphyatwork murphyatwork enabled auto-merge (squash) July 6, 2023 14:05
@murphyatwork murphyatwork merged commit d372958 into StarRocks:main Jul 6, 2023
26 of 27 checks passed
@silverbullet233
Copy link
Contributor

@mergify backport branch-3.0 branch-3.1

@mergify
Copy link
Contributor

mergify bot commented Jul 7, 2023

backport branch-3.0 branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 7, 2023
Fixes [#23420](#23420)

(cherry picked from commit d372958)

# Conflicts:
#	test/sql/test_time_fn/R/test_time_fn
#	test/sql/test_time_fn/T/test_time_fn
mergify bot pushed a commit that referenced this pull request Jul 7, 2023
Fixes [#23420](#23420)

(cherry picked from commit d372958)

# Conflicts:
#	be/src/exprs/time_functions.cpp
#	test/sql/test_time_fn/R/test_time_fn
#	test/sql/test_time_fn/T/test_time_fn
fzhedu pushed a commit to fzhedu/starrocks that referenced this pull request Jul 7, 2023
silverbullet233 pushed a commit to silverbullet233/starrocks that referenced this pull request Jul 11, 2023
silverbullet233 pushed a commit to silverbullet233/starrocks that referenced this pull request Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behavior_changed documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[function] date_diff
6 participants