[substrait] producer `LogicalPlan::EmptyRelation` bug
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
the `field_qualifiers` in the DFSchema are missing when producer `LogicalPlan::EmptyRelation`
### To Reproduce
Add test in file: datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
```rust
#[tokio::test]
async fn test_empty_relation() -> Result<()> {
roundtrip("SELECT * FROM data LIMIT 0").await
}
```
Error
```shell
assertion `left == right` failed
left: DFSchema { inner: Schema { fields: [Field { name: "a", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "b", data_type: Decimal128(5, 2), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "c", data_type: Date32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "d", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "e", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "f", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }], metadata: {} }, field_qualifiers: [Some(Bare { table: "data" }), Some(Bare { table: "data" }), Some(Bare { table: "data" }), Some(Bare { table: "data" }), Some(Bare { table: "data" }), Some(Bare { table: "data" })], functional_dependencies: FunctionalDependencies { deps: [] } }
right: DFSchema { inner: Schema { fields: [Field { name: "a", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "b", data_type: Decimal128(5, 2), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "c", data_type: Date32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "d", data_type: Boolean, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "e", data_type: UInt32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "f", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }], metadata: {} }, field_qualifiers: [None, None, None, None, None, None], functional_dependencies: FunctionalDependencies { deps: [] } }
```
### Expected behavior
pass test
### Additional context
#### EmptyRelation producer
https://github.com/apache/datafusion/blob/2482ff45d0109c4a576e4cbfdd5769107fd9ede2/datafusion/substrait/src/logical_plan/producer.rs#L223-L243
#### EmptyRelation consumer
https://github.com/apache/datafusion/blob/2482ff45d0109c4a576e4cbfdd5769107fd9ede2/datafusion/substrait/src/logical_plan/consumer.rs#L889-L895
#### TableScan consumer
add `field_qualifiers` into `DFSchema`
https://github.com/apache/datafusion/blob/2482ff45d0109c4a576e4cbfdd5769107fd9ede2/datafusion/substrait/src/logical_plan/consumer.rs#L884-L885
Contributor guide
Research direction
Start with datafusion/substrait/tests/cases/roundtrip_logical_plan.rs and add the provided test for SELECT * FROM data LIMIT 0. Read the EmptyRelation producer in datafusion/substrait/src/logical_plan/producer.rs and its consumer in consumer.rs, compare it with the TableScan consumer's field_qualifiers handling, and run the roundtrip test until it passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100