From 6bf62d865330f48648899f452aca4ba4ea218d80 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov Date: Thu, 27 May 2021 21:39:06 +0300 Subject: [PATCH] fix --- src/AggregateFunctions/AggregateFunctionFactory.cpp | 6 ++++-- tests/queries/0_stateless/01591_window_functions.reference | 2 ++ tests/queries/0_stateless/01591_window_functions.sql | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionFactory.cpp b/src/AggregateFunctions/AggregateFunctionFactory.cpp index 17c3974390b..d0e45053695 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.cpp +++ b/src/AggregateFunctions/AggregateFunctionFactory.cpp @@ -92,8 +92,10 @@ AggregateFunctionPtr AggregateFunctionFactory::get( // 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()) + // nullability themselves. Another special case is functions from Nothing + // that are rewritten to AggregateFunctionNothing, in this case + // nested_function is nullptr. + if (nested_function && nested_function->asWindowFunction()) { return nested_function; } diff --git a/tests/queries/0_stateless/01591_window_functions.reference b/tests/queries/0_stateless/01591_window_functions.reference index 1defb38c5ae..fa909972678 100644 --- a/tests/queries/0_stateless/01591_window_functions.reference +++ b/tests/queries/0_stateless/01591_window_functions.reference @@ -1058,6 +1058,8 @@ settings max_block_size = 3; select lagInFrame(toNullable(1)) over (); 0 select lagInFrameOrNull(1) over (); -- { serverError 36 } +select intDiv(1, NULL) x, toTypeName(x), max(x) over (); +\N Nullable(Nothing) \N -- case-insensitive SQL-standard synonyms for any and anyLast select number, diff --git a/tests/queries/0_stateless/01591_window_functions.sql b/tests/queries/0_stateless/01591_window_functions.sql index 42216d089e4..05f4cb49252 100644 --- a/tests/queries/0_stateless/01591_window_functions.sql +++ b/tests/queries/0_stateless/01591_window_functions.sql @@ -379,6 +379,7 @@ settings max_block_size = 3; -- careful with auto-application of Null combinator select lagInFrame(toNullable(1)) over (); select lagInFrameOrNull(1) over (); -- { serverError 36 } +select intDiv(1, NULL) x, toTypeName(x), max(x) over (); -- case-insensitive SQL-standard synonyms for any and anyLast select