1#include "duckdb/execution/operator/scan/physical_dummy_scan.hpp"
2#include "duckdb/execution/operator/scan/physical_table_scan.hpp"
3#include "duckdb/execution/physical_plan_generator.hpp"
4#include "duckdb/planner/operator/logical_get.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalGet &op) {
10 assert(op.children.empty());
11 unordered_map<idx_t, vector<TableFilter>> table_filter_umap;
12 if (!op.table) {
13 return make_unique<PhysicalDummyScan>(op.types);
14 } else {
15 for (auto &tableFilter : op.tableFilters) {
16 for (idx_t i = 0; i < op.column_ids.size(); i++) {
17 if (tableFilter.column_index == op.column_ids[i]) {
18 tableFilter.column_index = i;
19 auto filter = table_filter_umap.find(i);
20 if (filter != table_filter_umap.end()) {
21 filter->second.push_back(tableFilter);
22 } else {
23 table_filter_umap.insert(make_pair(i, vector<TableFilter>{tableFilter}));
24 }
25 break;
26 }
27 }
28 }
29 dependencies.insert(op.table);
30 return make_unique<PhysicalTableScan>(op, *op.table, *op.table->storage, op.column_ids, move(op.expressions),
31 move(table_filter_umap));
32 }
33}
34