== Physical Plan ==
TakeOrderedAndProject (57)
+- * HashAggregate (56)
   +- Exchange (55)
      +- * HashAggregate (54)
         +- * Project (53)
            +- * SortMergeJoin Inner (52)
               :- * Sort (27)
               :  +- Exchange (26)
               :     +- * Project (25)
               :        +- * SortMergeJoin Inner (24)
               :           :- * Sort (18)
               :           :  +- Exchange (17)
               :           :     +- * Project (16)
               :           :        +- * BroadcastHashJoin Inner BuildRight (15)
               :           :           :- * Project (10)
               :           :           :  +- * BroadcastHashJoin Inner BuildRight (9)
               :           :           :     :- * Filter (3)
               :           :           :     :  +- * ColumnarToRow (2)
               :           :           :     :     +- Scan parquet default.store_sales (1)
               :           :           :     +- BroadcastExchange (8)
               :           :           :        +- * Project (7)
               :           :           :           +- * Filter (6)
               :           :           :              +- * ColumnarToRow (5)
               :           :           :                 +- Scan parquet default.date_dim (4)
               :           :           +- BroadcastExchange (14)
               :           :              +- * Filter (13)
               :           :                 +- * ColumnarToRow (12)
               :           :                    +- Scan parquet default.store (11)
               :           +- * Sort (23)
               :              +- Exchange (22)
               :                 +- * Filter (21)
               :                    +- * ColumnarToRow (20)
               :                       +- Scan parquet default.item (19)
               +- * Sort (51)
                  +- Exchange (50)
                     +- * Project (49)
                        +- * SortMergeJoin Inner (48)
                           :- * Sort (39)
                           :  +- Exchange (38)
                           :     +- * Project (37)
                           :        +- * BroadcastHashJoin Inner BuildRight (36)
                           :           :- * Filter (30)
                           :           :  +- * ColumnarToRow (29)
                           :           :     +- Scan parquet default.store_returns (28)
                           :           +- BroadcastExchange (35)
                           :              +- * Project (34)
                           :                 +- * Filter (33)
                           :                    +- * ColumnarToRow (32)
                           :                       +- Scan parquet default.date_dim (31)
                           +- * Sort (47)
                              +- Exchange (46)
                                 +- * Project (45)
                                    +- * BroadcastHashJoin Inner BuildRight (44)
                                       :- * Filter (42)
                                       :  +- * ColumnarToRow (41)
                                       :     +- Scan parquet default.catalog_sales (40)
                                       +- ReusedExchange (43)


(1) Scan parquet default.store_sales
Output [6]: [ss_sold_date_sk#1, ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_customer_sk), IsNotNull(ss_item_sk), IsNotNull(ss_ticket_number), IsNotNull(ss_sold_date_sk), IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_item_sk:int,ss_customer_sk:int,ss_store_sk:int,ss_ticket_number:int,ss_quantity:int>

(2) ColumnarToRow [codegen id : 3]
Input [6]: [ss_sold_date_sk#1, ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6]

(3) Filter [codegen id : 3]
Input [6]: [ss_sold_date_sk#1, ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6]
Condition : ((((isnotnull(ss_customer_sk#3) AND isnotnull(ss_item_sk#2)) AND isnotnull(ss_ticket_number#5)) AND isnotnull(ss_sold_date_sk#1)) AND isnotnull(ss_store_sk#4))

(4) Scan parquet default.date_dim
Output [2]: [d_date_sk#7, d_quarter_name#8]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_quarter_name), EqualTo(d_quarter_name,2001Q1), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_quarter_name:string>

(5) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#7, d_quarter_name#8]

(6) Filter [codegen id : 1]
Input [2]: [d_date_sk#7, d_quarter_name#8]
Condition : ((isnotnull(d_quarter_name#8) AND (d_quarter_name#8 = 2001Q1)) AND isnotnull(d_date_sk#7))

(7) Project [codegen id : 1]
Output [1]: [d_date_sk#7]
Input [2]: [d_date_sk#7, d_quarter_name#8]

(8) BroadcastExchange
Input [1]: [d_date_sk#7]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#9]

(9) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_sold_date_sk#1]
Right keys [1]: [d_date_sk#7]
Join condition: None

(10) Project [codegen id : 3]
Output [5]: [ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6]
Input [7]: [ss_sold_date_sk#1, ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6, d_date_sk#7]

(11) Scan parquet default.store
Output [2]: [s_store_sk#10, s_state#11]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store]
PushedFilters: [IsNotNull(s_store_sk)]
ReadSchema: struct<s_store_sk:int,s_state:string>

(12) ColumnarToRow [codegen id : 2]
Input [2]: [s_store_sk#10, s_state#11]

(13) Filter [codegen id : 2]
Input [2]: [s_store_sk#10, s_state#11]
Condition : isnotnull(s_store_sk#10)

(14) BroadcastExchange
Input [2]: [s_store_sk#10, s_state#11]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#12]

(15) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_store_sk#4]
Right keys [1]: [s_store_sk#10]
Join condition: None

(16) Project [codegen id : 3]
Output [5]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11]
Input [7]: [ss_item_sk#2, ss_customer_sk#3, ss_store_sk#4, ss_ticket_number#5, ss_quantity#6, s_store_sk#10, s_state#11]

(17) Exchange
Input [5]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11]
Arguments: hashpartitioning(ss_item_sk#2, 5), ENSURE_REQUIREMENTS, [id=#13]

(18) Sort [codegen id : 4]
Input [5]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11]
Arguments: [ss_item_sk#2 ASC NULLS FIRST], false, 0

(19) Scan parquet default.item
Output [3]: [i_item_sk#14, i_item_id#15, i_item_desc#16]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_item_id:string,i_item_desc:string>

(20) ColumnarToRow [codegen id : 5]
Input [3]: [i_item_sk#14, i_item_id#15, i_item_desc#16]

(21) Filter [codegen id : 5]
Input [3]: [i_item_sk#14, i_item_id#15, i_item_desc#16]
Condition : isnotnull(i_item_sk#14)

(22) Exchange
Input [3]: [i_item_sk#14, i_item_id#15, i_item_desc#16]
Arguments: hashpartitioning(i_item_sk#14, 5), ENSURE_REQUIREMENTS, [id=#17]

(23) Sort [codegen id : 6]
Input [3]: [i_item_sk#14, i_item_id#15, i_item_desc#16]
Arguments: [i_item_sk#14 ASC NULLS FIRST], false, 0

(24) SortMergeJoin [codegen id : 7]
Left keys [1]: [ss_item_sk#2]
Right keys [1]: [i_item_sk#14]
Join condition: None

(25) Project [codegen id : 7]
Output [7]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11, i_item_id#15, i_item_desc#16]
Input [8]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11, i_item_sk#14, i_item_id#15, i_item_desc#16]

(26) Exchange
Input [7]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11, i_item_id#15, i_item_desc#16]
Arguments: hashpartitioning(cast(ss_customer_sk#3 as bigint), cast(ss_item_sk#2 as bigint), cast(ss_ticket_number#5 as bigint), 5), ENSURE_REQUIREMENTS, [id=#18]

(27) Sort [codegen id : 8]
Input [7]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11, i_item_id#15, i_item_desc#16]
Arguments: [cast(ss_customer_sk#3 as bigint) ASC NULLS FIRST, cast(ss_item_sk#2 as bigint) ASC NULLS FIRST, cast(ss_ticket_number#5 as bigint) ASC NULLS FIRST], false, 0

(28) Scan parquet default.store_returns
Output [5]: [sr_returned_date_sk#19, sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_returns]
PushedFilters: [IsNotNull(sr_customer_sk), IsNotNull(sr_item_sk), IsNotNull(sr_ticket_number), IsNotNull(sr_returned_date_sk)]
ReadSchema: struct<sr_returned_date_sk:bigint,sr_item_sk:bigint,sr_customer_sk:bigint,sr_ticket_number:bigint,sr_return_quantity:int>

(29) ColumnarToRow [codegen id : 10]
Input [5]: [sr_returned_date_sk#19, sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]

(30) Filter [codegen id : 10]
Input [5]: [sr_returned_date_sk#19, sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]
Condition : (((isnotnull(sr_customer_sk#21) AND isnotnull(sr_item_sk#20)) AND isnotnull(sr_ticket_number#22)) AND isnotnull(sr_returned_date_sk#19))

(31) Scan parquet default.date_dim
Output [2]: [d_date_sk#24, d_quarter_name#25]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [In(d_quarter_name, [2001Q1,2001Q2,2001Q3]), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_quarter_name:string>

(32) ColumnarToRow [codegen id : 9]
Input [2]: [d_date_sk#24, d_quarter_name#25]

(33) Filter [codegen id : 9]
Input [2]: [d_date_sk#24, d_quarter_name#25]
Condition : (d_quarter_name#25 IN (2001Q1,2001Q2,2001Q3) AND isnotnull(d_date_sk#24))

(34) Project [codegen id : 9]
Output [1]: [d_date_sk#24]
Input [2]: [d_date_sk#24, d_quarter_name#25]

(35) BroadcastExchange
Input [1]: [d_date_sk#24]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#26]

(36) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [sr_returned_date_sk#19]
Right keys [1]: [cast(d_date_sk#24 as bigint)]
Join condition: None

(37) Project [codegen id : 10]
Output [4]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]
Input [6]: [sr_returned_date_sk#19, sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, d_date_sk#24]

(38) Exchange
Input [4]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]
Arguments: hashpartitioning(sr_customer_sk#21, sr_item_sk#20, 5), ENSURE_REQUIREMENTS, [id=#27]

(39) Sort [codegen id : 11]
Input [4]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23]
Arguments: [sr_customer_sk#21 ASC NULLS FIRST, sr_item_sk#20 ASC NULLS FIRST], false, 0

(40) Scan parquet default.catalog_sales
Output [4]: [cs_sold_date_sk#28, cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]
Batched: true
Location [not included in comparison]/{warehouse_dir}/catalog_sales]
PushedFilters: [IsNotNull(cs_bill_customer_sk), IsNotNull(cs_item_sk), IsNotNull(cs_sold_date_sk)]
ReadSchema: struct<cs_sold_date_sk:int,cs_bill_customer_sk:int,cs_item_sk:int,cs_quantity:int>

(41) ColumnarToRow [codegen id : 13]
Input [4]: [cs_sold_date_sk#28, cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]

(42) Filter [codegen id : 13]
Input [4]: [cs_sold_date_sk#28, cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]
Condition : ((isnotnull(cs_bill_customer_sk#29) AND isnotnull(cs_item_sk#30)) AND isnotnull(cs_sold_date_sk#28))

(43) ReusedExchange [Reuses operator id: 35]
Output [1]: [d_date_sk#32]

(44) BroadcastHashJoin [codegen id : 13]
Left keys [1]: [cs_sold_date_sk#28]
Right keys [1]: [d_date_sk#32]
Join condition: None

(45) Project [codegen id : 13]
Output [3]: [cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]
Input [5]: [cs_sold_date_sk#28, cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31, d_date_sk#32]

(46) Exchange
Input [3]: [cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]
Arguments: hashpartitioning(cast(cs_bill_customer_sk#29 as bigint), cast(cs_item_sk#30 as bigint), 5), ENSURE_REQUIREMENTS, [id=#33]

(47) Sort [codegen id : 14]
Input [3]: [cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]
Arguments: [cast(cs_bill_customer_sk#29 as bigint) ASC NULLS FIRST, cast(cs_item_sk#30 as bigint) ASC NULLS FIRST], false, 0

(48) SortMergeJoin [codegen id : 15]
Left keys [2]: [sr_customer_sk#21, sr_item_sk#20]
Right keys [2]: [cast(cs_bill_customer_sk#29 as bigint), cast(cs_item_sk#30 as bigint)]
Join condition: None

(49) Project [codegen id : 15]
Output [5]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, cs_quantity#31]
Input [7]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, cs_bill_customer_sk#29, cs_item_sk#30, cs_quantity#31]

(50) Exchange
Input [5]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, cs_quantity#31]
Arguments: hashpartitioning(sr_customer_sk#21, sr_item_sk#20, sr_ticket_number#22, 5), ENSURE_REQUIREMENTS, [id=#34]

(51) Sort [codegen id : 16]
Input [5]: [sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, cs_quantity#31]
Arguments: [sr_customer_sk#21 ASC NULLS FIRST, sr_item_sk#20 ASC NULLS FIRST, sr_ticket_number#22 ASC NULLS FIRST], false, 0

(52) SortMergeJoin [codegen id : 17]
Left keys [3]: [cast(ss_customer_sk#3 as bigint), cast(ss_item_sk#2 as bigint), cast(ss_ticket_number#5 as bigint)]
Right keys [3]: [sr_customer_sk#21, sr_item_sk#20, sr_ticket_number#22]
Join condition: None

(53) Project [codegen id : 17]
Output [6]: [ss_quantity#6, sr_return_quantity#23, cs_quantity#31, s_state#11, i_item_id#15, i_item_desc#16]
Input [12]: [ss_item_sk#2, ss_customer_sk#3, ss_ticket_number#5, ss_quantity#6, s_state#11, i_item_id#15, i_item_desc#16, sr_item_sk#20, sr_customer_sk#21, sr_ticket_number#22, sr_return_quantity#23, cs_quantity#31]

(54) HashAggregate [codegen id : 17]
Input [6]: [ss_quantity#6, sr_return_quantity#23, cs_quantity#31, s_state#11, i_item_id#15, i_item_desc#16]
Keys [3]: [i_item_id#15, i_item_desc#16, s_state#11]
Functions [9]: [partial_count(ss_quantity#6), partial_avg(cast(ss_quantity#6 as bigint)), partial_stddev_samp(cast(ss_quantity#6 as double)), partial_count(sr_return_quantity#23), partial_avg(cast(sr_return_quantity#23 as bigint)), partial_stddev_samp(cast(sr_return_quantity#23 as double)), partial_count(cs_quantity#31), partial_avg(cast(cs_quantity#31 as bigint)), partial_stddev_samp(cast(cs_quantity#31 as double))]
Aggregate Attributes [18]: [count#35, sum#36, count#37, n#38, avg#39, m2#40, count#41, sum#42, count#43, n#44, avg#45, m2#46, count#47, sum#48, count#49, n#50, avg#51, m2#52]
Results [21]: [i_item_id#15, i_item_desc#16, s_state#11, count#53, sum#54, count#55, n#56, avg#57, m2#58, count#59, sum#60, count#61, n#62, avg#63, m2#64, count#65, sum#66, count#67, n#68, avg#69, m2#70]

(55) Exchange
Input [21]: [i_item_id#15, i_item_desc#16, s_state#11, count#53, sum#54, count#55, n#56, avg#57, m2#58, count#59, sum#60, count#61, n#62, avg#63, m2#64, count#65, sum#66, count#67, n#68, avg#69, m2#70]
Arguments: hashpartitioning(i_item_id#15, i_item_desc#16, s_state#11, 5), ENSURE_REQUIREMENTS, [id=#71]

(56) HashAggregate [codegen id : 18]
Input [21]: [i_item_id#15, i_item_desc#16, s_state#11, count#53, sum#54, count#55, n#56, avg#57, m2#58, count#59, sum#60, count#61, n#62, avg#63, m2#64, count#65, sum#66, count#67, n#68, avg#69, m2#70]
Keys [3]: [i_item_id#15, i_item_desc#16, s_state#11]
Functions [9]: [count(ss_quantity#6), avg(cast(ss_quantity#6 as bigint)), stddev_samp(cast(ss_quantity#6 as double)), count(sr_return_quantity#23), avg(cast(sr_return_quantity#23 as bigint)), stddev_samp(cast(sr_return_quantity#23 as double)), count(cs_quantity#31), avg(cast(cs_quantity#31 as bigint)), stddev_samp(cast(cs_quantity#31 as double))]
Aggregate Attributes [9]: [count(ss_quantity#6)#72, avg(cast(ss_quantity#6 as bigint))#73, stddev_samp(cast(ss_quantity#6 as double))#74, count(sr_return_quantity#23)#75, avg(cast(sr_return_quantity#23 as bigint))#76, stddev_samp(cast(sr_return_quantity#23 as double))#77, count(cs_quantity#31)#78, avg(cast(cs_quantity#31 as bigint))#79, stddev_samp(cast(cs_quantity#31 as double))#80]
Results [15]: [i_item_id#15, i_item_desc#16, s_state#11, count(ss_quantity#6)#72 AS store_sales_quantitycount#81, avg(cast(ss_quantity#6 as bigint))#73 AS store_sales_quantityave#82, stddev_samp(cast(ss_quantity#6 as double))#74 AS store_sales_quantitystdev#83, (stddev_samp(cast(ss_quantity#6 as double))#74 / avg(cast(ss_quantity#6 as bigint))#73) AS store_sales_quantitycov#84, count(sr_return_quantity#23)#75 AS as_store_returns_quantitycount#85, avg(cast(sr_return_quantity#23 as bigint))#76 AS as_store_returns_quantityave#86, stddev_samp(cast(sr_return_quantity#23 as double))#77 AS as_store_returns_quantitystdev#87, (stddev_samp(cast(sr_return_quantity#23 as double))#77 / avg(cast(sr_return_quantity#23 as bigint))#76) AS store_returns_quantitycov#88, count(cs_quantity#31)#78 AS catalog_sales_quantitycount#89, avg(cast(cs_quantity#31 as bigint))#79 AS catalog_sales_quantityave#90, (stddev_samp(cast(cs_quantity#31 as double))#80 / avg(cast(cs_quantity#31 as bigint))#79) AS catalog_sales_quantitystdev#91, (stddev_samp(cast(cs_quantity#31 as double))#80 / avg(cast(cs_quantity#31 as bigint))#79) AS catalog_sales_quantitycov#92]

(57) TakeOrderedAndProject
Input [15]: [i_item_id#15, i_item_desc#16, s_state#11, store_sales_quantitycount#81, store_sales_quantityave#82, store_sales_quantitystdev#83, store_sales_quantitycov#84, as_store_returns_quantitycount#85, as_store_returns_quantityave#86, as_store_returns_quantitystdev#87, store_returns_quantitycov#88, catalog_sales_quantitycount#89, catalog_sales_quantityave#90, catalog_sales_quantitystdev#91, catalog_sales_quantitycov#92]
Arguments: 100, [i_item_id#15 ASC NULLS FIRST, i_item_desc#16 ASC NULLS FIRST, s_state#11 ASC NULLS FIRST], [i_item_id#15, i_item_desc#16, s_state#11, store_sales_quantitycount#81, store_sales_quantityave#82, store_sales_quantitystdev#83, store_sales_quantitycov#84, as_store_returns_quantitycount#85, as_store_returns_quantityave#86, as_store_returns_quantitystdev#87, store_returns_quantitycov#88, catalog_sales_quantitycount#89, catalog_sales_quantityave#90, catalog_sales_quantitystdev#91, catalog_sales_quantitycov#92]

