Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jul 4, 2024
1 parent 7ae4c00 commit 5a8b4c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 115 deletions.
116 changes: 1 addition & 115 deletions pkg/bindinfo/tests/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,125 +925,11 @@ func testFuzzyBindingHints(t *testing.T) {
binding string
qTemplate string
}{
// use index
{`create global binding using select /*+ use_index(t1, c) */ * from *.t1 where a=1`,
`select * from %st1 where a=1000`},
{`create global binding using select /*+ use_index(t1, c) */ * from *.t1 where d<1`,
`select * from %st1 where d<10000`},
{`create global binding using select /*+ use_index(t1, c) */ * from *.t1, *.t2 where t1.d<1`,
`select * from %st1, t2 where t1.d<100`},
{`create global binding using select /*+ use_index(t1, c) */ * from *.t1, *.t2 where t1.d<1`,
`select * from t1, %st2 where t1.d<100`},
{`create global binding using select /*+ use_index(t1, c), use_index(t2, a) */ * from *.t1, *.t2 where t1.d<1`,
`select * from %st1, t2 where t1.d<100`},
{`create global binding using select /*+ use_index(t1, c), use_index(t2, a) */ * from *.t1, *.t2 where t1.d<1`,
`select * from t1, %st2 where t1.d<100`},
{`create global binding using select /*+ use_index(t1, c), use_index(t2, a) */ * from *.t1, *.t2, *.t3 where t1.d<1`,
`select * from %st1, t2, t3 where t1.d<100`},
{`create global binding using select /*+ use_index(t1, c), use_index(t2, a) */ * from *.t1, *.t2, *.t3 where t1.d<1`,
`select * from t1, t2, %st3 where t1.d<100`},

// ignore index
{`create global binding using select /*+ ignore_index(t1, b) */ * from *.t1 where b=1`,
`select * from %st1 where b=1000`},
{`create global binding using select /*+ ignore_index(t1, b) */ * from *.t1 where b>1`,
`select * from %st1 where b>1000`},
{`create global binding using select /*+ ignore_index(t1, b) */ * from *.t1 where b in (1,2)`,
`select * from %st1 where b in (1)`},
{`create global binding using select /*+ ignore_index(t1, b) */ * from *.t1 where b in (1,2)`,
`select * from %st1 where b in (1,2,3,4,5)`},

// order index hint
{`create global binding using select /*+ order_index(t1, a) */ a from *.t1 where a<10 order by a limit 10`,
`select a from %st1 where a<10000 order by a limit 10`},
{`create global binding using select /*+ order_index(t1, b) */ b from *.t1 where b>10 order by b limit 1111`,
`select b from %st1 where b>2 order by b limit 10`},

// no order index hint
{`create global binding using select /*+ no_order_index(t1, c) */ c from *.t1 where c<10 order by c limit 10`,
`select c from %st1 where c<10000 order by c limit 10`},
{`create global binding using select /*+ no_order_index(t1, d) */ d from *.t1 where d>10 order by d limit 1111`,
`select d from %st1 where d>2 order by d limit 10`},

// agg hint
{`create global binding using select /*+ hash_agg() */ count(*) from *.t1 group by a`,
`select count(*) from %st1 group by a`},
{`create global binding using select /*+ stream_agg() */ count(*) from *.t1 group by b`,
`select count(*) from %st1 group by b`},

// to_cop hint
{`create global binding using select /*+ agg_to_cop() */ sum(a) from *.t1`,
`select sum(a) from %st1`},
{`create global binding using select /*+ limit_to_cop() */ a from *.t1 limit 10`,
`select a from %st1 limit 101`},

// index merge hint
{`create global binding using select /*+ use_index_merge(t1, c, d) */ * from *.t1 where c=1 or d=1`,
`select * from %st1 where c=1000 or d=1000`},
{`create global binding using select /*+ no_index_merge() */ * from *.t1 where a=1 or b=1`,
`select * from %st1 where a=1000 or b=1000`},

// join type hint
{`create global binding using select /*+ hash_join(t1) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from %st1, t2 where t1.a=t2.a`},
{`create global binding using select /*+ hash_join(t2) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from t1, %st2 where t1.a=t2.a`},
{`create global binding using select /*+ hash_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ hash_join_build(t1) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from t1, %st2 where t1.a=t2.a`},
{`create global binding using select /*+ hash_join_probe(t1) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from t1, %st2 where t1.a=t2.a`},
{`create global binding using select /*+ merge_join(t1) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from %st1, t2 where t1.a=t2.a`},
{`create global binding using select /*+ merge_join(t2) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from t1, %st2 where t1.a=t2.a`},
{`create global binding using select /*+ merge_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},

{`create global binding using select /*+ inl_join(t1) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from %st1, t2 where t1.a=t2.a`},
{`create global binding using select /*+ inl_join(t2) */ * from *.t1, *.t2 where t1.a=t2.a`,
`select * from t1, %st2 where t1.a=t2.a`},
{`create global binding using select /*+ inl_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},

// no join type hint
{`create global binding using select /*+ no_hash_join(t1) */ * from *.t1, *.t2 where t1.b=t2.b`,
`select * from %st1, t2 where t1.b=t2.b`},
{`create global binding using select /*+ no_hash_join(t2) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ no_hash_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ no_merge_join(t1) */ * from *.t1, *.t2 where t1.b=t2.b`,
`select * from %st1, t2 where t1.b=t2.b`},
{`create global binding using select /*+ no_merge_join(t2) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ no_merge_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ no_index_join(t1) */ * from *.t1, *.t2 where t1.b=t2.b`,
`select * from %st1, t2 where t1.b=t2.b`},
{`create global binding using select /*+ no_index_join(t2) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ no_index_join(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},

// join order hint
{`create global binding using select /*+ leading(t2) */ * from *.t1, *.t2 where t1.b=t2.b`,
`select * from %st1, t2 where t1.b=t2.b`},
{`create global binding using select /*+ leading(t2) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ leading(t2, t1) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ leading(t1, t2) */ * from *.t1, *.t2 where t1.c=t2.c`,
`select * from t1, %st2 where t1.c=t2.c`},
{`create global binding using select /*+ leading(t1) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ leading(t2) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ leading(t2,t3) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
{`create global binding using select /*+ leading(t2,t3,t1) */ * from *.t1, *.t2, *.t3 where t1.a=t2.a and t3.b=t2.b`,
`select * from t1, %st2, t3 where t1.a=t2.a and t3.b=t2.b`},
} {
removeAllBindings(tk, true)
tk.MustExec(c.binding)
Expand Down
1 change: 1 addition & 0 deletions pkg/planner/core/issuetest/planner_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ WHERE
FROM
w
);`)
tk.MustQuery(`show warnings`).Check(testkit.Rows())
}

0 comments on commit 5a8b4c4

Please sign in to comment.