forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test for Decimal aggregateFunction normalization ClickHouse#39420
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
tests/queries/0_stateless/02366_decimal_agg_state_conversion.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,3 @@ | ||
1.100001 | ||
0.000001 | ||
19 0.1 |
62 changes: 62 additions & 0 deletions
62
tests/queries/0_stateless/02366_decimal_agg_state_conversion.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,62 @@ | ||
select sumMerge(y) from | ||
( | ||
select cast(x, 'AggregateFunction(sum, Decimal(50, 10))') y from | ||
( | ||
select arrayReduce('sumState', [toDecimal256('0.000001', 10), toDecimal256('1.1', 10)]) x | ||
) | ||
); | ||
|
||
select minMerge(y) from | ||
( | ||
select cast(x, 'AggregateFunction(min, Decimal(18, 10))') y from | ||
( | ||
select arrayReduce('minState', [toDecimal64('0.000001', 10), toDecimal64('1.1', 10)]) x | ||
) | ||
); | ||
|
||
|
||
drop table if exists consumer_02366; | ||
drop table if exists producer_02366; | ||
drop table if exists mv_02366; | ||
|
||
CREATE TABLE consumer_02366 | ||
( | ||
`id` UInt16, | ||
`dec` AggregateFunction(argMin, Decimal(24, 10), UInt16) | ||
) | ||
ENGINE = AggregatingMergeTree | ||
PRIMARY KEY id | ||
ORDER BY id; | ||
|
||
CREATE TABLE producer_02366 | ||
( | ||
`id` UInt16, | ||
`dec` String | ||
) | ||
ENGINE = MergeTree | ||
PRIMARY KEY id | ||
ORDER BY id; | ||
|
||
CREATE MATERIALIZED VIEW mv_02366 TO consumer_02366 AS | ||
SELECT | ||
id, | ||
argMinState(dec, id) AS dec | ||
FROM | ||
( | ||
SELECT | ||
id, | ||
toDecimal128(dec, 10) AS dec | ||
FROM producer_02366 | ||
) | ||
GROUP BY id; | ||
|
||
INSERT INTO producer_02366 (*) VALUES (19, '.1'); | ||
|
||
SELECT | ||
id, | ||
finalizeAggregation(dec) | ||
FROM consumer_02366; | ||
|
||
drop table consumer_02366; | ||
drop table producer_02366; | ||
drop table mv_02366; |