ISSUES-863 fix failure tests

This commit is contained in:
zhang2014 2018-08-24 11:32:20 +08:00
parent 32cc611f5d
commit bf517d5523
4 changed files with 17 additions and 10 deletions

View File

@ -155,7 +155,7 @@ bool PredicateExpressionsOptimizer::cannotPushDownOuterPredicate(
const ProjectionsWithAliases & subquery_projection_columns, ASTSelectQuery * subquery,
IdentifiersWithQualifiedNameSet & outer_predicate_dependencies, bool & is_prewhere, OptimizeKind & optimize_kind)
{
if (subquery->final() || subquery->limit_by_expression_list || subquery->limit_offset || subquery->with_expression_list)
if (subquery->final() || subquery->limit_by_expression_list || subquery->limit_length || subquery->with_expression_list)
return true;
for (auto & predicate_dependency : outer_predicate_dependencies)
@ -259,14 +259,17 @@ void PredicateExpressionsOptimizer::getSubqueryProjectionColumns(SubqueriesProje
ProjectionsWithAliases subquery_projections;
auto select_projection_columns = getSelectQueryProjectionColumns(select_without_union_query);
if (select_with_union_projections.empty())
select_with_union_projections = select_projection_columns;
if (!select_projection_columns.empty())
{
if (select_with_union_projections.empty())
select_with_union_projections = select_projection_columns;
for (size_t i = 0; i < select_projection_columns.size(); i++)
subquery_projections.emplace_back(std::pair(select_projection_columns[i],
qualified_name_prefix + select_with_union_projections[i]->getAliasOrColumnName()));
for (size_t i = 0; i < select_projection_columns.size(); i++)
subquery_projections.emplace_back(std::pair(select_projection_columns[i],
qualified_name_prefix + select_with_union_projections[i]->getAliasOrColumnName()));
all_subquery_projection_columns.insert(std::pair(select_without_union_query.get(), subquery_projections));
all_subquery_projection_columns.insert(std::pair(select_without_union_query.get(), subquery_projections));
}
}
}
@ -292,10 +295,10 @@ ASTs PredicateExpressionsOptimizer::getSelectQueryProjectionColumns(ASTPtr & ast
return projection_columns;
}
ASTs PredicateExpressionsOptimizer::evaluateAsterisk(ASTSelectQuery *select_query, const ASTPtr &asterisk)
ASTs PredicateExpressionsOptimizer::evaluateAsterisk(ASTSelectQuery * select_query, const ASTPtr & asterisk)
{
if (!select_query->tables || select_query->tables->children.empty())
throw Exception("Logical error: The asterisk cannot be replaced, because there is no table.", ErrorCodes::LOGICAL_ERROR);
return {};
std::vector<ASTTableExpression *> tables_expression = getSelectTablesExpression(select_query);

View File

@ -157,4 +157,4 @@ void DatabaseAndTableWithAlias::makeQualifiedName(const ASTPtr & ast) const
}
}
}
}

View File

@ -21,3 +21,4 @@
2000-01-01 1 test string 1 1
1 2000-01-01 2000-01-01 1 test string 1 1
-------Push to having expression, need check.-------
-------Compatibility test-------

View File

@ -53,4 +53,7 @@ SELECT * FROM (SELECT 1 AS id, toDate('2000-01-01') AS date FROM system.numbers
SELECT '-------Push to having expression, need check.-------';
SELECT id FROM (SELECT min(id) AS id FROM test.test) WHERE id = 1; -- { serverError 277 }
SELECT '-------Compatibility test-------';
SELECT * FROM (SELECT 1 AS id, toDate('2000-01-01') AS date FROM system.numbers LIMIT 1) ANY LEFT JOIN (SELECT * FROM test.test) AS b USING date WHERE b.date = toDate('2000-01-01'); -- {serverError 47}
DROP TABLE IF EXISTS test.test;