Skip to content

Commit

Permalink
fix bug with quailified columns in where clause
Browse files Browse the repository at this point in the history
  • Loading branch information
CurtizJ committed Aug 29, 2018
1 parent 9cdd576 commit e007fd2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contrib/poco
Submodule poco updated from 3df947 to 3a2d0a
2 changes: 1 addition & 1 deletion contrib/ssl
Submodule ssl updated from de0222 to 6fbe1c
2 changes: 1 addition & 1 deletion contrib/zlib-ng
10 changes: 10 additions & 0 deletions dbms/src/Interpreters/ExpressionAnalyzer.cpp
Expand Up @@ -355,6 +355,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.
Expand Down
@@ -0,0 +1,5 @@
retentionMerge
retentionState
retentionIf
retentionNull
retentionForEach
@@ -0,0 +1 @@
SELECT concat(func.name, comb.name) FROM system.functions AS func CROSS JOIN system.aggregate_function_combinators AS comb WHERE func.is_aggregate LIMIT 5;

0 comments on commit e007fd2

Please sign in to comment.