//===----------------------------------------------------------------------===//
//                         DuckDB
//
// duckdb/planner/tableref/bound_joinref.hpp
//
//
//===----------------------------------------------------------------------===//

#pragma once

#include "duckdb/planner/binder.hpp"
#include "duckdb/common/enums/join_type.hpp"
#include "duckdb/common/enums/joinref_type.hpp"
#include "duckdb/planner/expression.hpp"

namespace duckdb {

//! Represents a join
class BoundJoinRef {
public:
	explicit BoundJoinRef(JoinRefType ref_type) : type(JoinType::INNER), ref_type(ref_type), lateral(false) {
	}

	//! The binder used to bind the LHS of the join
	shared_ptr<Binder> left_binder;
	//! The binder used to bind the RHS of the join
	shared_ptr<Binder> right_binder;
	//! The left hand side of the join
	BoundStatement left;
	//! The right hand side of the join
	BoundStatement right;
	//! The join condition
	unique_ptr<Expression> condition;
	//! Duplicate Eliminated Columns (if any)
	vector<unique_ptr<Expression>> duplicate_eliminated_columns;
	//! If the delim is flipped
	bool delim_flipped;
	//! The join type
	JoinType type;
	//! Join condition type
	JoinRefType ref_type;
	//! Whether or not this is a lateral join
	bool lateral;
	//! The correlated columns of the right-side with the left-side
	CorrelatedColumns correlated_columns;
	//! The mark index, for mark joins generated by the relational API
	idx_t mark_index {};
};
} // namespace duckdb
