mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Fix projection materialization with missing columns
This commit is contained in:
parent
9cbc4b4f7f
commit
e63c26edb7
@ -920,9 +920,10 @@ BlockInputStreamPtr MutationsInterpreter::execute()
|
||||
return result_stream;
|
||||
}
|
||||
|
||||
const Block & MutationsInterpreter::getUpdatedHeader() const
|
||||
Block MutationsInterpreter::getUpdatedHeader() const
|
||||
{
|
||||
return *updated_header;
|
||||
// If it's an index/projection materialization, we don't write any data columns, thus empty header is used
|
||||
return mutation_kind.mutation_kind == MutationKind::MUTATE_INDEX_PROJECTION ? Block{} : *updated_header;
|
||||
}
|
||||
|
||||
const ColumnDependencies & MutationsInterpreter::getColumnDependencies() const
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
BlockInputStreamPtr execute();
|
||||
|
||||
/// Only changed columns.
|
||||
const Block & getUpdatedHeader() const;
|
||||
Block getUpdatedHeader() const;
|
||||
|
||||
const ColumnDependencies & getColumnDependencies() const;
|
||||
|
||||
|
@ -1332,11 +1332,8 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
|
||||
{
|
||||
/// We will modify only some of the columns. Other columns and key values can be copied as-is.
|
||||
NameSet updated_columns;
|
||||
if (mutation_kind != MutationsInterpreter::MutationKind::MUTATE_INDEX_PROJECTION)
|
||||
{
|
||||
for (const auto & name_type : updated_header.getNamesAndTypesList())
|
||||
updated_columns.emplace(name_type.name);
|
||||
}
|
||||
for (const auto & name_type : updated_header.getNamesAndTypesList())
|
||||
updated_columns.emplace(name_type.name);
|
||||
|
||||
auto indices_to_recalc = getIndicesToRecalculate(
|
||||
in, updated_columns, metadata_snapshot, context, materialized_indices, source_part);
|
||||
@ -1345,7 +1342,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
|
||||
|
||||
NameSet files_to_skip = collectFilesToSkip(
|
||||
source_part,
|
||||
mutation_kind == MutationsInterpreter::MutationKind::MUTATE_INDEX_PROJECTION ? Block{} : updated_header,
|
||||
updated_header,
|
||||
indices_to_recalc,
|
||||
mrk_extension,
|
||||
projections_to_recalc);
|
||||
@ -1413,8 +1410,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
|
||||
metadata_snapshot,
|
||||
indices_to_recalc,
|
||||
projections_to_recalc,
|
||||
// If it's an index/projection materialization, we don't write any data columns, thus empty header is used
|
||||
mutation_kind == MutationsInterpreter::MutationKind::MUTATE_INDEX_PROJECTION ? Block{} : updated_header,
|
||||
updated_header,
|
||||
new_data_part,
|
||||
in,
|
||||
time_of_mutation,
|
||||
|
@ -361,10 +361,11 @@ QueryPlanPtr MergeTreeDataSelectExecutor::read(
|
||||
pipes.emplace_back(std::move(projection_pipe));
|
||||
pipes.emplace_back(std::move(ordinary_pipe));
|
||||
auto pipe = Pipe::unitePipes(std::move(pipes));
|
||||
// TODO what if pipe is empty?
|
||||
pipe.resize(1);
|
||||
|
||||
auto step = std::make_unique<ReadFromStorageStep>(std::move(pipe), "MergeTree(with projection)");
|
||||
auto step = std::make_unique<ReadFromStorageStep>(
|
||||
std::move(pipe),
|
||||
fmt::format("MergeTree(with {} projection {})", query_info.projection->desc->type, query_info.projection->desc->name));
|
||||
auto plan = std::make_unique<QueryPlan>();
|
||||
plan->addStep(std::move(step));
|
||||
return plan;
|
||||
|
@ -0,0 +1,9 @@
|
||||
drop table if exists x;
|
||||
|
||||
create table x (i int) engine MergeTree order by tuple();
|
||||
insert into x values (1);
|
||||
alter table x add column j int;
|
||||
alter table x add projection p_agg (select sum(j));
|
||||
alter table x materialize projection p_agg settings mutations_sync = 1;
|
||||
|
||||
drop table x;
|
Loading…
Reference in New Issue
Block a user