Skip to content

Commit

Permalink
test for Decimal aggregateFunction normalization ClickHouse#39420
Browse files Browse the repository at this point in the history
  • Loading branch information
den-crane committed Aug 12, 2022
1 parent 0dc1839 commit 1bf98f4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
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 tests/queries/0_stateless/02366_decimal_agg_state_conversion.sql
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;

0 comments on commit 1bf98f4

Please sign in to comment.