Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](function) fix bug of if function of nullable column process #13779

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion be/src/vec/functions/if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,23 @@ class FunctionIf : public IFunction {

if (auto* nullable = check_and_get_column<ColumnNullable>(*arg_cond.column)) {
DCHECK(remove_nullable(arg_cond.type)->get_type_id() == TypeIndex::UInt8);

// update neseted column by nullmap
auto* __restrict null_map = nullable->get_null_map_data().data();
auto* __restrict nested_bool_data =
((ColumnVector<UInt8>&)(nullable->get_nested_column())).get_data().data();
auto rows = nullable->size();
for (size_t i = 0; i < rows; i++) {
nested_bool_data[i] = null_map[i] ? false : nested_bool_data[i];
}

Block temporary_block {{nullable->get_nested_column_ptr(),
remove_nullable(arg_cond.type), arg_cond.name},
arg_then,
arg_else,
block.get_by_position(result)};

execute_impl(context, temporary_block, {0, 1, 2}, 3, temporary_block.rows());
execute_impl(context, temporary_block, {0, 1, 2}, 3, rows);

block.get_by_position(result).column =
std::move(temporary_block.get_by_position(3).column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ true
-- !select --
2010-01-02T04:03:06

-- !select --
\N
1999-01-08T02:05:06
1989-01-08T04:05:06
2010-01-02T02:05:06
2010-01-02T05:09:06
2010-01-02T04:03:06
2002-01-07T01:05:06
2005-01-09T04:05:06
2010-01-02T04:03:06
2010-01-02T04:03:06
2010-01-02T04:03:06
2010-01-02T04:03:06
2010-01-02T04:03:06
2010-01-02T04:03:06
\N
2010-01-02T04:03:06

-- !select --
2010-01-02T04:03:06

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ suite("test_nullif") {

qt_select "select nullif(k6, \"false\") k from test_query_db.test order by k1"
qt_select "select if(c_date is null,c_timestamp,c_date) from ${tableName} where c_date is null and c_timestamp is not null"
qt_select "select if(c_bigint > 10,c_timestamp,c_date) from ${tableName}"
qt_select "select if(c_date_1 is null,c_timestamp_1,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_1 is not null"
qt_select "select if(c_date_1 is null,c_timestamp_2,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_2 is not null"
qt_select "select if(c_date_1 is null,c_timestamp_3,c_date_1) from ${tableName} where c_date_1 is null and c_timestamp_3 is not null"
Expand Down