You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/04/10 02:23:22 UTC
[GitHub] [iceberg] singhpk234 commented on a diff in pull request #4530: Spark [3.2] : Improve #4446 stats estimation for spark scan with delete files
singhpk234 commented on code in PR #4530:
URL: https://github.com/apache/iceberg/pull/4530#discussion_r846702641
##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java:
##########
@@ -148,8 +149,9 @@ protected Statistics estimateStatistics(Snapshot snapshot) {
for (CombinedScanTask task : tasks()) {
for (FileScanTask file : task.files()) {
- // TODO: if possible, take deletes also into consideration.
- double fractionOfFileScanned = ((double) file.length()) / file.file().fileSizeInBytes();
+ // take deletes also into consideration.
+ long deletesSizeInBytes = file.deletes().stream().mapToLong(DeleteFile::fileSizeInBytes).sum();
+ double fractionOfFileScanned = ((double) file.length()) / (file.file().fileSizeInBytes() + deletesSizeInBytes);
Review Comment:
Thanks @felixYyu for your contribution.
As per my understanding a single delete file can be associated with multiple data files, (also position delete doesn't store complete deleted row info also (ref [this](https://iceberg.apache.org/spec/#position-delete-files)) there is also case of equality deletes (ref : [this](https://iceberg.apache.org/spec/#equality-delete-files)) where we just store the matching pred, hence it will not be so straight forward to estimate size / row count.
Hence row count post applying delete files will be hard to estimate without actually applying them, hence I left it as a todo.
From the looks of it, this approach looks incorrect to me (may be I am wrong here) will leave it to the better judgement of more experienced folks of iceberg.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org