mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
ISSUES-3225 fix alias conflict when predicate optimization
This commit is contained in:
parent
03d85227d1
commit
b35ab511cb
@ -222,6 +222,8 @@ void PredicateExpressionsOptimizer::cloneOuterPredicateForInnerPredicate(
|
||||
{
|
||||
inner_predicate = outer_predicate->clone();
|
||||
|
||||
/// clears the alias name contained in the outer predicate
|
||||
cleanExpressionAlias(inner_predicate);
|
||||
IdentifiersWithQualifiedNameSet new_expression_requires;
|
||||
getDependenciesAndQualifiedOfExpression(inner_predicate, new_expression_requires, tables);
|
||||
|
||||
@ -419,4 +421,14 @@ std::vector<ASTTableExpression *> PredicateExpressionsOptimizer::getSelectTables
|
||||
return tables_expression;
|
||||
}
|
||||
|
||||
void PredicateExpressionsOptimizer::cleanExpressionAlias(ASTPtr & expression)
|
||||
{
|
||||
const auto my_alias = expression->tryGetAlias();
|
||||
if (!my_alias.empty())
|
||||
expression->setAlias("");
|
||||
|
||||
for (auto & child : expression->children)
|
||||
cleanExpressionAlias(child);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,6 +88,8 @@ private:
|
||||
std::vector<ASTTableExpression *> getSelectTablesExpression(ASTSelectQuery * select_query);
|
||||
|
||||
ASTs evaluateAsterisk(ASTSelectQuery * select_query, const ASTPtr & asterisk);
|
||||
|
||||
void cleanExpressionAlias(ASTPtr & expression);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1 1
|
||||
3 3
|
||||
3 3
|
||||
|
@ -17,6 +17,7 @@ SELECT 1 AS id WHERE id = 1;
|
||||
SELECT arrayJoin([1,2,3]) AS id WHERE id = 1;
|
||||
|
||||
SELECT '-------Need push down-------';
|
||||
SELECT toString(value) AS value FROM (SELECT 1 AS value) WHERE value = '1';
|
||||
SELECT * FROM (SELECT 1 AS id UNION ALL SELECT 2) WHERE id = 1;
|
||||
SELECT * FROM (SELECT arrayJoin([1, 2, 3]) AS id) WHERE id = 1;
|
||||
SELECT id FROM (SELECT arrayJoin([1, 2, 3]) AS id) WHERE id = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user