| 1 | //===----------------------------------------------------------------------===// | 
|---|
| 2 | //                         DuckDB | 
|---|
| 3 | // | 
|---|
| 4 | // duckdb/planner/expression/bound_lambdaref_expression.hpp | 
|---|
| 5 | // | 
|---|
| 6 | // | 
|---|
| 7 | //===----------------------------------------------------------------------===// | 
|---|
| 8 |  | 
|---|
| 9 | #pragma once | 
|---|
| 10 |  | 
|---|
| 11 | #include "duckdb/planner/column_binding.hpp" | 
|---|
| 12 | #include "duckdb/planner/expression.hpp" | 
|---|
| 13 |  | 
|---|
| 14 | namespace duckdb { | 
|---|
| 15 |  | 
|---|
| 16 | class FieldReader; | 
|---|
| 17 | class FieldWriter; | 
|---|
| 18 |  | 
|---|
| 19 | //! A BoundLambdaRef expression represents a LambdaRef expression that was bound to an lambda parameter | 
|---|
| 20 | //! in the lambda bindings vector. When capturing lambdas the BoundLambdaRef becomes a | 
|---|
| 21 | //! BoundReferenceExpresssion, indexing the corresponding lambda parameter in the lambda bindings vector, | 
|---|
| 22 | //! which refers to the physical chunk of the lambda parameter during execution. | 
|---|
| 23 | class BoundLambdaRefExpression : public Expression { | 
|---|
| 24 | public: | 
|---|
| 25 | static constexpr const ExpressionClass TYPE = ExpressionClass::BOUND_LAMBDA_REF; | 
|---|
| 26 |  | 
|---|
| 27 | public: | 
|---|
| 28 | BoundLambdaRefExpression(LogicalType type, ColumnBinding binding, idx_t lambda_index, idx_t depth = 0); | 
|---|
| 29 | BoundLambdaRefExpression(string alias, LogicalType type, ColumnBinding binding, idx_t lambda_index, | 
|---|
| 30 | idx_t depth = 0); | 
|---|
| 31 | //! Column index set by the binder, used to generate the final BoundExpression | 
|---|
| 32 | ColumnBinding binding; | 
|---|
| 33 | //! The index of the lambda parameter in the lambda bindings vector | 
|---|
| 34 | idx_t lambda_index; | 
|---|
| 35 | //! The subquery depth (i.e. depth 0 = current query, depth 1 = parent query, depth 2 = parent of parent, etc...). | 
|---|
| 36 | //! This is only non-zero for correlated expressions inside subqueries. | 
|---|
| 37 | idx_t depth; | 
|---|
| 38 |  | 
|---|
| 39 | public: | 
|---|
| 40 | bool IsScalar() const override { | 
|---|
| 41 | return false; | 
|---|
| 42 | } | 
|---|
| 43 | bool IsFoldable() const override { | 
|---|
| 44 | return false; | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 | string ToString() const override; | 
|---|
| 48 |  | 
|---|
| 49 | bool Equals(const BaseExpression &other) const override; | 
|---|
| 50 | hash_t Hash() const override; | 
|---|
| 51 |  | 
|---|
| 52 | unique_ptr<Expression> Copy() override; | 
|---|
| 53 |  | 
|---|
| 54 | void Serialize(FieldWriter &writer) const override; | 
|---|
| 55 | static unique_ptr<Expression> Deserialize(ExpressionDeserializationState &state, FieldReader &reader); | 
|---|
| 56 | }; | 
|---|
| 57 | } // namespace duckdb | 
|---|
| 58 |  | 
|---|