Datafusion substrait does not set 'maintain_singular_struct' in MaskExpression
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Describe the bug
Datafusion substrait does not set 'maintain_singular_struct' in MaskExpression
https://github.com/substrait-io/substrait/blob/aab01537d750f6fb296a7fe8e18299d04ecc7a83/proto/substrait/algebra.proto#L1298-L1300
### To Reproduce
Generate the substrait plan from the following SQL
SQL
```
SELECT PS_AVAILQTY
FROM 'partsupp'
ORDER BY PS_AVAILQTY
```
The following substrait plan will be generated:
```
{
"relations": [
{
"root": {
"input": {
"fetch": {
"input": {
"sort": {
"input": {
"read": {
"baseSchema": {
"names": [
"ps_partkey",
"ps_suppkey",
"ps_availqty",
"ps_supplycost",
"ps_comment"
]
},
"projection": {
"select": {
"structItems": [
{
"field": 2
}
]
}
},
"namedTable": {
"names": [
"partsupp"
]
}
}
},
"sorts": [
{
"expr": {
"selection": {
"directReference": {
"structField": {}
}
}
},
"direction": "SORT_DIRECTION_ASC_NULLS_LAST"
}
]
}
},
"count": "10"
}
},
"names": [
"ps_availqty"
]
}
}
],
"version": {
"minorNumber": 51,
"producer": "datafusion"
}
}
```
projection doesn't include 'maintain_singular_struct' and therefore fails when running the plan through the substrait-validator
```
"projection": {
"select": {
"structItems": [
{
"field": 2
}
]
}
},
```
### Expected behavior
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by reproducing the SQL query and inspecting the generated Substrait plan's projection, especially the select structItems shown in the issue. Compare that projection with the Substrait MaskExpression definition linked in the report and validate the corrected plan with substrait-validator; done means the plan is accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100