1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/operator/logical_explain.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/parser/statement/explain_statement.hpp"
12#include "duckdb/planner/logical_operator.hpp"
13
14namespace duckdb {
15
16class LogicalExplain : public LogicalOperator {
17 LogicalExplain(ExplainType explain_type)
18 : LogicalOperator(LogicalOperatorType::LOGICAL_EXPLAIN), explain_type(explain_type) {};
19
20public:
21 static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_EXPLAIN;
22
23public:
24 LogicalExplain(unique_ptr<LogicalOperator> plan, ExplainType explain_type)
25 : LogicalOperator(LogicalOperatorType::LOGICAL_EXPLAIN), explain_type(explain_type) {
26 children.push_back(x: std::move(plan));
27 }
28
29 ExplainType explain_type;
30 string physical_plan;
31 string logical_plan_unopt;
32 string logical_plan_opt;
33
34public:
35 void Serialize(FieldWriter &writer) const override;
36 static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
37 idx_t EstimateCardinality(ClientContext &context) override {
38 return 3;
39 }
40 //! Skips the serialization check in VerifyPlan
41 bool SupportSerialization() const override {
42 return false;
43 }
44
45protected:
46 void ResolveTypes() override {
47 types = {LogicalType::VARCHAR, LogicalType::VARCHAR};
48 }
49 vector<ColumnBinding> GetColumnBindings() override {
50 return {ColumnBinding(0, 0), ColumnBinding(0, 1)};
51 }
52};
53} // namespace duckdb
54