From 0fc5fe8468fae6590a25300d0478e5d842c30919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20Benjamin=20Antal?= Date: Wed, 11 Dec 2024 14:21:00 +0000 Subject: [PATCH] Address minor review comments --- .../Passes/LogicalExpressionOptimizerPass.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Analyzer/Passes/LogicalExpressionOptimizerPass.cpp b/src/Analyzer/Passes/LogicalExpressionOptimizerPass.cpp index 40a849c7457..635ce73b5c4 100644 --- a/src/Analyzer/Passes/LogicalExpressionOptimizerPass.cpp +++ b/src/Analyzer/Passes/LogicalExpressionOptimizerPass.cpp @@ -217,15 +217,14 @@ std::shared_ptr getFlattenedLogicalExpression(const FunctionNode & flattened->getArguments().getNodes() = std::move(new_arguments); - auto function_resolver = FunctionFactory::instance().get(function_name, context); - flattened->resolveAsFunction(function_resolver); + resolveOrdinaryFunctionNodeByName(*flattened, function_name, context); return flattened; } 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 // as the conjunction of new_node and the nodes in common_expressions. It is guaranteed that // the common expressions are deduplicated. @@ -343,8 +342,7 @@ std::optional tryExtractCommonExpressions(cons { auto new_and_node = std::make_shared("and"); new_and_node->getArguments().getNodes() = std::move(filtered_and_arguments); - auto and_function_resolver = FunctionFactory::instance().get("and", context); - new_and_node->resolveAsFunction(and_function_resolver); + resolveOrdinaryFunctionNodeByName(*new_and_node, "and", context); insertIfNotPresentInSet(new_or_arguments_set, new_or_arguments, std::move(new_and_node)); } @@ -361,8 +359,7 @@ std::optional tryExtractCommonExpressions(cons auto new_or_node = std::make_shared("or"); new_or_node->getArguments().getNodes() = std::move(new_or_arguments); - auto or_function_resolver = FunctionFactory::instance().get("or", context); - new_or_node->resolveAsFunction(or_function_resolver); + resolveOrdinaryFunctionNodeByName(*new_or_node, "or", context); return CommonExpressionExtractionResult{new_or_node, common_exprs}; } @@ -418,7 +415,7 @@ void tryOptimizeCommonExpressionsInAnd(QueryTreeNodePtr & node, const ContextPtr 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; auto & result = *maybe_result; @@ -697,10 +694,9 @@ private: return new_or_operands[0]; /// Rebuild OR function - auto or_function_resolver = FunctionFactory::instance().get("or", context); auto function_node = std::make_shared("or"); function_node->getArguments().getNodes() = std::move(new_or_operands); - function_node->resolveAsFunction(or_function_resolver); + resolveOrdinaryFunctionNodeByName(*function_node, "or", context); return function_node; } };