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, plan: fix the index selection's bug #4286

Merged
merged 8 commits into from Aug 23, 2017

Conversation

Projects
None yet
5 participants
@hanfei1991
Member

hanfei1991 commented Aug 22, 2017

The expression like a = '1' or a < 1.5 can use index from now on.

This should fix #3911

Show outdated Hide outdated expression/util.go
Show outdated Hide outdated expression/builtin_compare.go
Show outdated Hide outdated expression/builtin_compare.go
Show outdated Hide outdated expression/builtin_compare.go
best: "TableReader(Table(t))->Sel([like(test.t.c_str, abc\\_, 92)])->Projection",
// best: "Index(t.c_d_e_str)[[abc_,abc_]]->Projection",
},
//{

This comment has been minimized.

@shenli

shenli Aug 22, 2017

Member

Why there are so many commented cases?

@shenli

shenli Aug 22, 2017

Member

Why there are so many commented cases?

This comment has been minimized.

@hanfei1991

hanfei1991 Aug 23, 2017

Member

Like cann't use index in new planner now.

@hanfei1991

hanfei1991 Aug 23, 2017

Member

Like cann't use index in new planner now.

@blacktear23

This comment has been minimized.

Show comment
Hide comment
@blacktear23

blacktear23 Aug 23, 2017

Contributor

@hanfei1991 will this PR cover Date column compare with String, such as: created_at > "2017-09-01" which created_at's type is Date not Datetime.

Contributor

blacktear23 commented Aug 23, 2017

@hanfei1991 will this PR cover Date column compare with String, such as: created_at > "2017-09-01" which created_at's type is Date not Datetime.

@shenli

This comment has been minimized.

Show comment
Hide comment
@shenli

shenli Aug 23, 2017

Member

@blacktear23 That case will be fixed in another PR soon.

Member

shenli commented Aug 23, 2017

@blacktear23 That case will be fixed in another PR soon.

{conOnePointOne, colInt, ast.LE, "le(2, a)"},
{conOnePointOne, colInt, ast.GT, "gt(2, a)"},
{conOnePointOne, colInt, ast.GE, "ge(1, a)"},
{conOnePointOne, colInt, ast.EQ, "eq(1.1, cast(a))"},

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor

why can't this be converted?
cast 1.1 to int will cause truncate error?

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor

why can't this be converted?
cast 1.1 to int will cause truncate error?

This comment has been minimized.

@hanfei1991

hanfei1991 Aug 23, 2017

Member

This should be folded as false

@hanfei1991

hanfei1991 Aug 23, 2017

Member

This should be folded as false

@shenli

This comment has been minimized.

Show comment
Hide comment
@shenli

shenli Aug 23, 2017

Member

LGTM

Member

shenli commented Aug 23, 2017

LGTM

shenli and others added some commits Aug 23, 2017

Show outdated Hide outdated expression/builtin_compare.go
}
// refineConstantArg changes the constant argument to it's ceiling or flooring result by the given op.
func refineConstantArg(con *Constant, op opcode.Op, ctx context.Context) *Constant {

This comment has been minimized.

@zz-jason

zz-jason Aug 23, 2017

Member

ditto

@zz-jason

zz-jason Aug 23, 2017

Member

ditto

log.Warnf("failed to refine this expression, the constant argument is %s", con)
return con
}
datumInt := types.NewIntDatum(i64)

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor
create table t(a bigint unsigned);
select a < cast(-1 as unsigned);

a < cast(-1 as unsigned) will be refined as a < -1?
a < cast(-1 as unsigned) will be compared as unsigned int,
but a < -1 will be compared as signed int.

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor
create table t(a bigint unsigned);
select a < cast(-1 as unsigned);

a < cast(-1 as unsigned) will be refined as a < -1?
a < cast(-1 as unsigned) will be compared as unsigned int,
but a < -1 will be compared as signed int.

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor

never mind

@XuHuaiyu

XuHuaiyu Aug 23, 2017

Contributor

never mind

@hanfei1991 hanfei1991 merged commit 72ba0bc into master Aug 23, 2017

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@hanfei1991 hanfei1991 deleted the hanfei/refine branch Aug 23, 2017

dbjoa added a commit to cloud-pi/tidb that referenced this pull request Aug 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment