HappenLee commented on code in PR #68312:
URL: https://github.com/apache/doris/pull/68312#discussion_r4244467607
##########
be/src/exprs/vectorized_fn_call.cpp:
##########
@@ -215,6 +217,33 @@ size_t raw_comparison_value_size(PrimitiveType
primitive_type) {
}
}
+Status create_agg_state_finalize_function(const std::string& function_name,
+ const DataTypes& argument_types,
+ const DataTypePtr& return_type,
+ FunctionBasePtr& function) {
+ if (argument_types.size() != 1 ||
+ remove_nullable(argument_types[0])->get_primitive_type() !=
TYPE_AGG_STATE) {
+ return Status::InternalError("Finalize function requires one AGG_STATE
argument");
+ }
+ const auto state_type = remove_nullable(argument_types[0]);
+ const auto* agg_state = assert_cast<const
DataTypeAggState*>(state_type.get());
+ if (agg_state->get_function_name() + AGG_FINALIZE_SUFFIX != function_name)
{
+ return Status::InternalError("{} does not match function {}",
state_type->get_name(),
+ function_name);
+ }
+ const auto& nested = agg_state->get_nested_function();
+ auto expected_type = nested->get_return_type();
+ if (argument_types[0]->is_nullable()) {
+ expected_type = make_nullable(expected_type);
+ }
+ if (!expected_type->equals(*return_type)) {
Review Comment:
We have decided not to address the decimal/MAP finalizer return-type issue
in this PR, including both the Decimal256 and default-mode decimal MAP cases.
We are treating this finding as non-blocking for this PR; this does not mean
the issue has been fixed.
##########
be/src/exprs/aggregate/aggregate_function_state_union.h:
##########
@@ -107,6 +108,32 @@ class AggregateStateUnion : public
AggregateFunctionNonFinalBase,
size_t align_of_data() const override { return _function->align_of_data();
}
+private:
+ template <bool selected>
+ void add_batch_impl(size_t batch_size, AggregateDataPtr* places, size_t
place_offset,
+ const IColumn** columns, Arena& arena) const {
+ // Some batch implementations read the first serialized row before
entering their loop.
+ if (batch_size == 0) {
+ return;
+ }
+ // Delegate the whole batch so native state columns (e.g. SUM) can
merge directly,
+ // instead of dispatching through the range interface for every input
row.
+ // Generic implementations need aligned scratch states and manage
their construction,
+ // destruction and exception cleanup. Release only this storage after
the batch;
+ // keep passing the caller's arena for allocations that merged states
may retain.
+ // The function can be shared by evaluators, so scratch must not be a
mutable member.
+ Arena scratch_arena;
+ auto* scratch = scratch_arena.aligned_alloc(batch_size *
_function->size_of_data(),
+
_function->align_of_data());
+ if constexpr (selected) {
+ _function->deserialize_and_merge_vec_selected(places,
place_offset, scratch, columns[0],
Review Comment:
Confirming that we have decided not to address the wide string MIN/MAX
state-batch deserialization issue in this PR, including decoding skipped
selected rows. We are treating this finding as non-blocking for this PR; this
does not mean the issue has been fixed.
--
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]