1#include "duckdb/execution/expression_executor.hpp"
2#include "duckdb/planner/expression/bound_reference_expression.hpp"
3
4namespace duckdb {
5
6unique_ptr<ExpressionState> ExpressionExecutor::InitializeState(const BoundReferenceExpression &expr,
7 ExpressionExecutorState &root) {
8 auto result = make_uniq<ExpressionState>(args: expr, args&: root);
9 result->Finalize();
10 return result;
11}
12
13void ExpressionExecutor::Execute(const BoundReferenceExpression &expr, ExpressionState *state,
14 const SelectionVector *sel, idx_t count, Vector &result) {
15 D_ASSERT(expr.index != DConstants::INVALID_INDEX);
16 D_ASSERT(expr.index < chunk->ColumnCount());
17
18 if (sel) {
19 result.Slice(other&: chunk->data[expr.index], sel: *sel, count);
20 } else {
21 result.Reference(other&: chunk->data[expr.index]);
22 }
23}
24
25} // namespace duckdb
26