Merge pull request #52432 from amosbird/fix_52405

Fix normal projection with merge table
This commit is contained in:
Alexey Milovidov 2023-07-23 18:27:51 +03:00 committed by GitHub
commit e3c85613c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -92,6 +92,10 @@ bool optimizeUseNormalProjections(Stack & stack, QueryPlan::Nodes & nodes)
break;
}
/// Dangling query plan node. This might be generated by StorageMerge.
if (iter->node->step.get() == reading)
return false;
const auto metadata = reading->getStorageMetadata();
const auto & projections = metadata->projections;
@ -105,8 +109,8 @@ bool optimizeUseNormalProjections(Stack & stack, QueryPlan::Nodes & nodes)
QueryDAG query;
{
auto & clild = iter->node->children[iter->next_child - 1];
if (!query.build(*clild))
auto & child = iter->node->children[iter->next_child - 1];
if (!query.build(*child))
return false;
if (query.dag)

View File

@ -0,0 +1,11 @@
drop table if exists t;
create table t (x Int32, codectest Int32) engine = MergeTree order by x;
alter table t add projection x (select * order by codectest);
insert into t values (1, 2);
select * from merge('', 't');
drop table t;