Fix inconsistency

This commit is contained in:
kssenii 2021-06-28 13:19:13 +00:00
parent da1ac3fda5
commit 48d21bb03b
3 changed files with 17 additions and 0 deletions

View File

@ -219,6 +219,9 @@ const ActionsDAG::Node & ActionsDAG::addFunction(
column = node.function_base->getConstantResultForNonConstArguments(arguments, node.result_type);
}
if (all_const && column && !isColumnConst(*column) && column->size() <= 1)
column = ColumnConst::create(std::move(column), column->size());
/// If the result is not a constant, just in case, we will consider the result as unknown.
if (column && isColumnConst(*column))
{

View File

@ -0,0 +1,6 @@
1 0
1 0
1 0
1 0
1 1 0
0 0 0

View File

@ -0,0 +1,8 @@
SELECT 1 as a, count() FROM numbers(10) WHERE 0 GROUP BY a;
SELECT materialize(1) as a, count() FROM numbers(10) WHERE 0 GROUP BY a;
SELECT materialize(1) as a, count() FROM numbers(10) WHERE 0 ORDER BY a;
SELECT isConstant(1) as a, count() FROM numbers(10) WHERE 0 GROUP BY a;
SELECT 1 as b, isConstant(b) as a, count() FROM numbers(10) WHERE 0 GROUP BY a;
SELECT 0 as b, least(isConstant(materialize(1)), b) as a, count() FROM numbers(10) WHERE 0 GROUP BY a;