Select with order by from empty table triggers SanityCheckPlan error
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
```sql
CREATE TABLE test (vendor_id INT)
SELECT * FROM test ORDER BY by app_id
```
```rust
Fails with DataFusion error: SanityCheckPlan caused by Error during planning: Plan: [\"SortExec: expr=[vendor_id@0 ASC NULLS LAST], preserve_partitioning=[false]\", \" DataSourceExec: file_groups={0 groups: []}, projection=[vendor_id], file_type=parquet\"] does not satisfy distribution requirements: SinglePartition. Child-0 output partitioning: UnknownPartitioning(0)
```
Execution plan SortExec has .**input** DataSourceExec cache -> PlanProperties partitioning: **UnknownPartitioning(0)**,
and .**cache** -> PlanProperties partitioning: **UnknownPartitioning(1)**
### To Reproduce
```sql
CREATE TABLE test (vendor_id INT)
SELECT * FROM test ORDER BY by app_id
```
### Expected behavior
Return empty records batch
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.