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

*: make chunk.SwapColumn private (#57274) #59190

Open
wants to merge 1 commit into
base: release-6.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ func (b *executorBuilder) buildLimit(v *plannercore.PhysicalLimit) Executor {
end: v.Offset + v.Count,
}

<<<<<<< HEAD:executor/builder.go
childUsedSchema := markChildrenUsedCols(v.Schema().Columns, v.Children()[0].Schema())[0]
e.columnIdxsUsedByChild = make([]int, 0, len(childUsedSchema))
for i, used := range childUsedSchema {
Expand All @@ -726,7 +727,17 @@ func (b *executorBuilder) buildLimit(v *plannercore.PhysicalLimit) Executor {
}
}
if len(e.columnIdxsUsedByChild) == len(childUsedSchema) {
=======
childSchemaLen := v.Children()[0].Schema().Len()
childUsedSchema := markChildrenUsedCols(v.Schema().Columns, v.Children()[0].Schema())[0]
e.columnIdxsUsedByChild = make([]int, 0, len(childUsedSchema))
e.columnIdxsUsedByChild = append(e.columnIdxsUsedByChild, childUsedSchema...)
if len(e.columnIdxsUsedByChild) == childSchemaLen {
>>>>>>> 65281ad3073 (*: make `chunk.SwapColumn` private (#57274)):pkg/executor/builder.go
e.columnIdxsUsedByChild = nil // indicates that all columns are used. LimitExec will improve performance for this condition.
} else {
// construct a project evaluator to do the inline projection
e.columnSwapHelper = chunk.NewColumnSwapHelper(e.columnIdxsUsedByChild)
}
return e
}
Expand Down
56 changes: 56 additions & 0 deletions expression/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package expression

import (
<<<<<<< HEAD:expression/evaluator_test.go
"sync/atomic"
=======
>>>>>>> 65281ad3073 (*: make `chunk.SwapColumn` private (#57274)):pkg/expression/evaluator_test.go
"testing"
"time"

Expand Down Expand Up @@ -593,3 +596,56 @@ func TestMod(t *testing.T) {
require.NoError(t, err)
require.Equal(t, types.NewDatum(1.5), r)
}
<<<<<<< HEAD:expression/evaluator_test.go
=======

func TestOptionalProp(t *testing.T) {
ctx := createContext(t)

fc := funcs[ast.Plus]
arg1fc := funcs[ast.CurrentUser]
arg1f, err := arg1fc.getFunction(ctx, nil)
require.NoError(t, err)
arg1 := &ScalarFunction{
FuncName: model.NewCIStr(ast.CurrentUser),
Function: arg1f,
RetType: arg1f.getRetTp(),
}
arg2fc := funcs[ast.TiDBIsDDLOwner]
arg2f, err := arg2fc.getFunction(ctx, nil)
require.NoError(t, err)
arg2 := &ScalarFunction{
FuncName: model.NewCIStr(ast.TiDBIsDDLOwner),
Function: arg2f,
RetType: arg2f.getRetTp(),
}

f, err := fc.getFunction(ctx, []Expression{arg1, arg2})
require.NoError(t, err)
fe := &ScalarFunction{
FuncName: model.NewCIStr(ast.Plus),
Function: f,
RetType: f.getRetTp(),
}

fc2 := funcs[ast.GetLock]
f2, err := fc2.getFunction(ctx, datumsToConstants(types.MakeDatums("tidb_distsql_scan_concurrency", 10)))
require.NoError(t, err)
fe2 := &ScalarFunction{
FuncName: model.NewCIStr(ast.GetLock),
Function: f2,
RetType: f2.getRetTp(),
}

require.Equal(t, exprctx.OptionalEvalPropKeySet(0), f.RequiredOptionalEvalProps())
require.Equal(t, exprctx.OptPropCurrentUser.AsPropKeySet()|exprctx.OptPropDDLOwnerInfo.AsPropKeySet(),
GetOptionalEvalPropsForExpr(fe))
require.Equal(t, exprctx.OptPropCurrentUser.AsPropKeySet()|exprctx.OptPropDDLOwnerInfo.AsPropKeySet()|
exprctx.OptPropAdvisoryLock.AsPropKeySet(),
GetOptionalEvalPropsForExpr(fe)|GetOptionalEvalPropsForExpr(fe2))

evalSuit := NewEvaluatorSuite([]Expression{fe, fe2}, false)
require.Equal(t, exprctx.OptPropCurrentUser.AsPropKeySet()|exprctx.OptPropDDLOwnerInfo.AsPropKeySet()|
exprctx.OptPropAdvisoryLock.AsPropKeySet(), evalSuit.RequiredOptionalEvalProps())
}
>>>>>>> 65281ad3073 (*: make `chunk.SwapColumn` private (#57274)):pkg/expression/evaluator_test.go
Loading
Loading