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

Fixing issue with explode_outer position not nulling position entries of null rows #7754

Merged
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
29 changes: 17 additions & 12 deletions cpp/src/lists/explode.cu
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,27 @@ std::unique_ptr<table> build_table(

std::vector<std::unique_ptr<column>> columns = gathered_table.release()->release();

columns.insert(columns.begin() + explode_column_idx,
explode_col_gather_map
? std::move(detail::gather(table_view({sliced_child}),
explode_col_gather_map->begin(),
explode_col_gather_map->end(),
cudf::out_of_bounds_policy::NULLIFY,
stream,
mr)
->release()[0])
: std::make_unique<column>(sliced_child, stream, mr));
auto inserted = columns.insert(columns.begin() + explode_column_idx,
explode_col_gather_map
? std::move(detail::gather(table_view({sliced_child}),
explode_col_gather_map->begin(),
explode_col_gather_map->end(),
cudf::out_of_bounds_policy::NULLIFY,
stream,
mr)
->release()[0])
: std::make_unique<column>(sliced_child, stream, mr));

if (position_array) {
size_type position_size = position_array->size();
// the null mask for position matches the exploded column's gather map, so copy it over
rmm::device_buffer nullmask =
explode_col_gather_map ? copy_bitmask(*inserted->get()) : rmm::device_buffer(0, stream);
columns.insert(columns.begin() + explode_column_idx,
std::make_unique<column>(
data_type(type_to_id<size_type>()), position_size, position_array->release()));
std::make_unique<column>(data_type(type_to_id<size_type>()),
position_size,
position_array->release(),
std::move(nullmask)));
}

return std::make_unique<table>(std::move(columns));
Expand Down
21 changes: 11 additions & 10 deletions cpp/tests/lists/explode_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ TEST_F(ExplodeOuterTest, SingleNull)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 0, 1, 0, 0, 1};
FCW expected_pos_col{{0, 0, 1, 0, 0, 1}, {0, 1, 1, 0, 1, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -561,7 +561,7 @@ TEST_F(ExplodeOuterTest, Nulls)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 2, 0, 0, 1};
FCW expected_pos_col{{0, 1, 2, 0, 0, 1}, {1, 1, 1, 0, 1, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -591,7 +591,7 @@ TEST_F(ExplodeOuterTest, AllNulls)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 0, 0};
FCW expected_pos_col{{0, 0, 0}, {0, 0, 0}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -624,7 +624,7 @@ TEST_F(ExplodeOuterTest, SequentialNulls)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 2, 0, 1, 0, 0, 0, 1, 2};
FCW expected_pos_col{{0, 1, 2, 0, 1, 0, 0, 0, 1, 2}, {1, 1, 0, 1, 1, 0, 0, 1, 1, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -655,7 +655,7 @@ TEST_F(ExplodeOuterTest, MoreEmptyThanData)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 0, 0, 0, 0, 0};
FCW expected_pos_col{{0, 1, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -685,7 +685,7 @@ TEST_F(ExplodeOuterTest, TrailingEmptys)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 0, 0, 0, 0};
FCW expected_pos_col{{0, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -718,7 +718,7 @@ TEST_F(ExplodeOuterTest, LeadingNulls)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 0, 0, 0, 0, 1};
FCW expected_pos_col{{0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 1, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -753,7 +753,7 @@ TEST_F(ExplodeOuterTest, NullsInList)

CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 2, 0, 1, 2, 3, 0, 0, 1, 2};
FCW expected_pos_col{{0, 1, 2, 0, 1, 2, 3, 0, 0, 1, 2}, {1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -813,7 +813,7 @@ TEST_F(ExplodeOuterTest, NestedNulls)
auto ret = cudf::explode_outer(t, 0);
CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 0, 0, 1, 2};
FCW expected_pos_col{{0, 1, 0, 0, 1, 2}, {1, 1, 0, 1, 1, 1}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(t, 0);
Expand Down Expand Up @@ -884,7 +884,8 @@ TEST_F(ExplodeOuterTest, NullsInNestedDoubleExplode)

CUDF_TEST_EXPECT_TABLES_EQUAL(ret->view(), expected);

FCW expected_pos_col{0, 1, 0, 0, 1, 2, 0, 1, 0, 1, 0, 0, 1};
FCW expected_pos_col{{0, 1, 0, 0, 1, 2, 0, 1, 0, 1, 0, 0, 1},
{1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}};
cudf::table_view pos_expected({expected_pos_col, expected_a, expected_b});

auto pos_ret = cudf::explode_outer_position(first_explode_ret->view(), 0);
Expand Down