-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[fix](date_function) fix str_to_date function return wrong microsecond issue #47129
Conversation
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
run buildall |
TPC-H: Total hot run time: 32247 ms
|
TPC-DS: Total hot run time: 188727 ms
|
ClickBench: Total hot run time: 31.59 s
|
) | ||
""" | ||
sql """ insert into ${tableName} values (3, 'Carl','2024-12-29 10:11:12') """ | ||
def result1 = try_sql """ |
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.
should also check all constant parameters for fe fold constant
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.
like: select cast(str_to_date('2024-12-29 10:11:12', '%Y-%m-%d %H:%i:%s.%f') as string);
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.
done
run buildall |
TPC-H: Total hot run time: 32730 ms
|
TPC-DS: Total hot run time: 187521 ms
|
ClickBench: Total hot run time: 30.77 s
|
PR approved by anyone and no changes requested. |
PR approved by at least one committer and no changes requested. |
…d issue (#47129) ### What problem does this PR solve? Issue Number: close #47105 Related PR: #24932 Problem Summary: ### Release note str_to_date always return microsecond part for datetime even if user does not specfic %f in date format string. This is wrong. mysql> select id,str_to_date(dt, '%Y-%m-%d %H:%i:%s') from test1 limit 1; +------+--------------------------------------+ | id | str_to_date(dt, '%Y-%m-%d %H:%i:%s') | +------+--------------------------------------+ | 2 | 2024-12-28 10:11:12.000000 | +------+--------------------------------------+ and constant fold scenario is wrong too: mysql> select cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as string); +--------------------------------------------------------------------------+ | cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as TEXT) | +--------------------------------------------------------------------------+ | 2025-01-17 11:59:30.000000 | +--------------------------------------------------------------------------+ ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [x] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
…d issue (#47129) ### What problem does this PR solve? Issue Number: close #47105 Related PR: #24932 Problem Summary: ### Release note str_to_date always return microsecond part for datetime even if user does not specfic %f in date format string. This is wrong. mysql> select id,str_to_date(dt, '%Y-%m-%d %H:%i:%s') from test1 limit 1; +------+--------------------------------------+ | id | str_to_date(dt, '%Y-%m-%d %H:%i:%s') | +------+--------------------------------------+ | 2 | 2024-12-28 10:11:12.000000 | +------+--------------------------------------+ and constant fold scenario is wrong too: mysql> select cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as string); +--------------------------------------------------------------------------+ | cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as TEXT) | +--------------------------------------------------------------------------+ | 2025-01-17 11:59:30.000000 | +--------------------------------------------------------------------------+ ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [x] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
What problem does this PR solve?
Issue Number: close #47105
Related PR: #24932
Problem Summary:
Release note
str_to_date always return microsecond part for datetime even if user does not specfic %f in date format string. This is wrong.
mysql> select id,str_to_date(dt, '%Y-%m-%d %H:%i:%s') from test1 limit 1;
+------+--------------------------------------+
| id | str_to_date(dt, '%Y-%m-%d %H:%i:%s') |
+------+--------------------------------------+
| 2 | 2024-12-28 10:11:12.000000 |
+------+--------------------------------------+
and constant fold scenario is wrong too:
mysql> select cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as string);
+--------------------------------------------------------------------------+
| cast(str_to_date('2025-01-17 11:59:30', '%Y-%m-%d %H:%i:%s') as TEXT) |
+--------------------------------------------------------------------------+
| 2025-01-17 11:59:30.000000 |
+--------------------------------------------------------------------------+
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)