Merge pull request #32506 from ClickHouse/fix-has-column-in-table-subquery

Fix queries with hasColumnInTable constant condition and non existing column
This commit is contained in:
alexey-milovidov 2021-12-11 02:50:06 +03:00 committed by GitHub
commit c90e588e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -51,7 +51,7 @@ static bool tryExtractConstValueFromCondition(const ASTPtr & condition, bool & v
}
}
}
else if (function->name == "toUInt8" || function->name == "toInt8")
else if (function->name == "toUInt8" || function->name == "toInt8" || function->name == "identity")
{
if (const auto * expr_list = function->arguments->as<ASTExpressionList>())
{

View File

@ -6,3 +6,7 @@
42
42
42
SELECT
x,
concat(x, \'_\')
FROM test

View File

@ -11,4 +11,7 @@ select if(toUInt8(1), 42, y) from test;
select if(toInt8(1), 42, y) from test;
select if(toUInt8(toUInt8(0)), y, 42) from test;
select if(cast(cast(0, 'UInt8'), 'UInt8'), y, 42) from test;
explain syntax select x, if((select hasColumnInTable(currentDatabase(), 'test', 'y')), y, x || '_') from test;
drop table if exists t;