Skip to content

Commit

Permalink
Add plan fragment in explain operator
Browse files Browse the repository at this point in the history
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN committed Mar 6, 2025
1 parent c163b94 commit ac0deb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/executor/operator/physical_explain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import status;
import infinity_exception;
import logical_type;
import logger;
import plan_fragment;

namespace infinity {

Expand Down Expand Up @@ -172,4 +173,6 @@ bool PhysicalExplain::Execute(QueryContext *, OperatorState *operator_state) {
return true;
}

void PhysicalExplain::SetPlanFragment(PlanFragment *plan_fragment_ptr) { plan_fragment_ptr_ = plan_fragment_ptr; }

} // namespace infinity
7 changes: 6 additions & 1 deletion src/executor/operator/physical_explain.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import internal_types;
import explain_statement;
import data_type;
import logger;
import plan_fragment;

namespace infinity {

Expand All @@ -43,14 +44,16 @@ public:

~PhysicalExplain() override = default;

void Init(QueryContext* query_context) override;
void Init(QueryContext *query_context) override;

bool Execute(QueryContext *query_context, OperatorState *operator_state) final;

void SetExplainText(SharedPtr<Vector<SharedPtr<String>>> text) { texts_ = std::move(text); }

void SetExplainTaskText(SharedPtr<Vector<SharedPtr<String>>> text) { task_texts_ = std::move(text); }

void SetPlanFragment(PlanFragment *plan_fragment_ptr);

inline SharedPtr<Vector<String>> GetOutputNames() const final { return output_names_; }

inline SharedPtr<Vector<SharedPtr<DataType>>> GetOutputTypes() const final { return output_types_; }
Expand All @@ -66,6 +69,8 @@ private:

SharedPtr<Vector<String>> output_names_{};
SharedPtr<Vector<SharedPtr<DataType>>> output_types_{};

PlanFragment *plan_fragment_ptr_;
};

} // namespace infinity
5 changes: 3 additions & 2 deletions src/scheduler/fragment_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ void FragmentContext::BuildTask(QueryContext *query_context, FragmentContext *pa
if (explain_op->explain_type() == ExplainType::kPipeline or explain_op->explain_type() == ExplainType::kAnalyze) {
CollectTasks(result, plan_fragment_ptr->Children()[0].get());
explain_op->SetExplainTaskText(MakeShared<Vector<SharedPtr<String>>>(result));
explain_op->SetPlanFragment(plan_fragment_ptr->Children()[0].get());
break;
}
}
Expand Down Expand Up @@ -1114,8 +1115,8 @@ void FragmentContext::MakeSinkState(i64 parallel_count) {
}
case PhysicalOperatorType::kLimit: {
// if (fragment_type_ != FragmentType::kParallelStream) {
// String error_message = fmt::format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()));
// UnrecoverableError(error_message);
// String error_message = fmt::format("{} should in parallel stream fragment",
// PhysicalOperatorToString(last_operator->operator_type())); UnrecoverableError(error_message);
// }

if ((i64)tasks_.size() != parallel_count) {
Expand Down

0 comments on commit ac0deb2

Please sign in to comment.