Skip to content

Commit

Permalink
Fix crash when select count(*) from table with delta delete (facebook…
Browse files Browse the repository at this point in the history
…incubator#9984)

Summary: Pull Request resolved: facebookincubator#9984

Differential Revision: D57970942
  • Loading branch information
Yuhta authored and facebook-github-bot committed May 30, 2024
1 parent 0dc4633 commit 40e7262
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions velox/dwio/common/Mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ struct Mutation {
random::RandomSkipTracker* randomSkip = nullptr;
};

inline bool hasDeletion(const Mutation* mutation) {
return mutation && (mutation->deletedRows || mutation->randomSkip);
}

} // namespace facebook::velox::dwio::common
2 changes: 1 addition & 1 deletion velox/dwio/common/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void RowReader::readWithRowNumber(
flatRowNum = rowNumVector->asUnchecked<FlatVector<int64_t>>();
}
auto* rawRowNum = flatRowNum->mutableRawValues();
if (numChildren == 0 && !mutation) {
if (numChildren == 0 && !hasDeletion(mutation)) {
VELOX_DCHECK_EQ(rowsToRead, result->size());
std::iota(rawRowNum, rawRowNum + rowsToRead, previousRow);
} else {
Expand Down
6 changes: 3 additions & 3 deletions velox/dwio/common/SelectiveStructColumnReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ void SelectiveStructColumnReaderBase::next(
VectorPtr& result,
const Mutation* mutation) {
process::TraceContext trace("SelectiveStructColumnReaderBase::next");
mutation_ = mutation;
hasMutation_ = hasDeletion(mutation);
if (children_.empty()) {
if (mutation) {
if (hasMutation_) {
if (fillMutatedOutputRows_) {
fillOutputRowsFromMutation(numValues);
numValues = outputRows_.size();
Expand Down Expand Up @@ -121,8 +123,6 @@ void SelectiveStructColumnReaderBase::next(
if (numValues > oldSize) {
std::iota(&rows_[oldSize], &rows_[rows_.size()], oldSize);
}
mutation_ = mutation;
hasMutation_ = mutation && (mutation->deletedRows || mutation->randomSkip);
read(readOffset_, rows_, nullptr);
getValues(outputRows(), &result);
}
Expand Down

0 comments on commit 40e7262

Please sign in to comment.