diff --git a/src/Storages/ProjectionsDescription.cpp b/src/Storages/ProjectionsDescription.cpp index e5117a306ee..dc0598de72f 100644 --- a/src/Storages/ProjectionsDescription.cpp +++ b/src/Storages/ProjectionsDescription.cpp @@ -237,7 +237,7 @@ Block ProjectionDescription::calculate(const Block & block, ContextPtr context) auto builder = InterpreterSelectQuery( query_ast, context, - Pipe(std::make_shared(block, Chunk(block.getColumns(), block.rows()))), + Pipe(std::make_shared(block)), SelectQueryOptions{ type == ProjectionDescription::Type::Normal ? QueryProcessingStage::FetchColumns : QueryProcessingStage::WithMergeableState}) diff --git a/tests/queries/0_stateless/01710_aggregate_projection_with_hashing.reference b/tests/queries/0_stateless/01710_aggregate_projection_with_hashing.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01710_aggregate_projection_with_hashing.sql b/tests/queries/0_stateless/01710_aggregate_projection_with_hashing.sql new file mode 100644 index 00000000000..d5eaa2617a6 --- /dev/null +++ b/tests/queries/0_stateless/01710_aggregate_projection_with_hashing.sql @@ -0,0 +1,11 @@ +set allow_experimental_projection_optimization = 1, force_optimize_projection = 1; + +drop table if exists tp; + +create table tp (type Int32, device UUID, cnt UInt64) engine = MergeTree order by (type, device); +insert into tp select number%3, generateUUIDv4(), 1 from numbers(300); + +alter table tp add projection uniq_city_proj ( select type, uniq(cityHash64(device)), sum(cnt) group by type ); +alter table tp materialize projection uniq_city_proj settings mutations_sync = 1; + +drop table tp;