1#include "duckdb/planner/expression/bound_operator_expression.hpp"
2#include "duckdb/common/string_util.hpp"
3#include "duckdb/parser/expression/operator_expression.hpp"
4#include "duckdb/common/field_writer.hpp"
5
6namespace duckdb {
7
8BoundOperatorExpression::BoundOperatorExpression(ExpressionType type, LogicalType return_type)
9 : Expression(type, ExpressionClass::BOUND_OPERATOR, std::move(return_type)) {
10}
11
12string BoundOperatorExpression::ToString() const {
13 return OperatorExpression::ToString<BoundOperatorExpression, Expression>(entry: *this);
14}
15
16bool BoundOperatorExpression::Equals(const BaseExpression &other_p) const {
17 if (!Expression::Equals(other: other_p)) {
18 return false;
19 }
20 auto &other = other_p.Cast<BoundOperatorExpression>();
21 if (!Expression::ListEquals(left: children, right: other.children)) {
22 return false;
23 }
24 return true;
25}
26
27unique_ptr<Expression> BoundOperatorExpression::Copy() {
28 auto copy = make_uniq<BoundOperatorExpression>(args&: type, args&: return_type);
29 copy->CopyProperties(other&: *this);
30 for (auto &child : children) {
31 copy->children.push_back(x: child->Copy());
32 }
33 return std::move(copy);
34}
35
36void BoundOperatorExpression::Serialize(FieldWriter &writer) const {
37 writer.WriteSerializable(element: return_type);
38 writer.WriteSerializableList(elements: children);
39}
40
41unique_ptr<Expression> BoundOperatorExpression::Deserialize(ExpressionDeserializationState &state,
42 FieldReader &reader) {
43 auto return_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
44 auto children = reader.ReadRequiredSerializableList<Expression>(args&: state.gstate);
45
46 auto result = make_uniq<BoundOperatorExpression>(args&: state.type, args&: return_type);
47 result->children = std::move(children);
48 return std::move(result);
49}
50
51} // namespace duckdb
52