1#include "duckdb/common/field_writer.hpp"
2#include "duckdb/common/string_util.hpp"
3#include "duckdb/planner/operator/logical_distinct.hpp"
4
5namespace duckdb {
6
7string LogicalDistinct::ParamsToString() const {
8 string result = LogicalOperator::ParamsToString();
9 if (!distinct_targets.empty()) {
10 result += StringUtil::Join(input: distinct_targets, count: distinct_targets.size(), separator: "\n",
11 f: [](const unique_ptr<Expression> &child) { return child->GetName(); });
12 }
13
14 return result;
15}
16void LogicalDistinct::Serialize(FieldWriter &writer) const {
17 writer.WriteField<DistinctType>(element: distinct_type);
18 writer.WriteSerializableList(elements: distinct_targets);
19 writer.WriteOptional(element: order_by);
20}
21
22unique_ptr<LogicalOperator> LogicalDistinct::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
23 auto distinct_type = reader.ReadRequired<DistinctType>();
24 auto distinct_targets = reader.ReadRequiredSerializableList<Expression>(args&: state.gstate);
25 auto order_by = reader.ReadOptional<BoundOrderModifier>(default_value: nullptr, args&: state.gstate);
26 auto ret = make_uniq<LogicalDistinct>(args: std::move(distinct_targets), args&: distinct_type);
27 ret->order_by = std::move(order_by);
28 return std::move(ret);
29}
30
31} // namespace duckdb
32