andygrove commented on PR #3242:
URL: 
https://github.com/apache/arrow-datafusion/pull/3242#issuecomment-1225004505

   > Given the above sql, it results in this plan. Isn't this 1 too many 
projections?
   > 
   > ```
   > create view v as select 1 as a, 2 as b, 3 as c;
   > explain analyze select * from (select b from v);
   > 
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > | plan_type         | plan                                                 
                                                                                
                                        |
   > 
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > | Plan with Metrics | CoalescePartitionsExec, metrics=[output_rows=1, 
elapsed_compute=72.1µs, spill_count=0, spilled_bytes=0, mem_used=0]             
                                             |
   > |                   |   ProjectionExec: expr=[b@0 as b], 
metrics=[output_rows=1, elapsed_compute=3.311µs, spill_count=0, 
spilled_bytes=0, mem_used=0]                                              |
   > |                   |     ProjectionExec: expr=[b@0 as b], 
metrics=[output_rows=1, elapsed_compute=5.511µs, spill_count=0, 
spilled_bytes=0, mem_used=0]                                            |
   > |                   |       ProjectionExec: expr=[2 as b], 
metrics=[output_rows=1, elapsed_compute=53.011µs, spill_count=0, 
spilled_bytes=0, mem_used=0]                                           |
   > |                   |         RepartitionExec: 
partitioning=RoundRobinBatch(12), metrics=[repart_time{inputPartition=0}=1ns, 
fetch_time{inputPartition=0}=27µs, send_time{inputPartition=0}=7.6µs] |
   > |                   |           EmptyExec: produce_one_row=true, 
metrics=[]                                                                      
                                                  |
   > |                   |                                                      
                                                                                
                                        |
   > 
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   > ```
   
   These could easily be optimized out if we could run the optimizer here, but 
we can't. This also means we lose projection push-down when selecting from a 
view. This does at least fix the correctness issue, even if this is not 
efficient so it might be best to file a specific issue for this. I'll take 
another look at this tomorrow.


-- 
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]

Reply via email to