1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/operator/logical_join.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/enums/join_type.hpp"
12#include "duckdb/common/unordered_set.hpp"
13#include "duckdb/planner/logical_operator.hpp"
14#include "duckdb/storage/statistics/base_statistics.hpp"
15
16namespace duckdb {
17
18//! LogicalJoin represents a join between two relations
19class LogicalJoin : public LogicalOperator {
20public:
21 static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_INVALID;
22
23public:
24 explicit LogicalJoin(JoinType type, LogicalOperatorType logical_type = LogicalOperatorType::LOGICAL_JOIN);
25
26 // Gets the set of table references that are reachable from this node
27 static void GetTableReferences(LogicalOperator &op, unordered_set<idx_t> &bindings);
28 static void GetExpressionBindings(Expression &expr, unordered_set<idx_t> &bindings);
29
30 //! The type of the join (INNER, OUTER, etc...)
31 JoinType join_type;
32 //! Table index used to refer to the MARK column (in case of a MARK join)
33 idx_t mark_index;
34 //! The columns of the LHS that are output by the join
35 vector<idx_t> left_projection_map;
36 //! The columns of the RHS that are output by the join
37 vector<idx_t> right_projection_map;
38 //! Join Keys statistics (optional)
39 vector<unique_ptr<BaseStatistics>> join_stats;
40
41public:
42 vector<ColumnBinding> GetColumnBindings() override;
43 void Serialize(FieldWriter &writer) const override;
44 static void Deserialize(LogicalJoin &join, LogicalDeserializationState &state, FieldReader &reader);
45
46protected:
47 void ResolveTypes() override;
48};
49
50} // namespace duckdb
51