| 1 | #include "duckdb/planner/binder.hpp" |
|---|---|
| 2 | #include "duckdb/parser/statement/explain_statement.hpp" |
| 3 | #include "duckdb/planner/operator/logical_explain.hpp" |
| 4 | |
| 5 | using namespace duckdb; |
| 6 | using namespace std; |
| 7 | |
| 8 | BoundStatement Binder::Bind(ExplainStatement &stmt) { |
| 9 | BoundStatement result; |
| 10 | |
| 11 | // bind the underlying statement |
| 12 | auto plan = Bind(*stmt.stmt); |
| 13 | // get the unoptimized logical plan, and create the explain statement |
| 14 | auto logical_plan_unopt = plan.plan->ToString(); |
| 15 | auto explain = make_unique<LogicalExplain>(move(plan.plan)); |
| 16 | explain->logical_plan_unopt = logical_plan_unopt; |
| 17 | |
| 18 | result.plan = move(explain); |
| 19 | result.names = {"explain_key", "explain_value"}; |
| 20 | result.types = {SQLType::VARCHAR, SQLType::VARCHAR}; |
| 21 | return result; |
| 22 | } |
| 23 |