1 | #include "duckdb/planner/operator/logical_get.hpp" |
2 | |
3 | #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp" |
4 | #include "duckdb/storage/data_table.hpp" |
5 | |
6 | using namespace duckdb; |
7 | using namespace std; |
8 | |
9 | LogicalGet::LogicalGet(idx_t table_index) |
10 | : LogicalOperator(LogicalOperatorType::GET), table(nullptr), table_index(table_index) { |
11 | } |
12 | LogicalGet::LogicalGet(TableCatalogEntry *table, idx_t table_index) |
13 | : LogicalOperator(LogicalOperatorType::GET), table(table), table_index(table_index) { |
14 | } |
15 | LogicalGet::LogicalGet(TableCatalogEntry *table, idx_t table_index, vector<column_t> column_ids) |
16 | : LogicalOperator(LogicalOperatorType::GET), table(table), table_index(table_index), column_ids(column_ids) { |
17 | } |
18 | |
19 | string LogicalGet::ParamsToString() const { |
20 | if (!table) { |
21 | return "" ; |
22 | } |
23 | return "(" + table->name + ")" ; |
24 | } |
25 | |
26 | vector<ColumnBinding> LogicalGet::GetColumnBindings() { |
27 | if (!table) { |
28 | return {ColumnBinding(INVALID_INDEX, 0)}; |
29 | } |
30 | if (column_ids.size() == 0) { |
31 | return {ColumnBinding(table_index, 0)}; |
32 | } |
33 | vector<ColumnBinding> result; |
34 | for (idx_t i = 0; i < column_ids.size(); i++) { |
35 | result.push_back(ColumnBinding(table_index, i)); |
36 | } |
37 | return result; |
38 | } |
39 | |
40 | void LogicalGet::ResolveTypes() { |
41 | if (column_ids.size() == 0) { |
42 | column_ids.push_back(COLUMN_IDENTIFIER_ROW_ID); |
43 | } |
44 | types = table->GetTypes(column_ids); |
45 | } |
46 | |
47 | idx_t LogicalGet::EstimateCardinality() { |
48 | if (table) { |
49 | return table->storage->info->cardinality; |
50 | } else { |
51 | return 1; |
52 | } |
53 | } |
54 | |