From 7e9b8359a8828fa4175a32821dfd5f30b03da2fb Mon Sep 17 00:00:00 2001 From: Freejww <103876282+Freejww@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:09:54 +0800 Subject: [PATCH] chore(query): turn on new agg hashtable (#15155) * fix hits-q18-perf * turn on new agg hashtable * rewrite sqllogical test * fix sqllogical test --------- Co-authored-by: jw --- src/query/expression/src/aggregate/aggregate_hashtable.rs | 6 ++++-- src/query/settings/src/settings_default.rs | 2 +- tests/sqllogictests/suites/mode/cluster/exchange.test | 8 ++++---- tests/sqllogictests/suites/mode/cluster/explain_v2.test | 4 ++-- .../sqllogictests/suites/mode/cluster/group_shuffle.test | 4 ++-- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/query/expression/src/aggregate/aggregate_hashtable.rs b/src/query/expression/src/aggregate/aggregate_hashtable.rs index 6c0b8ea05830..3f118cd8ac09 100644 --- a/src/query/expression/src/aggregate/aggregate_hashtable.rs +++ b/src/query/expression/src/aggregate/aggregate_hashtable.rs @@ -220,9 +220,11 @@ impl AggregateHashTable { } } - if self.config.partial_agg && self.capacity >= self.config.max_partial_capacity { + if self.config.partial_agg { // check size - if self.count + BATCH_ADD_SIZE > self.resize_threshold() { + if self.count + BATCH_ADD_SIZE > self.resize_threshold() + && self.capacity >= self.config.max_partial_capacity + { self.clear_ht(); self.reset_count(); } diff --git a/src/query/settings/src/settings_default.rs b/src/query/settings/src/settings_default.rs index 87a5bb65322f..e1f917725eca 100644 --- a/src/query/settings/src/settings_default.rs +++ b/src/query/settings/src/settings_default.rs @@ -643,7 +643,7 @@ impl DefaultSettings { range: Some(SettingRange::Numeric(0..=1)), }), ("enable_experimental_aggregate_hashtable", DefaultSettingValue { - value: UserSettingValue::UInt64(0), + value: UserSettingValue::UInt64(1), desc: "Enables experimental aggregate hashtable", mode: SettingMode::Both, range: Some(SettingRange::Numeric(0..=1)), diff --git a/tests/sqllogictests/suites/mode/cluster/exchange.test b/tests/sqllogictests/suites/mode/cluster/exchange.test index b1fa94daaa0a..749e7f77cf6a 100644 --- a/tests/sqllogictests/suites/mode/cluster/exchange.test +++ b/tests/sqllogictests/suites/mode/cluster/exchange.test @@ -167,8 +167,8 @@ Exchange │ ├── aggregate functions: [sum(number)] │ ├── estimated rows: 1.00 │ └── Exchange - │ ├── output columns: [sum(number) (#2), #_group_by_key] - │ ├── exchange type: Hash(_group_by_key) + │ ├── output columns: [sum(number) (#2), numbers.number (#0)] + │ ├── exchange type: Hash(0) │ └── AggregatePartial │ ├── group by: [number] │ ├── aggregate functions: [sum(number)] @@ -198,7 +198,7 @@ explain fragments select * from (select sum(number) as number from numbers(1) gr Fragment 0: DataExchange: Shuffle ExchangeSink - ├── output columns: [sum(number) (#2), #_group_by_key] + ├── output columns: [sum(number) (#2), numbers.number (#0)] ├── destination fragment: [1] └── AggregatePartial ├── group by: [number] @@ -226,7 +226,7 @@ Fragment 1: ├── aggregate functions: [sum(number)] ├── estimated rows: 1.00 └── ExchangeSource - ├── output columns: [sum(number) (#2), #_group_by_key] + ├── output columns: [sum(number) (#2), numbers.number (#0)] └── source fragment: [0] (empty) (empty) diff --git a/tests/sqllogictests/suites/mode/cluster/explain_v2.test b/tests/sqllogictests/suites/mode/cluster/explain_v2.test index 799cf664fb2e..8a92ee5faf33 100644 --- a/tests/sqllogictests/suites/mode/cluster/explain_v2.test +++ b/tests/sqllogictests/suites/mode/cluster/explain_v2.test @@ -410,8 +410,8 @@ Exchange │ ├── aggregate functions: [] │ ├── estimated rows: 2.00 │ └── Exchange - │ ├── output columns: [#_group_by_key] - │ ├── exchange type: Hash(_group_by_key) + │ ├── output columns: [col0 (#2)] + │ ├── exchange type: Hash(0) │ └── AggregatePartial │ ├── group by: [col0] │ ├── aggregate functions: [] diff --git a/tests/sqllogictests/suites/mode/cluster/group_shuffle.test b/tests/sqllogictests/suites/mode/cluster/group_shuffle.test index 55535eaf1d65..656b56ec9208 100644 --- a/tests/sqllogictests/suites/mode/cluster/group_shuffle.test +++ b/tests/sqllogictests/suites/mode/cluster/group_shuffle.test @@ -45,8 +45,8 @@ Exchange ├── aggregate functions: [] ├── estimated rows: 100000.00 └── Exchange - ├── output columns: [#_group_by_key] - ├── exchange type: Hash(_group_by_key) + ├── output columns: [numbers_mt.number (#0)] + ├── exchange type: Hash(0) └── AggregatePartial ├── group by: [number] ├── aggregate functions: []