1 | #include "duckdb/common/field_writer.hpp" |
2 | #include "duckdb/planner/expression/bound_comparison_expression.hpp" |
3 | #include "duckdb/parser/expression/comparison_expression.hpp" |
4 | |
5 | namespace duckdb { |
6 | |
7 | BoundComparisonExpression::BoundComparisonExpression(ExpressionType type, unique_ptr<Expression> left, |
8 | unique_ptr<Expression> right) |
9 | : Expression(type, ExpressionClass::BOUND_COMPARISON, LogicalType::BOOLEAN), left(std::move(left)), |
10 | right(std::move(right)) { |
11 | } |
12 | |
13 | string BoundComparisonExpression::ToString() const { |
14 | return ComparisonExpression::ToString<BoundComparisonExpression, Expression>(entry: *this); |
15 | } |
16 | |
17 | bool BoundComparisonExpression::Equals(const BaseExpression &other_p) const { |
18 | if (!Expression::Equals(other: other_p)) { |
19 | return false; |
20 | } |
21 | auto &other = other_p.Cast<BoundComparisonExpression>(); |
22 | if (!Expression::Equals(left: *left, right: *other.left)) { |
23 | return false; |
24 | } |
25 | if (!Expression::Equals(left: *right, right: *other.right)) { |
26 | return false; |
27 | } |
28 | return true; |
29 | } |
30 | |
31 | unique_ptr<Expression> BoundComparisonExpression::Copy() { |
32 | auto copy = make_uniq<BoundComparisonExpression>(args&: type, args: left->Copy(), args: right->Copy()); |
33 | copy->CopyProperties(other&: *this); |
34 | return std::move(copy); |
35 | } |
36 | |
37 | void BoundComparisonExpression::Serialize(FieldWriter &writer) const { |
38 | writer.WriteOptional(element: left); |
39 | writer.WriteOptional(element: right); |
40 | } |
41 | |
42 | unique_ptr<Expression> BoundComparisonExpression::Deserialize(ExpressionDeserializationState &state, |
43 | FieldReader &reader) { |
44 | auto left = reader.ReadOptional<Expression>(default_value: nullptr, args&: state.gstate); |
45 | auto right = reader.ReadOptional<Expression>(default_value: nullptr, args&: state.gstate); |
46 | return make_uniq<BoundComparisonExpression>(args&: state.type, args: std::move(left), args: std::move(right)); |
47 | } |
48 | |
49 | } // namespace duckdb |
50 | |