-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
base: master
Are you sure you want to change the base?
Conversation
/run-all-tests |
1 similar comment
/run-all-tests |
/cc @breeswish @XuHuaiyu PTAL, thanks~ |
@ZiheLiu PTAL, PR involves code you contributed, thanks~ |
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 test cases for "Signed-Unsigned" & "Unsigned-Signed" in TestArithmeticDivide
. Rest LGTM.
6527613
to
a740811
Compare
77b7a87
to
b11e6e3
Compare
expression/integration_test.go
Outdated
@@ -3507,6 +3507,25 @@ func (s *testIntegrationSuite) TestArithmeticBuiltin(c *C) { | |||
c.Assert(terror.ErrorEqual(err, types.ErrOverflow), IsTrue) | |||
c.Assert(rs.Close(), IsNil) | |||
|
|||
//IntDiv overflow test |
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.
@Tjianke
Cover only two of four overflow cases here looks a little strange to me.
In my previous comment I suggested to add test cases for "Signed-Unsigned" & "Unsigned-Signed" only because the other two (UU and SS) exists in (*testEvaluatorSuite) TestArithmeticDivide()
.
I think place US
and SU
in (*testEvaluatorSuite) TestArithmeticDivide()
would be easier, and would be better.
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.
@@ -360,6 +360,14 @@ func (s *testEvaluatorSuite) TestArithmeticDivide(c *C) { | |||
args: []interface{}{nil, nil}, | |||
expect: nil, | |||
}, | |||
{ | |||
args: []interface{}{uint64(3), -3}, |
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.
@Tjianke
It seems not working as expected. err
returned by evalBuiltinFunc
in line 389 should not be IsNil
when overflow.
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 added tests under TestArithmeticIntDivide
, which covers cases of not nil err. Also switch case seems wrong in TestArithmeticDivide
, as ast.Div
applies only for Real
and Decimal
type.
case *builtinArithmeticDivideRealSig: | ||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_DivideReal) | ||
case *builtinArithmeticDivideDecimalSig: | ||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_DivideDecimal) |
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.
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntUnsignedSigned) | ||
case *builtinArithmeticIntDivideIntUnsignedUnsignedSig: | ||
c.Assert(sig.PbCode(), Equals, tipb.ScalarFuncSig_IntDivideIntUnsignedUnsigned) | ||
} |
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.
Ditto.
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 would be more common to use c.Fatal
in unit test.
@@ -371,6 +371,8 @@ func (s *testEvaluatorSuite) TestArithmeticDivide(c *C) { | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
panic("Wrong type of signature tested") | |
c.Fatal("Wrong type of signature tested") |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
panic("Wrong type of signature tested") | |
c.Fatal("Wrong type of signature tested") |
LGTM |
@Tjianke: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
The DIV function can be pushed down to the tikv and tiflash. |
What problem does this PR solve?
Issue Number: closes #13979
Problem Summary:
ArithmeticDivideIntSig
at planning stage will be more efficient then current statusWhat is changed and how it works?
Benchmark result:
macIntDivOld.txt
macIntDivNew.txt
What's Changed:
Impl vectorized, separated func sig from original
DivideIntSig
, separatedDivideIntSig
into four signatures by sign/unsign of argumentsUpdated tipb dependency to introduce new func signatures
How it Works:
Check List
Tests
Release note
DivideIntSig