Skip to content

Commit

Permalink
fix full outer join with null value compare in right side
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf committed Nov 8, 2024
1 parent afcb38e commit 97fbc9c
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions velox/exec/MergeJoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,14 +1009,16 @@ RowVectorPtr MergeJoin::getOutput() {
} else if (isAntiJoin(joinType_)) {
output = filterOutputForAntiJoin(output);
if (output) {
std::cout << "the output is " << output->toString(0, output->size())
<< "\n";
return output;
}

// No rows survived the filter for anti join. Get more rows.
continue;
} else {
// std::cout << "the output is " << output->toString(0, output->size())
// << "\n";
std::cout << "the output is " << output->toString(0, output->size())
<< "\n";
return output;
}
}
Expand All @@ -1038,22 +1040,19 @@ RowVectorPtr MergeJoin::getOutput() {
if (rightInput_) {
// std::cout << "the right input is " << rightInput_->toString(0,
// rightInput_->size()) << "\n";
if (isFullJoin(joinType_)) {
rightIndex_ = 0;
} else {
auto firstNonNullIndex = firstNonNull(rightInput_, rightKeys_);
if (isRightJoin(joinType_) && firstNonNullIndex > 0) {
prepareOutput(nullptr, rightInput_);
for (auto i = 0; i < firstNonNullIndex; ++i) {
addOutputRowForRightJoin(rightInput_, i);
}
}
rightIndex_ = firstNonNullIndex;
if (rightIndex_ == rightInput_->size()) {
// Ran out of rows on the right side.
rightInput_ = nullptr;
auto firstNonNullIndex = firstNonNull(rightInput_, rightKeys_);
if ((isRightJoin(joinType_) || isFullJoin(joinType_)) &&
firstNonNullIndex > 0) {
prepareOutput(nullptr, rightInput_);
for (auto i = 0; i < firstNonNullIndex; ++i) {
addOutputRowForRightJoin(rightInput_, i);
}
}
rightIndex_ = firstNonNullIndex;
if (rightIndex_ == rightInput_->size()) {
// Ran out of rows on the right side.
rightInput_ = nullptr;
}
} else {
noMoreRightInput_ = true;
}
Expand Down

0 comments on commit 97fbc9c

Please sign in to comment.