l1t1 opened a new issue, #10040: URL: https://github.com/apache/arrow-datafusion/issues/10040
### Describe the bug I cannot sum an unnest result, it reports following error message. ```sql > select unnest(generate_series(1,10)); +---------------------------------------------+ | unnest(generate_series(Int64(1),Int64(10))) | +---------------------------------------------+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +---------------------------------------------+ 10 row(s) fetched. Elapsed 0.003 seconds. > select sum(unnest(generate_series(1,10))); type_coercion caused by Internal error: Unnest should be rewritten to LogicalPlan::Unnest before type coercion. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker ``` while if use a CTE to save the unnest result, it works ```sql > with t(a) as (select unnest(generate_series(1,10)))select * from t; +----+ | a | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +----+ 10 row(s) fetched. Elapsed 0.005 seconds. > with t(a) as (select unnest(generate_series(1,10)))select sum(a) from t; +----------+ | SUM(t.a) | +----------+ | 55 | +----------+ 1 row(s) fetched. Elapsed 0.014 seconds. ``` ### To Reproduce ``` select sum(unnest(generate_series(1,10))); ``` ### Expected behavior it return a value of 55 as the CTE vesion does ### Additional context _No response_ -- 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]
