| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/parser/tableref/joinref.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/common/enums/join_type.hpp" |
| 12 | #include "duckdb/common/enums/joinref_type.hpp" |
| 13 | #include "duckdb/common/unordered_set.hpp" |
| 14 | #include "duckdb/parser/parsed_expression.hpp" |
| 15 | #include "duckdb/parser/tableref.hpp" |
| 16 | #include "duckdb/common/vector.hpp" |
| 17 | |
| 18 | namespace duckdb { |
| 19 | |
| 20 | //! Represents a JOIN between two expressions |
| 21 | class JoinRef : public TableRef { |
| 22 | public: |
| 23 | static constexpr const TableReferenceType TYPE = TableReferenceType::JOIN; |
| 24 | |
| 25 | public: |
| 26 | explicit JoinRef(JoinRefType ref_type) |
| 27 | : TableRef(TableReferenceType::JOIN), type(JoinType::INNER), ref_type(ref_type) { |
| 28 | } |
| 29 | |
| 30 | //! The left hand side of the join |
| 31 | unique_ptr<TableRef> left; |
| 32 | //! The right hand side of the join |
| 33 | unique_ptr<TableRef> right; |
| 34 | //! The join condition |
| 35 | unique_ptr<ParsedExpression> condition; |
| 36 | //! The join type |
| 37 | JoinType type; |
| 38 | //! Join condition type |
| 39 | JoinRefType ref_type; |
| 40 | //! The set of USING columns (if any) |
| 41 | vector<string> using_columns; |
| 42 | |
| 43 | public: |
| 44 | string ToString() const override; |
| 45 | bool Equals(const TableRef &other_p) const override; |
| 46 | |
| 47 | unique_ptr<TableRef> Copy() override; |
| 48 | |
| 49 | //! Serializes a blob into a JoinRef |
| 50 | void Serialize(FieldWriter &serializer) const override; |
| 51 | //! Deserializes a blob back into a JoinRef |
| 52 | static unique_ptr<TableRef> Deserialize(FieldReader &source); |
| 53 | |
| 54 | void FormatSerialize(FormatSerializer &serializer) const override; |
| 55 | static unique_ptr<TableRef> FormatDeserialize(FormatDeserializer &source); |
| 56 | }; |
| 57 | } // namespace duckdb |
| 58 |