mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 20:32:43 +00:00
Address minor review comments
This commit is contained in:
parent
b44c891ea9
commit
0fc5fe8468
@ -217,15 +217,14 @@ std::shared_ptr<FunctionNode> getFlattenedLogicalExpression(const FunctionNode &
|
|||||||
|
|
||||||
flattened->getArguments().getNodes() = std::move(new_arguments);
|
flattened->getArguments().getNodes() = std::move(new_arguments);
|
||||||
|
|
||||||
auto function_resolver = FunctionFactory::instance().get(function_name, context);
|
resolveOrdinaryFunctionNodeByName(*flattened, function_name, context);
|
||||||
flattened->resolveAsFunction(function_resolver);
|
|
||||||
|
|
||||||
return flattened;
|
return flattened;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CommonExpressionExtractionResult
|
struct CommonExpressionExtractionResult
|
||||||
{
|
{
|
||||||
// new_node: if the new node is empty, then contain the new node, otherwise nullptr
|
// new_node: if the new node is not empty, then it contains the new node, otherwise nullptr
|
||||||
// common_expressions: the extracted common expressions. The new expressions can be created
|
// common_expressions: the extracted common expressions. The new expressions can be created
|
||||||
// as the conjunction of new_node and the nodes in common_expressions. It is guaranteed that
|
// as the conjunction of new_node and the nodes in common_expressions. It is guaranteed that
|
||||||
// the common expressions are deduplicated.
|
// the common expressions are deduplicated.
|
||||||
@ -343,8 +342,7 @@ std::optional<CommonExpressionExtractionResult> tryExtractCommonExpressions(cons
|
|||||||
{
|
{
|
||||||
auto new_and_node = std::make_shared<FunctionNode>("and");
|
auto new_and_node = std::make_shared<FunctionNode>("and");
|
||||||
new_and_node->getArguments().getNodes() = std::move(filtered_and_arguments);
|
new_and_node->getArguments().getNodes() = std::move(filtered_and_arguments);
|
||||||
auto and_function_resolver = FunctionFactory::instance().get("and", context);
|
resolveOrdinaryFunctionNodeByName(*new_and_node, "and", context);
|
||||||
new_and_node->resolveAsFunction(and_function_resolver);
|
|
||||||
|
|
||||||
insertIfNotPresentInSet(new_or_arguments_set, new_or_arguments, std::move(new_and_node));
|
insertIfNotPresentInSet(new_or_arguments_set, new_or_arguments, std::move(new_and_node));
|
||||||
}
|
}
|
||||||
@ -361,8 +359,7 @@ std::optional<CommonExpressionExtractionResult> tryExtractCommonExpressions(cons
|
|||||||
auto new_or_node = std::make_shared<FunctionNode>("or");
|
auto new_or_node = std::make_shared<FunctionNode>("or");
|
||||||
new_or_node->getArguments().getNodes() = std::move(new_or_arguments);
|
new_or_node->getArguments().getNodes() = std::move(new_or_arguments);
|
||||||
|
|
||||||
auto or_function_resolver = FunctionFactory::instance().get("or", context);
|
resolveOrdinaryFunctionNodeByName(*new_or_node, "or", context);
|
||||||
new_or_node->resolveAsFunction(or_function_resolver);
|
|
||||||
|
|
||||||
return CommonExpressionExtractionResult{new_or_node, common_exprs};
|
return CommonExpressionExtractionResult{new_or_node, common_exprs};
|
||||||
}
|
}
|
||||||
@ -418,7 +415,7 @@ void tryOptimizeCommonExpressionsInAnd(QueryTreeNodePtr & node, const ContextPtr
|
|||||||
|
|
||||||
for (const auto & argument : root_node->getArguments())
|
for (const auto & argument : root_node->getArguments())
|
||||||
{
|
{
|
||||||
if (auto maybe_result = tryExtractCommonExpressions(argument, context); maybe_result.has_value())
|
if (auto maybe_result = tryExtractCommonExpressions(argument, context))
|
||||||
{
|
{
|
||||||
extracted_something = true;
|
extracted_something = true;
|
||||||
auto & result = *maybe_result;
|
auto & result = *maybe_result;
|
||||||
@ -697,10 +694,9 @@ private:
|
|||||||
return new_or_operands[0];
|
return new_or_operands[0];
|
||||||
|
|
||||||
/// Rebuild OR function
|
/// Rebuild OR function
|
||||||
auto or_function_resolver = FunctionFactory::instance().get("or", context);
|
|
||||||
auto function_node = std::make_shared<FunctionNode>("or");
|
auto function_node = std::make_shared<FunctionNode>("or");
|
||||||
function_node->getArguments().getNodes() = std::move(new_or_operands);
|
function_node->getArguments().getNodes() = std::move(new_or_operands);
|
||||||
function_node->resolveAsFunction(or_function_resolver);
|
resolveOrdinaryFunctionNodeByName(*function_node, "or", context);
|
||||||
return function_node;
|
return function_node;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user