This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 26962e4cf44 [Bug](AggState) fix not match function when agg combinator
function has alias (#31101) (#31208)
26962e4cf44 is described below
commit 26962e4cf44b4dfce5a16070c77c3988359cace8
Author: Pxl <[email protected]>
AuthorDate: Wed Feb 21 16:58:51 2024 +0800
[Bug](AggState) fix not match function when agg combinator function has
alias (#31101) (#31208)
---
be/src/vec/data_types/data_type_agg_state.h | 24 ++++------------------
be/src/vec/exprs/vectorized_agg_fn.cpp | 4 +---
.../data/datatype_p0/agg_state/test_agg_state.out | 6 ++++++
.../datatype_p0/agg_state/test_agg_state.groovy | 3 +++
4 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/be/src/vec/data_types/data_type_agg_state.h
b/be/src/vec/data_types/data_type_agg_state.h
index 3406c540805..a9d960e10b6 100644
--- a/be/src/vec/data_types/data_type_agg_state.h
+++ b/be/src/vec/data_types/data_type_agg_state.h
@@ -14,20 +14,10 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-// This file is copied from
-//
https://github.com/ClickHouse/ClickHouse/blob/master/src/DataTypes/DataTypeString.h
-// and modified by Doris
#pragma once
-#include <gen_cpp/Types_types.h>
#include <gen_cpp/data.pb.h>
-#include <glog/logging.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#include <memory>
-#include <string>
#include "common/exception.h"
#include "common/status.h"
@@ -41,22 +31,14 @@
#include "vec/data_types/data_type_string.h"
#include "vec/data_types/serde/data_type_fixedlengthobject_serde.h"
-namespace doris {
-namespace vectorized {
-class BufferWritable;
-class IColumn;
-class ReadBuffer;
-} // namespace vectorized
-} // namespace doris
-
namespace doris::vectorized {
class DataTypeAggState : public DataTypeString {
public:
DataTypeAggState(DataTypes sub_types, bool result_is_nullable, std::string
function_name)
: _result_is_nullable(result_is_nullable),
- _sub_types(sub_types),
- _function_name(function_name) {
+ _sub_types(std::move(sub_types)),
+ _function_name(std::move(function_name)) {
_agg_function =
AggregateFunctionSimpleFactory::instance().get(_function_name, _sub_types,
_result_is_nullable);
if (_agg_function == nullptr) {
@@ -73,6 +55,8 @@ public:
_function_name, _result_is_nullable,
get_types_string());
}
+ std::string get_function_name() const { return _function_name; }
+
TypeIndex get_type_id() const override { return TypeIndex::AggState; }
TypeDescriptor get_type_as_type_descriptor() const override {
diff --git a/be/src/vec/exprs/vectorized_agg_fn.cpp
b/be/src/vec/exprs/vectorized_agg_fn.cpp
index 885f53dc663..37050b2077c 100644
--- a/be/src/vec/exprs/vectorized_agg_fn.cpp
+++ b/be/src/vec/exprs/vectorized_agg_fn.cpp
@@ -170,9 +170,7 @@ Status AggFnEvaluator::prepare(RuntimeState* state, const
RowDescriptor& desc,
}
std::string type_function_name =
- assert_cast<const DataTypeAggState*>(argument_types[0].get())
- ->get_nested_function()
- ->get_name();
+ assert_cast<const
DataTypeAggState*>(argument_types[0].get())->get_function_name();
if (type_function_name + AGG_UNION_SUFFIX == _fn.name.function_name) {
if (_data_type->is_nullable()) {
return Status::InternalError(
diff --git a/regression-test/data/datatype_p0/agg_state/test_agg_state.out
b/regression-test/data/datatype_p0/agg_state/test_agg_state.out
index 03b46f74a49..120a9844f64 100644
--- a/regression-test/data/datatype_p0/agg_state/test_agg_state.out
+++ b/regression-test/data/datatype_p0/agg_state/test_agg_state.out
@@ -44,3 +44,9 @@
-- !max_by_null --
\N \N
+-- !ndv --
+1
+
+-- !approx_count_distinct --
+1
+
diff --git a/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
index 5c03d8f745e..434f6823cc2 100644
--- a/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
+++ b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy
@@ -68,4 +68,7 @@ suite("test_agg_state") {
qt_union """ select max_by_merge(kstate) from (select k1,max_by_union(k2)
kstate from a_table group by k1 order by k1) t; """
qt_max_by_null """ select
max_by_merge(max_by_state(k1,null)),min_by_merge(min_by_state(null,k3)) from
d_table; """
+
+ qt_ndv """select ndv_merge(t) from (select ndv_union(ndv_state(1)) as t
from d_table group by k1)p;"""
+ qt_approx_count_distinct """select approx_count_distinct_merge(t) from
(select approx_count_distinct_union(approx_count_distinct_state(1)) as t from
d_table group by k1)p;"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]