HappenLee commented on code in PR #66601:
URL: https://github.com/apache/doris/pull/66601#discussion_r3747755061


##########
be/src/exprs/aggregate/aggregate_function_array_agg.h:
##########
@@ -265,15 +268,28 @@ struct AggregateFunctionArrayAggData<T> {
     }
 
     void write(BufferWritable& buf) const {
-        throw Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "array_agg not 
support write");
+        const auto serialized_bytes =
+                column_type->get_uncompressed_serialized_bytes(*column_data, 
be_exec_version);
+        std::string serialized_buffer(serialized_bytes, '\0');
+        const auto* end =
+                column_type->serialize(*column_data, serialized_buffer.data(), 
be_exec_version);
+        DORIS_CHECK_LE(end, serialized_buffer.data() + serialized_bytes);
+        serialized_buffer.resize(end - serialized_buffer.data());
+        buf.write_binary(serialized_buffer);
     }
 
     void read(BufferReadable& buf) {
-        throw Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "array_agg not 
support read");
+        DORIS_CHECK(column_data->empty());
+        UInt64 serialized_bytes = 0;
+        buf.read_var_uint(serialized_bytes);
+        const auto* serialized_data = buf.data();
+        const auto* end = column_type->deserialize(serialized_data, 
&column_data, be_exec_version);
+        DORIS_CHECK_EQ(end, serialized_data + serialized_bytes);
+        buf.add_offset(serialized_bytes);
     }
 
     void merge(const Self& rhs) {
-        throw Exception(ErrorCode::NOT_IMPLEMENTED_ERROR, "array_agg not 
support merge");
+        column_data->insert_range_from(*rhs.column_data, 0, 
rhs.column_data->size());

Review Comment:
   Fixed in 6d36bea5958. Foreach growth now keeps every old nested state alive 
while all replacement states are constructed and merged. If construction or any 
merge throws, it destroys every constructed replacement state and leaves the 
published old buffer and size unchanged; only a fully successful relocation 
destroys the old states and publishes the replacement. Added failure-injection 
coverage that throws MEM_ALLOC_FAILED on the second migrated position and 
verifies the three replacement states are cleaned before the two original 
states are destroyed normally. The focused ASAN run passes 11/11 tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to