duongcongtoai commented on issue #11198:
URL: https://github.com/apache/datafusion/issues/11198#issuecomment-2229340200

   Although theoretically #6543 can solve this ticket, but i think the bug 
presented here comes from the internal implementation inside try_process_unnest 
function itself, and can be fixed within this function
   ```
   CREATE TABLE unnest_table
   AS VALUES
       ([1,2,3]);
   
   query TT
   explain select unnest(column1), unnest(column1) + 1 from unnest_table;
   ----
   Current plan generated (which causes error)
   logical_plan
   01)Projection: unnest(unnest_table.column1), unnest(unnest_table.column1) + 
Int64(1)
   02)--Unnest: lists[unnest(unnest_table.column1)] structs[]
   03)----Projection: unnest_table.column1 AS unnest(unnest_table.column1), 
unnest_table.column1 AS unnest(unnest_table.column1)
   04)------TableScan: unnest_table projection=[column1]
   
   Better plan generated
   logical_plan
   01)Projection: unnest(unnest_table.column1), unnest(unnest_table.column1) + 
Int64(1)
   02)--Unnest: lists[unnest(unnest_table.column1)] structs[]
   03)----Projection: unnest_table.column1 AS unnest(unnest_table.column1)
   04)------TableScan: unnest_table projection=[column1]
   ```
   
   We also avoid unnecessary columns generated in the intermediate projection 
step


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to