From d538871d569b77910542d4679dae696eff299e00 Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Thu, 30 Sep 2021 19:23:15 +0300 Subject: [PATCH] ExpressionJIT fix short-circuit with alias --- src/Interpreters/ExpressionJIT.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/ExpressionJIT.cpp b/src/Interpreters/ExpressionJIT.cpp index 9203c2182d8..ceede628f5d 100644 --- a/src/Interpreters/ExpressionJIT.cpp +++ b/src/Interpreters/ExpressionJIT.cpp @@ -324,6 +324,16 @@ static bool isCompilableConstant(const ActionsDAG::Node & node) return node.column && isColumnConst(*node.column) && canBeNativeType(*node.result_type); } +static const ActionsDAG::Node * removeAliasIfNeccessasry(const ActionsDAG::Node * node) +{ + const ActionsDAG::Node * node_no_alias = node; + + while (node_no_alias->type == ActionsDAG::ActionType::ALIAS) + node_no_alias = node_no_alias->children[0]; + + return node_no_alias; +} + static bool isCompilableFunction(const ActionsDAG::Node & node, const std::unordered_set & lazy_executed_nodes) { if (node.type != ActionsDAG::ActionType::FUNCTION) @@ -336,7 +346,9 @@ static bool isCompilableFunction(const ActionsDAG::Node & node, const std::unord { for (const auto & child : node.children) { - if (lazy_executed_nodes.contains(child)) + const ActionsDAG::Node * child_no_alias = removeAliasIfNeccessasry(child); + + if (lazy_executed_nodes.contains(child_no_alias)) return false; } }