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)
11 : Relation(child_p->context, RelationType::EXPLAIN_RELATION), child(move(child_p)) {
12 context.TryBindRelation(*this, this->columns);
13}
14
15unique_ptr<QueryNode> ExplainRelation::GetQueryNode() {
16 throw InternalException("Cannot create a query node from a ExplainRelation!");
17}
18
19BoundStatement ExplainRelation::Bind(Binder &binder) {
20 auto select = make_unique<SelectStatement>();
21 select->node = child->GetQueryNode();
22 ExplainStatement explain(move(select));
23 return binder.Bind((SQLStatement &)explain);
24}
25
26const vector<ColumnDefinition> &ExplainRelation::Columns() {
27 return columns;
28}
29
30string ExplainRelation::ToString(idx_t depth) {
31 string str = RenderWhitespace(depth) + "Explain\n";
32 return str + child->ToString(depth + 1);
33}
34
35} // namespace duckdb
36