-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: incompatibility with MySQL for ADDTIME() #21401
Conversation
671470c
to
be29d7e
Compare
There is no reward for this challenge pull request, so you can request a reward from @SunRunAway. |
@qw4990 PTAL |
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.
Rest LGTM
if !isDuration(arg1) { | ||
result.AppendNull() // fixed: false | ||
continue | ||
} |
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.
The file is generated by go generate in expression/generator. We shouldn't edit it by manual.. Maybe we should modify the template in time_vec.go and run make gogenerate
to generate the code.
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.
that's the way
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.
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.
If the reason is the same, I think we can fix it in this pr.
Test case fails
|
@@ -5559,6 +5559,9 @@ func (b *builtinAddStringAndStringSig) evalString(row chunk.Row) (result string, | |||
if isNull || err != nil { | |||
return "", isNull, err | |||
} | |||
if !isDuration(arg1Str) { |
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.
Test case fails
[2021-08-12T09:34:14.503Z] FAIL: builtin_time_test.go:903: testEvaluatorSuite.TestAddTimeSig [2021-08-12T09:34:14.503Z] [2021-08-12T09:34:14.503Z] builtin_time_test.go:1012: [2021-08-12T09:34:14.503Z] c.Assert(len(warnings), Equals, i+1+beforeWarnCnt) [2021-08-12T09:34:14.503Z] ... obtained int = 8 [2021-08-12T09:34:14.503Z] ... expected int = 9 [2021-08-12T09:34:14.503Z]
Here is the reason, if arg1Str
is not a MySQL Time
, it just return without error.
@@ -5559,6 +5559,9 @@ func (b *builtinAddStringAndStringSig) evalString(row chunk.Row) (result string, | |||
if isNull || err != nil { | |||
return "", isNull, err | |||
} | |||
if !isDuration(arg1Str) { | |||
return "", true, nil | |||
} | |||
sc := b.ctx.GetSessionVars().StmtCtx | |||
arg1, err = types.ParseDuration(sc, arg1Str, getFsp4TimeAddSub(arg1Str)) |
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.
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.
I don't think so. MySQL also doesn't throw a error/warning.
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.
It's make sense. Should we remove those two test cases(below)? Or we should throw a error/warning inside func (b *builtinAddStringAndStringSig) evalString(row chunk.Row)
?
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.
What problem does this PR solve?
Issue Number: close #19150
What is changed and how it works?
What's Changed:
builtinAddStringStringSig
eval/vecEval return null whenarg1
isn'tDuration
type (eg:ADDTIME('2020-05-13 14:01:24', '2020-04-29 05:11:19')
)How it Works:
make
builtinAddStringStringSig
return null whenarg1
isn'tDuration
type (eg:ADDTIME('2020-05-13 14:01:24', '2020-04-29 05:11:19')
)Related changes
Tests
Side effects
Release note