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


(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 : 8]
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 : 8]
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) Scan parquet default.store_returns
Output [5]: [sr_item_sk#8, sr_customer_sk#9, sr_ticket_number#10, sr_return_quantity#11, sr_returned_date_sk#12]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(sr_returned_date_sk#12), dynamicpruningexpression(sr_returned_date_sk#12 IN dynamicpruning#13)]
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>

(5) ColumnarToRow [codegen id : 1]
Input [5]: [sr_item_sk#8, sr_customer_sk#9, sr_ticket_number#10, sr_return_quantity#11, sr_returned_date_sk#12]

(6) Filter [codegen id : 1]
Input [5]: [sr_item_sk#8, sr_customer_sk#9, sr_ticket_number#10, sr_return_quantity#11, sr_returned_date_sk#12]
Condition : ((isnotnull(sr_customer_sk#9) AND isnotnull(sr_item_sk#8)) AND isnotnull(sr_ticket_number#10))

(7) BroadcastExchange
Input [5]: [sr_item_sk#8, sr_customer_sk#9, sr_ticket_number#10, sr_return_quantity#11, sr_returned_date_sk#12]
Arguments: HashedRelationBroadcastMode(List(input[1, int, false], input[0, int, false], input[2, int, false]),false), [id=#14]

(8) BroadcastHashJoin [codegen id : 8]
Left keys [3]: [ss_customer_sk#2, ss_item_sk#1, ss_ticket_number#4]
Right keys [3]: [sr_customer_sk#9, sr_item_sk#8, sr_ticket_number#10]
Join condition: None

(9) Project [codegen id : 8]
Output [8]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, ss_sold_date_sk#6, sr_item_sk#8, sr_customer_sk#9, sr_return_quantity#11, sr_returned_date_sk#12]
Input [11]: [ss_item_sk#1, ss_customer_sk#2, ss_store_sk#3, ss_ticket_number#4, ss_quantity#5, ss_sold_date_sk#6, sr_item_sk#8, sr_customer_sk#9, sr_ticket_number#10, sr_return_quantity#11, sr_returned_date_sk#12]

(10) Scan parquet default.catalog_sales
Output [4]: [cs_bill_customer_sk#15, cs_item_sk#16, cs_quantity#17, cs_sold_date_sk#18]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#18), dynamicpruningexpression(cs_sold_date_sk#18 IN dynamicpruning#13)]
PushedFilters: [IsNotNull(cs_bill_customer_sk), IsNotNull(cs_item_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_item_sk:int,cs_quantity:int>

(11) ColumnarToRow [codegen id : 2]
Input [4]: [cs_bill_customer_sk#15, cs_item_sk#16, cs_quantity#17, cs_sold_date_sk#18]

(12) Filter [codegen id : 2]
Input [4]: [cs_bill_customer_sk#15, cs_item_sk#16, cs_quantity#17, cs_sold_date_sk#18]
Condition : (isnotnull(cs_bill_customer_sk#15) AND isnotnull(cs_item_sk#16))

(13) BroadcastExchange
Input [4]: [cs_bill_customer_sk#15, cs_item_sk#16, cs_quantity#17, cs_sold_date_sk#18]
Arguments: HashedRelationBroadcastMode(List((shiftleft(cast(input[0, int, false] as bigint), 32) | (cast(input[1, int, false] as bigint) & 4294967295))),false), [id=#19]

(14) BroadcastHashJoin [codegen id : 8]
Left keys [2]: [sr_customer_sk#9, sr_item_sk#8]
Right keys [2]: [cs_bill_customer_sk#15, cs_item_sk#16]
Join condition: None

(15) Project [codegen id : 8]
Output [8]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, ss_sold_date_sk#6, sr_return_quantity#11, sr_returned_date_sk#12, cs_quantity#17, cs_sold_date_sk#18]
Input [12]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, ss_sold_date_sk#6, sr_item_sk#8, sr_customer_sk#9, sr_return_quantity#11, sr_returned_date_sk#12, cs_bill_customer_sk#15, cs_item_sk#16, cs_quantity#17, cs_sold_date_sk#18]

(16) ReusedExchange [Reuses operator id: 45]
Output [1]: [d_date_sk#20]

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

(18) Project [codegen id : 8]
Output [7]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, sr_returned_date_sk#12, cs_quantity#17, cs_sold_date_sk#18]
Input [9]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, ss_sold_date_sk#6, sr_return_quantity#11, sr_returned_date_sk#12, cs_quantity#17, cs_sold_date_sk#18, d_date_sk#20]

(19) ReusedExchange [Reuses operator id: 50]
Output [1]: [d_date_sk#21]

(20) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [sr_returned_date_sk#12]
Right keys [1]: [d_date_sk#21]
Join condition: None

(21) Project [codegen id : 8]
Output [6]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, cs_quantity#17, cs_sold_date_sk#18]
Input [8]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, sr_returned_date_sk#12, cs_quantity#17, cs_sold_date_sk#18, d_date_sk#21]

(22) ReusedExchange [Reuses operator id: 50]
Output [1]: [d_date_sk#22]

(23) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [cs_sold_date_sk#18]
Right keys [1]: [d_date_sk#22]
Join condition: None

(24) Project [codegen id : 8]
Output [5]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, cs_quantity#17]
Input [7]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, cs_quantity#17, cs_sold_date_sk#18, d_date_sk#22]

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

(26) ColumnarToRow [codegen id : 6]
Input [2]: [s_store_sk#23, s_state#24]

(27) Filter [codegen id : 6]
Input [2]: [s_store_sk#23, s_state#24]
Condition : isnotnull(s_store_sk#23)

(28) BroadcastExchange
Input [2]: [s_store_sk#23, s_state#24]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#25]

(29) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [ss_store_sk#3]
Right keys [1]: [s_store_sk#23]
Join condition: None

(30) Project [codegen id : 8]
Output [5]: [ss_item_sk#1, ss_quantity#5, sr_return_quantity#11, cs_quantity#17, s_state#24]
Input [7]: [ss_item_sk#1, ss_store_sk#3, ss_quantity#5, sr_return_quantity#11, cs_quantity#17, s_store_sk#23, s_state#24]

(31) Scan parquet default.item
Output [3]: [i_item_sk#26, i_item_id#27, i_item_desc#28]
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>

(32) ColumnarToRow [codegen id : 7]
Input [3]: [i_item_sk#26, i_item_id#27, i_item_desc#28]

(33) Filter [codegen id : 7]
Input [3]: [i_item_sk#26, i_item_id#27, i_item_desc#28]
Condition : isnotnull(i_item_sk#26)

(34) BroadcastExchange
Input [3]: [i_item_sk#26, i_item_id#27, i_item_desc#28]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#29]

(35) BroadcastHashJoin [codegen id : 8]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#26]
Join condition: None

(36) Project [codegen id : 8]
Output [6]: [ss_quantity#5, sr_return_quantity#11, cs_quantity#17, s_state#24, i_item_id#27, i_item_desc#28]
Input [8]: [ss_item_sk#1, ss_quantity#5, sr_return_quantity#11, cs_quantity#17, s_state#24, i_item_sk#26, i_item_id#27, i_item_desc#28]

(37) HashAggregate [codegen id : 8]
Input [6]: [ss_quantity#5, sr_return_quantity#11, cs_quantity#17, s_state#24, i_item_id#27, i_item_desc#28]
Keys [3]: [i_item_id#27, i_item_desc#28, s_state#24]
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#11), partial_avg(sr_return_quantity#11), partial_stddev_samp(cast(sr_return_quantity#11 as double)), partial_count(cs_quantity#17), partial_avg(cs_quantity#17), partial_stddev_samp(cast(cs_quantity#17 as double))]
Aggregate Attributes [18]: [count#30, sum#31, count#32, n#33, avg#34, m2#35, count#36, sum#37, count#38, n#39, avg#40, m2#41, count#42, sum#43, count#44, n#45, avg#46, m2#47]
Results [21]: [i_item_id#27, i_item_desc#28, s_state#24, count#48, sum#49, count#50, n#51, avg#52, m2#53, count#54, sum#55, count#56, n#57, avg#58, m2#59, count#60, sum#61, count#62, n#63, avg#64, m2#65]

(38) Exchange
Input [21]: [i_item_id#27, i_item_desc#28, s_state#24, count#48, sum#49, count#50, n#51, avg#52, m2#53, count#54, sum#55, count#56, n#57, avg#58, m2#59, count#60, sum#61, count#62, n#63, avg#64, m2#65]
Arguments: hashpartitioning(i_item_id#27, i_item_desc#28, s_state#24, 5), ENSURE_REQUIREMENTS, [id=#66]

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

(40) TakeOrderedAndProject
Input [15]: [i_item_id#27, i_item_desc#28, s_state#24, store_sales_quantitycount#76, store_sales_quantityave#77, store_sales_quantitystdev#78, store_sales_quantitycov#79, as_store_returns_quantitycount#80, as_store_returns_quantityave#81, as_store_returns_quantitystdev#82, store_returns_quantitycov#83, catalog_sales_quantitycount#84, catalog_sales_quantityave#85, catalog_sales_quantitystdev#86, catalog_sales_quantitycov#87]
Arguments: 100, [i_item_id#27 ASC NULLS FIRST, i_item_desc#28 ASC NULLS FIRST, s_state#24 ASC NULLS FIRST], [i_item_id#27, i_item_desc#28, s_state#24, store_sales_quantitycount#76, store_sales_quantityave#77, store_sales_quantitystdev#78, store_sales_quantitycov#79, as_store_returns_quantitycount#80, as_store_returns_quantityave#81, as_store_returns_quantitystdev#82, store_returns_quantitycov#83, catalog_sales_quantitycount#84, catalog_sales_quantityave#85, catalog_sales_quantitystdev#86, catalog_sales_quantitycov#87]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#6 IN dynamicpruning#7
BroadcastExchange (45)
+- * Project (44)
   +- * Filter (43)
      +- * ColumnarToRow (42)
         +- Scan parquet default.date_dim (41)


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

(42) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#20, d_quarter_name#88]

(43) Filter [codegen id : 1]
Input [2]: [d_date_sk#20, d_quarter_name#88]
Condition : ((isnotnull(d_quarter_name#88) AND (d_quarter_name#88 = 2001Q1)) AND isnotnull(d_date_sk#20))

(44) Project [codegen id : 1]
Output [1]: [d_date_sk#20]
Input [2]: [d_date_sk#20, d_quarter_name#88]

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

Subquery:2 Hosting operator id = 4 Hosting Expression = sr_returned_date_sk#12 IN dynamicpruning#13
BroadcastExchange (50)
+- * Project (49)
   +- * Filter (48)
      +- * ColumnarToRow (47)
         +- Scan parquet default.date_dim (46)


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

(47) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#21, d_quarter_name#90]

(48) Filter [codegen id : 1]
Input [2]: [d_date_sk#21, d_quarter_name#90]
Condition : (d_quarter_name#90 IN (2001Q1,2001Q2,2001Q3) AND isnotnull(d_date_sk#21))

(49) Project [codegen id : 1]
Output [1]: [d_date_sk#21]
Input [2]: [d_date_sk#21, d_quarter_name#90]

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

Subquery:3 Hosting operator id = 10 Hosting Expression = cs_sold_date_sk#18 IN dynamicpruning#13


