apache / apache/datafusion

`FileScanConfig::output_ordering` must be vector of optionals

Open
#17,354 3 comments 0 reactions 1 assignee Claimed by @destrex271 View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

Currently the output ordering -- which is defined per partition -- is a vector of `LexOrdering`:

https://github.com/apache/datafusion/blob/d19bf524e384bc24e509c70f1806b6f330829529/datafusion/datasource/src/file_scan_config.rs#L183-L184

This was kinda OK before #16217 because `LexOrdering` was allowed to be empty -- which was basically a sentinel value for "not ordering". Now however the code cannot specify that a partition isn't ordered anymore. This actually leads to some funky bugs like in this code here:

https://github.com/apache/datafusion/blob/d19bf524e384bc24e509c70f1806b6f330829529/datafusion/datasource/src/file_scan_config.rs#L1382-L1384

So if the projection for a single partition leads to "unordered", then `get_projected_output_ordering(input).len() < input.len()`, i.e. we loose partitions. This can clearly not be right.

### To Reproduce

_No response_

### Expected behavior

`FileScanConfig::output_ordering` must be `Vec>`.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.