This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/dev-1.0.1 by this push:
new 4f670020fd [BUGFIX] wrong answer with `with as` + two phase agg
(#10303)
4f670020fd is described below
commit 4f670020fdc6a36962aa4901840a735d1d28cd80
Author: Gabriel <[email protected]>
AuthorDate: Wed Jun 22 14:39:39 2022 +0800
[BUGFIX] wrong answer with `with as` + two phase agg (#10303)
---
be/src/vec/exec/vaggregation_node.cpp | 12 ++++++++++--
be/src/vec/exprs/vectorized_agg_fn.h | 1 +
be/src/vec/exprs/vslot_ref.h | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exec/vaggregation_node.cpp
b/be/src/vec/exec/vaggregation_node.cpp
index dcd7b375d7..8230d4d697 100644
--- a/be/src/vec/exec/vaggregation_node.cpp
+++ b/be/src/vec/exec/vaggregation_node.cpp
@@ -526,8 +526,12 @@ Status AggregationNode::_merge_without_key(Block* block) {
std::unique_ptr<char[]> deserialize_buffer(new
char[_total_size_of_aggregate_states]);
int rows = block->rows();
for (int i = 0; i < _aggregate_evaluators.size(); ++i) {
+ DCHECK(_aggregate_evaluators[i]->input_exprs_ctxs().size() == 1 &&
+
_aggregate_evaluators[i]->input_exprs_ctxs()[0]->root()->is_slot_ref());
+ int col_id =
+
((VSlotRef*)_aggregate_evaluators[i]->input_exprs_ctxs()[0]->root())->column_id();
if (_aggregate_evaluators[i]->is_merge()) {
- auto column = block->get_by_position(i).column;
+ auto column = block->get_by_position(col_id).column;
if (column->is_nullable()) {
column =
((ColumnNullable*)column.get())->get_nested_column_ptr();
}
@@ -1046,8 +1050,12 @@ Status
AggregationNode::_merge_with_serialized_key(Block* block) {
std::unique_ptr<char[]> deserialize_buffer(new
char[_total_size_of_aggregate_states]);
for (int i = 0; i < _aggregate_evaluators.size(); ++i) {
+ DCHECK(_aggregate_evaluators[i]->input_exprs_ctxs().size() == 1 &&
+
_aggregate_evaluators[i]->input_exprs_ctxs()[0]->root()->is_slot_ref());
+ int col_id =
+
((VSlotRef*)_aggregate_evaluators[i]->input_exprs_ctxs()[0]->root())->column_id();
if (_aggregate_evaluators[i]->is_merge()) {
- auto column = block->get_by_position(i + key_size).column;
+ auto column = block->get_by_position(col_id).column;
if (column->is_nullable()) {
column =
((ColumnNullable*)column.get())->get_nested_column_ptr();
}
diff --git a/be/src/vec/exprs/vectorized_agg_fn.h
b/be/src/vec/exprs/vectorized_agg_fn.h
index f3e7c04b47..0f1f145ced 100644
--- a/be/src/vec/exprs/vectorized_agg_fn.h
+++ b/be/src/vec/exprs/vectorized_agg_fn.h
@@ -67,6 +67,7 @@ public:
static std::string debug_string(const std::vector<AggFnEvaluator*>& exprs);
std::string debug_string() const;
bool is_merge() const { return _is_merge; }
+ const std::vector<VExprContext*>& input_exprs_ctxs() const { return
_input_exprs_ctxs; }
private:
const TFunction _fn;
diff --git a/be/src/vec/exprs/vslot_ref.h b/be/src/vec/exprs/vslot_ref.h
index 975b90a223..1bc78a4c5c 100644
--- a/be/src/vec/exprs/vslot_ref.h
+++ b/be/src/vec/exprs/vslot_ref.h
@@ -39,6 +39,8 @@ public:
virtual std::string debug_string() const override;
virtual bool is_constant() const override { return false; }
+ const int column_id() const { return _column_id; }
+
private:
FunctionPtr _function;
int _slot_id;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]