Skip to content
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
19 changes: 6 additions & 13 deletions be/src/vec/aggregate_functions/aggregate_function_covar.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ struct BaseData {
count += 1;
}

static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }

double sum_x;
double sum_y;
double sum_xy;
Expand All @@ -134,6 +132,7 @@ struct PopData : Data {
auto& col = assert_cast<ColumnFloat64&>(to);
col.get_data().push_back(this->get_pop_result());
}
static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }
};

template <typename T, typename Data>
Expand All @@ -148,6 +147,9 @@ struct SampData_OLDER : Data {
nullable_column.get_null_map_data().push_back(0);
}
}
static DataTypePtr get_return_type() {
return make_nullable(std::make_shared<DataTypeNumber<Float64>>());
}
};

template <typename T, typename Data>
Expand All @@ -160,6 +162,7 @@ struct SampData : Data {
col.get_data().push_back(this->get_samp_result());
}
}
static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }
};

template <typename Data>
Expand All @@ -184,17 +187,7 @@ class AggregateFunctionSampCovariance

String get_name() const override { return Data::name(); }

DataTypePtr get_return_type() const override {
if constexpr (is_pop) {
return Data::get_return_type();
} else {
if (IAggregateFunction::version < AGG_FUNCTION_NULLABLE) {
return make_nullable(Data::get_return_type());
} else {
return Data::get_return_type();
}
}
}
DataTypePtr get_return_type() const override { return Data::get_return_type(); }

void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num,
Arena*) const override {
Expand Down
151 changes: 120 additions & 31 deletions be/src/vec/aggregate_functions/aggregate_function_percentile.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,6 @@ class AggregateFunctionPercentileApprox

String get_name() const override { return "percentile_approx"; }

DataTypePtr get_return_type() const override {
if (IAggregateFunction::version < AGG_FUNCTION_NULLABLE) {
return make_nullable(std::make_shared<DataTypeFloat64>());
}
return std::make_shared<DataTypeFloat64>();
}

void reset(AggregateDataPtr __restrict place) const override {
AggregateFunctionPercentileApprox::data(place).reset();
}
Expand All @@ -187,30 +180,6 @@ class AggregateFunctionPercentileApprox
Arena*) const override {
AggregateFunctionPercentileApprox::data(place).read(buf);
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
if (IAggregateFunction::version < AGG_FUNCTION_NULLABLE) {
ColumnNullable& nullable_column = assert_cast<ColumnNullable&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
nullable_column.insert_default();
} else {
auto& col = assert_cast<ColumnFloat64&>(nullable_column.get_nested_column());
col.get_data().push_back(result);
nullable_column.get_null_map_data().push_back(0);
}
} else {
auto& col = assert_cast<ColumnFloat64&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
col.insert_default();
} else {
col.get_data().push_back(result);
}
}
}
};

template <bool is_nullable>
Expand Down Expand Up @@ -256,6 +225,23 @@ class AggregateFunctionPercentileApproxTwoParams_OLDER : public AggregateFunctio
this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num));
}
}

DataTypePtr get_return_type() const override {
return make_nullable(std::make_shared<DataTypeFloat64>());
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& nullable_column = assert_cast<ColumnNullable&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
nullable_column.insert_default();
} else {
auto& col = assert_cast<ColumnFloat64&>(nullable_column.get_nested_column());
col.get_data().push_back(result);
nullable_column.get_null_map_data().push_back(0);
}
}
};

class AggregateFunctionPercentileApproxTwoParams : public AggregateFunctionPercentileApprox {
Expand All @@ -271,6 +257,19 @@ class AggregateFunctionPercentileApproxTwoParams : public AggregateFunctionPerce
this->data(place).init();
this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num));
}

DataTypePtr get_return_type() const override { return std::make_shared<DataTypeFloat64>(); }

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& col = assert_cast<ColumnFloat64&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
col.insert_default();
} else {
col.get_data().push_back(result);
}
}
};

template <bool is_nullable>
Expand Down Expand Up @@ -319,6 +318,23 @@ class AggregateFunctionPercentileApproxThreeParams_OLDER
this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num));
}
}

DataTypePtr get_return_type() const override {
return make_nullable(std::make_shared<DataTypeFloat64>());
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& nullable_column = assert_cast<ColumnNullable&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
nullable_column.insert_default();
} else {
auto& col = assert_cast<ColumnFloat64&>(nullable_column.get_nested_column());
col.get_data().push_back(result);
nullable_column.get_null_map_data().push_back(0);
}
}
};

class AggregateFunctionPercentileApproxThreeParams : public AggregateFunctionPercentileApprox {
Expand All @@ -337,6 +353,19 @@ class AggregateFunctionPercentileApproxThreeParams : public AggregateFunctionPer
this->data(place).init(compression.get_element(row_num));
this->data(place).add(sources.get_element(row_num), quantile.get_element(row_num));
}

DataTypePtr get_return_type() const override { return std::make_shared<DataTypeFloat64>(); }

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& col = assert_cast<ColumnFloat64&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
col.insert_default();
} else {
col.get_data().push_back(result);
}
}
};

template <bool is_nullable>
Expand Down Expand Up @@ -390,6 +419,23 @@ class AggregateFunctionPercentileApproxWeightedThreeParams_OLDER
quantile.get_element(row_num));
}
}

DataTypePtr get_return_type() const override {
return make_nullable(std::make_shared<DataTypeFloat64>());
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& nullable_column = assert_cast<ColumnNullable&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
nullable_column.insert_default();
} else {
auto& col = assert_cast<ColumnFloat64&>(nullable_column.get_nested_column());
col.get_data().push_back(result);
nullable_column.get_null_map_data().push_back(0);
}
}
};

class AggregateFunctionPercentileApproxWeightedThreeParams
Expand All @@ -411,6 +457,19 @@ class AggregateFunctionPercentileApproxWeightedThreeParams
this->data(place).add_with_weight(sources.get_element(row_num), weight.get_element(row_num),
quantile.get_element(row_num));
}

DataTypePtr get_return_type() const override { return std::make_shared<DataTypeFloat64>(); }

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& col = assert_cast<ColumnFloat64&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
col.insert_default();
} else {
col.get_data().push_back(result);
}
}
};

template <bool is_nullable>
Expand Down Expand Up @@ -467,6 +526,23 @@ class AggregateFunctionPercentileApproxWeightedFourParams_OLDER
quantile.get_element(row_num));
}
}

DataTypePtr get_return_type() const override {
return make_nullable(std::make_shared<DataTypeFloat64>());
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& nullable_column = assert_cast<ColumnNullable&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
nullable_column.insert_default();
} else {
auto& col = assert_cast<ColumnFloat64&>(nullable_column.get_nested_column());
col.get_data().push_back(result);
nullable_column.get_null_map_data().push_back(0);
}
}
};

class AggregateFunctionPercentileApproxWeightedFourParams
Expand All @@ -489,6 +565,19 @@ class AggregateFunctionPercentileApproxWeightedFourParams
this->data(place).add_with_weight(sources.get_element(row_num), weight.get_element(row_num),
quantile.get_element(row_num));
}

DataTypePtr get_return_type() const override { return std::make_shared<DataTypeFloat64>(); }

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
auto& col = assert_cast<ColumnFloat64&>(to);
double result = AggregateFunctionPercentileApprox::data(place).get();

if (std::isnan(result)) {
col.insert_default();
} else {
col.get_data().push_back(result);
}
}
};

template <typename T>
Expand Down
22 changes: 9 additions & 13 deletions be/src/vec/aggregate_functions/aggregate_function_stddev.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ struct BaseData {
count += 1;
}

static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }

double mean;
double m2;
int64_t count;
Expand All @@ -145,6 +143,8 @@ struct PopData : Data {
col.get_data().push_back(this->get_pop_result());
}
}

static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }
};

// For this series of functions, the Decimal type is not supported
Expand Down Expand Up @@ -189,6 +189,10 @@ struct SampData_OLDER : Data {
nullable_column.get_null_map_data().push_back(0);
}
}

static DataTypePtr get_return_type() {
return make_nullable(std::make_shared<DataTypeNumber<Float64>>());
}
};

template <typename T, typename Data>
Expand All @@ -207,6 +211,8 @@ struct SampData : Data {
}
}
}

static DataTypePtr get_return_type() { return std::make_shared<DataTypeNumber<Float64>>(); }
};

template <bool is_pop, typename Data, bool is_nullable>
Expand All @@ -221,17 +227,7 @@ class AggregateFunctionSampVariance

String get_name() const override { return Data::name(); }

DataTypePtr get_return_type() const override {
if constexpr (is_pop) {
return Data::get_return_type();
} else {
if (IAggregateFunction::version < AGG_FUNCTION_NULLABLE) {
return make_nullable(Data::get_return_type());
} else {
return Data::get_return_type();
}
}
}
DataTypePtr get_return_type() const override { return Data::get_return_type(); }

void add(AggregateDataPtr __restrict place, const IColumn** columns, ssize_t row_num,
Arena*) const override {
Expand Down