do not auto-apply -OrNull combinator to pure window functions

This commit is contained in:
Alexander Kuzmenkov 2021-05-27 18:20:29 +03:00
parent 56a0e02b4d
commit 1c21281456
3 changed files with 17 additions and 0 deletions

View File

@ -88,6 +88,15 @@ AggregateFunctionPtr AggregateFunctionFactory::get(
AggregateFunctionPtr nested_function = getImpl( AggregateFunctionPtr nested_function = getImpl(
name, nested_types, nested_parameters, out_properties, has_null_arguments); name, nested_types, nested_parameters, out_properties, has_null_arguments);
// Pure window functions are not real aggregate functions. Applying
// combinators doesn't make sense for them, they must handle the
// nullability themselves.
if (nested_function->asWindowFunction())
{
return nested_function;
}
return combinator->transformAggregateFunction(nested_function, out_properties, type_without_low_cardinality, parameters); return combinator->transformAggregateFunction(nested_function, out_properties, type_without_low_cardinality, parameters);
} }

View File

@ -1054,6 +1054,10 @@ settings max_block_size = 3;
13 2 10 12 10 10 143 13 2 10 12 10 10 143
14 2 10 13 10 10 154 14 2 10 13 10 10 154
15 3 15 0 15 15 15 15 3 15 0 15 15 15
-- careful with auto-application of Null combinator
select lagInFrame(toNullable(1)) over ();
0
select lagInFrameOrNull(1) over (); -- { serverError 36 }
-- case-insensitive SQL-standard synonyms for any and anyLast -- case-insensitive SQL-standard synonyms for any and anyLast
select select
number, number,

View File

@ -376,6 +376,10 @@ order by number
settings max_block_size = 3; settings max_block_size = 3;
; ;
-- careful with auto-application of Null combinator
select lagInFrame(toNullable(1)) over ();
select lagInFrameOrNull(1) over (); -- { serverError 36 }
-- case-insensitive SQL-standard synonyms for any and anyLast -- case-insensitive SQL-standard synonyms for any and anyLast
select select
number, number,