1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/planner/subquery/flatten_dependent_join.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/unordered_map.hpp" |
12 | #include "duckdb/planner/binder.hpp" |
13 | #include "duckdb/planner/column_binding_map.hpp" |
14 | #include "duckdb/planner/logical_operator.hpp" |
15 | |
16 | namespace duckdb { |
17 | |
18 | //! The FlattenDependentJoins class is responsible for pushing the dependent join down into the plan to create a |
19 | //! flattened subquery |
20 | struct FlattenDependentJoins { |
21 | FlattenDependentJoins(Binder &binder, const vector<CorrelatedColumnInfo> &correlated, bool perform_delim = true, |
22 | bool any_join = false); |
23 | |
24 | //! Detects which Logical Operators have correlated expressions that they are dependent upon, filling the |
25 | //! has_correlated_expressions map. |
26 | bool DetectCorrelatedExpressions(LogicalOperator *op, bool lateral = false); |
27 | |
28 | //! Push the dependent join down a LogicalOperator |
29 | unique_ptr<LogicalOperator> PushDownDependentJoin(unique_ptr<LogicalOperator> plan); |
30 | |
31 | Binder &binder; |
32 | ColumnBinding base_binding; |
33 | idx_t delim_offset; |
34 | idx_t data_offset; |
35 | unordered_map<LogicalOperator *, bool> has_correlated_expressions; |
36 | column_binding_map_t<idx_t> correlated_map; |
37 | column_binding_map_t<idx_t> replacement_map; |
38 | const vector<CorrelatedColumnInfo> &correlated_columns; |
39 | vector<LogicalType> delim_types; |
40 | |
41 | bool perform_delim; |
42 | bool any_join; |
43 | |
44 | private: |
45 | unique_ptr<LogicalOperator> PushDownDependentJoinInternal(unique_ptr<LogicalOperator> plan, |
46 | bool &parent_propagate_null_values); |
47 | }; |
48 | |
49 | } // namespace duckdb |
50 |