-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport #54480 to 23.3: Fix aggregate projections with normalized st…
…ates
- Loading branch information
1 parent
3390d54
commit fecd683
Showing
8 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/queries/0_stateless/01710_aggregate_projection_with_normalized_states.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
3 | ||
950 990 500 2000 |
31 changes: 31 additions & 0 deletions
31
tests/queries/0_stateless/01710_aggregate_projection_with_normalized_states.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
DROP TABLE IF EXISTS r; | ||
|
||
select finalizeAggregation(cast(quantileState(0)(arrayJoin([1,2,3])) as AggregateFunction(quantile(1), UInt8))); | ||
|
||
CREATE TABLE r ( | ||
x String, | ||
a LowCardinality(String), | ||
q AggregateFunction(quantilesTiming(0.5, 0.95, 0.99), Int64), | ||
s Int64, | ||
PROJECTION p | ||
(SELECT a, quantilesTimingMerge(0.5, 0.95, 0.99)(q), sum(s) GROUP BY a) | ||
) Engine=SummingMergeTree order by (x, a); | ||
|
||
insert into r | ||
select number%100 x, | ||
'x' a, | ||
quantilesTimingState(0.5, 0.95, 0.99)(number::Int64) q, | ||
sum(1) s | ||
from numbers(1000) | ||
group by x,a; | ||
|
||
SELECT | ||
ifNotFinite(quantilesTimingMerge(0.95)(q)[1],0) as d1, | ||
ifNotFinite(quantilesTimingMerge(0.99)(q)[1],0) as d2, | ||
ifNotFinite(quantilesTimingMerge(0.50)(q)[1],0) as d3, | ||
sum(s) | ||
FROM cluster('test_cluster_two_shards', currentDatabase(), r) | ||
WHERE a = 'x' | ||
settings prefer_localhost_replica=0; | ||
|
||
DROP TABLE r; |