Commit c256ccd
authored
fix: support total_size=0 in byte_range_to_row_range (#7115)
## Summary
In certain cases DataFusion might decide to create a ranges for empty
files that have zero rows. In order to avoid hitting a division by zero
error in the
```rust
let average_row = total_size / row_count;
```
line, add an early exit check to `VortexOpener::open` to immediately
return an empty stream if the file contains zero rows:
```rust
if vxf.row_count() == 0 {
let empty_stream = stream::iter(vec![]).boxed();
return Ok(empty_stream);
}
```
The enforced `row_count > 0` invariant for the `byte_range_to_row_range`
call is now also called out with a `debug_assert!` macro.
## Testing
Add a new `test_open_empty_file` test case.
Signed-off-by: Alexander Alexandrov <alexander.s.alexandrov@gmail.com>1 parent a773f86 commit c256ccd
1 file changed
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
| |||
430 | 436 | | |
431 | 437 | | |
432 | 438 | | |
| 439 | + | |
| 440 | + | |
433 | 441 | | |
434 | 442 | | |
435 | 443 | | |
| |||
619 | 627 | | |
620 | 628 | | |
621 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
622 | 657 | | |
623 | 658 | | |
624 | 659 | | |
| |||
0 commit comments