1#include "duckdb/main/relation/explain_relation.hpp"
2#include "duckdb/parser/statement/explain_statement.hpp"
3#include "duckdb/parser/statement/select_statement.hpp"
4#include "duckdb/parser/parsed_data/create_view_info.hpp"
5#include "duckdb/planner/binder.hpp"
6#include "duckdb/main/client_context.hpp"
7
8namespace duckdb {
9
10ExplainRelation::ExplainRelation(shared_ptr<Relation> child_p, ExplainType type)
11 : Relation(child_p->context, RelationType::EXPLAIN_RELATION), child(std::move(child_p)), type(type) {
12 context.GetContext()->TryBindRelation(relation&: *this, result_columns&: this->columns);
13}
14
15BoundStatement ExplainRelation::Bind(Binder &binder) {
16 auto select = make_uniq<SelectStatement>();
17 select->node = child->GetQueryNode();
18 ExplainStatement explain(std::move(select), type);
19 return binder.Bind(statement&: explain.Cast<SQLStatement>());
20}
21
22const vector<ColumnDefinition> &ExplainRelation::Columns() {
23 return columns;
24}
25
26string ExplainRelation::ToString(idx_t depth) {
27 string str = RenderWhitespace(depth) + "Explain\n";
28 return str + child->ToString(depth: depth + 1);
29}
30
31} // namespace duckdb
32