-
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: separated arithmeticIntDivideSig #22374
Open
Tjianke
wants to merge
23
commits into
pingcap:master
Choose a base branch
from
Tjianke:separateDivideInt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e3c3d5a
separate arithmeticDivideInt
Tjianke 454b651
fmt
Tjianke 6ee8718
Merge branch 'master' into separateDivideInt
Tjianke 96b8f85
improve tests
Tjianke 13eb821
address comments
Tjianke 7b0190b
address comments
Tjianke b11e6e3
address comments
Tjianke c6e7766
address comments
Tjianke 2570e21
address comment
Tjianke 4d8f2a3
address comment
Tjianke 31f1460
fix ut
Tjianke 5297a6f
enhance ut for wrong type of signature
Tjianke 1c79510
added sig type assertion
Tjianke 444347d
use C.Fatal() instead
Tjianke 05a5622
Merge branch 'master' into separateDivideInt
Tjianke 094ba18
Merge branch 'master' into separateDivideInt
Tjianke 9e6a6ab
Merge branch 'master' into separateDivideInt
Tjianke 44678cc
Merge branch 'master' into separateDivideInt
Tjianke e238deb
Merge branch 'master' into separateDivideInt
Tjianke 63b3cd6
Merge branch 'master' into separateDivideInt
Tjianke a728e6f
resolve conflicts
Tjianke c0fbccd
Merge branch 'master' into separateDivideInt
Tjianke a80ed9d
resolve conflicts
Tjianke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -367,10 +367,12 @@ func (s *testEvaluatorSuite) TestArithmeticDivide(c *C) { | |||||
c.Assert(err, IsNil) | ||||||
c.Assert(sig, NotNil) | ||||||
switch sig.(type) { | ||||||
case *builtinArithmeticIntDivideIntSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideInt) | ||||||
case *builtinArithmeticIntDivideDecimalSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideDecimal) | ||||||
case *builtinArithmeticDivideRealSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_DivideReal) | ||||||
case *builtinArithmeticDivideDecimalSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_DivideDecimal) | ||||||
default: | ||||||
panic("Wrong type of signature tested") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
val, err := evalBuiltinFunc(sig, chunk.Row{}) | ||||||
c.Assert(err, IsNil) | ||||||
|
@@ -475,12 +477,34 @@ func (s *testEvaluatorSuite) TestArithmeticIntDivide(c *C) { | |||||
args: []interface{}{uint64(1), float64(-1)}, | ||||||
expect: []interface{}{nil, "*BIGINT UNSIGNED value is out of range in '\\(1 DIV -1\\)'"}, | ||||||
}, | ||||||
{ | ||||||
args: []interface{}{uint64(3), -3}, | ||||||
expect: []interface{}{nil, "*BIGINT UNSIGNED value is out of range in '\\(3, -3\\)'"}, | ||||||
}, | ||||||
{ | ||||||
args: []interface{}{-3, uint64(3)}, | ||||||
expect: []interface{}{nil, "*BIGINT value is out of range in '\\(-3, 3\\)'"}, | ||||||
}, | ||||||
} | ||||||
|
||||||
for _, tc := range testCases { | ||||||
sig, err := funcs[ast.IntDiv].getFunction(s.ctx, s.datumsToConstants(types.MakeDatums(tc.args...))) | ||||||
c.Assert(err, IsNil) | ||||||
c.Assert(sig, NotNil) | ||||||
switch sig.(type) { | ||||||
case *builtinArithmeticIntDivideIntSignedUnsignedSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntSignedUnsigned) | ||||||
case *builtinArithmeticIntDivideIntSignedSignedSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntSignedSigned) | ||||||
case *builtinArithmeticIntDivideIntUnsignedSignedSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntUnsignedSigned) | ||||||
case *builtinArithmeticIntDivideIntUnsignedUnsignedSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntUnsignedUnsigned) | ||||||
case *builtinArithmeticIntDivideDecimalSig: | ||||||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideDecimal) | ||||||
default: | ||||||
panic("Wrong type of signature tested") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||||||
val, err := evalBuiltinFunc(sig, chunk.Row{}) | ||||||
if tc.expect[1] == nil { | ||||||
c.Assert(err, IsNil) | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Suggest add "default" branch and raise failure, to avoid similar error in the future.