1#include "duckdb/common/field_writer.hpp"
2#include "duckdb/common/string_util.hpp"
3#include "duckdb/planner/operator/logical_comparison_join.hpp"
4#include "duckdb/planner/expression/bound_comparison_expression.hpp"
5#include "duckdb/common/enum_util.hpp"
6namespace duckdb {
7
8LogicalComparisonJoin::LogicalComparisonJoin(JoinType join_type, LogicalOperatorType logical_type)
9 : LogicalJoin(join_type, logical_type) {
10}
11
12string LogicalComparisonJoin::ParamsToString() const {
13 string result = EnumUtil::ToChars(value: join_type);
14 for (auto &condition : conditions) {
15 result += "\n";
16 auto expr =
17 make_uniq<BoundComparisonExpression>(args: condition.comparison, args: condition.left->Copy(), args: condition.right->Copy());
18 result += expr->ToString();
19 }
20
21 return result;
22}
23
24void LogicalComparisonJoin::Serialize(FieldWriter &writer) const {
25 LogicalJoin::Serialize(writer);
26 writer.WriteRegularSerializableList(elements: conditions);
27 writer.WriteRegularSerializableList(elements: delim_types);
28}
29
30void LogicalComparisonJoin::Deserialize(LogicalComparisonJoin &comparison_join, LogicalDeserializationState &state,
31 FieldReader &reader) {
32 LogicalJoin::Deserialize(join&: comparison_join, state, reader);
33 comparison_join.conditions = reader.ReadRequiredSerializableList<JoinCondition, JoinCondition>(args&: state.gstate);
34 comparison_join.delim_types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
35}
36
37unique_ptr<LogicalOperator> LogicalComparisonJoin::Deserialize(LogicalDeserializationState &state,
38 FieldReader &reader) {
39 auto result = make_uniq<LogicalComparisonJoin>(args: JoinType::INVALID, args&: state.type);
40 LogicalComparisonJoin::Deserialize(comparison_join&: *result, state, reader);
41 return std::move(result);
42}
43
44} // namespace duckdb
45