== 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 spark_catalog.default.store_sales (1)
               :           :           :           :     +- ReusedExchange (4)
               :           :           :           +- BroadcastExchange (10)
               :           :           :              +- * Filter (9)
               :           :           :                 +- * ColumnarToRow (8)
               :           :           :                    +- Scan parquet spark_catalog.default.store (7)
               :           :           +- * Sort (19)
               :           :              +- Exchange (18)
               :           :                 +- * Filter (17)
               :           :                    +- * ColumnarToRow (16)
               :           :                       +- Scan parquet spark_catalog.default.item (15)
               :           +- * Sort (31)
               :              +- Exchange (30)
               :                 +- * Project (29)
               :                    +- * BroadcastHashJoin Inner BuildRight (28)
               :                       :- * Filter (26)
               :                       :  +- * ColumnarToRow (25)
               :                       :     +- Scan parquet spark_catalog.default.store_returns (24)
               :                       +- ReusedExchange (27)
               +- * Sort (43)
                  +- Exchange (42)
                     +- * Project (41)
                        +- * BroadcastHashJoin Inner BuildRight (40)
                           :- * Filter (38)
                           :  +- * ColumnarToRow (37)
                           :     +- Scan parquet spark_catalog.default.catalog_sales (36)
                           +- ReusedExchange (39)


(1) Scan parquet spark_catalog.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 type: Inner
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 spark_catalog.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), [plan_id=1]

(11) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ss_store_sk#3]
Right keys [1]: [s_store_sk#9]
Join type: Inner
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, [plan_id=2]

(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 spark_catalog.default.item
Output [3]: [i_item_sk#11, i_item_id#12, i_item_desc#13]
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#11, i_item_id#12, i_item_desc#13]

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

(18) Exchange
Input [3]: [i_item_sk#11, i_item_id#12, i_item_desc#13]
Arguments: hashpartitioning(i_item_sk#11, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

(20) SortMergeJoin [codegen id : 7]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#11]
Join type: Inner
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#12, i_item_desc#13]
Input [8]: [ss_item_sk#1, ss_customer_sk#2, ss_ticket_number#4, ss_quantity#5, s_state#10, i_item_sk#11, i_item_id#12, i_item_desc#13]

(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#12, i_item_desc#13]
Arguments: hashpartitioning(ss_customer_sk#2, ss_item_sk#1, ss_ticket_number#4, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(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#12, i_item_desc#13]
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 spark_catalog.default.store_returns
Output [5]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17, sr_returned_date_sk#18]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(sr_returned_date_sk#18), dynamicpruningexpression(sr_returned_date_sk#18 IN dynamicpruning#19)]
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#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17, sr_returned_date_sk#18]

(26) Filter [codegen id : 10]
Input [5]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17, sr_returned_date_sk#18]
Condition : ((isnotnull(sr_customer_sk#15) AND isnotnull(sr_item_sk#14)) AND isnotnull(sr_ticket_number#16))

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

(28) BroadcastHashJoin [codegen id : 10]
Left keys [1]: [sr_returned_date_sk#18]
Right keys [1]: [d_date_sk#20]
Join type: Inner
Join condition: None

(29) Project [codegen id : 10]
Output [4]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17]
Input [6]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17, sr_returned_date_sk#18, d_date_sk#20]

(30) Exchange
Input [4]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17]
Arguments: hashpartitioning(sr_customer_sk#15, sr_item_sk#14, sr_ticket_number#16, 5), ENSURE_REQUIREMENTS, [plan_id=5]

(31) Sort [codegen id : 11]
Input [4]: [sr_item_sk#14, sr_customer_sk#15, sr_ticket_number#16, sr_return_quantity#17]
Arguments: [sr_customer_sk#15 ASC NULLS FIRST, sr_item_sk#14 ASC NULLS FIRST, sr_ticket_number#16 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#15, sr_item_sk#14, sr_ticket_number#16]
Join type: Inner
Join condition: None

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

(34) Exchange
Input [7]: [ss_quantity#5, s_state#10, i_item_id#12, i_item_desc#13, sr_item_sk#14, sr_customer_sk#15, sr_return_quantity#17]
Arguments: hashpartitioning(sr_customer_sk#15, sr_item_sk#14, 5), ENSURE_REQUIREMENTS, [plan_id=6]

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

(36) Scan parquet spark_catalog.default.catalog_sales
Output [4]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23, cs_sold_date_sk#24]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#24), dynamicpruningexpression(cs_sold_date_sk#24 IN dynamicpruning#19)]
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#21, cs_item_sk#22, cs_quantity#23, cs_sold_date_sk#24]

(38) Filter [codegen id : 15]
Input [4]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23, cs_sold_date_sk#24]
Condition : (isnotnull(cs_bill_customer_sk#21) AND isnotnull(cs_item_sk#22))

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

(40) BroadcastHashJoin [codegen id : 15]
Left keys [1]: [cs_sold_date_sk#24]
Right keys [1]: [d_date_sk#25]
Join type: Inner
Join condition: None

(41) Project [codegen id : 15]
Output [3]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23]
Input [5]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23, cs_sold_date_sk#24, d_date_sk#25]

(42) Exchange
Input [3]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23]
Arguments: hashpartitioning(cs_bill_customer_sk#21, cs_item_sk#22, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(43) Sort [codegen id : 16]
Input [3]: [cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23]
Arguments: [cs_bill_customer_sk#21 ASC NULLS FIRST, cs_item_sk#22 ASC NULLS FIRST], false, 0

(44) SortMergeJoin [codegen id : 17]
Left keys [2]: [sr_customer_sk#15, sr_item_sk#14]
Right keys [2]: [cs_bill_customer_sk#21, cs_item_sk#22]
Join type: Inner
Join condition: None

(45) Project [codegen id : 17]
Output [6]: [ss_quantity#5, sr_return_quantity#17, cs_quantity#23, s_state#10, i_item_id#12, i_item_desc#13]
Input [10]: [ss_quantity#5, s_state#10, i_item_id#12, i_item_desc#13, sr_item_sk#14, sr_customer_sk#15, sr_return_quantity#17, cs_bill_customer_sk#21, cs_item_sk#22, cs_quantity#23]

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

(47) Exchange
Input [21]: [i_item_id#12, i_item_desc#13, s_state#10, count#44, sum#45, count#46, n#47, avg#48, m2#49, count#50, sum#51, count#52, n#53, avg#54, m2#55, count#56, sum#57, count#58, n#59, avg#60, m2#61]
Arguments: hashpartitioning(i_item_id#12, i_item_desc#13, s_state#10, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(48) HashAggregate [codegen id : 18]
Input [21]: [i_item_id#12, i_item_desc#13, s_state#10, count#44, sum#45, count#46, n#47, avg#48, m2#49, count#50, sum#51, count#52, n#53, avg#54, m2#55, count#56, sum#57, count#58, n#59, avg#60, m2#61]
Keys [3]: [i_item_id#12, i_item_desc#13, 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#17), avg(sr_return_quantity#17), stddev_samp(cast(sr_return_quantity#17 as double)), count(cs_quantity#23), avg(cs_quantity#23), stddev_samp(cast(cs_quantity#23 as double))]
Aggregate Attributes [9]: [count(ss_quantity#5)#62, avg(ss_quantity#5)#63, stddev_samp(cast(ss_quantity#5 as double))#64, count(sr_return_quantity#17)#65, avg(sr_return_quantity#17)#66, stddev_samp(cast(sr_return_quantity#17 as double))#67, count(cs_quantity#23)#68, avg(cs_quantity#23)#69, stddev_samp(cast(cs_quantity#23 as double))#70]
Results [15]: [i_item_id#12, i_item_desc#13, s_state#10, count(ss_quantity#5)#62 AS store_sales_quantitycount#71, avg(ss_quantity#5)#63 AS store_sales_quantityave#72, stddev_samp(cast(ss_quantity#5 as double))#64 AS store_sales_quantitystdev#73, (stddev_samp(cast(ss_quantity#5 as double))#64 / avg(ss_quantity#5)#63) AS store_sales_quantitycov#74, count(sr_return_quantity#17)#65 AS as_store_returns_quantitycount#75, avg(sr_return_quantity#17)#66 AS as_store_returns_quantityave#76, stddev_samp(cast(sr_return_quantity#17 as double))#67 AS as_store_returns_quantitystdev#77, (stddev_samp(cast(sr_return_quantity#17 as double))#67 / avg(sr_return_quantity#17)#66) AS store_returns_quantitycov#78, count(cs_quantity#23)#68 AS catalog_sales_quantitycount#79, avg(cs_quantity#23)#69 AS catalog_sales_quantityave#80, (stddev_samp(cast(cs_quantity#23 as double))#70 / avg(cs_quantity#23)#69) AS catalog_sales_quantitystdev#81, (stddev_samp(cast(cs_quantity#23 as double))#70 / avg(cs_quantity#23)#69) AS catalog_sales_quantitycov#82]

(49) TakeOrderedAndProject
Input [15]: [i_item_id#12, i_item_desc#13, s_state#10, store_sales_quantitycount#71, store_sales_quantityave#72, store_sales_quantitystdev#73, store_sales_quantitycov#74, as_store_returns_quantitycount#75, as_store_returns_quantityave#76, as_store_returns_quantitystdev#77, store_returns_quantitycov#78, catalog_sales_quantitycount#79, catalog_sales_quantityave#80, catalog_sales_quantitystdev#81, catalog_sales_quantitycov#82]
Arguments: 100, [i_item_id#12 ASC NULLS FIRST, i_item_desc#13 ASC NULLS FIRST, s_state#10 ASC NULLS FIRST], [i_item_id#12, i_item_desc#13, s_state#10, store_sales_quantitycount#71, store_sales_quantityave#72, store_sales_quantitystdev#73, store_sales_quantitycov#74, as_store_returns_quantitycount#75, as_store_returns_quantityave#76, as_store_returns_quantitystdev#77, store_returns_quantitycov#78, catalog_sales_quantitycount#79, catalog_sales_quantityave#80, catalog_sales_quantitystdev#81, catalog_sales_quantitycov#82]

===== 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 spark_catalog.default.date_dim (50)


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

(52) Filter [codegen id : 1]
Input [2]: [d_date_sk#8, d_quarter_name#83]
Condition : ((isnotnull(d_quarter_name#83) AND (d_quarter_name#83 = 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#83]

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

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


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

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

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

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

Subquery:3 Hosting operator id = 36 Hosting Expression = cs_sold_date_sk#24 IN dynamicpruning#19


