Skip to content

Simple Aggregation functions like Max and Sum requires AggregatingMergeTree instead of MergeTree #66815

@raghukn

Description

@raghukn

Please make sure that the version you're using is still supported (you can find the list here).

You have to provide the following information whenever possible.

Company or project name
Proect ReBase

Describe what's wrong

Simple Aggregation functions like Max and Sum requires AggregatingMergeTree instead of MergeTree

Does it reproduce on the most recent release?

24.4.1.2088

How to reproduce

  • Which ClickHouse server version to use : 24.4.1.2088

Using MergeTree - (Does not work)


CREATE TABLE knr_example_table(id UInt32, value UInt32) ENGINE = MergeTree() ORDER BY id;

CREATE TABLE knr_example_sum_tbl (id UInt32, maxval UInt32) ENGINE = MergeTree() ORDER BY id;

create materialized view knr_example_sum_mv to knr_example_sum_tbl as Select id, max(value) as maxval  from knr_example_table  group by id;

insert into knr_example_table values (4,50); insert into knr_example_table values (4,100);

select id, maxval from knr_example_sum_mv;

===============

Using AggregatingMergeTree - (Works correctly)

create table knr_example_sum_tbl (id UInt32, maxval AggregateFunction(max,UInt32)) ENGINE = AggregatingMergeTree() ORDER BY id;

create materialized view knr_example_sum_mv to knr_example_sum_tbl as Select id, maxState(value) as maxval  from knr_example_table  group by id;

insert into knr_example_table values (4,50); insert into knr_example_table values (4,100);

select id, maxMerge(maxval) from knr_example_sum_mv group by id;

Expected behavior

Simple Aggregation functions like Max and Sum doesnt work correctly when Enginen is MergeTree

Error message and/or stacktrace

Incorrect or unmerged rows in MV

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions