mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #2994 from CurtizJ/CLICKHOUSE-3935
ClickHouse-3935 Fix bug with qualified columns in where clause
This commit is contained in:
commit
b05c62be9f
@ -356,6 +356,16 @@ void ExpressionAnalyzer::translateQualifiedNamesImpl(ASTPtr & ast, const std::ve
|
||||
}
|
||||
else
|
||||
{
|
||||
/// If the WHERE clause or HAVING consists of a single quailified column, the reference must be translated not only in children, but also in where_expression and having_expression.
|
||||
if (ASTSelectQuery * select = typeid_cast<ASTSelectQuery *>(ast.get()))
|
||||
{
|
||||
if (select->prewhere_expression)
|
||||
translateQualifiedNamesImpl(select->prewhere_expression, tables);
|
||||
if (select->where_expression)
|
||||
translateQualifiedNamesImpl(select->where_expression, tables);
|
||||
if (select->having_expression)
|
||||
translateQualifiedNamesImpl(select->having_expression, tables);
|
||||
}
|
||||
for (auto & child : ast->children)
|
||||
{
|
||||
/// Do not go to FROM, JOIN, subqueries.
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,7 @@
|
||||
USE test;
|
||||
DROP TABLE IF EXISTS where_qualified;
|
||||
CREATE TABLE where_qualified(a UInt32, b UInt8) ENGINE = Memory;
|
||||
INSERT INTO where_qualified VALUES(1, 1);
|
||||
INSERT INTO where_qualified VALUES(2, 0);
|
||||
SELECT a from where_qualified WHERE where_qualified.b;
|
||||
DROP TABLE where_qualified;
|
Loading…
Reference in New Issue
Block a user