-
Notifications
You must be signed in to change notification settings - Fork 919
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 struct row comparator's exception on empty structs #10604
Merged
rapids-bot
merged 4 commits into
rapidsai:branch-22.06
from
sperlingxx:fix_empty_struct_cmp
Apr 8, 2022
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -804,6 +804,60 @@ TYPED_TEST(FixedPointTestAllReps, FixedPointSortedOrderGather) | |
CUDF_TEST_EXPECT_TABLES_EQUAL(sorted_table, sorted->view()); | ||
} | ||
|
||
struct SortCornerTest : public BaseFixture { | ||
}; | ||
|
||
TEST_F(SortCornerTest, WithEmptyStructColumn) | ||
{ | ||
using int_col = fixed_width_column_wrapper<int32_t>; | ||
|
||
// struct{}, int, int | ||
int_col col_for_mask{{0, 0, 0, 0, 0, 0}, {1, 0, 1, 1, 1, 1}}; | ||
auto null_mask = cudf::copy_bitmask(col_for_mask.release()->view()); | ||
auto struct_col = cudf::make_structs_column(6, {}, UNKNOWN_NULL_COUNT, std::move(null_mask)); | ||
|
||
int_col col1{{1, 2, 3, 1, 2, 3}}; | ||
int_col col2{{1, 1, 1, 2, 2, 2}}; | ||
table_view input{{struct_col->view(), col1, col2}}; | ||
|
||
int_col expected{{1, 0, 3, 4, 2, 5}}; | ||
std::vector<order> column_order{order::ASCENDING, order::ASCENDING, order::ASCENDING}; | ||
auto got = sorted_order(input, column_order); | ||
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, got->view()); | ||
|
||
// struct{struct{}, int} | ||
int_col col3{{0, 1, 2, 3, 4, 5}}; | ||
std::vector<std::unique_ptr<cudf::column>> child_columns; | ||
child_columns.push_back(std::move(struct_col)); | ||
child_columns.push_back(col3.release()); | ||
auto struct_col2 = | ||
cudf::make_structs_column(6, std::move(child_columns), 0, rmm::device_buffer{}); | ||
table_view input2{{struct_col2->view()}}; | ||
|
||
int_col expected2{{5, 4, 3, 2, 0, 1}}; | ||
auto got2 = sorted_order(input2, {order::DESCENDING}); | ||
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected2, got2->view()); | ||
|
||
// struct{struct{}, struct{int}} | ||
int_col col_for_mask2{{0, 0, 0, 0, 0, 0}, {1, 0, 1, 1, 0, 1}}; | ||
auto null_mask2 = cudf::copy_bitmask(col_for_mask2.release()->view()); | ||
std::vector<std::unique_ptr<cudf::column>> child_columns2; | ||
auto child_col_1 = cudf::make_structs_column(6, {}, UNKNOWN_NULL_COUNT, std::move(null_mask2)); | ||
child_columns2.push_back(std::move(child_col_1)); | ||
int_col col4{{5, 4, 3, 2, 1, 0}}; | ||
std::vector<std::unique_ptr<cudf::column>> grand_child; | ||
grand_child.push_back(std::move(col4.release())); | ||
auto child_col_2 = cudf::make_structs_column(6, std::move(grand_child), 0, rmm::device_buffer{}); | ||
child_columns2.push_back(std::move(child_col_2)); | ||
auto struct_col3 = | ||
cudf::make_structs_column(6, std::move(child_columns2), 0, rmm::device_buffer{}); | ||
table_view input3{{struct_col3->view()}}; | ||
|
||
int_col expected3{{4, 1, 5, 3, 2, 0}}; | ||
auto got3 = sorted_order(input3, {order::ASCENDING}); | ||
CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected3, got3->view(), debug_output_level::ALL_ERRORS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, why not. |
||
}; | ||
|
||
} // namespace test | ||
} // namespace cudf | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devavret I assume there is some check earlier on in hose code that verifies corresponding struct columns have the same number of children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. If it reaches here, they're the same structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does work. I added a test case to cover this scenario. IIUC, following the rule of
decompose_structs
, the second child will be detached from the root struct.=>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of
decompose_structs
itself was broken because it operated under the assumption that struct has at least 1 child. If S1 was empty then it would createI fixed the impl so this is good to go.