Skip to content

Commit

Permalink
fix inconsistent result before deleting some rows (#6133)
Browse files Browse the repository at this point in the history
close #6127
  • Loading branch information
xzhangxian1008 authored Oct 15, 2022
1 parent 0644a14 commit 1e0e3c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions dbms/src/Functions/FunctionsLogical.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ struct NotImpl
{
using ResultType = UInt8;

static inline UInt8 apply(A a)
static inline bool apply(A a)
{
return !a;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ struct AssociativeOperationImpl
{}

/// Returns a combination of values in the i-th row of all columns stored in the constructor.
inline UInt8 apply(size_t i) const
inline bool apply(size_t i) const
{
if (Op::isSaturable())
{
Expand Down Expand Up @@ -238,7 +238,7 @@ struct AssociativeOperationImpl<Op, 1>
: vec(in[in.size() - 1]->getData())
{}

inline UInt8 apply(size_t i) const
inline bool apply(size_t i) const
{
return vec[i];
}
Expand Down
28 changes: 21 additions & 7 deletions dbms/src/Functions/tests/gtest_logical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ try
func_name,
createOnlyNullColumnConst(2),
createColumn<Nullable<UInt8>>({1, 0})));
// issue 6127
ASSERT_COLUMN_EQ(
createColumn<UInt8>({0, 1, 0, 0}),
executeFunction(
func_name,
createColumn<Int64>({0, 123, 0, 41}),
createColumn<UInt8>({0, 11, 221, 0})));
// issue 6127, position of UInt8 column may affect the result
ASSERT_COLUMN_EQ(
createColumn<UInt8>({0, 1, 0, 0}),
executeFunction(
func_name,
createColumn<UInt8>({0, 123, 0, 41}),
createColumn<Int64>({0, 11, 221, 0})));
}
CATCH

Expand All @@ -73,13 +87,6 @@ try
func_name,
createColumn<Nullable<UInt8>>({0, 1, 0, 1, {}, 0}),
createColumn<Nullable<UInt8>>({0, 1, 1, 0, 1, {}})));
// issue 5849
ASSERT_COLUMN_EQ(
createColumn<UInt8>({0, 1, 1, 1}),
executeFunction(
func_name,
createColumn<UInt8>({0, 123, 0, 41}),
createColumn<Int64>({0, 11, 221, 0})));
// column, const
ASSERT_COLUMN_EQ(
createColumn<Nullable<UInt8>>({1, 1}),
Expand All @@ -101,6 +108,13 @@ try
func_name,
createOnlyNullColumnConst(2),
createColumn<Nullable<UInt8>>({1, 0})));
// issue 5849
ASSERT_COLUMN_EQ(
createColumn<UInt8>({0, 1, 1, 1}),
executeFunction(
func_name,
createColumn<UInt8>({0, 123, 0, 41}),
createColumn<Int64>({0, 11, 221, 0})));
}
CATCH

Expand Down

0 comments on commit 1e0e3c8

Please sign in to comment.