[
  {
    "name": "TestPKIsHandleRangeScan",
    "cases": [
      "select b from t where a > 1",
      "select b from t where a > 1 and a < 3",
      "select b from t where a > 1 and b < 6",
      "select a from t where a * 3 + 1 > 9 and a < 5",
      // Test TiDBSelection Implementation.
      "select a from t group by a having sum(b) > 4"
    ]
  },
  {
    "name": "TestSort",
    "cases": [
      "select a from t order by a",
      "select b from t order by b",
      "select b from t order by a+b",
      "select b from t order by b, a+b, a"
    ]
  },
  {
    "name": "TestAggregation",
    "cases": [
      "select sum(a) from t",
      "select max(a), min(b) from t",
      "select b, avg(a) from t group by b order by b",
      "select b, sum(a) from t group by b order by b",
      "select b, avg(a) from t group by b having sum(a) > 1 order by b",
      "select max(a+b) from t",
      "select sum(a) from t group by a, a+b order by a",
      "select b, sum(a) from t group by b having b > 1 order by b",
      "select c, sum(a) from (select a+b as c, a from t) t1 group by c having c > 1 order by c",
      "select max(a.a) from t a left join t b on a.a = b.a",
      "select avg(a.b) from t a left join t b on a.a = b.a",
      "select t1.a, max(t1.b) from t as t1 left join (select * from t) as t2 on t1.a = t2.a and t1.b = 3 group by t1.a order by a",
      "select t1.a, sum(distinct t1.b) from t as t1 left join (select * from t) as t2 on t1.b = t2.b group by t1.a order by a",
      "select t2.a, max(t2.b) from t as t1 right join (select * from t) as t2 on t1.a = t2.a group by t2.a order by a",
      "select t3.a, max(t3.b) from (select t1.a, t1.b from t as t1 left join t as t2 on t1.b = t2.b) t3 group by t3.a order by a",
      "select max(a) from t",
      "select sum(case when a > 0 and a <= 1000 then b else 0 end) from t",
      "select sum(case when a > 0 then (case when a <= 1000 then b end) else 0 end) from t",
      "select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t",
      "select count(case when a > 0 and a <= 1000 then b end) from t",
      "select count(case when a <= 0 or a > 1000 then null else b end) from t",
      "select count(distinct case when a > 0 and a <= 1000 then b end) from t",
      "select approx_count_distinct(case when a > 0 and a <= 1000 then b end) from t",
      "select count(b), sum(b), avg(b), b, max(b), min(b), bit_and(b), bit_or(b), bit_xor(b) from t group by a having sum(b) >= 0 and count(b) >= 0 order by b",
      "select group_concat(a, b), min(b), avg(a / b), a from t group by (a+b), a order by a",
      "select approx_percentile(a, 50) from t order by b"
    ]
  },
  {
    "name": "TestPushdownDistinctEnable",
    "cases": [
      "select /*+ HASH_AGG() */ avg(distinct a) from t;", // InjectProjBelowAgg
      "select /*+ HASH_AGG() */ a, count(distinct a) from t;", // firstrow(a) cannot be removed.
      "select /*+ HASH_AGG() */ avg(b), c, avg(b), count(distinct A, B),  count(distinct A), count(distinct c), sum(b) from t group by c;",
      "select /*+ STREAM_AGG() */ count(distinct c) from t group by c;", // should push down after stream agg implemented
      "select /*+ STREAM_AGG() */ count(distinct c) from t;", // should push down after stream agg implemented
      "select /*+ HASH_AGG() */ count(distinct c) from t;",
      "select count(distinct c) from t group by c;",
      "select count(distinct c) from t;"
    ]
  },
  {
    "name": "TestPushdownDistinctDisable",
    "cases": [
      // do not pushdown even AGG_TO_COP is specified.
      "select /*+ HASH_AGG(), AGG_TO_COP() */ avg(distinct a) from t;",
      "select /*+ HASH_AGG(), AGG_TO_COP() */ a, count(distinct a) from t;",
      "select /*+ HASH_AGG(), AGG_TO_COP() */ avg(b), c, avg(b), count(distinct A, B),  count(distinct A), count(distinct c), sum(b) from t group by c;",
      "select /*+ STREAM_AGG(), AGG_TO_COP() */ count(distinct c) from t group by c;",
      "select /*+ STREAM_AGG(), AGG_TO_COP() */ count(distinct c) from t;",
      "select /*+ HASH_AGG(), AGG_TO_COP() */ count(distinct c) from t;",
      "select /*+ AGG_TO_COP() */ count(distinct c) from t group by c;"
    ]
  },
  {
    "name": "TestSimplePlans",
    "cases": [
      "select a from t limit 2",
      "select a from t limit 1 offset 2",
      "select b from t order by b limit 3",
      "select a from t order by a limit 1 offset 2",
      "select * from ((select a as aa from t t1) union all (select b as aa from t t2)) as t3 order by aa",
      "select a, b, lag(a,1) over (order by b) from t order by b",
      "select * from (select a+1 as c, a+b as d from t) as t1 order by c+d limit 10",
      "select t1.a, t1.b from t as t1 left join t as t2 on t1.a = t2.a and t1.b = 3 order by a"
    ]
  },
  {
    "name": "TestIndexScan",
    "cases": [
      "select b from t",
      "select a from t order by b",
      "select c from t",
      "select a from t order by c",
      "select a, b from t where b > 5 order by b",
      "select a, b, c from t where c = 3 and b > 1 order by b",
      "select a, b from t where c > 1 and b > 1 order by c"
    ]
  },
  {
    "name": "TestJoin",
    "cases": [
      "select t1.a, t1.b from t1, t2 where t1.a = t2.a and t1.a > 2",
      "select t1.a, t1.b from t1, t2 where t1.a > t2.a and t2.b > 200",
      "select t1.a, t1.b from t1 left join t2 on t1.a = t2.a where t1.a > 2 and t2.b > 200",
      "select t2.a, t2.b from t1 right join t2 on t1.a = t2.a where t1.a > 2 and t2.b > 200",
      "select t1.a, t1.b from t1, t2 where t1.a = t2.a order by t1.a",
      "select * from t1 join t2 on t1.a = t2.a",
      "select * from t1 join t2 on t1.a = t2.a and t1.a > 2"
    ]
  },
  {
    "name": "TestApply",
    "cases": [
      "select a = (select a from t2 where t1.b = t2.b order by a limit 1) from t1",
      "select sum(a), (select t1.a from t1 where t1.a = t2.a limit 1), (select t1.b from t1 where t1.b = t2.b limit 1) from t2",
      "select a from t1 where exists(select 1 from t2 where t1.a = t2.a)"
    ]
  },
  {
    "name": "TestMemTableScan",
    "cases": [
      "select USER, HOST, DB, COMMAND, TIME, STATE, INFO, `DIGEST` from information_schema.processlist"
    ]
  },
  {
    "name": "TestTopN",
    "cases": [
      "select a from (select a from t where b > 2 order by a limit 3 offset 1) as t1 order by a limit 2 offset 1",
      "select * from (select * from t order by a limit 3) as t1 order by a limit 5",
      "select b from (select b from t order by b limit 10 offset 10) as t1 order by b limit 10 offset 5",
      "select b from (select b from t order by b limit 10 offset 2) as t1 order by b limit 3 offset 5",
      "select a from (select a from t order by a limit 3 offset 5) as t1 order by a limit 3 offset 5",
      "select a from (select a from t where b > 2 order by a, b limit 3 offset 1) as t1 order by a limit 2 offset 1",
      "select * from (select * from t order by a limit 3) as t1 order by a, b limit 5"
    ]
  },
  {
    "name": "TestCascadePlannerHashedPartTable",
    "cases": [
      "select * from pt1 order by a"
    ]
  },
  {
    "name": "TestInlineProjection",
    "cases": [
      "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1, t2 where t1.a = t2.a;", // TODO: need column pruning again.
      "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;",
      "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 left outer join t2 on t1.a = t2.a;",
      "select /*+ HASH_JOIN(t1) */ t1.b, t2.b from t1 right outer join t2 on t1.a = t2.a;",
      "select 1 from (select /*+ HASH_JOIN(t1) */ t1.a in (select t2.a from t2) from t1) x;", // TODO: should use hash join
      "select 1 from (select /*+ HASH_JOIN(t1) */ t1.a not in (select t2.a from t2) from t1) x;", // TODO: should use hash join
      "select /*+ INL_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;",
      "select /*+ INL_HASH_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;",
      "select /*+ INL_MERGE_JOIN(t1) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;",
      "select /*+ MERGE_JOIN(t1, t2) */ t1.b, t2.b from t1 inner join t2 on t1.a = t2.a;"
    ]
  }
]
