-
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
planner, expression: take NullFlag into consideration when optimize the int non-const
<cmp > non-int const
#20040
planner, expression: take NullFlag into consideration when optimize the int non-const
<cmp > non-int const
#20040
Conversation
The test failed because the optimization rule is changed, some plan will change according to it. |
@@ -260,3 +260,19 @@ func (s *testExpressionRewriterSuite) TestPatternLikeToExpression(c *C) { | |||
tk.MustQuery("select 0 like '0';").Check(testkit.Rows("1")) | |||
tk.MustQuery("select 0.00 like '0.00';").Check(testkit.Rows("1")) | |||
} | |||
|
|||
func (s *testExpressionRewriterSuite) TestFetchNullData(c *C) { |
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.
TestFetchNullData -> TestIssue16679, and please add a comment // TestIssue16679 contains tests for https://github.com/pingcap/tidb/issues/16679.
Thanks for your comments, I have fixed the tests. |
@@ -698,7 +698,7 @@ func (s *testIntegrationSuite) TestPartitionPruningForInExpr(c *C) { | |||
|
|||
tk.MustExec("use test") | |||
tk.MustExec("drop table if exists t") | |||
tk.MustExec("create table t(a int(11), b int) partition by range (a) (partition p0 values less than (4), partition p1 values less than(10), partition p2 values less than maxvalue);") | |||
tk.MustExec("create table t(a int(11) not null, b int) partition by range (a) (partition p0 values less than (4), partition p1 values less than(10), partition p2 values less than maxvalue);") |
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.
should we add a new test for the column a
without not null
?
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 have added a new test for it.
expression/builtin_compare_test.go
Outdated
@@ -67,6 +67,25 @@ func (s *testEvaluatorSuite) TestCompareFunctionWithRefine(c *C) { | |||
{"123456789123456789123456789.12345 < a", "0"}, | |||
{"-123456789123456789123456789.12345 < a", "1"}, | |||
{"'aaaa'=a", "eq(0, a)"}, | |||
//{"1.5071004017670217e-01=a", "eq(1.5071004017670217e-01, a)"}, |
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.
why comment here?
expression/builtin_compare.go
Outdated
@@ -1295,7 +1295,7 @@ func (c *compareFunctionClass) refineArgs(ctx sessionctx.Context, args []Express | |||
isExceptional, finalArg0, finalArg1 := false, args[0], args[1] | |||
isPositiveInfinite, isNegativeInfinite := false, false | |||
// int non-constant [cmp] non-int constant | |||
if arg0IsInt && !arg0IsCon && !arg1IsInt && arg1IsCon { | |||
if mysql.HasNotNullFlag(args[0].GetType().Flag) && arg0IsInt && !arg0IsCon && !arg1IsInt && arg1IsCon { |
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.
mysql.HasNotNullFlag(args[0].GetType().Flag)
-> mysql.HasNotNullFlag(arg0Type.Flag)
expression/builtin_compare.go
Outdated
@@ -1314,7 +1314,7 @@ func (c *compareFunctionClass) refineArgs(ctx sessionctx.Context, args []Express | |||
} | |||
} | |||
// non-int constant [cmp] int non-constant | |||
if arg1IsInt && !arg1IsCon && !arg0IsInt && arg0IsCon { | |||
if mysql.HasNotNullFlag(args[1].GetType().Flag) && arg1IsInt && !arg1IsCon && !arg0IsInt && arg0IsCon { |
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 is no reward for this challenge pull request, so you can request a reward from @XuHuaiyu. |
PTAL @XuHuaiyu |
/reward 300 |
Reward success. |
LGTM |
/run-all-tests |
int non-const
<cmp > non-int const
@TszKitLo40 -- table t with range partition [p0 (1~10)], [p1 (11~20)]
select * from t where par_col in (9); Before this commit, we only scan the A naive rule for whether we need to forbid
|
@TszKitLo40 is there any update? |
|
We cannot know whether the value is
Here is the result if we allow
And here is the result if we forbid it.
Notice that the where condition Hence, one improvement we can achieve is that when the comparison function is the where condition in select statement, even if |
But it is hard to define whether |
@TszKitLo40: 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. |
What problem does this PR solve?
Issue Number: close #16679
Problem Summary:
What is changed and how it works?
What's Changed:
Fix bug when fetching null data.
How it Works:
Check the
NotNullFlag
of the not-int constant.Check List
Tests
Release note