diff --git a/src/execution/mock_scan_executor.cpp b/src/execution/mock_scan_executor.cpp index 306de5e60..0527b254d 100644 --- a/src/execution/mock_scan_executor.cpp +++ b/src/execution/mock_scan_executor.cpp @@ -53,7 +53,9 @@ const char *mock_table_list[] = {"__mock_table_1", "__mock_table_2", "__mock_tab // For leaderboard Q2 "__mock_t4_1m", "__mock_t5_1m", "__mock_t6_1m", // For leaderboard Q3 - "__mock_t7", "__mock_t8", "__mock_t9", nullptr}; + "__mock_t7", "__mock_t8", "__mock_t9", + // For P3 leaderboard Q4 + "__mock_t10", "__mock_t11", nullptr}; static const int GRAPH_NODE_CNT = 10; @@ -128,6 +130,14 @@ auto GetMockTableSchemaOf(const std::string &table) -> Schema { return Schema{std::vector{Column{"x", TypeId::INTEGER}, Column{"y", TypeId::INTEGER}}}; } + if (table == "__mock_t10") { + return Schema{std::vector{Column{"x", TypeId::INTEGER}, Column{"y", TypeId::INTEGER}}}; + } + + if (table == "__mock_t11") { + return Schema{std::vector{Column{"x", TypeId::INTEGER}, Column{"y", TypeId::INTEGER}}}; + } + throw bustub::Exception(fmt::format("mock table {} not found", table)); } @@ -202,6 +212,14 @@ auto GetSizeOf(const MockScanPlanNode *plan) -> size_t { return 10000000; } + if (table == "__mock_t10") { + return 10000; // 10k + } + + if (table == "__mock_t11") { + return 1000000; // 1M + } + return 0; } @@ -428,6 +446,24 @@ auto GetFunctionOf(const MockScanPlanNode *plan) -> std::function }; } + if (table == "__mock_t10") { + return [plan](size_t cursor) { + std::vector values{}; + values.push_back(ValueFactory::GetIntegerValue(cursor)); + values.push_back(ValueFactory::GetIntegerValue(cursor * 10)); + return Tuple{values, &plan->OutputSchema()}; + }; + } + + if (table == "__mock_t11") { + return [plan](size_t cursor) { + std::vector values{}; + values.push_back(ValueFactory::GetIntegerValue(-1 * (cursor % 1000) - 1)); + values.push_back(ValueFactory::GetIntegerValue(cursor * 10)); + return Tuple{values, &plan->OutputSchema()}; + }; + } + // By default, return table of all 0. return [plan](size_t cursor) { std::vector values{}; diff --git a/test/sql/p3.leaderboard-q4.slt b/test/sql/p3.leaderboard-q4.slt new file mode 100644 index 000000000..86933563c --- /dev/null +++ b/test/sql/p3.leaderboard-q4.slt @@ -0,0 +1,3 @@ +query rowsort +timing:x20:.q1 +select * from __mock_t10 a join __mock_t11 b on a.x = b.x; +---- \ No newline at end of file