Skip to content

Commit

Permalink
change bc_join to broadcast_join
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 committed Jun 17, 2020
1 parent ac44a12 commit 444a49f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 34 deletions.
2 changes: 1 addition & 1 deletion ast/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ func (n *TableOptimizerHint) Restore(ctx *format.RestoreCtx) error {
ctx.WritePlainf("%d", n.HintData.(uint64))
case "nth_plan":
ctx.WritePlainf("%d", n.HintData.(int64))
case "tidb_hj", "tidb_smj", "tidb_inlj", "hash_join", "merge_join", "inl_join", "bc_join", "bcj_local", "tidb_bcj":
case "tidb_hj", "tidb_smj", "tidb_inlj", "hash_join", "merge_join", "inl_join", "broadcast_join", "broadcast_join_local":
for i, table := range n.Tables {
if i != 0 {
ctx.WritePlain(", ")
Expand Down
3 changes: 1 addition & 2 deletions ast/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ func (ts *testMiscSuite) TestTableOptimizerHintRestore(c *C) {
{"TIDB_HJ(t1,t2)", "TIDB_HJ(`t1`, `t2`)"},
{"TIDB_HJ(@sel1 t1,t2)", "TIDB_HJ(@`sel1` `t1`, `t2`)"},
{"TIDB_HJ(t1@sel1,t2@sel2)", "TIDB_HJ(`t1`@`sel1`, `t2`@`sel2`)"},
{"TIDB_BCJ(t1,t2)", "TIDB_BCJ(`t1`, `t2`)"},
{"MERGE_JOIN(t1,t2)", "MERGE_JOIN(`t1`, `t2`)"},
{"BC_JOIN(t1,t2)", "BC_JOIN(`t1`, `t2`)"},
{"BROADCAST_JOIN(t1,t2)", "BROADCAST_JOIN(`t1`, `t2`)"},
{"INL_JOIN(t1,t2)", "INL_JOIN(`t1`, `t2`)"},
{"HASH_JOIN(t1,t2)", "HASH_JOIN(`t1`, `t2`)"},
{"MAX_EXECUTION_TIME(3000)", "MAX_EXECUTION_TIME(3000)"},
Expand Down
12 changes: 6 additions & 6 deletions hintparser.y
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ import (
hintReadConsistentReplica "READ_CONSISTENT_REPLICA"
hintReadFromStorage "READ_FROM_STORAGE"
hintSMJoin "MERGE_JOIN"
hintBCJoin "BC_JOIN"
hintBCJoinPreferLocal "BCJ_LOCAL"
hintBCJoin "BROADCAST_JOIN"
hintBCJoinPreferLocal "BROADCAST_JOIN_LOCAL"
hintStreamAgg "STREAM_AGG"
hintSwapJoinInputs "SWAP_JOIN_INPUTS"
hintUseIndexMerge "USE_INDEX_MERGE"
Expand Down Expand Up @@ -524,8 +524,8 @@ UnsupportedTableLevelOptimizerHintName:

SupportedTableLevelOptimizerHintName:
"MERGE_JOIN"
| "BC_JOIN"
| "BCJ_LOCAL"
| "BROADCAST_JOIN"
| "BROADCAST_JOIN_LOCAL"
| "INL_JOIN"
| "INL_HASH_JOIN"
| "SWAP_JOIN_INPUTS"
Expand Down Expand Up @@ -622,8 +622,8 @@ Identifier:
| "READ_CONSISTENT_REPLICA"
| "READ_FROM_STORAGE"
| "MERGE_JOIN"
| "BC_JOIN"
| "BCJ_LOCAL"
| "BROADCAST_JOIN"
| "BROADCAST_JOIN_LOCAL"
| "STREAM_AGG"
| "SWAP_JOIN_INPUTS"
| "USE_INDEX_MERGE"
Expand Down
5 changes: 2 additions & 3 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,8 @@ var hintTokenMap = map[string]int{
"QUERY_TYPE": hintQueryType,
"READ_CONSISTENT_REPLICA": hintReadConsistentReplica,
"READ_FROM_STORAGE": hintReadFromStorage,
"BC_JOIN": hintBCJoin,
"BCJ_LOCAL": hintBCJoinPreferLocal,
"BROADCAST_JOIN": hintBCJoin,
"BROADCAST_JOIN_LOCAL": hintBCJoinPreferLocal,
"MERGE_JOIN": hintSMJoin,
"STREAM_AGG": hintStreamAgg,
"SWAP_JOIN_INPUTS": hintSwapJoinInputs,
Expand All @@ -864,7 +864,6 @@ var hintTokenMap = map[string]int{
"TIDB_HJ": hintHashJoin,
"TIDB_INLJ": hintInlJoin,
"TIDB_SMJ": hintSMJoin,
"TIDB_BCJ": hintBCJoin,

// Other keywords
"OLAP": hintOLAP,
Expand Down
27 changes: 5 additions & 22 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3153,23 +3153,6 @@ func (s *testParserSuite) TestOptimizerHints(c *C) {
c.Assert(hints[1].Tables[0].TableName.L, Equals, "t3")
c.Assert(hints[1].Tables[1].TableName.L, Equals, "t4")

// Test TIDB_BCJ
stmt, _, err = parser.Parse("select /*+ TIDB_BCJ(T1,t2), tidb_bcj(T3,t4) */ c1, c2 from t1, t2 where t1.c1 = t2.c1", "", "")
c.Assert(err, IsNil)
selectStmt = stmt[0].(*ast.SelectStmt)

hints = selectStmt.TableHints
c.Assert(hints, HasLen, 2)
c.Assert(hints[0].HintName.L, Equals, "tidb_bcj")
c.Assert(hints[0].Tables, HasLen, 2)
c.Assert(hints[0].Tables[0].TableName.L, Equals, "t1")
c.Assert(hints[0].Tables[1].TableName.L, Equals, "t2")

c.Assert(hints[1].HintName.L, Equals, "tidb_bcj")
c.Assert(hints[1].Tables, HasLen, 2)
c.Assert(hints[1].Tables[0].TableName.L, Equals, "t3")
c.Assert(hints[1].Tables[1].TableName.L, Equals, "t4")

// Test MERGE_JOIN
stmt, _, err = parser.Parse("select /*+ MERGE_JOIN(t1, T2), merge_join(t3, t4) */ c1, c2 from t1, t2 where t1.c1 = t2.c1", "", "")
c.Assert(err, IsNil)
Expand All @@ -3187,24 +3170,24 @@ func (s *testParserSuite) TestOptimizerHints(c *C) {
c.Assert(hints[1].Tables[0].TableName.L, Equals, "t3")
c.Assert(hints[1].Tables[1].TableName.L, Equals, "t4")

// TEST BC_JOIN
stmt, _, err = parser.Parse("select /*+ BC_JOIN(t1, T2), bc_join(t3, t4), BCJ_LOCAL(t2) */ c1, c2 from t1, t2 where t1.c1 = t2.c1", "", "")
// TEST BROADCAST_JOIN
stmt, _, err = parser.Parse("select /*+ BROADCAST_JOIN(t1, T2), broadcast_join(t3, t4), BROADCAST_JOIN_LOCAL(t2) */ c1, c2 from t1, t2 where t1.c1 = t2.c1", "", "")
c.Assert(err, IsNil)
selectStmt = stmt[0].(*ast.SelectStmt)

hints = selectStmt.TableHints
c.Assert(hints, HasLen, 3)
c.Assert(hints[0].HintName.L, Equals, "bc_join")
c.Assert(hints[0].HintName.L, Equals, "broadcast_join")
c.Assert(hints[0].Tables, HasLen, 2)
c.Assert(hints[0].Tables[0].TableName.L, Equals, "t1")
c.Assert(hints[0].Tables[1].TableName.L, Equals, "t2")

c.Assert(hints[1].HintName.L, Equals, "bc_join")
c.Assert(hints[1].HintName.L, Equals, "broadcast_join")
c.Assert(hints[1].Tables, HasLen, 2)
c.Assert(hints[1].Tables[0].TableName.L, Equals, "t3")
c.Assert(hints[1].Tables[1].TableName.L, Equals, "t4")

c.Assert(hints[2].HintName.L, Equals, "bcj_local")
c.Assert(hints[2].HintName.L, Equals, "broadcast_join_local")
c.Assert(hints[2].Tables, HasLen, 1)
c.Assert(hints[2].Tables[0].TableName.L, Equals, "t2")

Expand Down

0 comments on commit 444a49f

Please sign in to comment.