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

expression: bug fix for vectorized casting real as ... (#19485) #19594

Merged
merged 2 commits into from
Sep 7, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #19485 to release-4.0


What problem does this PR solve?

Issue Number: close #17809

Problem Summary:

Casting from column value 0.0 of real type to datetime type produces wrong result NULL.

CREATE TABLE t0(c0 DOUBLE);
INSERT INTO t0(c0) VALUES (0);
SELECT CAST(t0.c0 AS DATETIME) FROM t0; -- expected: {0000-00-00 00:00:00}, actual: {NULL}

But casting from constant produces the expected result 0000-00-00 00:00:00.

SELECT CAST(0.0 AS DATETIME) FROM t0; -- {0000-00-00 00:00:00}

What is changed and how it works?

What's Changed:

  • builtinCasrRealAsTimeSig.vecEvalTime will treat real value 0.0 as a special case, and assign ZeroTime to the result.

How it Works:

  • the non-vectorized evalTime has this special case but vecEvalTime does not.
  • add this special case to vecEvalTime

Related changes

Check List

Tests

  • Unit test

Release note

  • fix incorrect result of vectorized casting real as time

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 1, 2020
@lysu
Copy link
Contributor

lysu commented Sep 1, 2020

need merge with tikv/tikv#8562 to keep CI can pass

@lysu
Copy link
Contributor

lysu commented Sep 1, 2020

/run-integration-copr-test tikv=pr/8562

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 2, 2020
@lzmhhh123
Copy link
Contributor

It should merge with tikv/tikv#8562 together.

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@lysu
Copy link
Contributor

lysu commented Sep 7, 2020

@zz-jason tikv/tikv#8562 has all-test-pass please help merge if free (no privilege - -)

@zz-jason zz-jason changed the title expression: bug fix for vectorized casting real as time (#19485) expression: bug fix for vectorized casting real as ... (#19485) Sep 7, 2020
@zz-jason zz-jason merged commit 44c518c into pingcap:release-4.0 Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants