Skip to content

Commit

Permalink
ddl: invisibility for plannner (pingcap#36634)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Jul 28, 2022
1 parent 9b70603 commit e3ceffa
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 4 deletions.
12 changes: 11 additions & 1 deletion ddl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

package_group(
name = "ddl_friend",
packages = [
"-//planner/...",
"//...",
],
)

go_library(
name = "ddl",
srcs = [
Expand Down Expand Up @@ -36,7 +44,9 @@ go_library(
"table_lock.go",
],
importpath = "github.com/pingcap/tidb/ddl",
visibility = ["//visibility:public"],
visibility = [
":ddl_friend",
],
deps = [
"//config",
"//ddl/label",
Expand Down
1 change: 1 addition & 0 deletions dumpling/export/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ go_test(
"//config",
"//dumpling/context",
"//dumpling/log",
"//errno",
"//parser",
"//util/filter",
"//util/promutil",
Expand Down
2 changes: 1 addition & 1 deletion planner/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ go_test(
shard_count = 50,
deps = [
"//config",
"//ddl",
"//domain",
"//errno",
"//executor",
Expand Down Expand Up @@ -227,6 +226,7 @@ go_test(
"//statistics/handle",
"//table",
"//testkit",
"//testkit/ddlhelper",
"//testkit/testdata",
"//testkit/testmain",
"//testkit/testsetup",
Expand Down
4 changes: 2 additions & 2 deletions planner/core/partition_pruning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package core
import (
"testing"

"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/testkit/ddlhelper"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -131,7 +131,7 @@ func prepareTestCtx(t *testing.T, createTable string, partitionExpr string) *tes
stmt, err := p.ParseOneStmt(createTable, "", "")
require.NoError(t, err)
sctx := mock.NewContext()
tblInfo, err := ddl.BuildTableInfoFromAST(stmt.(*ast.CreateTableStmt))
tblInfo, err := ddlhelper.BuildTableInfoFromAST(stmt.(*ast.CreateTableStmt))
require.NoError(t, err)
columns, names, err := expression.ColumnInfos2ColumnsAndNames(sctx, model.NewCIStr("t"), tblInfo.Name, tblInfo.Cols(), tblInfo)
require.NoError(t, err)
Expand Down
13 changes: 13 additions & 0 deletions testkit/ddlhelper/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "ddlhelper",
srcs = ["helper.go"],
importpath = "github.com/pingcap/tidb/testkit/ddlhelper",
visibility = ["//visibility:public"],
deps = [
"//ddl",
"//parser/ast",
"//parser/model",
],
)
27 changes: 27 additions & 0 deletions testkit/ddlhelper/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ddlhelper

import (
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/model"
)

// BuildTableInfoFromAST builds model.TableInfo from a SQL statement.
// Note: TableID and PartitionID are left as uninitialized value.
func BuildTableInfoFromAST(s *ast.CreateTableStmt) (*model.TableInfo, error) {
return ddl.BuildTableInfoFromAST(s)
}
2 changes: 2 additions & 0 deletions util/plancodec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ go_library(
deps = [
"//kv",
"//util/hack",
"//util/logutil",
"//util/memory",
"//util/texttree",
"@com_github_golang_snappy//:snappy",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_tipb//go-tipb",
"@org_uber_go_zap//:zap",
],
)

Expand Down

0 comments on commit e3ceffa

Please sign in to comment.