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: fix the bug that cannot perform vectorized expression evaluation (#15902) #15956

Merged
merged 7 commits into from
Apr 1, 2020
2 changes: 1 addition & 1 deletion expression/chunk_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func checkSequenceFunction(exprs []Expression) bool {
for _, expr := range exprs {
scalaFunc, ok := expr.(*ScalarFunction)
if !ok {
return false
continue
}
switch scalaFunc.FuncName.L {
case ast.NextVal:
Expand Down
45 changes: 45 additions & 0 deletions expression/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,51 @@ func (s *testEvaluatorSuite) TestConstItem(c *C) {
c.Assert(sf.ConstItem(s.ctx.GetSessionVars().StmtCtx), Equals, true)
}

func (s *testEvaluatorSuite) TestVectorizable(c *C) {
exprs := make([]Expression, 0, 4)
sf := newFunction(ast.Rand)
column := &Column{
UniqueID: 0,
RetType: types.NewFieldType(mysql.TypeLonglong),
}
exprs = append(exprs, sf)
exprs = append(exprs, One)
exprs = append(exprs, Null)
exprs = append(exprs, column)
c.Assert(Vectorizable(exprs), Equals, true)

column0 := &Column{
UniqueID: 1,
RetType: types.NewFieldType(mysql.TypeString),
}
column1 := &Column{
UniqueID: 2,
RetType: types.NewFieldType(mysql.TypeString),
}
column2 := &Column{
UniqueID: 3,
RetType: types.NewFieldType(mysql.TypeLonglong),
}
exprs = exprs[:0]
sf = newFunction(ast.SetVar, column0, column1)
exprs = append(exprs, sf)
c.Assert(Vectorizable(exprs), Equals, false)

exprs = exprs[:0]
sf = newFunction(ast.GetVar, column0)
exprs = append(exprs, sf)
c.Assert(Vectorizable(exprs), Equals, false)

exprs = exprs[:0]
sf = newFunction(ast.NextVal, column0)
exprs = append(exprs, sf)
sf = newFunction(ast.LastVal, column0)
exprs = append(exprs, sf)
sf = newFunction(ast.SetVal, column1, column2)
exprs = append(exprs, sf)
c.Assert(Vectorizable(exprs), Equals, false)
}

type testTableBuilder struct {
tableName string
columnNames []string
Expand Down