1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/expression/bound_columnref_expression.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/column_binding.hpp"
12#include "duckdb/planner/expression.hpp"
13
14namespace duckdb {
15
16class FieldReader;
17class FieldWriter;
18
19//! A BoundColumnRef expression represents a ColumnRef expression that was bound to an actual table and column index. It
20//! is not yet executable, however. The ColumnBindingResolver transforms the BoundColumnRefExpressions into
21//! BoundExpressions, which refer to indexes into the physical chunks that pass through the executor.
22class BoundColumnRefExpression : public Expression {
23public:
24 static constexpr const ExpressionClass TYPE = ExpressionClass::BOUND_COLUMN_REF;
25
26public:
27 BoundColumnRefExpression(LogicalType type, ColumnBinding binding, idx_t depth = 0);
28 BoundColumnRefExpression(string alias, LogicalType type, ColumnBinding binding, idx_t depth = 0);
29
30 //! Column index set by the binder, used to generate the final BoundExpression
31 ColumnBinding binding;
32 //! The subquery depth (i.e. depth 0 = current query, depth 1 = parent query, depth 2 = parent of parent, etc...).
33 //! This is only non-zero for correlated expressions inside subqueries.
34 idx_t depth;
35
36public:
37 bool IsScalar() const override {
38 return false;
39 }
40 bool IsFoldable() const override {
41 return false;
42 }
43
44 string ToString() const override;
45 string GetName() const override;
46
47 bool Equals(const BaseExpression &other) const override;
48 hash_t Hash() const override;
49
50 unique_ptr<Expression> Copy() override;
51
52 void Serialize(FieldWriter &writer) const override;
53 static unique_ptr<Expression> Deserialize(ExpressionDeserializationState &state, FieldReader &reader);
54};
55} // namespace duckdb
56