== Physical Plan ==
TakeOrderedAndProject (24)
+- * HashAggregate (23)
   +- Exchange (22)
      +- * HashAggregate (21)
         +- * Project (20)
            +- * SortMergeJoin Inner (19)
               :- * Sort (13)
               :  +- Exchange (12)
               :     +- * Project (11)
               :        +- * BroadcastHashJoin Inner BuildRight (10)
               :           :- * Project (4)
               :           :  +- * Filter (3)
               :           :     +- * ColumnarToRow (2)
               :           :        +- Scan parquet spark_catalog.default.store_returns (1)
               :           +- BroadcastExchange (9)
               :              +- * Project (8)
               :                 +- * Filter (7)
               :                    +- * ColumnarToRow (6)
               :                       +- Scan parquet spark_catalog.default.reason (5)
               +- * Sort (18)
                  +- Exchange (17)
                     +- * Project (16)
                        +- * ColumnarToRow (15)
                           +- Scan parquet spark_catalog.default.store_sales (14)


(1) Scan parquet spark_catalog.default.store_returns
Output [5]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4, sr_returned_date_sk#5]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_returns]
PushedFilters: [IsNotNull(sr_item_sk), IsNotNull(sr_ticket_number), IsNotNull(sr_reason_sk)]
ReadSchema: struct<sr_item_sk:int,sr_reason_sk:int,sr_ticket_number:int,sr_return_quantity:int>

(2) ColumnarToRow [codegen id : 2]
Input [5]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4, sr_returned_date_sk#5]

(3) Filter [codegen id : 2]
Input [5]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4, sr_returned_date_sk#5]
Condition : ((isnotnull(sr_item_sk#1) AND isnotnull(sr_ticket_number#3)) AND isnotnull(sr_reason_sk#2))

(4) Project [codegen id : 2]
Output [4]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4]
Input [5]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4, sr_returned_date_sk#5]

(5) Scan parquet spark_catalog.default.reason
Output [2]: [r_reason_sk#6, r_reason_desc#7]
Batched: true
Location [not included in comparison]/{warehouse_dir}/reason]
PushedFilters: [IsNotNull(r_reason_desc), EqualTo(r_reason_desc,reason 28                                                                                           ), IsNotNull(r_reason_sk)]
ReadSchema: struct<r_reason_sk:int,r_reason_desc:string>

(6) ColumnarToRow [codegen id : 1]
Input [2]: [r_reason_sk#6, r_reason_desc#7]

(7) Filter [codegen id : 1]
Input [2]: [r_reason_sk#6, r_reason_desc#7]
Condition : ((isnotnull(r_reason_desc#7) AND (r_reason_desc#7 = reason 28                                                                                           )) AND isnotnull(r_reason_sk#6))

(8) Project [codegen id : 1]
Output [1]: [r_reason_sk#6]
Input [2]: [r_reason_sk#6, r_reason_desc#7]

(9) BroadcastExchange
Input [1]: [r_reason_sk#6]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=1]

(10) BroadcastHashJoin [codegen id : 2]
Left keys [1]: [sr_reason_sk#2]
Right keys [1]: [r_reason_sk#6]
Join type: Inner
Join condition: None

(11) Project [codegen id : 2]
Output [3]: [sr_item_sk#1, sr_ticket_number#3, sr_return_quantity#4]
Input [5]: [sr_item_sk#1, sr_reason_sk#2, sr_ticket_number#3, sr_return_quantity#4, r_reason_sk#6]

(12) Exchange
Input [3]: [sr_item_sk#1, sr_ticket_number#3, sr_return_quantity#4]
Arguments: hashpartitioning(sr_item_sk#1, sr_ticket_number#3, 5), ENSURE_REQUIREMENTS, [plan_id=2]

(13) Sort [codegen id : 3]
Input [3]: [sr_item_sk#1, sr_ticket_number#3, sr_return_quantity#4]
Arguments: [sr_item_sk#1 ASC NULLS FIRST, sr_ticket_number#3 ASC NULLS FIRST], false, 0

(14) Scan parquet spark_catalog.default.store_sales
Output [6]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12, ss_sold_date_sk#13]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
ReadSchema: struct<ss_item_sk:int,ss_customer_sk:int,ss_ticket_number:int,ss_quantity:int,ss_sales_price:decimal(7,2)>

(15) ColumnarToRow [codegen id : 4]
Input [6]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12, ss_sold_date_sk#13]

(16) Project [codegen id : 4]
Output [5]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12]
Input [6]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12, ss_sold_date_sk#13]

(17) Exchange
Input [5]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12]
Arguments: hashpartitioning(ss_item_sk#8, ss_ticket_number#10, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(18) Sort [codegen id : 5]
Input [5]: [ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12]
Arguments: [ss_item_sk#8 ASC NULLS FIRST, ss_ticket_number#10 ASC NULLS FIRST], false, 0

(19) SortMergeJoin [codegen id : 6]
Left keys [2]: [sr_item_sk#1, sr_ticket_number#3]
Right keys [2]: [ss_item_sk#8, ss_ticket_number#10]
Join type: Inner
Join condition: None

(20) Project [codegen id : 6]
Output [2]: [ss_customer_sk#9, CASE WHEN isnotnull(sr_return_quantity#4) THEN (cast((ss_quantity#11 - sr_return_quantity#4) as decimal(10,0)) * ss_sales_price#12) ELSE (cast(ss_quantity#11 as decimal(10,0)) * ss_sales_price#12) END AS act_sales#14]
Input [8]: [sr_item_sk#1, sr_ticket_number#3, sr_return_quantity#4, ss_item_sk#8, ss_customer_sk#9, ss_ticket_number#10, ss_quantity#11, ss_sales_price#12]

(21) HashAggregate [codegen id : 6]
Input [2]: [ss_customer_sk#9, act_sales#14]
Keys [1]: [ss_customer_sk#9]
Functions [1]: [partial_sum(act_sales#14)]
Aggregate Attributes [2]: [sum#15, isEmpty#16]
Results [3]: [ss_customer_sk#9, sum#17, isEmpty#18]

(22) Exchange
Input [3]: [ss_customer_sk#9, sum#17, isEmpty#18]
Arguments: hashpartitioning(ss_customer_sk#9, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(23) HashAggregate [codegen id : 7]
Input [3]: [ss_customer_sk#9, sum#17, isEmpty#18]
Keys [1]: [ss_customer_sk#9]
Functions [1]: [sum(act_sales#14)]
Aggregate Attributes [1]: [sum(act_sales#14)#19]
Results [2]: [ss_customer_sk#9, sum(act_sales#14)#19 AS sumsales#20]

(24) TakeOrderedAndProject
Input [2]: [ss_customer_sk#9, sumsales#20]
Arguments: 100, [sumsales#20 ASC NULLS FIRST, ss_customer_sk#9 ASC NULLS FIRST], [ss_customer_sk#9, sumsales#20]

