Skip to content

Commit

Permalink
chore(query): turn on new agg hashtable (databendlabs#15155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Freejww authored and yufan022 committed Jun 18, 2024
1 parent f2e7502 commit e63acd0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/query/expression/src/aggregate/aggregate_hashtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 4 additions & 4 deletions src/query/settings/src/settings_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,10 @@ impl DefaultSettings {
range: Some(SettingRange::Numeric(0..=1)),
}),
("enable_experimental_aggregate_hashtable", DefaultSettingValue {
value: UserSettingValue::UInt64(0),
desc: "Enables experimental aggregate hashtable",
mode: SettingMode::Both,
range: Some(SettingRange::Numeric(0..=1)),
value: UserSettingValue::UInt64(1),
desc: "Enables experimental aggregate hashtable",
mode: SettingMode::Both,
range: Some(SettingRange::Numeric(0..=1)),
}),
("numeric_cast_option", DefaultSettingValue {
value: UserSettingValue::String("rounding".to_string()),
Expand Down
8 changes: 4 additions & 4 deletions tests/sqllogictests/suites/mode/cluster/exchange.test
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
58 changes: 58 additions & 0 deletions tests/sqllogictests/suites/mode/cluster/explain_v2.test
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,61 @@ drop table t1;

statement ok
drop table t2;

statement ok
create table t1(a int, b int);

statement ok
insert into t1 values(1, 2), (2, 3), (3, 4);

statement ok
set inlist_to_join_threshold = 1;

query T
explain select * from t1 where a in (1, 2);
----
Exchange
├── output columns: [t1.a (#0), t1.b (#1)]
├── exchange type: Merge
└── HashJoin
├── output columns: [t1.a (#0), t1.b (#1)]
├── join type: INNER
├── build keys: [CAST(subquery_2 (#2) AS Int32 NULL)]
├── probe keys: [t1.a (#0)]
├── filters: []
├── estimated rows: 2.00
├── Exchange(Build)
│ ├── output columns: [col0 (#2)]
│ ├── exchange type: Broadcast
│ └── AggregateFinal
│ ├── output columns: [col0 (#2)]
│ ├── group by: [col0]
│ ├── aggregate functions: []
│ ├── estimated rows: 2.00
│ └── Exchange
│ ├── output columns: [col0 (#2)]
│ ├── exchange type: Hash(0)
│ └── AggregatePartial
│ ├── group by: [col0]
│ ├── aggregate functions: []
│ ├── estimated rows: 2.00
│ └── ConstantTableScan
│ ├── output columns: [col0 (#2)]
│ └── column 0: [1, 2]
└── TableScan(Probe)
├── table: default.default.t1
├── output columns: [a (#0), b (#1)]
├── read rows: 3
├── read bytes: 88
├── partitions total: 1
├── partitions scanned: 1
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1, bloom pruning: 0 to 0>]
├── push downs: [filters: [], limit: NONE]
└── estimated rows: 3.00


statement ok
drop table t1;

statement ok
unset inlist_to_join_threshold;
4 changes: 2 additions & 2 deletions tests/sqllogictests/suites/mode/cluster/group_shuffle.test
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down

0 comments on commit e63acd0

Please sign in to comment.