Skip to content

Commit 12101ef

Browse files
authored
fix: add group topn to executor factory (#655)
Signed-off-by: Alex Chi <[email protected]>
1 parent 76d2426 commit 12101ef

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/execution/executor_factory.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
#include "execution/executors/sort_executor.h"
3333
#include "execution/executors/topn_check_executor.h"
3434
#include "execution/executors/topn_executor.h"
35+
#include "execution/executors/topn_per_group_executor.h"
3536
#include "execution/executors/update_executor.h"
3637
#include "execution/executors/values_executor.h"
3738
#include "execution/executors/window_function_executor.h"
3839
#include "execution/plans/filter_plan.h"
3940
#include "execution/plans/mock_scan_plan.h"
4041
#include "execution/plans/projection_plan.h"
4142
#include "execution/plans/sort_plan.h"
43+
#include "execution/plans/topn_per_group_plan.h"
4244
#include "execution/plans/topn_plan.h"
4345
#include "execution/plans/values_plan.h"
4446
#include "execution/plans/window_plan.h"
@@ -180,6 +182,13 @@ auto ExecutorFactory::CreateExecutor(ExecutorContext *exec_ctx, const AbstractPl
180182
return std::make_unique<TopNExecutor>(exec_ctx, topn_plan, std::move(child));
181183
}
182184

185+
// Create a new groupTopN executor
186+
case PlanType::TopNPerGroup: {
187+
const auto *group_topn_plan = dynamic_cast<const TopNPerGroupPlanNode *>(plan.get());
188+
auto child = ExecutorFactory::CreateExecutor(exec_ctx, group_topn_plan->GetChildPlan());
189+
return std::make_unique<TopNPerGroupExecutor>(exec_ctx, group_topn_plan, std::move(child));
190+
}
191+
183192
default:
184193
UNREACHABLE("Unsupported plan type.");
185194
}

src/include/execution/executors/topn_per_group_executor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class TopNPerGroupExecutor : public AbstractExecutor {
4848
*/
4949
auto Next(Tuple *tuple, RID *rid) -> bool override;
5050

51+
auto GetOutputSchema() const -> const Schema & override { return plan_->OutputSchema(); }
52+
5153
private:
5254
/** The TopNPerGroup plan node to be executed */
5355
[[maybe_unused]] const TopNPerGroupPlanNode *plan_;

0 commit comments

Comments
 (0)