Skip to content

[bug](function)fix date_floor function return wrong result - #41948

Merged
HappenLee merged 2 commits into
apache:masterfrom
zhangstar333:fix_date_floor
Oct 17, 2024
Merged

[bug](function)fix date_floor function return wrong result#41948
HappenLee merged 2 commits into
apache:masterfrom
zhangstar333:fix_date_floor

Conversation

@zhangstar333

@zhangstar333zhangstar333 commented Oct 16, 2024

Copy link
Copy Markdown
Contributor

Proposed changes

 void resize_fill(size_t n, const T& value) {
size_t old_size = this->size();
if (n > old_size) {
this->reserve(n);
std::fill(t_end(), t_end() + n - old_size, value);
}
this->c_end = this->c_start + this->byte_size(n);
}

if n is not greater than old_size,
it's will not fill the data with value.

so it's not set the null_map flag to 1, it's can't return NULL

mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | |
+---------------------+--------------------+
1 row in set (0.03 se

after fix:

mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | NULL |
+---------------------+--------------------+
1 row in set (0.03 sec)

@doris-robot

Copy link
Copy Markdown

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@zhangstar333zhangstar333 changed the title Fix date floor[bug](function)fix date_floor function return wrong resultOct 16, 2024
@zhangstar333

Copy link
Copy Markdown
ContributorAuthor

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 37.46% (9707/25914)
Line Coverage: 28.73% (80618/280606)
Region Coverage: 28.16% (41700/148071)
Branch Coverage: 24.75% (21206/85698)
Coverage Report: http://coverage.selectdb-in.cc/coverage/13fe6046686c488e5ce48e4f5d40c33d6d04c364_13fe6046686c488e5ce48e4f5d40c33d6d04c364/report/index.html

@zhangstar333

Copy link
Copy Markdown
ContributorAuthor

run buildall

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 37.47% (9711/25919)
Line Coverage: 28.72% (80595/280613)
Region Coverage: 28.17% (41716/148085)
Branch Coverage: 24.75% (21207/85698)
Coverage Report: http://coverage.selectdb-in.cc/coverage/13fe6046686c488e5ce48e4f5d40c33d6d04c364_13fe6046686c488e5ce48e4f5d40c33d6d04c364/report/index.html

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@HappenLeeHappenLee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Oct 17, 2024
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@HappenLee
HappenLee merged commit 07fe7c0 into apache:masterOct 17, 2024
zhangstar333 added a commit to zhangstar333/incubator-doris that referenced this pull request Oct 18, 2024
)
```
void resize_fill(size_t n, const T& value) {
size_t old_size = this->size();
if (n > old_size) {
this->reserve(n);
std::fill(t_end(), t_end() + n - old_size, value);
}
this->c_end = this->c_start + this->byte_size(n);
}
```
if n is not greater than old_size,
it's will not fill the data with value.
so it's not set the null_map flag to 1, it's can't return NULL
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | |
+---------------------+--------------------+
1 row in set (0.03 se
```
after fix:
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | NULL |
+---------------------+--------------------+
1 row in set (0.03 sec)
```
yiguolei pushed a commit that referenced this pull request Oct 18, 2024
…41948) (#42065)
## Proposed changes
cherry-pick from master #41948
<!--Describe your changes.-->
@yiguoleiyiguolei mentioned this pull request Nov 6, 2024
zhangstar333 added a commit to zhangstar333/incubator-doris that referenced this pull request Nov 11, 2024
)
```
void resize_fill(size_t n, const T& value) {
size_t old_size = this->size();
if (n > old_size) {
this->reserve(n);
std::fill(t_end(), t_end() + n - old_size, value);
}
this->c_end = this->c_start + this->byte_size(n);
}
```
if n is not greater than old_size,
it's will not fill the data with value.
so it's not set the null_map flag to 1, it's can't return NULL
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | |
+---------------------+--------------------+
1 row in set (0.03 se
```
after fix:
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | NULL |
+---------------------+--------------------+
1 row in set (0.03 sec)
```
zhangstar333 added a commit that referenced this pull request Nov 11, 2024
@gavinchougavinchou mentioned this pull request Nov 26, 2024
@yiguoleiyiguolei mentioned this pull request Jan 19, 2025
HappenLee pushed a commit to HappenLee/incubator-doris that referenced this pull request Apr 24, 2026
)
```
void resize_fill(size_t n, const T& value) {
size_t old_size = this->size();
if (n > old_size) {
this->reserve(n);
std::fill(t_end(), t_end() + n - old_size, value);
}
this->c_end = this->c_start + this->byte_size(n);
}
```
if n is not greater than old_size,
it's will not fill the data with value.
so it's not set the null_map flag to 1, it's can't return NULL
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | |
+---------------------+--------------------+
1 row in set (0.03 se
```
after fix:
```
mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6;
+---------------------+--------------------+
| k11 | hour_floor(k11, 0) |
+---------------------+--------------------+
| 2015-03-13 12:36:38 | NULL |
+---------------------+--------------------+
1 row in set (0.03 sec)
```
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.dev/2.1.7-mergeddev/3.0.3-mergedp0_wreviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@zhangstar333@doris-robot@HappenLee@Mryange@yiguolei@wm1581066