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


(1) Scan parquet default.store_sales
Output [6]: [ss_item_sk#1, ss_customer_sk#2, ss_store_sk#3, ss_ticket_number#4, ss_quantity#5, ss_sold_date_sk#6]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#6), dynamicpruningexpression(ss_sold_date_sk#6 IN dynamicpruning#7)]
PushedFilters: [IsNotNull(ss_customer_sk), IsNotNull(ss_item_sk), IsNotNull(ss_ticket_number), IsNotNull(ss_store_sk)]
ReadSchema: struct<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_item_sk#1, ss_customer_sk#2, ss_store_sk#3, ss_ticket_number#4, ss_quantity#5, ss_sold_date_sk#6]

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

(4) ReusedExchange [Reuses operator id: 54]
Output [1]: [d_date_sk#8]

(5) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_sold_date_sk#6]
Right keys [1]: [d_date_sk#8]
Join condition: None

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

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

(8) ColumnarToRow [codegen id : 2]
Input [2]: [s_store_sk#9, s_state#10]

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

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

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_store_sk#3]
Right keys [1]: [s_store_sk#9]
Join condition: None

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

(13) Exchange
Input [5]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10]
Arguments: hashpartitioning(ss_item_sk#1, 5), ENSURE_REQUIREMENTS, [id=#12]

(14) Sort [codegen id : 4]
Input [5]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10]
Arguments: [ss_item_sk#1 ASC NULLS FIRST], false, 0

(15) Scan parquet default.item
Output [3]: [i_item_sk#13, i_item_id#14, i_item_desc#15]
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>

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

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

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

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

(20) SortMergeJoin [codegen id : 7]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#13]
Join condition: None

(21) Project [codegen id : 7]
Output [7]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15]
Input [8]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_sk#13, i_item_id#14, i_item_desc#15]

(22) Exchange
Input [7]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15]
Arguments: hashpartitioning(ss_customer_sk#2, ss_item_sk#1, ss_ticket_number#4, 5), ENSURE_REQUIREMENTS, [id=#17]

(23) Sort [codegen id : 8]
Input [7]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15]
Arguments: [ss_customer_sk#2 ASC NULLS FIRST, ss_item_sk#1 ASC NULLS FIRST, ss_ticket_number#4 ASC NULLS FIRST], false, 0

(24) Scan parquet default.store_returns
Output [5]: [sr_item_sk#18, sr_customer_sk#19, sr_ticket_number#20, sr_return_quantity#21, sr_returned_date_sk#22]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(sr_returned_date_sk#22), dynamicpruningexpression(sr_returned_date_sk#22 IN dynamicpruning#23)]
PushedFilters: [IsNotNull(sr_customer_sk), IsNotNull(sr_item_sk), IsNotNull(sr_ticket_number)]
ReadSchema: struct<sr_item_sk:int,sr_customer_sk:int,sr_ticket_number:int,sr_return_quantity:int>

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

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

(27) ReusedExchange [Reuses operator id: 59]
Output [1]: [d_date_sk#24]

(28) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [sr_returned_date_sk#22]
Right keys [1]: [d_date_sk#24]
Join condition: None

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

(30) Exchange
Input [4]: [sr_item_sk#18, sr_customer_sk#19, sr_ticket_number#20, sr_return_quantity#21]
Arguments: hashpartitioning(sr_customer_sk#19, sr_item_sk#18, sr_ticket_number#20, 5), ENSURE_REQUIREMENTS, [id=#25]

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

(32) SortMergeJoin [codegen id : 12]
Left keys [3]: [ss_customer_sk#2, ss_item_sk#1, ss_ticket_number#4]
Right keys [3]: [sr_customer_sk#19, sr_item_sk#18, sr_ticket_number#20]
Join condition: None

(33) Project [codegen id : 12]
Output [7]: [ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15, sr_item_sk#18, sr_customer_sk#19, sr_return_quantity#21]
Input [11]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15, sr_item_sk#18, sr_customer_sk#19, sr_ticket_number#20, sr_return_quantity#21]

(34) Exchange
Input [7]: [ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15, sr_item_sk#18, sr_customer_sk#19, sr_return_quantity#21]
Arguments: hashpartitioning(sr_customer_sk#19, sr_item_sk#18, 5), ENSURE_REQUIREMENTS, [id=#26]

(35) Sort [codegen id : 13]
Input [7]: [ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15, sr_item_sk#18, sr_customer_sk#19, sr_return_quantity#21]
Arguments: [sr_customer_sk#19 ASC NULLS FIRST, sr_item_sk#18 ASC NULLS FIRST], false, 0

(36) Scan parquet default.catalog_sales
Output [4]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29, cs_sold_date_sk#30]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#30), dynamicpruningexpression(cs_sold_date_sk#30 IN dynamicpruning#23)]
PushedFilters: [IsNotNull(cs_bill_customer_sk), IsNotNull(cs_item_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_item_sk:int,cs_quantity:int>

(37) ColumnarToRow [codegen id : 15]
Input [4]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29, cs_sold_date_sk#30]

(38) Filter [codegen id : 15]
Input [4]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29, cs_sold_date_sk#30]
Condition : (isnotnull(cs_bill_customer_sk#27) AND isnotnull(cs_item_sk#28))

(39) ReusedExchange [Reuses operator id: 59]
Output [1]: [d_date_sk#31]

(40) BroadcastHashJoin [codegen id : 15]
Left keys [1]: [cs_sold_date_sk#30]
Right keys [1]: [d_date_sk#31]
Join condition: None

(41) Project [codegen id : 15]
Output [3]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29]
Input [5]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29, cs_sold_date_sk#30, d_date_sk#31]

(42) Exchange
Input [3]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29]
Arguments: hashpartitioning(cs_bill_customer_sk#27, cs_item_sk#28, 5), ENSURE_REQUIREMENTS, [id=#32]

(43) Sort [codegen id : 16]
Input [3]: [cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29]
Arguments: [cs_bill_customer_sk#27 ASC NULLS FIRST, cs_item_sk#28 ASC NULLS FIRST], false, 0

(44) SortMergeJoin [codegen id : 17]
Left keys [2]: [sr_customer_sk#19, sr_item_sk#18]
Right keys [2]: [cs_bill_customer_sk#27, cs_item_sk#28]
Join condition: None

(45) Project [codegen id : 17]
Output [6]: [ss_quantity#5, sr_return_quantity#21, cs_quantity#29, s_state#10, i_item_id#14, i_item_desc#15]
Input [10]: [ss_quantity#5, s_state#10, i_item_id#14, i_item_desc#15, sr_item_sk#18, sr_customer_sk#19, sr_return_quantity#21, cs_bill_customer_sk#27, cs_item_sk#28, cs_quantity#29]

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

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

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

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

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#6 IN dynamicpruning#7
BroadcastExchange (54)
+- * Project (53)
   +- * Filter (52)
      +- * ColumnarToRow (51)
         +- Scan parquet default.date_dim (50)


(50) Scan parquet default.date_dim
Output [2]: [d_date_sk#8, d_quarter_name#91]
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>

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

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

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

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

Subquery:2 Hosting operator id = 24 Hosting Expression = sr_returned_date_sk#22 IN dynamicpruning#23
BroadcastExchange (59)
+- * Project (58)
   +- * Filter (57)
      +- * ColumnarToRow (56)
         +- Scan parquet default.date_dim (55)


(55) Scan parquet default.date_dim
Output [2]: [d_date_sk#24, d_quarter_name#93]
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>

(56) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#24, d_quarter_name#93]

(57) Filter [codegen id : 1]
Input [2]: [d_date_sk#24, d_quarter_name#93]
Condition : (d_quarter_name#93 IN (2001Q1,2001Q2,2001Q3) AND isnotnull(d_date_sk#24))

(58) Project [codegen id : 1]
Output [1]: [d_date_sk#24]
Input [2]: [d_date_sk#24, d_quarter_name#93]

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

Subquery:3 Hosting operator id = 36 Hosting Expression = cs_sold_date_sk#30 IN dynamicpruning#23


