Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature](function) support group concat with distinct and order by #38744

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions be/src/vec/aggregate_functions/aggregate_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class AggregateFunctionBitmapCount;
template <typename Op>
class AggregateFunctionBitmapOp;
struct AggregateFunctionBitmapUnionOp;
class IAggregateFunction;
using AggregateFunctionPtr = std::shared_ptr<IAggregateFunction>;

using DataTypePtr = std::shared_ptr<const IDataType>;
using DataTypes = std::vector<DataTypePtr>;
Expand Down Expand Up @@ -178,11 +180,6 @@ class IAggregateFunction {
const size_t offset, IColumn& to,
const size_t num_rows) const = 0;

/** Returns true for aggregate functions of type -State.
* They are executed as other aggregate functions, but not finalized (return an aggregation state that can be combined with another).
*/
virtual bool is_state() const { return false; }

/** Contains a loop with calls to "add" function. You can collect arguments into array "places"
* and do a single call to "add_batch" for devirtualization and inlining.
*/
Expand Down Expand Up @@ -223,6 +220,8 @@ class IAggregateFunction {

virtual void set_version(const int version_) { version = version_; }

virtual AggregateFunctionPtr transmit_to_stable() { return nullptr; }

protected:
DataTypes argument_types;
int version {};
Expand Down Expand Up @@ -519,8 +518,6 @@ class IAggregateFunctionDataHelper : public IAggregateFunctionHelper<Derived> {
}
};

using AggregateFunctionPtr = std::shared_ptr<IAggregateFunction>;

class AggregateFunctionGuard {
public:
using AggregateData = std::remove_pointer_t<AggregateDataPtr>;
Expand Down
25 changes: 14 additions & 11 deletions be/src/vec/aggregate_functions/aggregate_function_distinct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@

namespace doris::vectorized {

template <typename T>
struct Reducer {
template <bool stable>
using Output = AggregateFunctionDistinctSingleNumericData<T, stable>;
using AggregateFunctionDistinctNormal = AggregateFunctionDistinct<Output, false>;
};

template <typename T>
using AggregateFunctionDistinctNumeric = Reducer<T>::AggregateFunctionDistinctNormal;

class AggregateFunctionCombinatorDistinct final : public IAggregateFunctionCombinator {
public:
String get_name() const override { return "Distinct"; }
Expand All @@ -52,22 +62,15 @@ class AggregateFunctionCombinatorDistinct final : public IAggregateFunctionCombi

if (arguments.size() == 1) {
AggregateFunctionPtr res(
creator_with_numeric_type::create<AggregateFunctionDistinct,
AggregateFunctionDistinctSingleNumericData>(
creator_with_numeric_type::create<AggregateFunctionDistinctNumeric>(
arguments, result_is_nullable, nested_function));
if (res) {
return res;
}

if (arguments[0]->is_value_unambiguously_represented_in_contiguous_memory_region()) {
res = creator_without_type::create<AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<true>>>(
arguments, result_is_nullable, nested_function);
} else {
res = creator_without_type::create<AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<false>>>(
arguments, result_is_nullable, nested_function);
}
res = creator_without_type::create<
AggregateFunctionDistinct<AggregateFunctionDistinctSingleGenericData>>(
arguments, result_is_nullable, nested_function);
return res;
}
return creator_without_type::create<
Expand Down
Loading
Loading