From da571013488fe2f6a3898dc1f7febdcd034b64e8 Mon Sep 17 00:00:00 2001 From: arenatlx <314806019@qq.com> Date: Mon, 11 Nov 2024 12:11:27 +0800 Subject: [PATCH 1/3] . Signed-off-by: arenatlx <314806019@qq.com> --- pkg/planner/BUILD.bazel | 2 +- pkg/planner/cascades/{ => old}/BUILD.bazel | 9 ++++----- pkg/planner/cascades/{ => old}/enforcer_rules.go | 2 +- pkg/planner/cascades/{ => old}/enforcer_rules_test.go | 2 +- pkg/planner/cascades/{ => old}/implementation_rules.go | 2 +- pkg/planner/cascades/{ => old}/main_test.go | 2 +- pkg/planner/cascades/{ => old}/optimize.go | 2 +- pkg/planner/cascades/{ => old}/optimize_test.go | 2 +- pkg/planner/cascades/{ => old}/stringer.go | 2 +- pkg/planner/cascades/{ => old}/stringer_test.go | 2 +- pkg/planner/cascades/{ => old}/transformation_rules.go | 2 +- .../cascades/{ => old}/transformation_rules_test.go | 2 +- pkg/planner/optimize.go | 4 ++-- 13 files changed, 17 insertions(+), 18 deletions(-) rename pkg/planner/cascades/{ => old}/BUILD.bazel (91%) rename pkg/planner/cascades/{ => old}/enforcer_rules.go (99%) rename pkg/planner/cascades/{ => old}/enforcer_rules_test.go (99%) rename pkg/planner/cascades/{ => old}/implementation_rules.go (99%) rename pkg/planner/cascades/{ => old}/main_test.go (99%) rename pkg/planner/cascades/{ => old}/optimize.go (99%) rename pkg/planner/cascades/{ => old}/optimize_test.go (99%) rename pkg/planner/cascades/{ => old}/stringer.go (99%) rename pkg/planner/cascades/{ => old}/stringer_test.go (99%) rename pkg/planner/cascades/{ => old}/transformation_rules.go (99%) rename pkg/planner/cascades/{ => old}/transformation_rules_test.go (99%) diff --git a/pkg/planner/BUILD.bazel b/pkg/planner/BUILD.bazel index 7e651e8949d02..ca5759dfec44f 100644 --- a/pkg/planner/BUILD.bazel +++ b/pkg/planner/BUILD.bazel @@ -13,7 +13,7 @@ go_library( "//pkg/metrics", "//pkg/parser/ast", "//pkg/parser/model", - "//pkg/planner/cascades", + "//pkg/planner/cascades/old", "//pkg/planner/core", "//pkg/planner/core/base", "//pkg/planner/core/resolve", diff --git a/pkg/planner/cascades/BUILD.bazel b/pkg/planner/cascades/old/BUILD.bazel similarity index 91% rename from pkg/planner/cascades/BUILD.bazel rename to pkg/planner/cascades/old/BUILD.bazel index 115b5a3cfe87f..3cee3c3aa1786 100644 --- a/pkg/planner/cascades/BUILD.bazel +++ b/pkg/planner/cascades/old/BUILD.bazel @@ -1,7 +1,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( - name = "cascades", + name = "old", srcs = [ "enforcer_rules.go", "implementation_rules.go", @@ -9,7 +9,7 @@ go_library( "stringer.go", "transformation_rules.go", ], - importpath = "github.com/pingcap/tidb/pkg/planner/cascades", + importpath = "github.com/pingcap/tidb/pkg/planner/cascades/old", visibility = ["//visibility:public"], deps = [ "//pkg/expression", @@ -37,7 +37,7 @@ go_library( ) go_test( - name = "cascades_test", + name = "old_test", timeout = "short", srcs = [ "enforcer_rules_test.go", @@ -46,8 +46,7 @@ go_test( "stringer_test.go", "transformation_rules_test.go", ], - data = glob(["testdata/**"]), - embed = [":cascades"], + embed = [":old"], flaky = True, shard_count = 25, deps = [ diff --git a/pkg/planner/cascades/enforcer_rules.go b/pkg/planner/cascades/old/enforcer_rules.go similarity index 99% rename from pkg/planner/cascades/enforcer_rules.go rename to pkg/planner/cascades/old/enforcer_rules.go index ba2c6363b5187..e62ed311afef3 100644 --- a/pkg/planner/cascades/enforcer_rules.go +++ b/pkg/planner/cascades/old/enforcer_rules.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "math" diff --git a/pkg/planner/cascades/enforcer_rules_test.go b/pkg/planner/cascades/old/enforcer_rules_test.go similarity index 99% rename from pkg/planner/cascades/enforcer_rules_test.go rename to pkg/planner/cascades/old/enforcer_rules_test.go index a2d40b6141ca4..f9d93a013cf8f 100644 --- a/pkg/planner/cascades/enforcer_rules_test.go +++ b/pkg/planner/cascades/old/enforcer_rules_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "testing" diff --git a/pkg/planner/cascades/implementation_rules.go b/pkg/planner/cascades/old/implementation_rules.go similarity index 99% rename from pkg/planner/cascades/implementation_rules.go rename to pkg/planner/cascades/old/implementation_rules.go index 467cbcea228eb..dab62489fe632 100644 --- a/pkg/planner/cascades/implementation_rules.go +++ b/pkg/planner/cascades/old/implementation_rules.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "math" diff --git a/pkg/planner/cascades/main_test.go b/pkg/planner/cascades/old/main_test.go similarity index 99% rename from pkg/planner/cascades/main_test.go rename to pkg/planner/cascades/old/main_test.go index 0bc1b0bff6ca9..60e5c1c6aa955 100644 --- a/pkg/planner/cascades/main_test.go +++ b/pkg/planner/cascades/old/main_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "flag" diff --git a/pkg/planner/cascades/optimize.go b/pkg/planner/cascades/old/optimize.go similarity index 99% rename from pkg/planner/cascades/optimize.go rename to pkg/planner/cascades/old/optimize.go index 3b318d85740fc..3dd0abc798ac4 100644 --- a/pkg/planner/cascades/optimize.go +++ b/pkg/planner/cascades/old/optimize.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "container/list" diff --git a/pkg/planner/cascades/optimize_test.go b/pkg/planner/cascades/old/optimize_test.go similarity index 99% rename from pkg/planner/cascades/optimize_test.go rename to pkg/planner/cascades/old/optimize_test.go index d646171f7ef70..790ff9b43d092 100644 --- a/pkg/planner/cascades/optimize_test.go +++ b/pkg/planner/cascades/old/optimize_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "context" diff --git a/pkg/planner/cascades/stringer.go b/pkg/planner/cascades/old/stringer.go similarity index 99% rename from pkg/planner/cascades/stringer.go rename to pkg/planner/cascades/old/stringer.go index ef5f48f4c808d..298a2ac0b9e36 100644 --- a/pkg/planner/cascades/stringer.go +++ b/pkg/planner/cascades/old/stringer.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "bytes" diff --git a/pkg/planner/cascades/stringer_test.go b/pkg/planner/cascades/old/stringer_test.go similarity index 99% rename from pkg/planner/cascades/stringer_test.go rename to pkg/planner/cascades/old/stringer_test.go index 092d3606c6921..cbd3a474805f3 100644 --- a/pkg/planner/cascades/stringer_test.go +++ b/pkg/planner/cascades/old/stringer_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "context" diff --git a/pkg/planner/cascades/transformation_rules.go b/pkg/planner/cascades/old/transformation_rules.go similarity index 99% rename from pkg/planner/cascades/transformation_rules.go rename to pkg/planner/cascades/old/transformation_rules.go index 5fec45b01a216..f406b192339e1 100644 --- a/pkg/planner/cascades/transformation_rules.go +++ b/pkg/planner/cascades/old/transformation_rules.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "math" diff --git a/pkg/planner/cascades/transformation_rules_test.go b/pkg/planner/cascades/old/transformation_rules_test.go similarity index 99% rename from pkg/planner/cascades/transformation_rules_test.go rename to pkg/planner/cascades/old/transformation_rules_test.go index 36ee47625635f..922a0fd525b47 100644 --- a/pkg/planner/cascades/transformation_rules_test.go +++ b/pkg/planner/cascades/old/transformation_rules_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cascades +package old import ( "context" diff --git a/pkg/planner/optimize.go b/pkg/planner/optimize.go index 1c1f06fd6c04d..93faff2784ade 100644 --- a/pkg/planner/optimize.go +++ b/pkg/planner/optimize.go @@ -30,7 +30,7 @@ import ( "github.com/pingcap/tidb/pkg/metrics" "github.com/pingcap/tidb/pkg/parser/ast" "github.com/pingcap/tidb/pkg/parser/model" - "github.com/pingcap/tidb/pkg/planner/cascades" + "github.com/pingcap/tidb/pkg/planner/cascades/old" "github.com/pingcap/tidb/pkg/planner/core" "github.com/pingcap/tidb/pkg/planner/core/base" "github.com/pingcap/tidb/pkg/planner/core/resolve" @@ -521,7 +521,7 @@ func optimize(ctx context.Context, sctx planctx.PlanContext, node *resolve.NodeW // Handle the logical plan statement, use cascades planner if enabled. if sessVars.GetEnableCascadesPlanner() { - finalPlan, cost, err := cascades.DefaultOptimizer.FindBestPlan(sctx, logic) + finalPlan, cost, err := old.DefaultOptimizer.FindBestPlan(sctx, logic) return finalPlan, names, cost, err } From 909b43e9312b15447c42752fc13d9ddbfa12bd20 Mon Sep 17 00:00:00 2001 From: arenatlx <314806019@qq.com> Date: Mon, 11 Nov 2024 12:58:25 +0800 Subject: [PATCH 2/3] . Signed-off-by: arenatlx <314806019@qq.com> --- pkg/planner/cascades/{ => old}/testdata/stringer_suite_in.json | 0 pkg/planner/cascades/{ => old}/testdata/stringer_suite_out.json | 0 .../{ => old}/testdata/transformation_rules_suite_in.json | 0 .../{ => old}/testdata/transformation_rules_suite_out.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename pkg/planner/cascades/{ => old}/testdata/stringer_suite_in.json (100%) rename pkg/planner/cascades/{ => old}/testdata/stringer_suite_out.json (100%) rename pkg/planner/cascades/{ => old}/testdata/transformation_rules_suite_in.json (100%) rename pkg/planner/cascades/{ => old}/testdata/transformation_rules_suite_out.json (100%) diff --git a/pkg/planner/cascades/testdata/stringer_suite_in.json b/pkg/planner/cascades/old/testdata/stringer_suite_in.json similarity index 100% rename from pkg/planner/cascades/testdata/stringer_suite_in.json rename to pkg/planner/cascades/old/testdata/stringer_suite_in.json diff --git a/pkg/planner/cascades/testdata/stringer_suite_out.json b/pkg/planner/cascades/old/testdata/stringer_suite_out.json similarity index 100% rename from pkg/planner/cascades/testdata/stringer_suite_out.json rename to pkg/planner/cascades/old/testdata/stringer_suite_out.json diff --git a/pkg/planner/cascades/testdata/transformation_rules_suite_in.json b/pkg/planner/cascades/old/testdata/transformation_rules_suite_in.json similarity index 100% rename from pkg/planner/cascades/testdata/transformation_rules_suite_in.json rename to pkg/planner/cascades/old/testdata/transformation_rules_suite_in.json diff --git a/pkg/planner/cascades/testdata/transformation_rules_suite_out.json b/pkg/planner/cascades/old/testdata/transformation_rules_suite_out.json similarity index 100% rename from pkg/planner/cascades/testdata/transformation_rules_suite_out.json rename to pkg/planner/cascades/old/testdata/transformation_rules_suite_out.json From 1aa258fea1539a978ad850d57916869e39beba7e Mon Sep 17 00:00:00 2001 From: arenatlx <314806019@qq.com> Date: Mon, 11 Nov 2024 13:00:08 +0800 Subject: [PATCH 3/3] . Signed-off-by: arenatlx <314806019@qq.com> --- pkg/planner/cascades/old/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/planner/cascades/old/BUILD.bazel b/pkg/planner/cascades/old/BUILD.bazel index 3cee3c3aa1786..c14619c21176a 100644 --- a/pkg/planner/cascades/old/BUILD.bazel +++ b/pkg/planner/cascades/old/BUILD.bazel @@ -46,6 +46,7 @@ go_test( "stringer_test.go", "transformation_rules_test.go", ], + data = glob(["testdata/**"]), embed = [":old"], flaky = True, shard_count = 25,