Cleanup the incomplete fix of nullability return value of lagInFrame/leadInFrame

This commit is contained in:
ryzuo 2021-07-16 10:36:40 +08:00
parent df9ec5655c
commit 94d4fb9dfc
2 changed files with 5 additions and 38 deletions

View File

@ -1557,16 +1557,9 @@ struct WindowFunctionLagLeadInFrame final : public WindowFunction
else else
{ {
// Offset is inside the frame. // Offset is inside the frame.
auto srcColumnPtr = transform->blockAt(target_row).input_columns[workspace.argument_column_indices[0]]; to.insertFrom(*transform->blockAt(target_row).input_columns[
// If the original column type is Nullable(from DDL) workspace.argument_column_indices[0]],
if(srcColumnPtr->getDataType() == TypeIndex::Nullable) target_row.row);
{
to.insertFrom(*srcColumnPtr, target_row.row);
}
else
{
assert_cast<ColumnNullable&>(to).insertFromNotNullable(*srcColumnPtr, target_row.row);
}
} }
} }
}; };
@ -1589,7 +1582,7 @@ struct WindowFunctionNthValue final : public WindowFunction
"Function {} takes at least one argument", name_); "Function {} takes at least one argument", name_);
} }
if(argument_types.size() != 2) if (argument_types.size() != 2)
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Function '{}' accepts 2 arguments, {} given", "Function '{}' accepts 2 arguments, {} given",
@ -1640,7 +1633,7 @@ struct WindowFunctionNthValue final : public WindowFunction
// Offset is inside the frame. // Offset is inside the frame.
auto srcColumnPtr = transform->blockAt(target_row).input_columns[workspace.argument_column_indices[0]]; auto srcColumnPtr = transform->blockAt(target_row).input_columns[workspace.argument_column_indices[0]];
// If the original column type is Nullable(from DDL) // If the original column type is Nullable(from DDL)
if(srcColumnPtr->getDataType() == TypeIndex::Nullable) if (srcColumnPtr->getDataType() == TypeIndex::Nullable)
{ {
to.insertFrom(*srcColumnPtr, target_row.row); to.insertFrom(*srcColumnPtr, target_row.row);
} }

View File

@ -1053,33 +1053,11 @@ settings max_block_size = 3;
12 2 10 11 10 10 14 12 2 10 11 10 10 14
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
<<<<<<< HEAD
15 3 15 0 15 15 15 15 3 15 0 15 15 15
=======
15 3 15 \N 15 15 15
-- careful with auto-application of Null combinator
SELECT number,
lagInFrame(toNullable(number), 1) OVER w AS prevOne,
lagInFrame(toNullable(number), 2) OVER w AS prevTwo
FROM numbers(10)
WINDOW w AS (ORDER BY number ASC)
;
0 \N \N
1 0 \N
2 1 0
3 2 1
4 3 2
5 4 3
6 5 4
7 6 5
8 7 6
9 8 7
>>>>>>> Add missing test back in 01591_window_function
-- careful with auto-application of Null combinator -- careful with auto-application of Null combinator
select lagInFrame(toNullable(1)) over (); select lagInFrame(toNullable(1)) over ();
\N \N
select lagInFrameOrNull(1) over (); -- { serverError 36 } select lagInFrameOrNull(1) over (); -- { serverError 36 }
<<<<<<< HEAD
-- this is the same as `select max(Null::Nullable(Nothing))` -- this is the same as `select max(Null::Nullable(Nothing))`
select intDiv(1, NULL) x, toTypeName(x), max(x) over (); select intDiv(1, NULL) x, toTypeName(x), max(x) over ();
\N Nullable(Nothing) \N \N Nullable(Nothing) \N
@ -1098,10 +1076,6 @@ WINDOW w AS (ORDER BY number ASC)
1 0 \N 0 0 1 0 \N 0 0
2 1 0 1 0 2 1 0 1 0
3 2 1 2 1 3 2 1 2 1
=======
select intDiv(1, NULL) x, toTypeName(x), max(x) over ();
\N Nullable(Nothing) \N
>>>>>>> Add missing test back in 01591_window_function
-- case-insensitive SQL-standard synonyms for any and anyLast -- case-insensitive SQL-standard synonyms for any and anyLast
select select
number, number,