wangyum commented on pull request #30222:
URL: https://github.com/apache/spark/pull/30222#issuecomment-743725618


   @cloud-fan @dongjoon-hyun We can improve the following case to reduce 
`Union` operator:
   ```sql
   create table t1 using parquet as select * from range(100);
   create table t2 using parquet as select * from range(200);
   
   create temp view v1 as                                                       
      
   select 'a' as event_type, * from t1                                          
      
   union all                                                                    
      
   select CASE WHEN id = 1 THEN 'b' WHEN id = 3 THEN 'c' end as event_type, * 
from t2;
   
   explain select * from v1 where event_type = 'a';
   == Physical Plan ==
   Union
   :- *(1) Project [a AS event_type#8, id#10L]
   :  +- *(1) ColumnarToRow
   :     +- FileScan parquet default.t1[id#10L] Batched: true, DataFilters: [], 
Format: Parquet,
   +- *(2) Project [CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c END 
AS event_type#9, id#11L]
      +- *(2) Filter (CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c 
END = a)
         +- *(2) ColumnarToRow
            +- FileScan parquet default.t2[id#11L] Batched: true, DataFilters: 
[(CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c END = a)], Format: 
Parquet
   
   
   explain select * from v1 where event_type = 'b';
   == Physical Plan ==
   *(1) Project [CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c END AS 
event_type#8, id#11L AS id#10L]
   +- *(1) Filter (CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c END = 
b)
      +- *(1) ColumnarToRow
         +- FileScan parquet default.t2[id#11L] Batched: true, DataFilters: 
[(CASE WHEN (id#11L = 1) THEN b WHEN (id#11L = 3) THEN c END = b)], Format: 
Parquet
   
   ```


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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to