1#include "duckdb/planner/expression/bound_unnest_expression.hpp"
2
3#include "duckdb/common/types/hash.hpp"
4#include "duckdb/common/string_util.hpp"
5#include "duckdb/common/field_writer.hpp"
6
7namespace duckdb {
8
9BoundUnnestExpression::BoundUnnestExpression(LogicalType return_type)
10 : Expression(ExpressionType::BOUND_UNNEST, ExpressionClass::BOUND_UNNEST, std::move(return_type)) {
11}
12
13bool BoundUnnestExpression::IsFoldable() const {
14 return false;
15}
16
17string BoundUnnestExpression::ToString() const {
18 return "UNNEST(" + child->ToString() + ")";
19}
20
21hash_t BoundUnnestExpression::Hash() const {
22 hash_t result = Expression::Hash();
23 return CombineHash(left: result, right: duckdb::Hash(val: "unnest"));
24}
25
26bool BoundUnnestExpression::Equals(const BaseExpression &other_p) const {
27 if (!Expression::Equals(other: other_p)) {
28 return false;
29 }
30 auto &other = other_p.Cast<BoundUnnestExpression>();
31 if (!Expression::Equals(left: *child, right: *other.child)) {
32 return false;
33 }
34 return true;
35}
36
37unique_ptr<Expression> BoundUnnestExpression::Copy() {
38 auto copy = make_uniq<BoundUnnestExpression>(args&: return_type);
39 copy->child = child->Copy();
40 return std::move(copy);
41}
42
43void BoundUnnestExpression::Serialize(FieldWriter &writer) const {
44 writer.WriteSerializable(element: return_type);
45 writer.WriteSerializable(element: *child);
46}
47
48unique_ptr<Expression> BoundUnnestExpression::Deserialize(ExpressionDeserializationState &state, FieldReader &reader) {
49 auto return_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
50 auto child = reader.ReadRequiredSerializable<Expression>(args&: state.gstate);
51
52 auto result = make_uniq<BoundUnnestExpression>(args&: return_type);
53 result->child = std::move(child);
54 return std::move(result);
55}
56
57} // namespace duckdb
58