1#include "duckdb/execution/operator/projection/physical_projection.hpp"
2
3#include "duckdb/execution/expression_executor.hpp"
4
5using namespace duckdb;
6using namespace std;
7
8class PhysicalProjectionState : public PhysicalOperatorState {
9public:
10 PhysicalProjectionState(PhysicalOperator *child, vector<unique_ptr<Expression>> &expressions)
11 : PhysicalOperatorState(child), executor(expressions) {
12 assert(child);
13 }
14
15 ExpressionExecutor executor;
16};
17
18void PhysicalProjection::GetChunkInternal(ClientContext &context, DataChunk &chunk, PhysicalOperatorState *state_) {
19 auto state = reinterpret_cast<PhysicalProjectionState *>(state_);
20
21 // get the next chunk from the child
22 children[0]->GetChunk(context, state->child_chunk, state->child_state.get());
23 if (state->child_chunk.size() == 0) {
24 return;
25 }
26
27 state->executor.Execute(state->child_chunk, chunk);
28}
29
30unique_ptr<PhysicalOperatorState> PhysicalProjection::GetOperatorState() {
31 return make_unique<PhysicalProjectionState>(children[0].get(), select_list);
32}
33
34string PhysicalProjection::ExtraRenderInformation() const {
35 string extra_info;
36 for (auto &expr : select_list) {
37 extra_info += expr->GetName() + "\n";
38 }
39 return extra_info;
40}
41