Files
tidb/planner/core/testdata/integration_suite_in.json

878 lines
54 KiB
JSON

[
{
"name": "TestPushLimitDownIndexLookUpReader",
"cases": [
// Limit should be pushed down into IndexLookUpReader, row count of IndexLookUpReader and TableScan should be 1.00.
"explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 limit 2,1",
// Projection atop IndexLookUpReader, Limit should be pushed down into IndexLookUpReader, and Projection should have row count 1.00 as well.
"explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 order by b desc limit 2,1",
// Limit should be pushed down into IndexLookUpReader when Selection on top of IndexScan.
"explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 and c > 1 limit 2,1",
// Limit should NOT be pushed down into IndexLookUpReader when Selection on top of TableScan.
"explain format = 'brief' select * from tbl use index(idx_b_c) where b > 1 and a > 1 limit 2,1"
]
},
{
"name": "TestIsFromUnixtimeNullRejective",
"cases": [
// fix #12385
"explain format = 'brief' select * from t t1 left join t t2 on t1.a=t2.a where from_unixtime(t2.b);"
]
},
{
"name": "TestAggColumnPrune",
"cases": [
"select count(1) from t join (select count(1) from t where false) as tmp",
"select count(1) from t join (select max(a) from t where false) as tmp",
"select count(1) from t join (select min(a) from t where false) as tmp",
"select count(1) from t join (select sum(a) from t where false) as tmp",
"select count(1) from t join (select avg(a) from t where false) as tmp",
"select count(1) from t join (select count(1) from t where false group by a) as tmp",
"select count(1) from t join (select max(a) from t where false group by a) as tmp",
"select count(1) from t join (select min(a) from t where false group by a) as tmp",
"select count(1) from t join (select sum(a) from t where false group by a) as tmp",
"select count(1) from t join (select avg(a) from t where false group by a) as tmp",
"SELECT avg(2) FROM(SELECT min(c) FROM t JOIN(SELECT 1 c) d ORDER BY a) e"
]
},
{
"name": "TestIndexJoinInnerIndexNDV",
"cases": [
// t2 should use idx2 instead of idx1, since idx2 has larger NDV.
"explain format = 'brief' select /*+ inl_join(t2) */ * from t1, t2 where t1.a = t2.a and t1.b = t2.b and t1.c = t2.c"
]
},
{
"name": "TestSimplifyOuterJoinWithCast",
"cases": [
// LeftOuterJoin should no be simplified to InnerJoin.
"explain format = 'brief' select * from t t1 left join t t2 on t1.a = t2.a where cast(t1.b as date) >= '2019-01-01'"
]
},
{
"name": "TestMaxMinEliminate",
"cases": [
"explain format = 'brief' (select max(a) from t) union (select min(a) from t)",
"explain format = 'brief' select min(a), max(a) from cluster_index_t",
"explain format = 'brief' select min(b), max(b) from cluster_index_t where a = 1",
"explain format = 'brief' select min(a), max(a) from cluster_index_t where b = 1",
"explain format = 'brief' select min(b), max(b) from cluster_index_t where b = 1"
]
},
{
"name": "TestIndexJoinUniqueCompositeIndex",
"cases": [
// Row count of IndexScan should be 2.
"explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c = t2.c",
// Row count of IndexScan should be 2.
"explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t1.c <= t2.b",
// Row count of IndexScan should be 1.
"explain format = 'brief' select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a and t2.b = 1"
]
},
{
"name": "TestPartitionTableStats",
"cases": [
"explain format = 'brief' select * from t order by a",
"select * from t order by a",
"explain format = 'brief' select * from t order by a limit 3",
"select * from t order by a limit 3"
]
},
{
"name": "TestIndexMerge",
"cases": [
"explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b) */ * from t where a = 1 or b = 2",
"explain format = 'brief' select /*+ USE_INDEX_MERGE(t, primary) */ * from t where 1 or t.c",
"explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, b, c) */ * from t where 1 or t.a = 1 or t.b = 2"
]
},
{
"name": "TestIndexMergeHint4CNF",
"cases": [
"explain format = 'brief' select * from t where b = 1 and (a = 1 or c = 1)",
"explain format = 'brief' select /*+ USE_INDEX_MERGE(t, a, c) */ * from t where b = 1 and (a = 1 or c = 1)"
]
},
{
"name": "TestSubqueryWithTopN",
"cases": [
"desc format = 'brief' select t1.b from t t1 where t1.b in (select t2.a from t t2 order by t1.a+t2.a limit 1)",
"desc format = 'brief' select t1.a from t t1 order by (t1.b = 1 and exists (select 1 from t t2 where t1.b = t2.b)) limit 1",
"desc format = 'brief' select * from (select b+b as x from t) t1, t t2 where t1.x=t2.b order by t1.x limit 1"
]
},
{
"name": "TestIndexJoinTableRange",
"cases": [
"desc format = 'brief' select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.b",
"desc format = 'brief' select /*+ TIDB_INLJ(t2)*/ * from t1, t2 where t1.a = t2.a and t1.b = t2.a and t1.b = t2.b"
]
},
{
"name": "TestHintWithRequiredProperty",
"cases": [
"desc format = 'brief' select /*+ INL_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.b order by t2.a",
"desc format = 'brief' select /*+ INL_HASH_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.b order by t2.a",
"desc format = 'brief' select /*+ INL_MERGE_JOIN(t2)*/ t1.a, t2.a from t t1, t t2 ,t t3 where t1.a = t2.a and t3.a=t2.a",
"desc format = 'brief' select * from t t1, (select /*+ HASH_AGG() */ b, max(a) from t t2 group by b) t2 where t1.b = t2.b order by t1.b",
"desc format = 'brief' select /*+ INL_HASH_JOIN(t2) */ distinct t2.a from t t1 join t t2 on t1.a = t2.a",
// This hint cannot work, so choose another plan.
"desc format = 'brief' select /*+ INL_JOIN(t2) */ * from t t1, t t2 where t1.a = t2.c order by t1.a"
]
},
{
"name": "TestIndexHintWarning",
"cases": [
"select /*+ USE_INDEX(t1, j) */ * from t1",
"select /*+ IGNORE_INDEX(t1, j) */ * from t1",
"select /*+ USE_INDEX(t2, a, b, c) */ * from t1",
"select /*+ USE_INDEX(t2) */ * from t1",
"select /*+ USE_INDEX(t1, a), USE_INDEX(t2, a), USE_INDEX(t3, a) */ * from t1, t2 where t1.a=t2.a",
"select /*+ USE_INDEX(t3, a), USE_INDEX(t4, b), IGNORE_INDEX(t3, a) */ * from t1, t2 where t1.a=t2.a",
"select /*+ USE_INDEX_MERGE(t3, a, b, d) */ * from t1",
"select /*+ USE_INDEX_MERGE(t1, a, b, c, d) */ * from t1",
"select /*+ USE_INDEX_MERGE(t1, a, b), USE_INDEX(t1, a) */ * from t1",
"select /*+ USE_INDEX_MERGE(t1, a, b), IGNORE_INDEX(t1, a) */ * from t1",
"select /*+ USE_INDEX_MERGE(t1, primary, a, b, c) */ * from t1"
]
},
{
"name": "TestHintWithoutTableWarning",
"cases": [
"select /*+ TIDB_SMJ() */ * from t1, t2 where t1.a=t2.a",
"select /*+ MERGE_JOIN() */ * from t1, t2 where t1.a=t2.a",
"select /*+ INL_JOIN() */ * from t1, t2 where t1.a=t2.a",
"select /*+ TIDB_INLJ() */ * from t1, t2 where t1.a=t2.a",
"select /*+ INL_HASH_JOIN() */ * from t1, t2 where t1.a=t2.a",
"select /*+ INL_MERGE_JOIN() */ * from t1, t2 where t1.a=t2.a",
"select /*+ HASH_JOIN() */ * from t1, t2 where t1.a=t2.a",
"select /*+ USE_INDEX() */ * from t1, t2 where t1.a=t2.a",
"select /*+ IGNORE_INDEX() */ * from t1, t2 where t1.a=t2.a",
"select /*+ USE_INDEX_MERGE() */ * from t1, t2 where t1.a=t2.a"
]
},
{
"name": "TestPartitionPruningForInExpr",
"cases": [
"explain format = 'brief' select * from t where a in (1, 2,'11')",
"explain format = 'brief' select * from t where a in (17, null)",
"explain format = 'brief' select * from t where a in (16, 'abc')",
"explain format = 'brief' select * from t where a in (15, 0.12, 3.47)",
"explain format = 'brief' select * from t where a in (0.12, 3.47)",
"explain format = 'brief' select * from t where a in (14, floor(3.47))",
"explain format = 'brief' select * from t where b in (3, 4)"
]
},
{
"name": "TestStreamAggProp",
"cases": [
"select /*+ stream_agg() */ count(*) c from t group by a order by c limit 1",
"select /*+ stream_agg() */ count(*) c from t group by a order by c",
"select /*+ stream_agg() */ count(*) c from t group by a order by a limit 1",
"select /*+ stream_agg() */ count(*) c from t group by a order by a"
]
},
{
"name": "TestOptimizeHintOnPartitionTable",
"cases": [
"select /*+ use_index(t) */ * from t",
"select /*+ use_index(t partition(p0, p1) b, c) */ * from t partition(p1,p2)",
"select /*+ use_index(t partition(p_non_exist)) */ * from t partition(p1,p2)",
"select /*+ use_index(t partition(p0, p1) b, c) */ * from t",
"select /*+ ignore_index(t partition(p0, p1) b, c) */ * from t",
"select /*+ hash_join(t1, t2 partition(p0)) */ * from t t1 join t t2 on t1.a = t2.a",
"select /*+ use_index_merge(t partition(p0)) */ * from t where t.b = 1 or t.c = \"8\"",
"select /*+ use_index_merge(t partition(p0, p1) primary, b) */ * from t where t.a = 1 or t.b = 2",
"select /*+ use_index(t partition(p0) b) */ * from t partition(p0, p1)"
]
},
{
"name": "TestAccessPathOnClusterIndex",
"cases": [
"select * from t1",
"select * from t1 where t1.a >= 1 and t1.a < 4",
"select * from t1 where t1.a = 1 and t1.b < \"333\"",
"select t1.a, t1.b, t1.c from t1 where t1.c = 3.3",
"select t1.b, t1.c from t1 where t1.c = 2.2",
"select /*+ use_index(t1, c) */ * from t1",
"select * from t1 use index(c) where t1.c in (2.2, 3.3)",
"select * from t1 where t1.a = 1 order by b",
"select * from t1 order by a, b limit 1",
"select /*+ use_index_merge(t1 primary, c) */ * from t1 where t1.a >= 1 or t1.c = 2.2",
"select /*+ use_index_merge(t1 primary, c) */ * from t1 where t1.a = 1 and t1.b = '111' or t1.c = 3.3"
]
},
{
"name": "TestIndexJoinOnClusteredIndex",
"cases": [
"select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a",
"select /*+ inl_merge_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a",
"select /*+ inl_hash_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a",
"select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.a = t2.a and t1.b = t2.b",
"select /*+ inl_join(t1, t2) */ * from t t1 join t t2 on t1.c = t2.c",
"select /*+ inl_merge_join(t1,t2) */ t2.a, t2.c, t2.d from t t1 left join t t2 on t1.a = t2.c;"
]
},
{
"name": "TestPartitionExplain",
"cases": [
// Table reader
"select * from pt where c > 10",
"select * from pt where c > 8",
"select * from pt where c < 2 or c >= 9",
// Index reader
"select c from pt",
"select c from pt where c > 10",
"select c from pt where c > 8",
"select c from pt where c < 2 or c >= 9",
// Index Lookup
"select /*+ use_index(pt, i_id) */ * from pt",
"select /*+ use_index(pt, i_id) */ * from pt where id < 4 and c > 10",
"select /*+ use_index(pt, i_id) */ * from pt where id < 10 and c > 8",
"select /*+ use_index(pt, i_id) */ * from pt where id < 10 and c < 2 or c >= 9",
// Partition selection
"select * from pt partition (p0) where c > 8",
"select c from pt partition (p0, p2) where c > 8",
"select /*+ use_index(pt, i_id) */ * from pt partition (p1, p2) where c < 3 and id = 5",
// Index Merge
"select * from pt where id = 4 or c < 7",
"select * from pt where id > 4 or c = 7"
]
},
{
"name": "TestInvalidHint",
"cases": [
"explain format = 'brief' select /*+ use_index_merge(tt) */ * from tt where a=10 or a=20;",
"explain format = 'brief' select /*+ use_index_merge(tt) */ * from tt where a=15 or (a < 10 or a > 20);"
]
},
{
"name": "TestApproxPercentile",
"cases": [
"select approx_percentile(a, 50) from t",
"select approx_percentile(a, 10) from t",
"select approx_percentile(a, 10+70) from t",
"select approx_percentile(a, 10*10) from t",
"select approx_percentile(a, 50) from t group by b order by b"
]
},
{
"name": "TestConvertRangeToPoint",
"cases": [
"explain format = 'brief' select * from t0 where a > 1 and a < 3 order by b limit 2",
"explain format = 'brief' select * from t1 where a >= 2 and a <= 2 and b = 2 and c > 2",
"explain format = 'brief' select * from t2 where a >= 2.5 and a <= 2.5 order by b limit 2",
"explain format = 'brief' select * from t3 where a >= 'a' and a <= 'a' and b = 'b' and c > 'c'"
]
},
{
"name": "TestIssue22105",
"cases": [
"explain format = 'brief' SELECT /*+ use_index_merge(t1)*/ COUNT(*) FROM t1 WHERE (key4=42 AND key6 IS NOT NULL) OR (key1=4 AND key3=6)"
]
},
{
"name": "TestReorderSimplifiedOuterJoins",
"cases": [
// Query with INNER JOIN or LEFT JOIN should have the same plan.
"explain format = 'brief' SELECT t1.pk FROM t1 INNER JOIN t2 ON t1.col1 = t2.pk INNER JOIN t3 ON t1.col3 = t3.pk WHERE t2.col1 IN ('a' , 'b') AND t3.keycol = 'c' AND t1.col2 = 'a' AND t1.col1 != 'abcdef' AND t1.col1 != 'aaaaaa'",
"explain format = 'brief' SELECT t1.pk FROM t1 LEFT JOIN t2 ON t1.col1 = t2.pk LEFT JOIN t3 ON t1.col3 = t3.pk WHERE t2.col1 IN ('a' , 'b') AND t3.keycol = 'c' AND t1.col2 = 'a' AND t1.col1 != 'abcdef' AND t1.col1 != 'aaaaaa'"
]
},
{
"name": "TestDecorrelateInnerJoinInSubquery",
"cases": [
// Query with WHERE or ON should have the same plan, i.e, the Apply has been decorrelated.
"explain format = 'brief' select * from t where exists (select 1 from t t1 join t t2 where t1.a = t2.a and t1.a = t.a)",
"explain format = 'brief' select * from t where exists (select 1 from t t1 join t t2 on t1.a = t2.a and t1.a = t.a)"
]
},
{
"name": "TestMultiColMaxOneRow",
"cases": [
"select (select c from t2 where t2.a = t1.a and t2.b = 1) from t1",
"select (select c from t2 where t2.a = t1.a and (t2.b = 1 or t2.b = 2)) from t1"
]
},
{
"name": "TestIssue24095",
"cases": [
"select count(*) from t join (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 1) v on v.id = t.id and v.v1 = t.value;"
]
},
{
"name": "TestSequenceAsDataSource",
"cases": [
"select 1 from s1",
"select count(1) from s1",
"select count(*) from s1",
"select sum(1) from s1",
"select count(1) as cnt from s1 union select count(1) as cnt from s2"
]
},
{
"name": "TestIsMatchProp",
"cases": [
"select a, b, c from t1 where a > 3 and b = 4 order by a, c",
"select * from t2 where a = 1 and c = 2 order by b, d",
"select a, b, c from t1 where (a = 1 and b = 1 and c = 1) or (a = 1 and b = 1 and c = 2) order by c",
"select a, b, c from t1 where (a = 1 and b = 1 and c < 3) or (a = 1 and b = 1 and c > 6) order by c",
"select * from t2 where ((a = 1 and b = 1 and d < 3) or (a = 1 and b = 1 and d > 6)) and c = 3 order by d"
]
},
{
"name": "TestHeuristicIndexSelection",
"cases": [
"select * from t1 where a = 3 or a = 5",
"select f, g from t1 where f = 2 and g in (3, 4, 5)",
"select * from t1 where c = 1 and (d = 2 or d = 3) and e in (4, 5)",
"select f, g from t1 where f = 2 and g > 3",
"select a, b, c from t2 where a = 1 and b = 2 and c in (1, 2, 3, 4, 5)",
"select * from t3 where (a = 1 or a = 3) and b = 'xx'",
"select * from t4 where (a = 1 or a = 3) and b = 'xx'",
"select a, b from t3 where (a = 1 or a = 3) and b = 'xx'",
"select a, b from t4 where (a = 1 or a = 3) and b = 'xx'",
"update t1 set b = 2 where a = 4 or a = 6",
"delete from t1 where f = 2 and g in (3, 4)",
"insert into t3 select a, b, c from t1 where f = 2",
"replace into t3 select a, b, c from t1 where a = 3"
]
},
{
"name": "TestOutputSkylinePruningInfo",
"cases": [
"select * from t where a > 1 order by f",
"select * from t where f > 1",
"select f from t where f > 1",
"select * from t where f > 3 and g = 5",
"select * from t where g = 5 order by f",
"select * from t where d = 3 order by c, e"
]
},
{
"name": "TestPreferRangeScanForUnsignedIntHandle",
"cases": [
"set tidb_opt_prefer_range_scan = 0",
"explain format = 'verbose' select * from t where b > 5",
"explain format = 'verbose' select * from t where b = 6 order by a limit 1",
"explain format = 'verbose' select * from t where b = 6 limit 1",
"set tidb_opt_prefer_range_scan = 1",
"explain format = 'verbose' select * from t where b > 5",
"explain format = 'verbose' select * from t where b = 6 order by a limit 1",
"explain format = 'verbose' select * from t where b = 6 limit 1"
]
},
{
"name": "TestIssue27083",
"cases": [
"select * from t use index (idx_b) where b = 2 limit 1"
]
},
{
"name": "TestGroupBySetVar",
"cases": [
"select floor(dt.rn/2) rownum, count(c1) from (select @rownum := @rownum + 1 rn, c1 from (select @rownum := -1) drn, t1) dt group by floor(dt.rn/2) order by rownum;",
// TODO: fix these two cases
"select @n:=@n+1 as e from ta group by e",
"select @n:=@n+a as e from ta group by e",
"select * from (select @n:=@n+1 as e from ta) tt group by e",
"select * from (select @n:=@n+a as e from ta) tt group by e",
"select a from ta group by @n:=@n+1",
"select a from ta group by @n:=@n+a"
]
},
{
"name": "TestIssue30200",
"cases": [
// to_base64 and from_base64 has not been pushed to TiKV or TiFlash.
// We expect a Selection will be added above IndexMerge.
"select /*+ use_index_merge(t1) */ 1 from t1 where c1 = 'de' or c2 = '10' and from_base64(to_base64(c1)) = 'ab';",
// `left` has not been pushed to TiKV, but it has been pushed to TiFlash.
// We expect a Selection will be added above IndexMerge.
"select /*+ use_index_merge(t1) */ 1 from t1 where c1 = 'ab' or c2 = '10' and char_length(left(c1, 10)) = 10;",
// c3 is part of idx_1, so it will be put in partial_path's IndexFilters instead of TableFilters.
// But it still cannot be pushed to TiKV. This case cover code in DataSource.buildIndexMergeOrPath.
"select /*+ use_index_merge(tt1) */ 1 from tt1 where c1 = 'de' or c2 = '10' and from_base64(to_base64(c3)) = '10';",
// to_base64(left(pk, 5)) is in partial_path's TableFilters. But it cannot be pushed to TiKV.
// So it should be executed in TiDB. This case cover code in DataSource.buildIndexMergeOrPath.
"select /*+ use_index_merge( tt2 ) */ 1 from tt2 where tt2.c1 in (-3896405) or tt2.pk in (1, 53330) and to_base64(left(pk, 5));",
// This case covert expression index.
"select /*+ use_index_merge(tt3) */ 1 from tt3 where c1 < -10 or c2 < 10 and reverse(c3) = '2';",
// If no hint, we cannot use index merge if filter cannot be pushed to any storage.
"select 1 from t1 where c1 = 'de' or c2 = '10' and from_base64(to_base64(c1)) = 'ab';"
]
},
{
"name": "TestIndexMergeWithCorrelatedColumns",
"cases": [
"select * from t2 where c1 < all(select /*+ use_index_merge(t1) */ c1 from t1 where (c1 = 10 and c1 = t2.c3 or c2 = 1 and c2 = t2.c3) and substring(c3, 10)) order by c1;",
"select * from t2 where c1 < all(select /*+ use_index_merge(t1) */ c1 from t1 where (c1 = 10 and c1 = t2.c3 or c2 = 1 and c2 = t2.c3) and reverse(c3)) order by c1;",
"select * from t2 where c1 < all(select /*+ use_index_merge(t1) */ c1 from t1 where (c1 >= 10 and c1 = t2.c3 or c2 = 1 and c2 = t2.c3) and substring(c3, 10)) order by c1;",
// Test correlated column in IndexPath.TableFilters.
"select c_int from tt1 where c_decimal < all (select /*+ use_index_merge(tt2) */ c_decimal from tt2 where tt1.c_int = tt2.c_int and tt1.c_datetime > tt2.c_datetime and tt2.c_decimal = 9.060 or tt2.c_str <= 'interesting shtern' and tt1.c_int = tt2.c_int) order by 1;",
// Test correlated column in TablePath.TableFilters.
"select c_int from tt1 where c_decimal > all (select /*+ use_index_merge(tt2) */ c_decimal from tt2 where tt2.c_int = 7 and tt2.c_int < tt1.c_decimal or tt2.c_str >= 'zzzzzzzzzzzzzzzzzzz' and tt1.c_int = tt2.c_int) order by 1;"
]
},
{
"name": "TestIssue31240",
"cases": [
"explain format = 'brief' select count(*) from t31240;",
"set @@tidb_isolation_read_engines=\"tiflash,tidb\";",
"explain format = 'brief' select count(*) from t31240;"
]
},
{
"name": "TestSelPushDownTiFlash",
"cases": [
"explain format = 'brief' select * from t where t.a > 1 and t.b = \"flash\" or t.a + 3 * t.a = 5",
"explain format = 'brief' select * from t where cast(t.a as double) + 3 = 5.1",
"explain format = 'brief' select * from t where b > 'a' order by convert(b, unsigned) limit 2",
"explain format = 'brief' select * from t where b > 'a' order by b limit 2"
]
},
{
"name": "TestVerboseExplain",
"cases": [
"explain format = 'verbose' select count(*) from t3",
"explain format = 'verbose' select count(*) from t2",
"explain format = 'verbose' select * from t3 order by a",
"explain format = 'verbose' select * from t3 order by b",
"explain format = 'verbose' select * from t3 order by a limit 1",
"explain format = 'verbose' select * from t3 order by b limit 1",
"explain format = 'verbose' select count(*) from t2 group by a",
"explain format = 'verbose' select count(*) from t3 where b = 0",
"explain format = 'verbose' select /*+ use_index(t3, c) */ count(a) from t3 where b = 0",
"explain format = 'verbose' select count(*) from t2 where a = 0",
"explain format = 'verbose' select count(*) from t3 t join t3 on t.a = t3.b",
"explain format = 'verbose' select count(*) from t1 join t2 on t1.a = t2.a",
"explain format = 'verbose' select count(*) from t1 join t2 on t1.a = t2.a join t3 on t1.b = t3.b",
"explain format = 'verbose' select (2) in (select count(*) from t1) from (select t.b < (select t.b from t2 limit 1 ) from t3 t) t",
"explain format = 'verbose' select /*+ merge_join(t1) */ count(*) from t1 join t2 on t1.a = t2.a"
]
},
{
"name": "TestRegardNULLAsPoint",
"cases": [
"select * from tuk where a<=>null and b=1",
"select * from tik where a<=>null and b=1",
"select * from tuk where a<=>null and b>0 and b<2",
"select * from tik where a<=>null and b>0 and b<2",
"select * from tuk where a<=>null and b>=1 and b<2",
"select * from tik where a<=>null and b>=1 and b<2",
"select * from tuk where a<=>null and b=1 and c=1",
"select * from tik where a<=>null and b=1 and c=1",
"select * from tuk where a=1 and b<=>null and c=1",
"select * from tik where a=1 and b<=>null and c=1",
"select * from tuk where a<=>null and b<=>null and c=1",
"select * from tik where a<=>null and b<=>null and c=1",
"select * from tuk where a<=>null and b<=>null and c<=>null",
"select * from tik where a<=>null and b<=>null and c<=>null"
]
},
{
"name": "TestPushDownToTiFlashWithKeepOrder",
"cases": [
"explain format = 'brief' select max(a) from t",
"explain format = 'brief' select min(a) from t"
]
},
{
"name": "TestMPPJoin",
"cases": [
"explain format = 'brief' select count(*) from fact_t, d1_t where fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t, d1_t, d2_t, d3_t where fact_t.d1_k = d1_t.d1_k and fact_t.d2_k = d2_t.d2_k and fact_t.d3_k = d3_t.d3_k",
"explain format = 'brief' select count(*) from fact_t, d1_t where fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 10",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col2 > 10 and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10 and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t where exists (select 1 from d1_t where d1_k = fact_t.d1_k)",
"explain format = 'brief' select count(*) from fact_t where exists (select 1 from d1_t where d1_k = fact_t.d1_k and value > fact_t.col1)",
"explain format = 'brief' select count(*) from fact_t where not exists (select 1 from d1_t where d1_k = fact_t.d1_k)",
"explain format = 'brief' select count(*) from fact_t where not exists (select 1 from d1_t where d1_k = fact_t.d1_k and value > fact_t.col1)",
"explain format = 'brief' select count(*) from fact_t join d1_t on fact_t.d1_k > d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k > d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k > d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t where d1_k not in (select d1_k from d1_t)"
]
},
{
"name": "TestMPPLeftSemiJoin",
"cases": [
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.a in (select a from test.t); -- left semi",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.a in (select a from test.t where b<t1.b); ",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.a not in (select a from test.t); -- left anti",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.a not in (select a from test.t where b<t1.b);",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.b in (select a from test.t); -- cartesian left semi",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.a in (select b from test.t where b<t1.b);",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.b not in (select a from test.t); -- cartesian left anti",
"explain format = 'brief' select * from test.t t1 where t1.a>1 or t1.b not in (select a from test.t where b<t1.b);",
"explain format = 'brief' select a in (select a from test.t), a not in (select a from test.t) from test.t; -- semi join as scalar",
"explain format = 'brief' select a in (select b from test.t), a not in (select b from test.t) from test.t;",
"explain format = 'brief' select b in (select a from test.t), b not in (select a from test.t) from test.t;",
"explain format = 'brief' select b in (select b from test.t), b not in (select b from test.t) from test.t;",
"explain format = 'brief' select a, b, a in (select a from test.t), a in (select b from test.t), b in (select a from test.t), b in (select b from test.t), a not in (select a from test.t), a not in (select b from test.t), b not in (select a from test.t), b not in (select b from test.t) from test.t;"
]
},
{
"name": "TestMPPOuterJoinBuildSideForBroadcastJoin",
"cases": [
"explain format = 'brief' select count(*) from a left join b on a.id = b.id",
"explain format = 'brief' select count(*) from b right join a on a.id = b.id"
]
},
{
"name": "TestMPPOuterJoinBuildSideForShuffleJoinWithFixedBuildSide",
"cases": [
"explain format = 'brief' select count(*) from a left join b on a.id = b.id",
"explain format = 'brief' select count(*) from b right join a on a.id = b.id"
]
},
{
"name": "TestMPPOuterJoinBuildSideForShuffleJoin",
"cases": [
"explain format = 'brief' select count(*) from a left join b on a.id = b.id",
"explain format = 'brief' select count(*) from b right join a on a.id = b.id"
]
},
{
"name": "TestMPPShuffledJoin",
"cases": [
"explain format = 'brief' select count(*) from fact_t, d1_t where fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t, d1_t, d2_t, d3_t where fact_t.d1_k = d1_t.d1_k and fact_t.d2_k = d2_t.d2_k and fact_t.d3_k = d3_t.d3_k",
"explain format = 'brief' select count(*) from fact_t, d1_t where fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t, d1_t, d2_t, d3_t where fact_t.d1_k = d1_t.d1_k and fact_t.d1_k = d2_t.value and fact_t.d1_k = d3_t.value",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k",
"explain format = 'brief' select count(*) from fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 10",
"explain format = 'brief' select count(*) from (select case when t1.col1 is null then t2.col1 + 5 else 10 end as col1, t2.d1_k as d1_k from fact_t t1 right join fact_t t2 on t1.d1_k = t2.d1_k) fact_t join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col1 > 5",
"explain format = 'brief' select count(*) from fact_t left join d1_t on fact_t.d1_k = d1_t.d1_k and fact_t.col2 > 10 and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10",
"explain format = 'brief' select count(*) from fact_t right join d1_t on fact_t.d1_k = d1_t.d1_k and d1_t.value > 10 and fact_t.col1 > d1_t.value",
"explain format = 'brief' select count(*) from fact_t where exists (select 1 from d1_t where d1_k = fact_t.d1_k)",
"explain format = 'brief' select count(*) from fact_t where exists (select 1 from d1_t where d1_k = fact_t.d1_k and value > fact_t.col1)",
"explain format = 'brief' select count(*) from fact_t where not exists (select 1 from d1_t where d1_k = fact_t.d1_k)",
"explain format = 'brief' select count(*) from fact_t where not exists (select 1 from d1_t where d1_k = fact_t.d1_k and value > fact_t.col1)"
]
},
{
"name": "TestMPPJoinWithCanNotFoundColumnInSchemaColumnsError",
"cases": [
"explain format = 'brief' select v from t3 as a left join (select t1.v1, t1.v2, t1.v1 + t1.v2 as v from t1 left join t2 on t1.v1 = t2.v1 and t1.v2 = t2.v2) b on a.v1 = b.v1 and a.v2 = b.v2",
"explain format = 'brief' select count(*), t2.v1, t2.v2 from t1 left join t2 on t1.v1 = t2.v1 and t1.v2 = t2.v2 group by t2.v1, t2.v2",
"explain format = 'brief' select count(*), t2.v1, t2.v2 from t3 left join t2 on t3.v1 = t2.v1 and t3.v2 = t2.v2 group by t2.v1, t2.v2"
]
},
{
"name": "TestJoinNotSupportedByTiFlash",
"cases": [
"explain format = 'brief' select * from table_1 a, table_1 b where a.bit_col = b.bit_col",
"explain format = 'brief' select * from table_1 a left join table_1 b on a.id = b.id and dayofmonth(a.datetime_col) > 100",
"explain format = 'brief' select * from table_1 a right join table_1 b on a.id = b.id and dayofmonth(b.datetime_col) > 100",
"explain format = 'brief' select * from table_1 a join table_1 b on a.id = b.id and dayofmonth(a.datetime_col) > dayofmonth(b.datetime_col)"
]
},
{
"name": "TestMPPWithHashExchangeUnderNewCollation",
"cases": [
"explain format = 'brief' select * from table_1 a, table_1 b where a.value = b.value",
"explain format = 'brief' select * from table_1 a, table_2 b where a.value = b.value",
"explain format = 'brief' select * from table_1 a, table_2 b, table_1 c where a.value = b.value and b.value = c.value",
"explain format = 'brief' select * from table_1 a, table_2 b, table_1 c where a.value = b.value and a.value = c.value",
"explain format = 'brief' select /*+ agg_to_cop() */ count(*), value from table_1 group by value",
"explain format = 'brief' select /*+ agg_to_cop() */ count(*), value from table_2 group by value"
]
},
{
"name": "TestMPPWithBroadcastExchangeUnderNewCollation",
"cases": [
"explain format = 'brief' select /*+ broadcast_join(a,b) */ * from table_1 a, table_1 b where a.id = b.id",
"explain format = 'brief' select /*+ broadcast_join(a,b) */ * from table_1 a, table_1 b where a.value = b.value"
]
},
{
"name": "TestMPPAvgRewrite",
"cases": [
"explain format = 'brief' select /*+ avg_to_cop() */ id, avg(value+1),avg(value) from table_1 group by id"
]
},
{
"name": "TestReadFromStorageHint",
"cases": [
"desc format = 'brief' select avg(a) from t",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ avg(a) from t",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ sum(a) from t",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ sum(a+1) from t",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ sum(isnull(a)) from t",
"desc format = 'brief' select /*+ READ_FROM_STORAGE(TIKV[t1], TIKV[t2]) */ * from t t1, t t2 where t1.a = t2.a",
"desc format = 'brief' select /*+ READ_FROM_STORAGE(TIKV[t1], TIFLASH[t2]) */ * from t t1, t t2 where t1.a = t2.a",
"desc format = 'brief' select * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55)",
"desc format = 'brief' select /*+ read_from_storage(tiflash[tt]) */ * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55)",
"desc format = 'brief' select * from ttt order by ttt.a desc",
"desc format = 'brief' select /*+ read_from_storage(tiflash[ttt]) */ * from ttt order by ttt.a desc",
"desc format = 'brief' select /*+ read_from_storage(tiflash[ttt]) */ * from ttt order by ttt.a",
"desc format = 'brief' select /*+ read_from_storage(tikv[t, ttt]) */ * from ttt",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t, ttt], tikv[tt]) */ * from ttt"
]
},
{
"name": "TestReadFromStorageHintAndIsolationRead",
"cases": [
"desc format = 'brief' select /*+ read_from_storage(tikv[t], tiflash[t]) */ avg(a) from t",
"desc format = 'brief' select /*+ read_from_storage(tikv[t]) */ avg(a) from t",
"desc format = 'brief' select /*+ read_from_storage(tiflash[t]) */ avg(a) from t"
]
},
{
"name": "TestIsolationReadDoNotFilterSystemDB",
"cases": [
"desc format = 'brief' select * from metrics_schema.tidb_query_duration where time >= '2019-12-23 16:10:13' and time <= '2019-12-23 16:30:13'",
"desc format = 'brief' select * from information_schema.tables",
"desc format = 'brief' select * from mysql.stats_meta"
]
},
{
"name": "TestIsolationReadTiFlashNotChoosePointGet",
"cases": [
"explain format = 'brief' select * from t where t.a = 1",
"explain format = 'brief' select * from t where t.a in (1, 2)"
]
},
{
"name": "TestIsolationReadTiFlashUseIndexHint",
"cases": [
"explain format = 'brief' select * from t",
"explain format = 'brief' select * from t use index();",
"explain format = 'brief' select /*+ use_index(t, idx)*/ * from t",
"explain format = 'brief' select /*+ use_index(t)*/ * from t"
]
},
{
"name": "TestIssue20710",
"cases": [
"explain format = 'brief' select /*+ inl_join(s) */ * from t join s on t.a=s.a and t.b = s.b",
"explain format = 'brief' select /*+ inl_join(s) */ * from t join s on t.a=s.a and t.b = s.a",
"explain format = 'brief' select /*+ inl_join(s) */ * from t join s on t.a=s.a and t.a = s.b",
"explain format = 'brief' select /*+ inl_hash_join(s) */ * from t join s on t.a=s.a and t.b = s.b",
"explain format = 'brief' select /*+ inl_hash_join(s) */ * from t join s on t.a=s.a and t.b = s.a",
"explain format = 'brief' select /*+ inl_hash_join(s) */ * from t join s on t.a=s.a and t.a = s.b"
]
},
{
"name": "TestPushDownProjectionForTiFlash",
"cases": [
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select * from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select * from t join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t left join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t right join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select A.b, B.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select A.id from t as A where exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select A.id from t as A where not exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;"
]
},
{
"name": "TestPushDownProjectionForMPP",
"cases": [
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ count(*) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ stream_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select B.b+A.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select * from t join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t left join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select * from t right join (select id-2 as b from t) A on A.b=t.id",
"desc format = 'brief' select A.b, B.b from (select id-2 as b from t) B join (select id-2 as b from t) A on A.b=B.b",
"desc format = 'brief' select id from t as A where exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select id from t as A where not exists (select 1 from t where t.id=A.id)",
"desc format = 'brief' select b*2, id from (select avg(value+2) as b, id from t group by id) C order by id",
"desc format = 'brief' SELECT FROM_UNIXTIME(name,'%Y-%m-%d') FROM t;"
]
},
{
"name": "TestMppUnionAll",
"cases": [
"explain format = 'brief' select count(*) from (select a , b from t union all select a , b from t1) tt",
"explain format = 'brief' select count(*) from (select a , b from t union all select a , b from t1 union all select a, b from t where false) tt",
"explain format = 'brief' select count(*) from (select a , b from t union all select a , c from t1) tt",
"explain format = 'brief' select count(*) from (select a , b from t union all select a , c from t1 where false) tt",
"explain format = 'brief' select count(*) from (select a , b from t where false union all select a , c from t1 where false) tt"
]
},
{
"name": "TestMppJoinDecimal",
"cases": [
"desc format = 'brief' select t1.c1, t1.c2, t2.c1, t2.c2, t2.c3 from t t1 join t t2 on t1.c1 + 1 = t2.c2 - 10 and t1.c1 * 3 = t2.c3 / 2",
"desc format = 'brief' select * from (select c1, c2, c5, count(*) c from t group by c1, c2, c5) t1 join (select c1, c2, c3, count(*) c from t group by c1, c2, c3) t2 on t1.c1 = t2.c2 and t1.c2 = t2.c3 and t1.c5 = t2.c1",
"desc format = 'brief' select * from t t1 join t t2 on t1.c1 = t2.c2 and t1.c2 = t2.c2 and t1.c3 = t2.c3 and t1.c4 = t2.c4 and t1.c5 = t2.c5",
"desc format = 'brief' select * from t t1 join t t2 on t1.c1 = t2.c2 and t1.c2 = t2.c3 and t1.c3 = t2.c1 and t1.c4 = t2.c3 and t1.c1 = t2.c5",
"desc format = 'brief' select * from t t1 join t t2 on t1.c1 + t1.c2 = t2.c2 / t2.c3",
"desc format = 'brief' select * from t t1 where exists (select * from t t2 where t1.c1 = t2.c2 and t1.c2 = t2.c3 and t1.c3 = t2.c1 and t1.c4 = t2.c3 and t1.c1 = t2.c5)",
"desc format = 'brief' select * from t t1 left join t t2 on t1.c1 = t2.c2 join t t3 on t2.c5 = t3.c3 right join t t4 on t3.c3 = t4.c4 ",
"desc format = 'brief' SELECT STRAIGHT_JOIN t1 . col_varchar_64 , t1 . col_char_64_not_null FROM tt AS t1 INNER JOIN( tt AS t2 JOIN tt AS t3 ON(t3 . col_decimal_30_10_key = t2 . col_tinyint)) ON(t3 . col_varchar_64 = t2 . col_varchar_key) WHERE t3 . col_varchar_64 = t1 . col_char_64_not_null GROUP BY 1 , 2"
]
},
{
"name": "TestPushDownAggForMPP",
"cases": [
"desc format = 'brief' select /*+ hash_agg()*/ count(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ count(*) from (select id+1 from t)A",
"desc format = 'brief' select /*+ hash_agg()*/ sum(b) from (select id + 1 as b from t)A",
"desc format = 'brief' select count(*) from t",
"desc format = 'brief' select count(*), id from t group by id",
"desc format = 'brief' select count(*), id + 1 from t group by id + 1",
"desc format = 'brief' select * from t join ( select count(*), id from t group by id) as A on A.id = t.id",
"desc format = 'brief' select * from t join ( select /*+ hash_agg()*/ count(*) as a from t) as A on A.a = t.id",
"desc format = 'brief' select avg(value) as b,id from t group by id",
"desc format = 'brief' select /*+hash_agg()*/ sum(b) from (select avg(value) as b, id from t group by id)A",
"desc format = 'brief' select id from t group by id having avg(value)>0",
"desc format = 'brief' select avg(value),id from t group by id having avg(value)>0",
"desc format = 'brief' select avg(value) +1,id from t group by id",
"desc format = 'brief' select sum(b) from (select t.id, t1.id as b from t join t t1 on t.id=t1.id)A group by id",
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id",
"desc format = 'brief' select count(distinct value),id from t group by id",
"desc format = 'brief' select count(distinct value),sum(distinct value),id from t group by id",
"desc format = 'brief' select * from t join ( select count(distinct value), id from t group by id) as A on A.id = t.id",
"desc format = 'brief' select * from t join ( select count(1/value), id from t group by id) as A on A.id = t.id",
"desc format = 'brief' select /*+hash_agg()*/ sum(id) from (select value, id from t where id > value group by id, value)A group by value /*the exchange should have only one partition column: test.t.value*/",
"desc format = 'brief' select /*+hash_agg()*/ sum(B.value) from t as B where B.id+1 > (select count(*) from t where t.id= B.id and t.value=B.value) group by B.id /*the exchange should have only one partition column: test.t.id*/",
"desc format = 'brief' select count(distinct value) from t",
"desc format = 'brief' select count(distinct x ) from (select count(distinct value) x from t) t",
"desc format = 'brief' select count(distinct value), count(value), avg(value) from t"
]
},
{
"name": "TestMppAggTopNWithJoin",
"cases": [
"desc format = 'brief' select * from t join ( select count(*), id from t group by id) as A on A.id = t.id",
"desc format = 'brief' select * from t join ( select count(*)+id as v from t group by id) as A on A.v = t.id",
"desc format = 'brief' select * from t join ( select count(*) as v, id from t group by value,id having value+v <10) as A on A.id = t.id",
"desc format = 'brief' select * from t join ( select /*+ hash_agg()*/ count(*) as a from t) as A on A.a = t.id",
"desc format = 'brief' select sum(b) from (select t.id, t1.id as b from t join t t1 on t.id=t1.id)A group by id",
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(value),id from t group by id)B on C.id=B.id",
"desc format = 'brief' select * from (select id from t group by id) C join (select sum(b),id from (select t.id, t1.id as b from t join (select id, count(*) as c from t group by id) t1 on t.id=t1.id)A group by id)B on C.id=b.id",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value limit 1",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id order by t.value % 100 limit 1",
"desc format = 'brief' select count(*) from (select t.id, t.value v1 from t join t t1 on t.id = t1.id order by t.value limit 20) v group by v.v1",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id limit 1",
"desc format = 'brief' select * from t join t t1 on t.id = t1.id limit 1",
"desc format = 'brief' select count(*) from (select t.id, t.value v1 from t join t t1 on t.id = t1.id limit 20) v group by v.v1"
]
},
{
"name": "TestIndexMergeSerial",
"cases": [
"desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and b+2>1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where a =1 or (b=1 and length(b)=1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(a)=1) or (b=1 and length(b)=1)",
"desc format='brief' select /*+ use_index_merge(t) */ * from t where (a=1 and length(b)=1) or (b=1 and length(a)=1)"
]
},
{
"name": "TestLimitIndexLookUpKeepOrder",
"cases": [
"desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b,c limit 10",
"desc format = 'brief' select * from t where a = 1 and b > 2 and b < 10 and d = 10 order by b desc, c desc limit 10"
]
},
{
"name": "TestIssue23887",
"cases": [
"select (2) in (select b from t) from (select t.a < (select t.a from t t1 limit 1) from t) t"
]
},
{
"name": "TestMergeContinuousSelections",
"cases": [
"desc format = 'brief' SELECT table2 . `col_char_64` AS field1 FROM `ts` AS table2 INNER JOIN (SELECT DISTINCT SUBQUERY3_t1 . * FROM `ts` AS SUBQUERY3_t1 LEFT OUTER JOIN `ts` AS SUBQUERY3_t2 ON SUBQUERY3_t2 . `col_varchar_64_not_null` = SUBQUERY3_t1 . `col_varchar_key`) AS table3 ON (table3 . `col_varchar_key` = table2 . `col_varchar_64`) WHERE table3 . `col_char_64_not_null` >= SOME (SELECT SUBQUERY4_t1 . `col_varchar_64` AS SUBQUERY4_field1 FROM `ts` AS SUBQUERY4_t1) GROUP BY field1 ;"
]
},
{
"name": "TestPushDownGroupConcatToTiFlash",
"cases": [
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id order by col_0) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id order by col_0) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id order by col_0),count(*),min(col_1) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id order by col_0),count(*),max(col_0) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id order by col_0) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id order by col_0) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_1, id order by col_0) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_1, id order by col_0) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id order by col_0),count(*),min(col_0),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id order by col_0),count(*),max(col_1),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id order by col_0),count(distinct id),min(col_0),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id order by col_0),count(distinct id),max(col_1),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id),count(distinct id),min(col_0),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id),count(distinct id),max(col_1),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id),count(distinct id),min(col_0),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id),count(distinct id),max(col_1),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_1, id),count(distinct id),group_concat(col_0 order by 1),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0),count(distinct id),group_concat(col_1, id order by 1,2),avg(id) from ts group by col_2",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, id),count(distinct id),group_concat(col_1, id order by 1,2),min(col_0),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id),count(distinct id),group_concat(col_1, id order by 1,2),max(col_1),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id),count(distinct col_2),group_concat(col_1, id),max(col_1),avg(id) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0, col_1, id),count(distinct col_2),group_concat(col_1, id),max(col_1),avg(id) from ts group by col_0",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,'GG') from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,'01') from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,1) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,0) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,10) from ts group by '010'",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,0) from ts group by '011'",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 0,'GG') from ts group by 'GG'",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 'GG','GG') from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 'Gg','GG') from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct 'GG-10','GG') from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct '1200-01-01 00:00:00.023',1200) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_0) from ts group by id",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(col_0, col_0,id) from ts group by id",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0 order by id<10) from ts",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0 order by id<10) from ts group by col_1",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0>10 order by id<10) from ts group by col_1",
"desc format = 'brief' select /*+ hash_agg(),agg_to_cop() */ group_concat(distinct col_0 order by col_0<=>null) from ts"
]
},
{
"name": "TestRejectSortForMPP",
"cases": [
"desc format = 'brief' select count(*) from (select * from t order by id)a group by name,id order by id",
"desc format = 'brief' select count(*) from (select * from t order by id)a group by name order by 1",
"desc format = 'brief' select count(*) from (select id,name from t group by id,name order by id,name)a group by name order by 1",
"desc format = 'brief' select * from (select id from t group by id order by id)a join t on a.id=t.id order by 1",
"desc format = 'brief' select * from (select * from t order by id)a join t on a.id=t.id order by 1",
"desc format = 'brief' select * from ((select id from t order by 1) union all (select id+1 from t order by 1))c",
"desc format = 'brief' select * from ((select count(*) from (select id,name from t order by id)a group by name,id order by id) union all (select id+1 from t order by 1))c",
"desc format = 'brief' select * from (select * from t order by id)a order by name"
]
},
{
"name": "TestIssue32632",
"cases": [
"explain format = 'brief' select sum(ps_supplycost) from partsupp, supplier where ps_suppkey = s_suppkey;"
]
}
]