Respect table alias for additional_table_filters.

This commit is contained in:
Nikolai Kochetov 2022-07-21 11:23:09 +00:00
parent c24800c7d5
commit e6969d5010
3 changed files with 9 additions and 1 deletions

View File

@ -297,7 +297,8 @@ static ASTPtr parseAdditionalFilterConditionForTable(
auto & table = tuple.at(0).safeGet<String>(); auto & table = tuple.at(0).safeGet<String>();
auto & filter = tuple.at(1).safeGet<String>(); auto & filter = tuple.at(1).safeGet<String>();
if ((table == target.table && context.getCurrentDatabase() == target.database) || if (table == target.alias ||
(table == target.table && context.getCurrentDatabase() == target.database) ||
(table == target.database + '.' + target.table)) (table == target.database + '.' + target.table))
{ {
/// Try to parse expression /// Try to parse expression

View File

@ -66,6 +66,12 @@ select * from system.numbers limit 5;
2 2
3 3
4 4
select * from system.numbers as t limit 5 settings additional_table_filters={'t' : 'number % 2 != 0'};
1
3
5
7
9
select * from system.numbers limit 5 settings additional_table_filters={'system.numbers' : 'number != 3'}; select * from system.numbers limit 5 settings additional_table_filters={'system.numbers' : 'number != 3'};
0 0
1 1

View File

@ -30,6 +30,7 @@ select * from remote('127.0.0.{1,2}', system.one) settings additional_table_filt
select * from remote('127.0.0.{1,2}', system.one) settings additional_table_filters={'system.one' : 'dummy != 0'}; select * from remote('127.0.0.{1,2}', system.one) settings additional_table_filters={'system.one' : 'dummy != 0'};
select * from system.numbers limit 5; select * from system.numbers limit 5;
select * from system.numbers as t limit 5 settings additional_table_filters={'t' : 'number % 2 != 0'};
select * from system.numbers limit 5 settings additional_table_filters={'system.numbers' : 'number != 3'}; select * from system.numbers limit 5 settings additional_table_filters={'system.numbers' : 'number != 3'};
select * from system.numbers limit 5 settings additional_table_filters={'system.numbers':'number != 3','table_1':'x!=2'}; select * from system.numbers limit 5 settings additional_table_filters={'system.numbers':'number != 3','table_1':'x!=2'};
select * from (select number from system.numbers limit 5 union all select x from table_1) order by number settings additional_table_filters={'system.numbers':'number != 3','table_1':'x!=2'}; select * from (select number from system.numbers limit 5 union all select x from table_1) order by number settings additional_table_filters={'system.numbers':'number != 3','table_1':'x!=2'};