ActionsDAG: do not change result of and() during optimization - part 2 (#47028)

This commit is contained in:
Salvatore Mesoraca 2023-03-02 20:48:13 +01:00 committed by GitHub
parent 3cd88003dd
commit 81b30021db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View File

@ -1946,7 +1946,7 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
}
auto conjunction = getConjunctionNodes(predicate, allowed_nodes);
if (conjunction.rejected.size() == 1 && WhichDataType{conjunction.rejected.front()->result_type}.isFloat())
if (conjunction.rejected.size() == 1 && WhichDataType{removeNullable(conjunction.rejected.front()->result_type)}.isFloat())
return nullptr;
auto actions = cloneActionsForConjunction(conjunction.allowed, all_inputs);
@ -2014,7 +2014,7 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
node.children.swap(new_children);
*predicate = std::move(node);
}
else if (!WhichDataType{new_children.front()->result_type}.isFloat())
else if (!WhichDataType{removeNullable(new_children.front()->result_type)}.isFloat())
{
/// If type is different, cast column.
/// This case is possible, cause AND can use any numeric type as argument.
@ -2045,7 +2045,7 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
/// remove the AND.
/// Just update children and rebuild it.
predicate->children.swap(new_children);
if (WhichDataType{predicate->children.front()->result_type}.isFloat())
if (WhichDataType{removeNullable(predicate->children.front()->result_type)}.isFloat())
{
Node node;
node.type = ActionType::COLUMN;

View File

@ -0,0 +1,4 @@
10
#45218
10
=

View File

@ -0,0 +1,21 @@
SELECT SUM(number)
FROM
(
SELECT 10 AS number
)
GROUP BY number
HAVING 1 AND sin(SUMOrNull(number))
SETTINGS enable_optimize_predicate_expression = 0;
select '#45218';
SELECT SUM(number)
FROM
(
SELECT 10 AS number
)
GROUP BY cos(min2(number, number) % number) - number
HAVING ((-sign(-233841197)) IS NOT NULL) AND sin(lcm(SUM(number), SUM(number)) >= ('372497213' IS NOT NULL))
SETTINGS aggregate_functions_null_for_empty = 1, enable_optimize_predicate_expression = 0;
select '=';