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 Iceberg read when positional delete files are unaligned #10261

Closed
wants to merge 2 commits into from

Conversation

yingsu00
Copy link
Collaborator

@yingsu00 yingsu00 commented Jun 19, 2024

When the base data file and positional delete files contains multiple
unaligned RowGroups, some of the bits at the end of
IcebergSplitReader::deleteBitmap_ could be mistakenly skipped, causing
wrong result. This commit fixes it by introducing an offset into this
deleteBitmap_ and shift the unused bits to the beginning for each batch.

Fixes #9856

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 19, 2024
Copy link

netlify bot commented Jun 19, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e4df770
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/6686d9bef08a6400082ef023

@yingsu00 yingsu00 changed the title Iceberg row group fix Fix Iceberg read when positional delete files are unaligned Jun 20, 2024
@yingsu00 yingsu00 requested a review from Yuhta June 20, 2024 19:39
@yingsu00 yingsu00 marked this pull request as ready for review June 20, 2024 19:39

return rowsScanned;
}

void IcebergSplitReader::shiftDeleteBitmap() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use bits::copyBits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Jimmy! I updated to bits::copyBits().

btw. Just out of curiosity, I benchmarked bits::copyBits() and this shiftDeleteBitmap () function, and found bits::copyBits() was over 10x slower than this for many cases. Maybe we can improve the bits operations in the future.
Screenshot 2024-06-21 at 10 16 09

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is definitely room to improve copyBits. The overall timing of that function in the query is not large though.

}

mutation.deletedRows =
deleteBitmap_ ? deleteBitmap_->as<uint64_t>() : nullptr;

auto rowsScanned = baseRowReader_->next(size, output, &mutation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a function to get actual scanning size in row reader called nextReadSize. There is also nextRowNumber to help you track the number of rows scanned on base file. You can consider using these methods to make reading delta positions a little easier and fewer states to maintain (maybe in subsequent diffs).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuhta Thanks Jimmy! I checked these functions and yes we can get the actual rows scanned before calling base RowReader's next(). So I'll send a separate PR to simplify the logic using these functions.
For now I updated the PR with your another comment addressed. Would appreciate your review again.

This commit makes it possible to create base data files and delete fiels
with un-aligned Rowgroup boundaries. It also added several new test cases
and improved some variable and function namings.
@yingsu00
Copy link
Collaborator Author

@Yuhta Would you please review again? Thank you!

@Yuhta Yuhta added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Jun 26, 2024
@yingsu00
Copy link
Collaborator Author

yingsu00 commented Jul 1, 2024

@Yuhta Thanks for reviewing and approving this PR. Do we know when it will be merged?

@facebook-github-bot
Copy link
Contributor

@Yuhta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@Yuhta Yuhta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some lint errors

velox/connectors/hive/iceberg/tests/IcebergReadTest.cpp Outdated Show resolved Hide resolved
velox/connectors/hive/iceberg/tests/IcebergReadTest.cpp Outdated Show resolved Hide resolved
velox/connectors/hive/iceberg/tests/IcebergReadTest.cpp Outdated Show resolved Hide resolved
velox/connectors/hive/iceberg/tests/IcebergReadTest.cpp Outdated Show resolved Hide resolved
When the base data file and positional delete files contains multiple
unaligned RowGroups, some of the bits at the end of
IcebergSplitReader::deleteBitmap_ could be mistakenly skipped, causing
wrong result. This commit fixes it by introducing an offset into this
deleteBitmap_ and shift the unused bits to the beginning for each batch.
@yingsu00
Copy link
Collaborator Author

yingsu00 commented Jul 5, 2024

@Yuhta Thanks for importing the PR and let me know the failures! I have updated the PR with your comments addressed.

@facebook-github-bot
Copy link
Contributor

@Yuhta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link

Conbench analyzed the 1 benchmark run on commit 66aeca40.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

@facebook-github-bot
Copy link
Contributor

@Yuhta merged this pull request in 66aeca4.

@facebook-github-bot
Copy link
Contributor

This pull request has been reverted by e8a73ae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall Reverted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong result while Iceberg table read with Positional Delete
3 participants