Merge pull request #25801 from azat/storage-merge-no-col-fix

Fix "No available columns" for Merge() storage
This commit is contained in:
alexey-milovidov 2021-06-29 04:23:52 +03:00 committed by GitHub
commit 5b21ca72ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;