Skip to content

Projections inconsistent results for ReplacingMergeTree/CollapsingMergeTree #24778

@den-crane

Description

@den-crane
drop table if exists tp;

create table tp (type Int32, eventcnt UInt64,
projection p (select sum(eventcnt), type group by type)) 
engine = ReplacingMergeTree order by type;

insert into tp select number%3, 1 from numbers(3);
insert into tp select number%3, 2 from numbers(3);

optimize table tp final;

set allow_experimental_projection_optimization = 0, force_optimize_projection = 0;

select sum(eventcnt) eventcnt, type
from tp
group by type
┌─eventcnt─┬─type─┐
│        20 │
│        22 │
│        21 │
└──────────┴──────┘

set allow_experimental_projection_optimization = 1, force_optimize_projection = 1;

select sum(eventcnt) eventcnt, type
from tp
group by type
┌─eventcnt─┬─type─┐
│        30 │
│        32 │
│        31 │
└──────────┴──────┘

Metadata

Metadata

Assignees

Labels

comp-projectionsProjections: precomputed layouts for accelerating queries (projection parts, maintenance).unexpected behaviourResult is unexpected, but not entirely wrong at the same time.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions