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: make in more powerful. #4969

Merged
merged 8 commits into from
Nov 6, 2017
Merged

expression: make in more powerful. #4969

merged 8 commits into from
Nov 6, 2017

Conversation

winoros
Copy link
Member

@winoros winoros commented Nov 1, 2017

Let in can handle more case, so we can make more expression able to calculate range.
PTAL @XuHuaiyu @zz-jason @hanfei1991

for i := stkLen - lLen; i < stkLen; i++ {
if er.ctxStack[i].GetType().Tp != mysql.TypeNull && er.ctxStack[i].GetType().EvalType() != leftEt {
for _, arg := range args[1:] {
if arg.GetType().Tp != mysql.TypeNull && expression.GetAccurateCmpType(args[0], arg) != leftEt {
Copy link
Member

Choose a reason for hiding this comment

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

Can we collect all the argument types and merge them to one type, then just cast all the expressions to this type and always use in?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can group them to the form x in(type_x_expr) or cast(x to type_a) in(type_a_expr)or....But cannot to convert to one type. e.g. x in ('a', 1.1). x's type is string type. We should compare x and a in string type, x and 1.1 in double type. But we can't compare x and a in double type since this will make result absolutely wrong. And we can't compare x and 1.1 in string type since this don't obey the compare system in MySQL.

Copy link
Member

Choose a reason for hiding this comment

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

How about build DNF with different types?
(intValLeft in (intA, intB, intC)) or (floatValLeft in (floatA, floatB))?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is okay.

Copy link
Member Author

Choose a reason for hiding this comment

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

But currently this is not very necessary to do this. This case can't push down to tikv, and can't be used to calculate range.

@coocood
Copy link
Member

coocood commented Nov 2, 2017

LGTM

@@ -161,10 +161,12 @@ func (s *testRangerSuite) TestTableRange(c *C) {
resultStr: "[(-inf,-1] [1,+inf)]",
},
// TODO: cast will change the extraction behavior of accessCondition.
Copy link
Member

Choose a reason for hiding this comment

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

remove this comment ?

@winoros
Copy link
Member Author

winoros commented Nov 6, 2017

PTAL @hanfei1991 @zz-jason @XuHuaiyu

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

zz-jason
zz-jason previously approved these changes Nov 6, 2017
@winoros
Copy link
Member Author

winoros commented Nov 6, 2017

/run-all-tests

@winoros
Copy link
Member Author

winoros commented Nov 6, 2017

/run-unit-test /run-integration-ddl-test

@winoros
Copy link
Member Author

winoros commented Nov 6, 2017

mysql-test needs to do some change. Don't merge for a while.
UPDATE: Fixed.

@winoros
Copy link
Member Author

winoros commented Nov 6, 2017

/run-common-test tidb-test=pr/396

@winoros winoros merged commit 55529a5 into pingcap:master Nov 6, 2017
@winoros winoros deleted the in-func branch November 6, 2017 07:36
winoros added a commit to winoros/tidb that referenced this pull request Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants