Merge pull request #23763 from amosbird/rowfilterfix

Fix crash when prewhere and row policy filter are both in effect with empty result
This commit is contained in:
Nikolai Kochetov 2021-04-30 16:25:36 +03:00 committed by GitHub
commit 4bb56849b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -941,7 +941,10 @@ void MergeTreeRangeReader::executePrewhereActionsAndFilterColumns(ReadResult & r
auto columns = block.getColumns();
filterColumns(columns, row_level_filter);
block.setColumns(columns);
if (columns.empty())
block = block.cloneEmpty();
else
block.setColumns(columns);
}
prewhere_info->prewhere_actions->execute(block);

View File

@ -0,0 +1,12 @@
drop table if exists tbl;
create table tbl (s String, i int) engine MergeTree order by i;
insert into tbl values ('123', 123);
drop row policy if exists filter on tbl;
create row policy filter on tbl using (s = 'non_existing_domain') to all;
select * from tbl prewhere s = '123' where i = 123;
drop row policy filter on tbl;
drop table tbl;