Skip to content

Commit

Permalink
planner: remove internal pkg and move base code to certain place (#52620
Browse files Browse the repository at this point in the history
)

ref #51664
  • Loading branch information
AilinKid committed Apr 16, 2024
1 parent 2e1d9e1 commit 2ce8b56
Show file tree
Hide file tree
Showing 28 changed files with 65 additions and 65 deletions.
5 changes: 2 additions & 3 deletions pkg/planner/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ go_library(
"//pkg/planner/cardinality",
"//pkg/planner/context",
"//pkg/planner/core/base",
"//pkg/planner/core/internal",
"//pkg/planner/core/internal/base",
"//pkg/planner/core/metrics",
"//pkg/planner/core/operator/base",
"//pkg/planner/funcdep",
"//pkg/planner/property",
"//pkg/planner/util",
Expand Down Expand Up @@ -251,9 +250,9 @@ go_test(
"//pkg/parser/terror",
"//pkg/planner",
"//pkg/planner/core/base",
"//pkg/planner/core/internal",
"//pkg/planner/property",
"//pkg/planner/util",
"//pkg/planner/util/coretestsdk",
"//pkg/planner/util/coreusage",
"//pkg/session",
"//pkg/session/types",
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/enforcempp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_test(
deps = [
"//pkg/domain",
"//pkg/parser/model",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/sessionctx/stmtctx",
"//pkg/testkit",
"//pkg/testkit/external",
Expand Down
10 changes: 5 additions & 5 deletions pkg/planner/core/casetest/enforcempp/enforce_mpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/external"
Expand Down Expand Up @@ -532,7 +532,7 @@ func TestMPPSingleDistinct3Stage(t *testing.T) {
//
// since it doesn't change the schema out (index ref is still the right), so by now it's fine. SEE case: EXPLAIN select count(distinct a), count(distinct b), sum(c) from t.
func TestMPPMultiDistinct3Stage(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

// test table
Expand Down Expand Up @@ -590,7 +590,7 @@ func TestMPPMultiDistinct3Stage(t *testing.T) {

// Test null-aware semi join push down for MPP mode
func TestMPPNullAwareSemiJoinPushDown(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

// test table
Expand Down Expand Up @@ -638,7 +638,7 @@ func TestMPPNullAwareSemiJoinPushDown(t *testing.T) {
}

func TestMPPSharedCTEScan(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

// test table
Expand Down Expand Up @@ -686,7 +686,7 @@ func TestMPPSharedCTEScan(t *testing.T) {
}

func TestRollupMPP(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/hint/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_test(
"//pkg/config",
"//pkg/domain",
"//pkg/parser/model",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/sessionctx/variable",
"//pkg/testkit",
"//pkg/testkit/testdata",
Expand Down
6 changes: 3 additions & 3 deletions pkg/planner/core/casetest/hint/hint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/testdata"
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestReadFromStorageHint(t *testing.T) {
}

func TestAllViewHintType(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestAllViewHintType(t *testing.T) {
}

func TestJoinHintCompatibility(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/partition/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_test(
shard_count = 7,
deps = [
"//pkg/config",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/sessionctx/variable",
"//pkg/testkit",
"//pkg/testkit/testdata",
Expand Down
6 changes: 3 additions & 3 deletions pkg/planner/core/casetest/partition/partition_pruner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/testdata"
Expand Down Expand Up @@ -86,12 +86,12 @@ func getPartitionInfoFromPlan(plan []string) string {
infos := make([]testTablePartitionInfo, 0, 2)
info := testTablePartitionInfo{}
for _, row := range plan {
partitions := internal.GetFieldValue("partition:", row)
partitions := coretestsdk.GetFieldValue("partition:", row)
if partitions != "" {
info.Partitions = partitions
continue
}
tbl := internal.GetFieldValue("table:", row)
tbl := coretestsdk.GetFieldValue("table:", row)
if tbl != "" {
info.Table = tbl
infos = append(infos, info)
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/physicalplantest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go_test(
"//pkg/parser/model",
"//pkg/planner",
"//pkg/planner/core",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/sessionctx/stmtctx",
"//pkg/testkit",
"//pkg/testkit/external",
Expand Down
18 changes: 9 additions & 9 deletions pkg/planner/core/casetest/physicalplantest/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/planner"
"github.com/pingcap/tidb/pkg/planner/core"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/external"
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestUnmatchedTableInHint(t *testing.T) {
}

func TestIssue37520(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_cost_model_version=2")
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestIssue37520(t *testing.T) {
}

func TestMPPHints(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_cost_model_version=2")
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestMPPHints(t *testing.T) {
}

func TestMPPHintsScope(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_cost_model_version=2")
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestMPPBCJModel(t *testing.T) {
Probe: sizeof(Data) * 2 / 3
exchange size: Build + Probe = 4/3 * sizeof(Data)
*/
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(3))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(3))
{
cnt, err := store.GetMPPClient().GetMPPStoreCount()
require.Equal(t, cnt, 3)
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestMPPBCJModel(t *testing.T) {
}

func TestMPPPreferBCJ(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(3))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(3))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
Expand Down Expand Up @@ -449,7 +449,7 @@ func TestMPPBCJModelOneTiFlash(t *testing.T) {
Probe: sizeof(Data) * 0 / 1
exchange size: Build + Probe = 0 * sizeof(Data)
*/
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(1))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(1))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (a int, b int, c int, index idx_a(a), index idx_b(b))")
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestMPPBCJModelOneTiFlash(t *testing.T) {
}

func TestMPPRightSemiJoin(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(3))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(3))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
Expand Down Expand Up @@ -556,7 +556,7 @@ func TestMPPRightSemiJoin(t *testing.T) {
}

func TestMPPRightOuterJoin(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(3))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(3))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
Expand Down
3 changes: 2 additions & 1 deletion pkg/planner/core/casetest/rule/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ go_test(
"//pkg/parser/ast",
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/planner/util/coreusage",
"//pkg/testkit",
"//pkg/testkit/testdata",
"//pkg/testkit/testmain",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/testdata"
)
Expand All @@ -35,7 +35,7 @@ func TestPushDerivedTopnFlash(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, primary key(b,a))")
internal.SetTiFlashReplica(t, dom, "test", "t")
coretestsdk.SetTiFlashReplica(t, dom, "test", "t")
tk.MustExec("set tidb_enforce_mpp=1")
tk.MustExec("set @@session.tidb_allow_mpp=ON;")
var input Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/pingcap/tidb/pkg/expression/aggregation"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coreusage"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestWrapCastForAggFuncs(t *testing.T) {
orgAggFuncs = append(orgAggFuncs, agg.Clone())
}

internal.WrapCastForAggFuncs(mock.NewContext(), aggFuncs)
coreusage.WrapCastForAggFuncs(mock.NewContext(), aggFuncs)
for i := range aggFuncs {
if aggFuncs[i].Mode != aggregation.FinalMode && aggFuncs[i].Mode != aggregation.Partial2Mode {
require.Equal(t, aggFuncs[i].Args[0].GetType().GetType(), aggFuncs[i].RetTp.GetType())
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/windows/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_test(
shard_count = 5,
deps = [
"//pkg/domain",
"//pkg/planner/core/internal",
"//pkg/planner/util/coretestsdk",
"//pkg/testkit",
"//pkg/testkit/testdata",
"//pkg/testkit/testmain",
Expand Down
12 changes: 6 additions & 6 deletions pkg/planner/core/casetest/windows/window_push_down_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/pkg/domain"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/testdata"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestWindowFunctionDescCanPushDown(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists employee")
tk.MustExec("create table employee (empid int, deptid int, salary decimal(10,2))")
internal.SetTiFlashReplica(t, dom, "test", "employee")
coretestsdk.SetTiFlashReplica(t, dom, "test", "employee")

var input Input
var output Output
Expand All @@ -80,7 +80,7 @@ func TestWindowPushDownPlans(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists employee")
tk.MustExec("create table employee (empid int, deptid int, salary decimal(10,2))")
internal.SetTiFlashReplica(t, dom, "test", "employee")
coretestsdk.SetTiFlashReplica(t, dom, "test", "employee")

var input Input
var output Output
Expand All @@ -98,7 +98,7 @@ func TestWindowPlanWithOtherOperators(t *testing.T) {
tk.MustExec("set tidb_cost_model_version=2")
tk.MustExec("drop table if exists employee")
tk.MustExec("create table employee (empid int, deptid int, salary decimal(10,2))")
internal.SetTiFlashReplica(t, dom, "test", "employee")
coretestsdk.SetTiFlashReplica(t, dom, "test", "employee")

var input Input
var output Output
Expand All @@ -116,8 +116,8 @@ func TestIssue34765(t *testing.T) {
tk.MustExec("create table t1(c1 varchar(32), c2 datetime, c3 bigint, c4 varchar(64));")
tk.MustExec("create table t2(b2 varchar(64));")
tk.MustExec("set tidb_enforce_mpp=1;")
internal.SetTiFlashReplica(t, dom, "test", "t1")
internal.SetTiFlashReplica(t, dom, "test", "t2")
coretestsdk.SetTiFlashReplica(t, dom, "test", "t1")
coretestsdk.SetTiFlashReplica(t, dom, "test", "t2")

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/CheckMPPWindowSchemaLength", "return"))
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/kv"
base2 "github.com/pingcap/tidb/pkg/planner/core/base"
"github.com/pingcap/tidb/pkg/planner/core/internal/base"
"github.com/pingcap/tidb/pkg/planner/core/operator/base"
"github.com/pingcap/tidb/pkg/planner/property"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/plancodec"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "base",
srcs = ["plan.go"],
importpath = "github.com/pingcap/tidb/pkg/planner/core/internal/base",
visibility = ["//pkg/planner/core:__subpackages__"],
importpath = "github.com/pingcap/tidb/pkg/planner/core/operator/base",
visibility = ["//visibility:public"],
deps = [
"//pkg/expression",
"//pkg/planner/context",
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions pkg/planner/core/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
"github.com/pingcap/tidb/pkg/planner"
"github.com/pingcap/tidb/pkg/planner/core"
"github.com/pingcap/tidb/pkg/planner/core/base"
"github.com/pingcap/tidb/pkg/planner/core/internal"
"github.com/pingcap/tidb/pkg/planner/property"
"github.com/pingcap/tidb/pkg/planner/util"
"github.com/pingcap/tidb/pkg/planner/util/coretestsdk"
"github.com/pingcap/tidb/pkg/session"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/external"
Expand Down Expand Up @@ -222,7 +222,7 @@ func TestIndexLookupCartesianJoin(t *testing.T) {
}

func TestMPPHintsWithBinding(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_cost_model_version=2")
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestMPPHintsWithBinding(t *testing.T) {
}

func TestJoinHintCompatibilityWithBinding(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_cost_model_version=2")
Expand Down Expand Up @@ -442,7 +442,7 @@ func TestPhysicalPlanMemoryTrace(t *testing.T) {
}

func TestPhysicalTableScanExtractCorrelatedCols(t *testing.T) {
store := testkit.CreateMockStore(t, internal.WithMockTiFlash(2))
store := testkit.CreateMockStore(t, coretestsdk.WithMockTiFlash(2))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t1 (id int, client_type tinyint, client_no char(18), taxpayer_no varchar(50), status tinyint, update_time datetime)")
Expand Down
Loading

0 comments on commit 2ce8b56

Please sign in to comment.