1 | #include "duckdb/execution/operator/scan/physical_column_data_scan.hpp" |
2 | #include "duckdb/execution/physical_plan_generator.hpp" |
3 | #include "duckdb/parser/parsed_data/show_select_info.hpp" |
4 | #include "duckdb/planner/operator/logical_show.hpp" |
5 | |
6 | namespace duckdb { |
7 | |
8 | unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalShow &op) { |
9 | DataChunk output; |
10 | output.Initialize(allocator&: Allocator::Get(context), types: op.types); |
11 | |
12 | auto collection = make_uniq<ColumnDataCollection>(args&: context, args&: op.types); |
13 | ColumnDataAppendState append_state; |
14 | collection->InitializeAppend(state&: append_state); |
15 | for (idx_t column_idx = 0; column_idx < op.types_select.size(); column_idx++) { |
16 | auto type = op.types_select[column_idx]; |
17 | auto &name = op.aliases[column_idx]; |
18 | |
19 | // "name", TypeId::VARCHAR |
20 | output.SetValue(col_idx: 0, index: output.size(), val: Value(name)); |
21 | // "type", TypeId::VARCHAR |
22 | output.SetValue(col_idx: 1, index: output.size(), val: Value(type.ToString())); |
23 | // "null", TypeId::VARCHAR |
24 | output.SetValue(col_idx: 2, index: output.size(), val: Value("YES" )); |
25 | // "pk", TypeId::BOOL |
26 | output.SetValue(col_idx: 3, index: output.size(), val: Value()); |
27 | // "dflt_value", TypeId::VARCHAR |
28 | output.SetValue(col_idx: 4, index: output.size(), val: Value()); |
29 | // "extra", TypeId::VARCHAR |
30 | output.SetValue(col_idx: 5, index: output.size(), val: Value()); |
31 | |
32 | output.SetCardinality(output.size() + 1); |
33 | if (output.size() == STANDARD_VECTOR_SIZE) { |
34 | collection->Append(state&: append_state, new_chunk&: output); |
35 | output.Reset(); |
36 | } |
37 | } |
38 | |
39 | collection->Append(state&: append_state, new_chunk&: output); |
40 | |
41 | // create a chunk scan to output the result |
42 | auto chunk_scan = make_uniq<PhysicalColumnDataScan>(args&: op.types, args: PhysicalOperatorType::COLUMN_DATA_SCAN, |
43 | args&: op.estimated_cardinality, args: std::move(collection)); |
44 | return std::move(chunk_scan); |
45 | } |
46 | |
47 | } // namespace duckdb |
48 | |