== Physical Plan ==
TakeOrderedAndProject (76)
+- * HashAggregate (75)
   +- * HashAggregate (74)
      +- Union (73)
         :- * Project (24)
         :  +- * Filter (23)
         :     +- Window (22)
         :        +- * Sort (21)
         :           +- Window (20)
         :              +- * Sort (19)
         :                 +- Exchange (18)
         :                    +- * HashAggregate (17)
         :                       +- Exchange (16)
         :                          +- * HashAggregate (15)
         :                             +- * Project (14)
         :                                +- * BroadcastHashJoin Inner BuildRight (13)
         :                                   :- * Project (11)
         :                                   :  +- * BroadcastHashJoin Inner BuildLeft (10)
         :                                   :     :- BroadcastExchange (5)
         :                                   :     :  +- * Project (4)
         :                                   :     :     +- * Filter (3)
         :                                   :     :        +- * ColumnarToRow (2)
         :                                   :     :           +- Scan parquet spark_catalog.default.web_sales (1)
         :                                   :     +- * Project (9)
         :                                   :        +- * Filter (8)
         :                                   :           +- * ColumnarToRow (7)
         :                                   :              +- Scan parquet spark_catalog.default.web_returns (6)
         :                                   +- ReusedExchange (12)
         :- * Project (48)
         :  +- * Filter (47)
         :     +- Window (46)
         :        +- * Sort (45)
         :           +- Window (44)
         :              +- * Sort (43)
         :                 +- Exchange (42)
         :                    +- * HashAggregate (41)
         :                       +- Exchange (40)
         :                          +- * HashAggregate (39)
         :                             +- * Project (38)
         :                                +- * BroadcastHashJoin Inner BuildRight (37)
         :                                   :- * Project (35)
         :                                   :  +- * BroadcastHashJoin Inner BuildLeft (34)
         :                                   :     :- BroadcastExchange (29)
         :                                   :     :  +- * Project (28)
         :                                   :     :     +- * Filter (27)
         :                                   :     :        +- * ColumnarToRow (26)
         :                                   :     :           +- Scan parquet spark_catalog.default.catalog_sales (25)
         :                                   :     +- * Project (33)
         :                                   :        +- * Filter (32)
         :                                   :           +- * ColumnarToRow (31)
         :                                   :              +- Scan parquet spark_catalog.default.catalog_returns (30)
         :                                   +- ReusedExchange (36)
         +- * Project (72)
            +- * Filter (71)
               +- Window (70)
                  +- * Sort (69)
                     +- Window (68)
                        +- * Sort (67)
                           +- Exchange (66)
                              +- * HashAggregate (65)
                                 +- Exchange (64)
                                    +- * HashAggregate (63)
                                       +- * Project (62)
                                          +- * BroadcastHashJoin Inner BuildRight (61)
                                             :- * Project (59)
                                             :  +- * BroadcastHashJoin Inner BuildLeft (58)
                                             :     :- BroadcastExchange (53)
                                             :     :  +- * Project (52)
                                             :     :     +- * Filter (51)
                                             :     :        +- * ColumnarToRow (50)
                                             :     :           +- Scan parquet spark_catalog.default.store_sales (49)
                                             :     +- * Project (57)
                                             :        +- * Filter (56)
                                             :           +- * ColumnarToRow (55)
                                             :              +- Scan parquet spark_catalog.default.store_returns (54)
                                             +- ReusedExchange (60)


(1) Scan parquet spark_catalog.default.web_sales
Output [6]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_net_profit#5, ws_sold_date_sk#6]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#6), dynamicpruningexpression(ws_sold_date_sk#6 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(ws_net_profit), IsNotNull(ws_net_paid), IsNotNull(ws_quantity), GreaterThan(ws_net_profit,1.00), GreaterThan(ws_net_paid,0.00), GreaterThan(ws_quantity,0), IsNotNull(ws_order_number), IsNotNull(ws_item_sk)]
ReadSchema: struct<ws_item_sk:int,ws_order_number:int,ws_quantity:int,ws_net_paid:decimal(7,2),ws_net_profit:decimal(7,2)>

(2) ColumnarToRow [codegen id : 1]
Input [6]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_net_profit#5, ws_sold_date_sk#6]

(3) Filter [codegen id : 1]
Input [6]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_net_profit#5, ws_sold_date_sk#6]
Condition : (((((((isnotnull(ws_net_profit#5) AND isnotnull(ws_net_paid#4)) AND isnotnull(ws_quantity#3)) AND (ws_net_profit#5 > 1.00)) AND (ws_net_paid#4 > 0.00)) AND (ws_quantity#3 > 0)) AND isnotnull(ws_order_number#2)) AND isnotnull(ws_item_sk#1))

(4) Project [codegen id : 1]
Output [5]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_sold_date_sk#6]
Input [6]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_net_profit#5, ws_sold_date_sk#6]

(5) BroadcastExchange
Input [5]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_sold_date_sk#6]
Arguments: HashedRelationBroadcastMode(List((shiftleft(cast(input[1, int, true] as bigint), 32) | (cast(input[0, int, true] as bigint) & 4294967295))),false), [plan_id=1]

(6) Scan parquet spark_catalog.default.web_returns
Output [5]: [wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11, wr_returned_date_sk#12]
Batched: true
Location [not included in comparison]/{warehouse_dir}/web_returns]
PushedFilters: [IsNotNull(wr_return_amt), GreaterThan(wr_return_amt,10000.00), IsNotNull(wr_order_number), IsNotNull(wr_item_sk)]
ReadSchema: struct<wr_item_sk:int,wr_order_number:int,wr_return_quantity:int,wr_return_amt:decimal(7,2)>

(7) ColumnarToRow
Input [5]: [wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11, wr_returned_date_sk#12]

(8) Filter
Input [5]: [wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11, wr_returned_date_sk#12]
Condition : (((isnotnull(wr_return_amt#11) AND (wr_return_amt#11 > 10000.00)) AND isnotnull(wr_order_number#9)) AND isnotnull(wr_item_sk#8))

(9) Project
Output [4]: [wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11]
Input [5]: [wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11, wr_returned_date_sk#12]

(10) BroadcastHashJoin [codegen id : 3]
Left keys [2]: [ws_order_number#2, ws_item_sk#1]
Right keys [2]: [wr_order_number#9, wr_item_sk#8]
Join type: Inner
Join condition: None

(11) Project [codegen id : 3]
Output [6]: [ws_item_sk#1, ws_quantity#3, ws_net_paid#4, ws_sold_date_sk#6, wr_return_quantity#10, wr_return_amt#11]
Input [9]: [ws_item_sk#1, ws_order_number#2, ws_quantity#3, ws_net_paid#4, ws_sold_date_sk#6, wr_item_sk#8, wr_order_number#9, wr_return_quantity#10, wr_return_amt#11]

(12) ReusedExchange [Reuses operator id: 81]
Output [1]: [d_date_sk#13]

(13) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ws_sold_date_sk#6]
Right keys [1]: [d_date_sk#13]
Join type: Inner
Join condition: None

(14) Project [codegen id : 3]
Output [5]: [ws_item_sk#1, ws_quantity#3, ws_net_paid#4, wr_return_quantity#10, wr_return_amt#11]
Input [7]: [ws_item_sk#1, ws_quantity#3, ws_net_paid#4, ws_sold_date_sk#6, wr_return_quantity#10, wr_return_amt#11, d_date_sk#13]

(15) HashAggregate [codegen id : 3]
Input [5]: [ws_item_sk#1, ws_quantity#3, ws_net_paid#4, wr_return_quantity#10, wr_return_amt#11]
Keys [1]: [ws_item_sk#1]
Functions [4]: [partial_sum(coalesce(wr_return_quantity#10, 0)), partial_sum(coalesce(ws_quantity#3, 0)), partial_sum(coalesce(cast(wr_return_amt#11 as decimal(12,2)), 0.00)), partial_sum(coalesce(cast(ws_net_paid#4 as decimal(12,2)), 0.00))]
Aggregate Attributes [6]: [sum#14, sum#15, sum#16, isEmpty#17, sum#18, isEmpty#19]
Results [7]: [ws_item_sk#1, sum#20, sum#21, sum#22, isEmpty#23, sum#24, isEmpty#25]

(16) Exchange
Input [7]: [ws_item_sk#1, sum#20, sum#21, sum#22, isEmpty#23, sum#24, isEmpty#25]
Arguments: hashpartitioning(ws_item_sk#1, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(17) HashAggregate [codegen id : 4]
Input [7]: [ws_item_sk#1, sum#20, sum#21, sum#22, isEmpty#23, sum#24, isEmpty#25]
Keys [1]: [ws_item_sk#1]
Functions [4]: [sum(coalesce(wr_return_quantity#10, 0)), sum(coalesce(ws_quantity#3, 0)), sum(coalesce(cast(wr_return_amt#11 as decimal(12,2)), 0.00)), sum(coalesce(cast(ws_net_paid#4 as decimal(12,2)), 0.00))]
Aggregate Attributes [4]: [sum(coalesce(wr_return_quantity#10, 0))#26, sum(coalesce(ws_quantity#3, 0))#27, sum(coalesce(cast(wr_return_amt#11 as decimal(12,2)), 0.00))#28, sum(coalesce(cast(ws_net_paid#4 as decimal(12,2)), 0.00))#29]
Results [3]: [ws_item_sk#1 AS item#30, (cast(sum(coalesce(wr_return_quantity#10, 0))#26 as decimal(15,4)) / cast(sum(coalesce(ws_quantity#3, 0))#27 as decimal(15,4))) AS return_ratio#31, (cast(sum(coalesce(cast(wr_return_amt#11 as decimal(12,2)), 0.00))#28 as decimal(15,4)) / cast(sum(coalesce(cast(ws_net_paid#4 as decimal(12,2)), 0.00))#29 as decimal(15,4))) AS currency_ratio#32]

(18) Exchange
Input [3]: [item#30, return_ratio#31, currency_ratio#32]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=3]

(19) Sort [codegen id : 5]
Input [3]: [item#30, return_ratio#31, currency_ratio#32]
Arguments: [return_ratio#31 ASC NULLS FIRST], false, 0

(20) Window
Input [3]: [item#30, return_ratio#31, currency_ratio#32]
Arguments: [rank(return_ratio#31) windowspecdefinition(return_ratio#31 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS return_rank#33], [return_ratio#31 ASC NULLS FIRST]

(21) Sort [codegen id : 6]
Input [4]: [item#30, return_ratio#31, currency_ratio#32, return_rank#33]
Arguments: [currency_ratio#32 ASC NULLS FIRST], false, 0

(22) Window
Input [4]: [item#30, return_ratio#31, currency_ratio#32, return_rank#33]
Arguments: [rank(currency_ratio#32) windowspecdefinition(currency_ratio#32 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS currency_rank#34], [currency_ratio#32 ASC NULLS FIRST]

(23) Filter [codegen id : 7]
Input [5]: [item#30, return_ratio#31, currency_ratio#32, return_rank#33, currency_rank#34]
Condition : ((return_rank#33 <= 10) OR (currency_rank#34 <= 10))

(24) Project [codegen id : 7]
Output [5]: [web AS channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Input [5]: [item#30, return_ratio#31, currency_ratio#32, return_rank#33, currency_rank#34]

(25) Scan parquet spark_catalog.default.catalog_sales
Output [6]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_net_profit#40, cs_sold_date_sk#41]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#41), dynamicpruningexpression(cs_sold_date_sk#41 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(cs_net_profit), IsNotNull(cs_net_paid), IsNotNull(cs_quantity), GreaterThan(cs_net_profit,1.00), GreaterThan(cs_net_paid,0.00), GreaterThan(cs_quantity,0), IsNotNull(cs_order_number), IsNotNull(cs_item_sk)]
ReadSchema: struct<cs_item_sk:int,cs_order_number:int,cs_quantity:int,cs_net_paid:decimal(7,2),cs_net_profit:decimal(7,2)>

(26) ColumnarToRow [codegen id : 8]
Input [6]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_net_profit#40, cs_sold_date_sk#41]

(27) Filter [codegen id : 8]
Input [6]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_net_profit#40, cs_sold_date_sk#41]
Condition : (((((((isnotnull(cs_net_profit#40) AND isnotnull(cs_net_paid#39)) AND isnotnull(cs_quantity#38)) AND (cs_net_profit#40 > 1.00)) AND (cs_net_paid#39 > 0.00)) AND (cs_quantity#38 > 0)) AND isnotnull(cs_order_number#37)) AND isnotnull(cs_item_sk#36))

(28) Project [codegen id : 8]
Output [5]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_sold_date_sk#41]
Input [6]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_net_profit#40, cs_sold_date_sk#41]

(29) BroadcastExchange
Input [5]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_sold_date_sk#41]
Arguments: HashedRelationBroadcastMode(List((shiftleft(cast(input[1, int, true] as bigint), 32) | (cast(input[0, int, true] as bigint) & 4294967295))),false), [plan_id=4]

(30) Scan parquet spark_catalog.default.catalog_returns
Output [5]: [cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45, cr_returned_date_sk#46]
Batched: true
Location [not included in comparison]/{warehouse_dir}/catalog_returns]
PushedFilters: [IsNotNull(cr_return_amount), GreaterThan(cr_return_amount,10000.00), IsNotNull(cr_order_number), IsNotNull(cr_item_sk)]
ReadSchema: struct<cr_item_sk:int,cr_order_number:int,cr_return_quantity:int,cr_return_amount:decimal(7,2)>

(31) ColumnarToRow
Input [5]: [cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45, cr_returned_date_sk#46]

(32) Filter
Input [5]: [cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45, cr_returned_date_sk#46]
Condition : (((isnotnull(cr_return_amount#45) AND (cr_return_amount#45 > 10000.00)) AND isnotnull(cr_order_number#43)) AND isnotnull(cr_item_sk#42))

(33) Project
Output [4]: [cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45]
Input [5]: [cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45, cr_returned_date_sk#46]

(34) BroadcastHashJoin [codegen id : 10]
Left keys [2]: [cs_order_number#37, cs_item_sk#36]
Right keys [2]: [cr_order_number#43, cr_item_sk#42]
Join type: Inner
Join condition: None

(35) Project [codegen id : 10]
Output [6]: [cs_item_sk#36, cs_quantity#38, cs_net_paid#39, cs_sold_date_sk#41, cr_return_quantity#44, cr_return_amount#45]
Input [9]: [cs_item_sk#36, cs_order_number#37, cs_quantity#38, cs_net_paid#39, cs_sold_date_sk#41, cr_item_sk#42, cr_order_number#43, cr_return_quantity#44, cr_return_amount#45]

(36) ReusedExchange [Reuses operator id: 81]
Output [1]: [d_date_sk#47]

(37) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [cs_sold_date_sk#41]
Right keys [1]: [d_date_sk#47]
Join type: Inner
Join condition: None

(38) Project [codegen id : 10]
Output [5]: [cs_item_sk#36, cs_quantity#38, cs_net_paid#39, cr_return_quantity#44, cr_return_amount#45]
Input [7]: [cs_item_sk#36, cs_quantity#38, cs_net_paid#39, cs_sold_date_sk#41, cr_return_quantity#44, cr_return_amount#45, d_date_sk#47]

(39) HashAggregate [codegen id : 10]
Input [5]: [cs_item_sk#36, cs_quantity#38, cs_net_paid#39, cr_return_quantity#44, cr_return_amount#45]
Keys [1]: [cs_item_sk#36]
Functions [4]: [partial_sum(coalesce(cr_return_quantity#44, 0)), partial_sum(coalesce(cs_quantity#38, 0)), partial_sum(coalesce(cast(cr_return_amount#45 as decimal(12,2)), 0.00)), partial_sum(coalesce(cast(cs_net_paid#39 as decimal(12,2)), 0.00))]
Aggregate Attributes [6]: [sum#48, sum#49, sum#50, isEmpty#51, sum#52, isEmpty#53]
Results [7]: [cs_item_sk#36, sum#54, sum#55, sum#56, isEmpty#57, sum#58, isEmpty#59]

(40) Exchange
Input [7]: [cs_item_sk#36, sum#54, sum#55, sum#56, isEmpty#57, sum#58, isEmpty#59]
Arguments: hashpartitioning(cs_item_sk#36, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(41) HashAggregate [codegen id : 11]
Input [7]: [cs_item_sk#36, sum#54, sum#55, sum#56, isEmpty#57, sum#58, isEmpty#59]
Keys [1]: [cs_item_sk#36]
Functions [4]: [sum(coalesce(cr_return_quantity#44, 0)), sum(coalesce(cs_quantity#38, 0)), sum(coalesce(cast(cr_return_amount#45 as decimal(12,2)), 0.00)), sum(coalesce(cast(cs_net_paid#39 as decimal(12,2)), 0.00))]
Aggregate Attributes [4]: [sum(coalesce(cr_return_quantity#44, 0))#60, sum(coalesce(cs_quantity#38, 0))#61, sum(coalesce(cast(cr_return_amount#45 as decimal(12,2)), 0.00))#62, sum(coalesce(cast(cs_net_paid#39 as decimal(12,2)), 0.00))#63]
Results [3]: [cs_item_sk#36 AS item#64, (cast(sum(coalesce(cr_return_quantity#44, 0))#60 as decimal(15,4)) / cast(sum(coalesce(cs_quantity#38, 0))#61 as decimal(15,4))) AS return_ratio#65, (cast(sum(coalesce(cast(cr_return_amount#45 as decimal(12,2)), 0.00))#62 as decimal(15,4)) / cast(sum(coalesce(cast(cs_net_paid#39 as decimal(12,2)), 0.00))#63 as decimal(15,4))) AS currency_ratio#66]

(42) Exchange
Input [3]: [item#64, return_ratio#65, currency_ratio#66]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=6]

(43) Sort [codegen id : 12]
Input [3]: [item#64, return_ratio#65, currency_ratio#66]
Arguments: [return_ratio#65 ASC NULLS FIRST], false, 0

(44) Window
Input [3]: [item#64, return_ratio#65, currency_ratio#66]
Arguments: [rank(return_ratio#65) windowspecdefinition(return_ratio#65 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS return_rank#67], [return_ratio#65 ASC NULLS FIRST]

(45) Sort [codegen id : 13]
Input [4]: [item#64, return_ratio#65, currency_ratio#66, return_rank#67]
Arguments: [currency_ratio#66 ASC NULLS FIRST], false, 0

(46) Window
Input [4]: [item#64, return_ratio#65, currency_ratio#66, return_rank#67]
Arguments: [rank(currency_ratio#66) windowspecdefinition(currency_ratio#66 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS currency_rank#68], [currency_ratio#66 ASC NULLS FIRST]

(47) Filter [codegen id : 14]
Input [5]: [item#64, return_ratio#65, currency_ratio#66, return_rank#67, currency_rank#68]
Condition : ((return_rank#67 <= 10) OR (currency_rank#68 <= 10))

(48) Project [codegen id : 14]
Output [5]: [catalog AS channel#69, item#64, return_ratio#65, return_rank#67, currency_rank#68]
Input [5]: [item#64, return_ratio#65, currency_ratio#66, return_rank#67, currency_rank#68]

(49) Scan parquet spark_catalog.default.store_sales
Output [6]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_net_profit#74, ss_sold_date_sk#75]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#75), dynamicpruningexpression(ss_sold_date_sk#75 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(ss_net_profit), IsNotNull(ss_net_paid), IsNotNull(ss_quantity), GreaterThan(ss_net_profit,1.00), GreaterThan(ss_net_paid,0.00), GreaterThan(ss_quantity,0), IsNotNull(ss_ticket_number), IsNotNull(ss_item_sk)]
ReadSchema: struct<ss_item_sk:int,ss_ticket_number:int,ss_quantity:int,ss_net_paid:decimal(7,2),ss_net_profit:decimal(7,2)>

(50) ColumnarToRow [codegen id : 15]
Input [6]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_net_profit#74, ss_sold_date_sk#75]

(51) Filter [codegen id : 15]
Input [6]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_net_profit#74, ss_sold_date_sk#75]
Condition : (((((((isnotnull(ss_net_profit#74) AND isnotnull(ss_net_paid#73)) AND isnotnull(ss_quantity#72)) AND (ss_net_profit#74 > 1.00)) AND (ss_net_paid#73 > 0.00)) AND (ss_quantity#72 > 0)) AND isnotnull(ss_ticket_number#71)) AND isnotnull(ss_item_sk#70))

(52) Project [codegen id : 15]
Output [5]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_sold_date_sk#75]
Input [6]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_net_profit#74, ss_sold_date_sk#75]

(53) BroadcastExchange
Input [5]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_sold_date_sk#75]
Arguments: HashedRelationBroadcastMode(List((shiftleft(cast(input[1, int, true] as bigint), 32) | (cast(input[0, int, true] as bigint) & 4294967295))),false), [plan_id=7]

(54) Scan parquet spark_catalog.default.store_returns
Output [5]: [sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79, sr_returned_date_sk#80]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_returns]
PushedFilters: [IsNotNull(sr_return_amt), GreaterThan(sr_return_amt,10000.00), IsNotNull(sr_ticket_number), IsNotNull(sr_item_sk)]
ReadSchema: struct<sr_item_sk:int,sr_ticket_number:int,sr_return_quantity:int,sr_return_amt:decimal(7,2)>

(55) ColumnarToRow
Input [5]: [sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79, sr_returned_date_sk#80]

(56) Filter
Input [5]: [sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79, sr_returned_date_sk#80]
Condition : (((isnotnull(sr_return_amt#79) AND (sr_return_amt#79 > 10000.00)) AND isnotnull(sr_ticket_number#77)) AND isnotnull(sr_item_sk#76))

(57) Project
Output [4]: [sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79]
Input [5]: [sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79, sr_returned_date_sk#80]

(58) BroadcastHashJoin [codegen id : 17]
Left keys [2]: [ss_ticket_number#71, ss_item_sk#70]
Right keys [2]: [sr_ticket_number#77, sr_item_sk#76]
Join type: Inner
Join condition: None

(59) Project [codegen id : 17]
Output [6]: [ss_item_sk#70, ss_quantity#72, ss_net_paid#73, ss_sold_date_sk#75, sr_return_quantity#78, sr_return_amt#79]
Input [9]: [ss_item_sk#70, ss_ticket_number#71, ss_quantity#72, ss_net_paid#73, ss_sold_date_sk#75, sr_item_sk#76, sr_ticket_number#77, sr_return_quantity#78, sr_return_amt#79]

(60) ReusedExchange [Reuses operator id: 81]
Output [1]: [d_date_sk#81]

(61) BroadcastHashJoin [codegen id : 17]
Left keys [1]: [ss_sold_date_sk#75]
Right keys [1]: [d_date_sk#81]
Join type: Inner
Join condition: None

(62) Project [codegen id : 17]
Output [5]: [ss_item_sk#70, ss_quantity#72, ss_net_paid#73, sr_return_quantity#78, sr_return_amt#79]
Input [7]: [ss_item_sk#70, ss_quantity#72, ss_net_paid#73, ss_sold_date_sk#75, sr_return_quantity#78, sr_return_amt#79, d_date_sk#81]

(63) HashAggregate [codegen id : 17]
Input [5]: [ss_item_sk#70, ss_quantity#72, ss_net_paid#73, sr_return_quantity#78, sr_return_amt#79]
Keys [1]: [ss_item_sk#70]
Functions [4]: [partial_sum(coalesce(sr_return_quantity#78, 0)), partial_sum(coalesce(ss_quantity#72, 0)), partial_sum(coalesce(cast(sr_return_amt#79 as decimal(12,2)), 0.00)), partial_sum(coalesce(cast(ss_net_paid#73 as decimal(12,2)), 0.00))]
Aggregate Attributes [6]: [sum#82, sum#83, sum#84, isEmpty#85, sum#86, isEmpty#87]
Results [7]: [ss_item_sk#70, sum#88, sum#89, sum#90, isEmpty#91, sum#92, isEmpty#93]

(64) Exchange
Input [7]: [ss_item_sk#70, sum#88, sum#89, sum#90, isEmpty#91, sum#92, isEmpty#93]
Arguments: hashpartitioning(ss_item_sk#70, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(65) HashAggregate [codegen id : 18]
Input [7]: [ss_item_sk#70, sum#88, sum#89, sum#90, isEmpty#91, sum#92, isEmpty#93]
Keys [1]: [ss_item_sk#70]
Functions [4]: [sum(coalesce(sr_return_quantity#78, 0)), sum(coalesce(ss_quantity#72, 0)), sum(coalesce(cast(sr_return_amt#79 as decimal(12,2)), 0.00)), sum(coalesce(cast(ss_net_paid#73 as decimal(12,2)), 0.00))]
Aggregate Attributes [4]: [sum(coalesce(sr_return_quantity#78, 0))#94, sum(coalesce(ss_quantity#72, 0))#95, sum(coalesce(cast(sr_return_amt#79 as decimal(12,2)), 0.00))#96, sum(coalesce(cast(ss_net_paid#73 as decimal(12,2)), 0.00))#97]
Results [3]: [ss_item_sk#70 AS item#98, (cast(sum(coalesce(sr_return_quantity#78, 0))#94 as decimal(15,4)) / cast(sum(coalesce(ss_quantity#72, 0))#95 as decimal(15,4))) AS return_ratio#99, (cast(sum(coalesce(cast(sr_return_amt#79 as decimal(12,2)), 0.00))#96 as decimal(15,4)) / cast(sum(coalesce(cast(ss_net_paid#73 as decimal(12,2)), 0.00))#97 as decimal(15,4))) AS currency_ratio#100]

(66) Exchange
Input [3]: [item#98, return_ratio#99, currency_ratio#100]
Arguments: SinglePartition, ENSURE_REQUIREMENTS, [plan_id=9]

(67) Sort [codegen id : 19]
Input [3]: [item#98, return_ratio#99, currency_ratio#100]
Arguments: [return_ratio#99 ASC NULLS FIRST], false, 0

(68) Window
Input [3]: [item#98, return_ratio#99, currency_ratio#100]
Arguments: [rank(return_ratio#99) windowspecdefinition(return_ratio#99 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS return_rank#101], [return_ratio#99 ASC NULLS FIRST]

(69) Sort [codegen id : 20]
Input [4]: [item#98, return_ratio#99, currency_ratio#100, return_rank#101]
Arguments: [currency_ratio#100 ASC NULLS FIRST], false, 0

(70) Window
Input [4]: [item#98, return_ratio#99, currency_ratio#100, return_rank#101]
Arguments: [rank(currency_ratio#100) windowspecdefinition(currency_ratio#100 ASC NULLS FIRST, specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS currency_rank#102], [currency_ratio#100 ASC NULLS FIRST]

(71) Filter [codegen id : 21]
Input [5]: [item#98, return_ratio#99, currency_ratio#100, return_rank#101, currency_rank#102]
Condition : ((return_rank#101 <= 10) OR (currency_rank#102 <= 10))

(72) Project [codegen id : 21]
Output [5]: [store AS channel#103, item#98, return_ratio#99, return_rank#101, currency_rank#102]
Input [5]: [item#98, return_ratio#99, currency_ratio#100, return_rank#101, currency_rank#102]

(73) Union

(74) HashAggregate [codegen id : 22]
Input [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Keys [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Functions: []
Aggregate Attributes: []
Results [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]

(75) HashAggregate [codegen id : 22]
Input [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Keys [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Functions: []
Aggregate Attributes: []
Results [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]

(76) TakeOrderedAndProject
Input [5]: [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]
Arguments: 100, [channel#35 ASC NULLS FIRST, return_rank#33 ASC NULLS FIRST, currency_rank#34 ASC NULLS FIRST, item#30 ASC NULLS FIRST], [channel#35, item#30, return_ratio#31, return_rank#33, currency_rank#34]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ws_sold_date_sk#6 IN dynamicpruning#7
BroadcastExchange (81)
+- * Project (80)
   +- * Filter (79)
      +- * ColumnarToRow (78)
         +- Scan parquet spark_catalog.default.date_dim (77)


(77) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#13, d_year#104, d_moy#105]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), IsNotNull(d_moy), EqualTo(d_year,2001), EqualTo(d_moy,12), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_moy:int>

(78) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#13, d_year#104, d_moy#105]

(79) Filter [codegen id : 1]
Input [3]: [d_date_sk#13, d_year#104, d_moy#105]
Condition : ((((isnotnull(d_year#104) AND isnotnull(d_moy#105)) AND (d_year#104 = 2001)) AND (d_moy#105 = 12)) AND isnotnull(d_date_sk#13))

(80) Project [codegen id : 1]
Output [1]: [d_date_sk#13]
Input [3]: [d_date_sk#13, d_year#104, d_moy#105]

(81) BroadcastExchange
Input [1]: [d_date_sk#13]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=10]

Subquery:2 Hosting operator id = 25 Hosting Expression = cs_sold_date_sk#41 IN dynamicpruning#7

Subquery:3 Hosting operator id = 49 Hosting Expression = ss_sold_date_sk#75 IN dynamicpruning#7


