mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Fixed tests
This commit is contained in:
parent
43a0996356
commit
225e0bdcc2
@ -1075,18 +1075,11 @@ void Planner::buildPlanForQueryNode()
|
||||
if (query_node.hasPrewhere())
|
||||
{
|
||||
if (query_node.hasWhere())
|
||||
{
|
||||
auto function_node = std::make_shared<FunctionNode>("and");
|
||||
auto and_function = FunctionFactory::instance().get("and", query_context);
|
||||
function_node->getArguments().getNodes() = {query_node.getPrewhere(), query_node.getWhere()};
|
||||
function_node->resolveAsFunction(and_function->build(function_node->getArgumentColumns()));
|
||||
query_node.getWhere() = std::move(function_node);
|
||||
query_node.getPrewhere() = {};
|
||||
}
|
||||
query_node.getWhere() = mergeConditionNodes({query_node.getPrewhere(), query_node.getWhere()}, query_context);
|
||||
else
|
||||
{
|
||||
query_node.getWhere() = query_node.getPrewhere();
|
||||
}
|
||||
|
||||
query_node.getPrewhere() = {};
|
||||
}
|
||||
|
||||
SelectQueryInfo select_query_info;
|
||||
@ -1106,6 +1099,16 @@ void Planner::buildPlanForQueryNode()
|
||||
select_query_info.has_aggregates = !aggregate_function_nodes.empty();
|
||||
select_query_info.need_aggregate = query_node.hasGroupBy() || !aggregate_function_nodes.empty();
|
||||
|
||||
if (!select_query_info.need_aggregate && query_node.hasHaving())
|
||||
{
|
||||
if (query_node.hasWhere())
|
||||
query_node.getWhere() = mergeConditionNodes({query_node.getWhere(), query_node.getHaving()}, query_context);
|
||||
else
|
||||
query_node.getWhere() = query_node.getHaving();
|
||||
|
||||
query_node.getHaving() = {};
|
||||
}
|
||||
|
||||
checkStoragesSupportTransactions(planner_context);
|
||||
collectTableExpressionData(query_tree, *planner_context);
|
||||
collectSets(query_tree, *planner_context);
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include <IO/WriteBufferFromString.h>
|
||||
|
||||
#include <Functions/FunctionFactory.h>
|
||||
|
||||
#include <Interpreters/Context.h>
|
||||
|
||||
#include <Analyzer/ConstantNode.h>
|
||||
@ -308,4 +310,14 @@ bool queryHasWithTotalsInAnySubqueryInJoinTree(const QueryTreeNodePtr & query_no
|
||||
return false;
|
||||
}
|
||||
|
||||
QueryTreeNodePtr mergeConditionNodes(const QueryTreeNodes & condition_nodes, const ContextPtr & context)
|
||||
{
|
||||
auto function_node = std::make_shared<FunctionNode>("and");
|
||||
auto and_function = FunctionFactory::instance().get("and", context);
|
||||
function_node->getArguments().getNodes() = condition_nodes;
|
||||
function_node->resolveAsFunction(and_function->build(function_node->getArgumentColumns()));
|
||||
|
||||
return function_node;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,4 +59,7 @@ bool queryHasArrayJoinInJoinTree(const QueryTreeNodePtr & query_node);
|
||||
*/
|
||||
bool queryHasWithTotalsInAnySubqueryInJoinTree(const QueryTreeNodePtr & query_node);
|
||||
|
||||
/// Returns `and` function node that has condition nodes as its arguments
|
||||
QueryTreeNodePtr mergeConditionNodes(const QueryTreeNodes & condition_nodes, const ContextPtr & context);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user