gabotechs opened a new issue, #15344:
URL: https://github.com/apache/datafusion/issues/15344
### Describe the bug
Providing empty aggregation functions in a Substrait plan results in an
invalid logical plan that fails in the physical transformation step with the
following error:
```
Error: Internal("args should not be empty")
```
Coming from this line:
https://github.com/apache/datafusion/blob/11838be5efa8607f762504c198615c54575b0593/datafusion/physical-expr/src/aggregate.rs#L113
### To Reproduce
Feed this simple `SELECT count(*) FROM (SELECT 1))` substrait plan:
<details><summary>substrait plan</summary>
```json
{
"extensionUris": [
{
"uri":
"https://github.com/substrait-io/substrait/blob/main/extensions/functions_aggregate_generic.yaml"
}
],
"extensions": [
{
"extensionFunction": {
"functionAnchor": 185,
"name": "count:any"
}
}
],
"relations": [
{
"root": {
"input": {
"aggregate": {
"common": {
"direct": {
}
},
"input": {
"read": {
"common": {
"direct": {
}
},
"baseSchema": {
"names": [
"dummy"
],
"struct": {
"types": [
{
"i64": {
"nullability": "NULLABILITY_REQUIRED"
}
}
],
"nullability": "NULLABILITY_REQUIRED"
}
},
"virtualTable": {
"values": [
{
"fields": [
{
"i64": "0",
"nullable": false
}
]
}
]
}
}
},
"groupings": [
{
"groupingExpressions": [],
"expressionReferences": []
}
],
"measures": [
{
"measure": {
"functionReference": 185,
"args": [],
"sorts": [],
"phase": "AGGREGATION_PHASE_INITIAL_TO_RESULT",
"outputType": {
"i64": {
"nullability": "NULLABILITY_REQUIRED"
}
},
"invocation": "AGGREGATION_INVOCATION_ALL",
"arguments": [],
"options": []
}
}
],
"groupingExpressions": []
}
},
"names": [
"count(*)"
]
}
}
]
}
```
</details>
Or simply add the following line to the Substrait integration tests
[here](https://github.com/apache/datafusion/blob/9278233e9fe34f7712370f2fa583ba94663a0678/datafusion/substrait/tests/cases/consumer_integration.rs#L44)
and run them.
```rust
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto)?;
let plan = from_substrait_plan(&ctx.state(), &proto).await?;
+ ctx.state().create_physical_plan(&plan).await?;
Ok(format!("{}", plan))
}
```
### Expected behavior
The Substrait to DF conversion logic works as before injecting dummy
arguments where necessary
### Additional context
I suspect that this regression was introduced in this change
https://github.com/apache/datafusion/pull/14824/files#diff-474e53672159d74dae38992a914a74eba81b8350ebe161f11d755f06414ed7b4,
but not sure if just adding that back will break something else
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]