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: Fix cast( date as datetime) error #4484

Merged
merged 1 commit into from Sep 11, 2017

Conversation

Projects
None yet
5 participants
@spongedu
Contributor

spongedu commented Sep 10, 2017

for issue #4483 , #4259
In MySQL

mysql> select cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2));
Field   1:  `cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2))`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DATETIME
Collation:  binary (63)
Length:     22
Max_length: 22
Decimals:   2
Flags:      BINARY


+-------------------------------------------------------------+
| cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2)) |
+-------------------------------------------------------------+
| 2017-01-01 00:00:00.00                                      |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

In TiDB

tidb> select cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2));
Field   1:  `cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2))`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       DATETIME
Collation:  binary (63)
Length:     22
Max_length: 10
Decimals:   2
Flags:      BINARY


+-------------------------------------------------------------+
| cast(cast('2017-01-01 01:01:11.12' as date) as datetime(2)) |
+-------------------------------------------------------------+
| 2017-01-01                                                  |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
@sre-bot

This comment has been minimized.

Show comment
Hide comment
@sre-bot

sre-bot Sep 10, 2017

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

sre-bot commented Sep 10, 2017

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@spongedu

This comment has been minimized.

Show comment
Hide comment
@spongedu

spongedu Sep 10, 2017

Contributor

Issue #4259 seems the same.

Contributor

spongedu commented Sep 10, 2017

Issue #4259 seems the same.

@@ -991,6 +991,10 @@ func (b *builtinCastTimeAsTimeSig) evalTime(row []types.Datum) (res types.Time,
if isNull || err != nil {
return res, isNull, errors.Trace(err)
}
if res, err = res.Convert(b.tp.Tp); err != nil {

This comment has been minimized.

@zz-jason

zz-jason Sep 10, 2017

Member

should we also modify other builtinCastXXXAsTimeSig functions ?

@zz-jason

zz-jason Sep 10, 2017

Member

should we also modify other builtinCastXXXAsTimeSig functions ?

This comment has been minimized.

@spongedu

spongedu Sep 11, 2017

Contributor

@zz-jason Seems no need. No other cast as time error found so far.

@spongedu

spongedu Sep 11, 2017

Contributor

@zz-jason Seems no need. No other cast as time error found so far.

@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason
Member

zz-jason commented Sep 10, 2017

@XuHuaiyu PTAL

@shenli

This comment has been minimized.

Show comment
Hide comment
@shenli

shenli Sep 10, 2017

Member

/ok-to-test

Member

shenli commented Sep 10, 2017

/ok-to-test

@winkyao

LGTM

@winkyao winkyao merged commit acc8104 into pingcap:master Sep 11, 2017

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@spongedu spongedu deleted the spongedu:issue_4483_cast branch Sep 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment