1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/expression_binder/lateral_binder.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/expression_binder.hpp"
12#include "duckdb/planner/binder.hpp"
13
14namespace duckdb {
15
16class ColumnAliasBinder;
17
18//! The LATERAL binder is responsible for binding an expression within a LATERAL join
19class LateralBinder : public ExpressionBinder {
20public:
21 LateralBinder(Binder &binder, ClientContext &context);
22
23 //! Extract the correlated lateral join columns and remove them from the targeted binder
24 vector<CorrelatedColumnInfo> ExtractCorrelatedColumns(Binder &binder);
25 bool HasCorrelatedColumns() const {
26 return !correlated_columns.empty();
27 }
28
29 static void ReduceExpressionDepth(LogicalOperator &op, const vector<CorrelatedColumnInfo> &info);
30
31protected:
32 BindResult BindExpression(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth,
33 bool root_expression = false) override;
34
35 string UnsupportedAggregateMessage() override;
36
37private:
38 BindResult BindColumnRef(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression);
39 void ExtractCorrelatedColumns(Expression &expr);
40
41private:
42 vector<CorrelatedColumnInfo> correlated_columns;
43};
44
45} // namespace duckdb
46