Skip to content

Commit fc3bbf3

Browse files
authored
feat(p3): new leaderboard q1 (#537)
Signed-off-by: Alex Chi <[email protected]>
1 parent 345f05a commit fc3bbf3

File tree

4 files changed

+66
-53
lines changed

4 files changed

+66
-53
lines changed

src/execution/mock_scan_executor.cpp

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const char *mock_table_list[] = {"__mock_table_1", "__mock_table_2", "__mock_tab
4242
"__mock_table_schedule_2022", "__mock_table_schedule_2023", "__mock_table_123",
4343
"__mock_graph",
4444
// For leaderboard Q1
45-
"__mock_t1_50k", "__mock_t2_100k", "__mock_t3_1k",
45+
"__mock_t1",
4646
// For leaderboard Q2
4747
"__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m",
4848
// For leaderboard Q3
@@ -95,11 +95,15 @@ auto GetMockTableSchemaOf(const std::string &table) -> Schema {
9595
return Schema{std::vector{Column{"number", TypeId::INTEGER}}};
9696
}
9797

98-
if (table == "__mock_t1_50k" || table == "__mock_t2_100k" || table == "__mock_t3_1k" || table == "__mock_t4_1m" ||
99-
table == "__mock_t5_1m" || table == "__mock_t6_1m") {
98+
if (table == "__mock_t4_1m" || table == "__mock_t5_1m" || table == "__mock_t6_1m") {
10099
return Schema{std::vector{Column{"x", TypeId::INTEGER}, Column{"y", TypeId::INTEGER}}};
101100
}
102101

102+
if (table == "__mock_t1") {
103+
return Schema{
104+
std::vector{Column{"x", TypeId::INTEGER}, Column{"y", TypeId::INTEGER}, Column{"z", TypeId::INTEGER}}};
105+
}
106+
103107
if (table == "__mock_t7") {
104108
return Schema{
105109
std::vector{Column{"v", TypeId::INTEGER}, Column{"v1", TypeId::INTEGER}, Column{"v2", TypeId::INTEGER}}};
@@ -159,16 +163,8 @@ auto GetSizeOf(const MockScanPlanNode *plan) -> size_t {
159163
return 3;
160164
}
161165

162-
if (table == "__mock_t1_50k") {
163-
return 50000;
164-
}
165-
166-
if (table == "__mock_t2_100k") {
167-
return 100000;
168-
}
169-
170-
if (table == "__mock_t3_1k") {
171-
return 1000;
166+
if (table == "__mock_t1") {
167+
return 1000000;
172168
}
173169

174170
if (table == "__mock_t4_1m" || table == "__mock_t5_1m" || table == "__mock_t6_1m") {
@@ -189,7 +185,7 @@ auto GetSizeOf(const MockScanPlanNode *plan) -> size_t {
189185
auto GetShuffled(const MockScanPlanNode *plan) -> bool {
190186
const auto &table = plan->GetTable();
191187

192-
if (table == "__mock_t1_50k") {
188+
if (table == "__mock_t1") {
193189
return true;
194190
}
195191

@@ -332,29 +328,12 @@ auto GetFunctionOf(const MockScanPlanNode *plan) -> std::function<Tuple(size_t)>
332328
};
333329
}
334330

335-
if (table == "__mock_t1_50k") {
336-
return [plan](size_t cursor) {
337-
std::vector<Value> values{};
338-
values.push_back(ValueFactory::GetIntegerValue(cursor * 10));
339-
values.push_back(ValueFactory::GetIntegerValue(cursor * 1000));
340-
return Tuple{values, &plan->OutputSchema()};
341-
};
342-
}
343-
344-
if (table == "__mock_t2_100k") {
331+
if (table == "__mock_t1") {
345332
return [plan](size_t cursor) {
346333
std::vector<Value> values{};
334+
values.push_back(ValueFactory::GetIntegerValue(cursor / 10000));
335+
values.push_back(ValueFactory::GetIntegerValue(cursor % 10000));
347336
values.push_back(ValueFactory::GetIntegerValue(cursor));
348-
values.push_back(ValueFactory::GetIntegerValue(cursor * 100));
349-
return Tuple{values, &plan->OutputSchema()};
350-
};
351-
}
352-
353-
if (table == "__mock_t3_1k") {
354-
return [plan](size_t cursor) {
355-
std::vector<Value> values{};
356-
values.push_back(ValueFactory::GetIntegerValue(cursor * 100));
357-
values.push_back(ValueFactory::GetIntegerValue(cursor * 10000));
358337
return Tuple{values, &plan->OutputSchema()};
359338
};
360339
}

test/sql/p3.leaderboard-q1.slt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
statement ok
2-
create table t1_50k(x int, y int);
2+
create table t1(x int, y int, z int);
33

44
statement ok
5-
create index t1x on t1_50k(x);
5+
create index t1xy on t1(x, y);
66

77
query
8-
INSERT INTO t1_50k SELECT * FROM __mock_t1_50k;
8+
INSERT INTO t1 SELECT * FROM __mock_t1;
99
----
10-
50000
10+
1000000
1111

1212
statement ok
13-
explain (o) select count(*), max(t1_50k.x), max(t1_50k.y), max(__mock_t2_100k.x), max(__mock_t2_100k.y), max(__mock_t3_1k.x), max(__mock_t3_1k.y) from (
14-
t1_50k inner join __mock_t2_100k on t1_50k.x = __mock_t2_100k.x
15-
) inner join __mock_t3_1k on __mock_t2_100k.y = __mock_t3_1k.y;
13+
explain (o) select * from t1 where x >= 90 and y = 10;
1614

17-
query +timing:x10:.q1
18-
select count(*), max(t1_50k.x), max(t1_50k.y), max(__mock_t2_100k.x), max(__mock_t2_100k.y), max(__mock_t3_1k.x), max(__mock_t3_1k.y) from (
19-
t1_50k inner join __mock_t2_100k on t1_50k.x = __mock_t2_100k.x
20-
) inner join __mock_t3_1k on __mock_t2_100k.y = __mock_t3_1k.y;
15+
query rowsort +timing:x10:.q1
16+
select * from t1 where x >= 90 and y = 10;
2117
----
22-
1000 99900 9990000 99900 9990000 99900 9990000
18+
91 10 910010
19+
92 10 920010
20+
95 10 950010
21+
93 10 930010
22+
98 10 980010
23+
96 10 960010
24+
90 10 900010
25+
99 10 990010
26+
97 10 970010
27+
94 10 940010

test/sql/p3.leaderboard-q2.slt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
statement ok
22
explain (o) select count(*), max(__mock_t4_1m.x), max(__mock_t4_1m.y), max(__mock_t5_1m.x), max(__mock_t5_1m.y), max(__mock_t6_1m.x), max(__mock_t6_1m.y)
3-
from (select * from __mock_t4_1m, __mock_t5_1m where __mock_t4_1m.x = __mock_t5_1m.x), __mock_t6_1m
4-
where (__mock_t6_1m.y = __mock_t5_1m.y)
5-
and (__mock_t4_1m.y >= 1000000) and (__mock_t4_1m.y < 1500000) and (__mock_t6_1m.x < 150000) and (__mock_t6_1m.x >= 100000);
3+
from __mock_t4_1m, __mock_t5_1m, __mock_t6_1m
4+
where (__mock_t4_1m.x = __mock_t5_1m.x)
5+
and (__mock_t6_1m.y = __mock_t5_1m.y)
6+
and (__mock_t4_1m.y >= 1000000)
7+
and (__mock_t4_1m.y < 1500000)
8+
and (__mock_t6_1m.x < 150000)
9+
and (__mock_t6_1m.x >= 100000);
610

711
query +timing:x10:.q2
812
select count(*), max(__mock_t4_1m.x), max(__mock_t4_1m.y), max(__mock_t5_1m.x), max(__mock_t5_1m.y), max(__mock_t6_1m.x), max(__mock_t6_1m.y)
9-
from (select * from __mock_t4_1m, __mock_t5_1m where __mock_t4_1m.x = __mock_t5_1m.x), __mock_t6_1m
10-
where (__mock_t6_1m.y = __mock_t5_1m.y)
11-
and (__mock_t4_1m.y >= 1000000) and (__mock_t4_1m.y < 1500000) and (__mock_t6_1m.x < 150000) and (__mock_t6_1m.x >= 100000);
13+
from __mock_t4_1m, __mock_t5_1m, __mock_t6_1m
14+
where (__mock_t4_1m.x = __mock_t5_1m.x)
15+
and (__mock_t6_1m.y = __mock_t5_1m.y)
16+
and (__mock_t4_1m.y >= 1000000)
17+
and (__mock_t4_1m.y < 1500000)
18+
and (__mock_t6_1m.x < 150000)
19+
and (__mock_t6_1m.x >= 100000);
1220
----
1321
400000 149999 1499990 149999 1499990 149999 1499990

test/sql/p3.leaderboard-q3.slt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,31 @@ explain (o) select v, d1, d2 from (
66
from __mock_t7 left join (select v4 from __mock_t8 where 1 == 2) on v < v4 group by v
77
)
88

9-
statement ok +timing:x10:.q3
9+
query rowsort ok +timing:x10:.q3
1010
select v, d1, d2 from (
1111
select
1212
v, max(v1) as d1, max(v1) + max(v1) + max(v2) as d2,
1313
min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2), min(v1), max(v2), min(v2), max(v1) + min(v1), max(v2) + min(v2)
1414
from __mock_t7 left join (select v4 from __mock_t8 where 1 == 2) on v < v4 group by v
1515
)
16+
----
17+
19 999999 2999997
18+
15 999995 2999985
19+
16 999996 2999988
20+
14 999994 2999982
21+
17 999997 2999991
22+
13 999993 2999979
23+
18 999998 2999994
24+
12 999992 2999976
25+
11 999991 2999973
26+
10 999990 2999970
27+
9 999989 2999967
28+
7 999987 2999961
29+
8 999988 2999964
30+
6 999986 2999958
31+
5 999985 2999955
32+
3 999983 2999949
33+
4 999984 2999952
34+
2 999982 2999946
35+
1 999981 2999943
36+
0 999980 2999940

0 commit comments

Comments
 (0)