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

View File

@ -1053,33 +1053,11 @@ settings max_block_size = 3;
12 2 10 11 10 10 14
13 2 10 12 10 10 143
14 2 10 13 10 10 154
<<<<<<< HEAD
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
select lagInFrame(toNullable(1)) over ();
\N
select lagInFrameOrNull(1) over (); -- { serverError 36 }
<<<<<<< HEAD
-- this is the same as `select max(Null::Nullable(Nothing))`
select intDiv(1, NULL) x, toTypeName(x), max(x) over ();
\N Nullable(Nothing) \N
@ -1098,10 +1076,6 @@ WINDOW w AS (ORDER BY number ASC)
1 0 \N 0 0
2 1 0 1 0
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
select
number,