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: fix issue that TimeIsNull is not compatible with MySQL #10957

Closed
wants to merge 10 commits into from

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Jun 27, 2019

What problem does this PR solve?

Fix #9763.

What is changed and how it works?

Introduce a new variable isNotNull to builtinTimeIsNullSig to judge if this column has a NotNull attribution and push it down to TiKV.

Check List

Tests

  • Unit test

@codecov
Copy link

codecov bot commented Jun 27, 2019

Codecov Report

Merging #10957 into master will decrease coverage by 0.2445%.
The diff coverage is 94.7368%.

@@               Coverage Diff               @@
##            master     #10957        +/-   ##
===============================================
- Coverage   81.222%   80.9774%   -0.2446%     
===============================================
  Files          420        419         -1     
  Lines        90031      89373       -658     
===============================================
- Hits         73125      72372       -753     
- Misses       11675      11765        +90     
- Partials      5231       5236         +5

@qw4990 qw4990 requested review from breezewish and lonng June 27, 2019 04:44
@qw4990 qw4990 requested review from XuHuaiyu, winoros and alivxxx and removed request for lonng June 27, 2019 05:16
@@ -336,7 +336,12 @@ func getSignatureByPB(ctx sessionctx.Context, sigCode tipb.ScalarFuncSig, tp *ti
case tipb.ScalarFuncSig_RealIsNull:
f = &builtinRealIsNullSig{base}
case tipb.ScalarFuncSig_TimeIsNull:
f = &builtinTimeIsNullSig{base}
isNotNull := false
if len(expr.Children) > 0 && mysql.HasNotNullFlag(uint(expr.Children[0].FieldType.Flag)) {
Copy link
Member

Choose a reason for hiding this comment

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

No need for this check any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which check? len(expr.Children) > 0?.

expression/builtin_op.go Outdated Show resolved Hide resolved
@qw4990 qw4990 force-pushed the fix-TimeIsNull branch 6 times, most recently from aea4cee to 95b1dd9 Compare July 3, 2019 08:53
@qw4990
Copy link
Contributor Author

qw4990 commented Jul 3, 2019

@lamxTyler @breeswish PTAL~

@qw4990 qw4990 force-pushed the fix-TimeIsNull branch 2 times, most recently from a2ea4af to d1bc2c5 Compare July 4, 2019 08:14
Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -799,7 +799,12 @@ func (c *isNullFunctionClass) getFunction(ctx sessionctx.Context, args []Express
sig = &builtinRealIsNullSig{bf}
sig.setPbCode(tipb.ScalarFuncSig_RealIsNull)
case types.ETDatetime:
sig = &builtinTimeIsNullSig{bf}
isNotNull := false
_, isCol := args[0].(*Column)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_, isCol := args[0].(*Column)
col, isCol := args[0].(*Column)

sig = &builtinTimeIsNullSig{bf}
isNotNull := false
_, isCol := args[0].(*Column)
if isCol && mysql.HasNotNullFlag(args[0].GetType().Flag) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if isCol && mysql.HasNotNullFlag(args[0].GetType().Flag) {
if isCol && mysql.HasNotNullFlag(col.GetType().Flag) {

There is no need to index the slice again.

@lonng
Copy link
Contributor

lonng commented Jul 5, 2019

@qw4990 You should override the implicitArgs for this function and push it down to TiKV according to your description. But I cannot find the code snippet corresponding.

@qw4990
Copy link
Contributor Author

qw4990 commented Jul 22, 2019

The way in this PR to fix this issue is not appropriate, so I close it and fix it by another PR.

@qw4990 qw4990 closed this Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Null datetime is not compatible with MySQL
4 participants