|
8 | 8 | #include "duckdb/execution/expression_executor.hpp" |
9 | 9 | #include "duckdb/common/types/cast_helpers.hpp" |
10 | 10 | #include "duckdb/common/operator/subtract.hpp" |
| 11 | +#include "duckdb/common/serializer/deserializer.hpp" |
| 12 | +#include "duckdb/common/serializer/serializer.hpp" |
11 | 13 |
|
12 | 14 | namespace duckdb { |
13 | 15 |
|
@@ -43,6 +45,21 @@ struct BitstringAggBindData : public FunctionData { |
43 | 45 | } |
44 | 46 | return false; |
45 | 47 | } |
| 48 | + |
| 49 | + static void Serialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p, |
| 50 | + const AggregateFunction &) { |
| 51 | + auto &bind_data = bind_data_p->Cast<BitstringAggBindData>(); |
| 52 | + serializer.WriteProperty(100, "min", bind_data.min); |
| 53 | + serializer.WriteProperty(101, "max", bind_data.max); |
| 54 | + } |
| 55 | + |
| 56 | + static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &) { |
| 57 | + Value min; |
| 58 | + Value max; |
| 59 | + deserializer.ReadProperty(100, "min", min); |
| 60 | + deserializer.ReadProperty(101, "max", max); |
| 61 | + return make_uniq<BitstringAggBindData>(min, max); |
| 62 | + } |
46 | 63 | }; |
47 | 64 |
|
48 | 65 | struct BitStringAggOperation { |
@@ -247,7 +264,9 @@ static void BindBitString(AggregateFunctionSet &bitstring_agg, const LogicalType |
247 | 264 | auto function = |
248 | 265 | AggregateFunction::UnaryAggregateDestructor<BitAggState<TYPE>, TYPE, string_t, BitStringAggOperation>( |
249 | 266 | type, LogicalType::BIT); |
250 | | - function.bind = BindBitstringAgg; // create new a 'BitstringAggBindData' |
| 267 | + function.bind = BindBitstringAgg; // create new a 'BitstringAggBindData' |
| 268 | + function.serialize = BitstringAggBindData::Serialize; |
| 269 | + function.deserialize = BitstringAggBindData::Deserialize; |
251 | 270 | function.statistics = BitstringPropagateStats; // stores min and max from column stats in BitstringAggBindData |
252 | 271 | bitstring_agg.AddFunction(function); // uses the BitstringAggBindData to access statistics for creating bitstring |
253 | 272 | function.arguments = {type, type, type}; |
|
0 commit comments