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

Fix a bug in distinct: using nested nulls logic #10848

Merged
merged 3 commits into from
May 16, 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
2 changes: 1 addition & 1 deletion cpp/src/stream_compaction/distinct.cu
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::unique_ptr<table> distinct(table_view const& input,
auto keys_view = input.select(keys);
auto preprocessed_keys =
cudf::experimental::row::hash::preprocessed_table::create(keys_view, stream);
auto has_null = nullate::DYNAMIC{cudf::has_nulls(keys_view)};
auto const has_null = nullate::DYNAMIC{cudf::has_nested_nulls(keys_view)};
auto const num_rows{keys_view.num_rows()};

hash_map_type key_map{compute_hash_table_size(num_rows),
Expand Down
40 changes: 40 additions & 0 deletions cpp/tests/stream_compaction/distinct_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,46 @@ TEST_F(Distinct, StructOfStruct)
CUDF_TEST_EXPECT_COLUMNS_EQUAL(sliced_expect->get_column(1), sorted_sliced_result->get_column(1));
}

TEST_F(Distinct, StructWithNullElement)
{
using FWCW = cudf::test::fixed_width_column_wrapper<int>;
using MASK = std::vector<bool>;

/*
`@` indicates null

/+-------------+
|s1{s2{a,b}, c}|
+--------------+
0 | { {1, 1}, 2}|
1 | {@{1, 1}, 2}|
+--------------+
*/

auto col_a = FWCW{1, 1};
auto col_b = FWCW{1, 1};
auto s2_mask = MASK{1, 0};
auto col_c = FWCW{2, 2};
auto s1_mask = MASK{1, 1};
auto idx = FWCW{0, 1};

std::vector<std::unique_ptr<cudf::column>> s2_children;
s2_children.push_back(col_a.release());
s2_children.push_back(col_b.release());
auto s2 = cudf::test::structs_column_wrapper(std::move(s2_children), s2_mask);
PointKernel marked this conversation as resolved.
Show resolved Hide resolved

std::vector<std::unique_ptr<cudf::column>> s1_children;
s1_children.push_back(s2.release());
s1_children.push_back(col_c.release());
auto s1 = cudf::test::structs_column_wrapper(std::move(s1_children), s1_mask);

auto input = cudf::table_view({idx, s1});

auto result = cudf::distinct(input, {1});
auto sorted_result = cudf::sort_by_key(*result, result->select({0}));
CUDF_TEST_EXPECT_COLUMNS_EQUAL(input.column(1), sorted_result->get_column(1));
}

TEST_F(Distinct, ListOfEmptyStruct)
{
// 0. [] ==
Expand Down