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

GH-41121: [C++] Fix: left anti join filter empty rows. #41122

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix lint for hashjoin test
Light-City authored and pitrou committed Apr 15, 2024
commit 5d59164bfe4d2b69f08a58c37fce233de203b204
9 changes: 6 additions & 3 deletions cpp/src/arrow/acero/hash_join_node_test.cc
Original file line number Diff line number Diff line change
@@ -2038,14 +2038,17 @@ TEST(HashJoin, ResidualFilter) {

TEST(HashJoin, FilterEmptyRows) {
BatchesWithSchema input_left;
pitrou marked this conversation as resolved.
Show resolved Hide resolved
input_left.batches = {ExecBatchFromJSON({int32(), utf8(), int32()}, R"([[2, "Jarry", 28]])")};
input_left.schema = schema({field("id", int32()), field("name", utf8()), field("age", int32())});
input_left.batches = {
ExecBatchFromJSON({int32(), utf8(), int32()}, R"([[2, "Jarry", 28]])")};
input_left.schema =
schema({field("id", int32()), field("name", utf8()), field("age", int32())});

BatchesWithSchema input_right;
input_right.batches = {ExecBatchFromJSON(
{int32(), int32(), utf8()},
R"([[2, 10, "Jack"], [3, 12, "Mark"], [4, 15, "Tom"], [1, 10, "Jack"]])")};
input_right.schema = schema({field("id", int32()), field("stu_id", int32()), field("subject", utf8())});
input_right.schema =
schema({field("id", int32()), field("stu_id", int32()), field("subject", utf8())});

const ResidualFilterCaseRunner runner{std::move(input_left), std::move(input_right)};

8 changes: 5 additions & 3 deletions cpp/src/arrow/acero/swiss_join.cc
Original file line number Diff line number Diff line change
@@ -2160,16 +2160,18 @@ Status JoinResidualFilter::FilterOneBatch(const ExecBatch& keypayload_batch,
bool output_key_ids, bool output_payload_ids,
arrow::util::TempVectorStack* temp_stack,
int* num_passing_rows) const {
if (num_batch_rows == 0) {
return Status::OK();
}
// Caller must do shortcuts for trivial filter.
ARROW_DCHECK(!filter_.IsNullLiteral() && filter_ != literal(true) &&
filter_ != literal(false));
ARROW_DCHECK(!output_key_ids || key_ids_maybe_null);
ARROW_DCHECK(!output_payload_ids || payload_ids_maybe_null);

*num_passing_rows = 0;

if (num_batch_rows == 0) {
return Status::OK();
}

ARROW_ASSIGN_OR_RAISE(Datum mask,
EvalFilter(keypayload_batch, num_batch_rows, batch_row_ids,
key_ids_maybe_null, payload_ids_maybe_null));