Fix "No available columns" for Merge() storage

This commit is contained in:
Azat Khuzhin 2021-06-28 23:08:18 +03:00
parent d9c46003cb
commit 15a14d6da2
3 changed files with 5 additions and 1 deletions

View File

@ -742,7 +742,7 @@ void TreeRewriterResult::collectUsedColumns(const ASTPtr & query, bool is_select
if (!columns.empty())
required.insert(std::min_element(columns.begin(), columns.end())->name);
else
else if (!source_columns.empty())
/// If we have no information about columns sizes, choose a column of minimum size of its data type.
required.insert(ExpressionActions::getSmallestColumn(source_columns));
}

View File

@ -0,0 +1,4 @@
drop table if exists data;
create table data (key Int) engine=MergeTree() order by key;
select 1 from merge(currentDatabase(), '^data$') prewhere _table in (NULL);
drop table data;