Repository navigation
fix(arrow): skip data files with a known zero record count - #3682
Merged
Merged
Conversation
alexanderbianchi
marked this pull request as ready for review
November 12, 2026 22:22
Contributor
Author
|
Thank you for the quick review + merge! We noticed this on production migrating trino traffic to datafusion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #3681.
What changes are included in this PR?
Return an empty stream from
FileScanTaskReader::processwhen the task has a known zero record count (Some(0)), before loading deletes or opening the Parquet reader.The metrics evaluator already excludes zero-record files when empty files are not requested, but unfiltered scans can bypass that evaluator. Tasks can also be supplied directly to
ArrowReader::read. Those tasks currently try to load a footer even though they cannot contribute rows, failing on zero-byte or missing files.The check belongs in the Arrow reader so it covers both planned and directly supplied tasks.
Explicit mapping to the Java implementation
The semantic rule is known zero records means no rows to read. Java applies it during metrics evaluation and avoids zero-length read ranges during splitting.
task.record_count() == Some(0)returns an empty stream.InclusiveMetricsEvaluator.MetricsEvalVisitor.evalreturnsROWS_CANNOT_MATCHwhenfile.recordCount() == 0, before evaluating the predicate.Nonedoes not take the empty-file fast path.recordCount() < 0) asROWS_MIGHT_MATCH, not an empty file.BaseContentScanTask.splitusesFixedSizeSplitScanTaskIterator. ItshasNext()isremainingLength > 0, so a zero-length file produces no file-range tasks.For that splitting path,
BaseContentScanTask.length()callsScanTaskUtil.contentSizeInBytes, which returnsfileSizeInBytes()for data files. Trino 479'sIcebergSplitSourceuses this splitting path for scans projecting data columns.The Rust change deliberately uses record count, not byte size: a positive-record/zero-byte task must still fail. Keeping the check in
FileScanTaskReader::processalso covers direct task streams from data sources without requiring a particular planner or predicate.