== Physical Plan ==
TakeOrderedAndProject (27)
+- * Project (26)
   +- * Filter (25)
      +- Window (24)
         +- * Sort (23)
            +- Exchange (22)
               +- * HashAggregate (21)
                  +- Exchange (20)
                     +- * HashAggregate (19)
                        +- * Project (18)
                           +- * BroadcastHashJoin Inner BuildRight (17)
                              :- * 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)
                              +- BroadcastExchange (16)
                                 +- * Filter (15)
                                    +- * ColumnarToRow (14)
                                       +- Scan parquet spark_catalog.default.item (13)


(1) Scan parquet spark_catalog.default.store_sales
Output [4]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, ss_sold_date_sk#4]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#4), (ss_sold_date_sk#4 >= 2451545), (ss_sold_date_sk#4 <= 2451910), dynamicpruningexpression(ss_sold_date_sk#4 IN dynamicpruning#5)]
PushedFilters: [IsNotNull(ss_item_sk), IsNotNull(ss_store_sk)]
ReadSchema: struct<ss_item_sk:int,ss_store_sk:int,ss_sales_price:decimal(7,2)>

(2) ColumnarToRow [codegen id : 4]
Input [4]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, ss_sold_date_sk#4]

(3) Filter [codegen id : 4]
Input [4]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, ss_sold_date_sk#4]
Condition : (isnotnull(ss_item_sk#1) AND isnotnull(ss_store_sk#2))

(4) ReusedExchange [Reuses operator id: 32]
Output [2]: [d_date_sk#6, d_moy#7]

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

(6) Project [codegen id : 4]
Output [4]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, d_moy#7]
Input [6]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, ss_sold_date_sk#4, d_date_sk#6, d_moy#7]

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

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

(9) Filter [codegen id : 2]
Input [3]: [s_store_sk#8, s_store_name#9, s_company_name#10]
Condition : isnotnull(s_store_sk#8)

(10) BroadcastExchange
Input [3]: [s_store_sk#8, s_store_name#9, s_company_name#10]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=1]

(11) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [ss_store_sk#2]
Right keys [1]: [s_store_sk#8]
Join type: Inner
Join condition: None

(12) Project [codegen id : 4]
Output [5]: [ss_item_sk#1, ss_sales_price#3, d_moy#7, s_store_name#9, s_company_name#10]
Input [7]: [ss_item_sk#1, ss_store_sk#2, ss_sales_price#3, d_moy#7, s_store_sk#8, s_store_name#9, s_company_name#10]

(13) Scan parquet spark_catalog.default.item
Output [4]: [i_item_sk#11, i_brand#12, i_class#13, i_category#14]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [Or(And(In(i_category, [Books                                             ,Electronics                                       ,Home                                              ]),In(i_class, [musical                                           ,parenting                                         ,wallpaper                                         ])),And(In(i_category, [Jewelry                                           ,Men                                               ,Shoes                                             ]),In(i_class, [birdal                                            ,pants                                             ,womens                                            ]))), IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_brand:string,i_class:string,i_category:string>

(14) ColumnarToRow [codegen id : 3]
Input [4]: [i_item_sk#11, i_brand#12, i_class#13, i_category#14]

(15) Filter [codegen id : 3]
Input [4]: [i_item_sk#11, i_brand#12, i_class#13, i_category#14]
Condition : (((i_category#14 IN (Home                                              ,Books                                             ,Electronics                                       ) AND i_class#13 IN (wallpaper                                         ,parenting                                         ,musical                                           )) OR (i_category#14 IN (Shoes                                             ,Jewelry                                           ,Men                                               ) AND i_class#13 IN (womens                                            ,birdal                                            ,pants                                             ))) AND isnotnull(i_item_sk#11))

(16) BroadcastExchange
Input [4]: [i_item_sk#11, i_brand#12, i_class#13, i_category#14]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=2]

(17) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [ss_item_sk#1]
Right keys [1]: [i_item_sk#11]
Join type: Inner
Join condition: None

(18) Project [codegen id : 4]
Output [7]: [i_brand#12, i_class#13, i_category#14, ss_sales_price#3, d_moy#7, s_store_name#9, s_company_name#10]
Input [9]: [ss_item_sk#1, ss_sales_price#3, d_moy#7, s_store_name#9, s_company_name#10, i_item_sk#11, i_brand#12, i_class#13, i_category#14]

(19) HashAggregate [codegen id : 4]
Input [7]: [i_brand#12, i_class#13, i_category#14, ss_sales_price#3, d_moy#7, s_store_name#9, s_company_name#10]
Keys [6]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7]
Functions [1]: [partial_sum(UnscaledValue(ss_sales_price#3))]
Aggregate Attributes [1]: [sum#15]
Results [7]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum#16]

(20) Exchange
Input [7]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum#16]
Arguments: hashpartitioning(i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, 5), ENSURE_REQUIREMENTS, [plan_id=3]

(21) HashAggregate [codegen id : 5]
Input [7]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum#16]
Keys [6]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7]
Functions [1]: [sum(UnscaledValue(ss_sales_price#3))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_sales_price#3))#17]
Results [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, MakeDecimal(sum(UnscaledValue(ss_sales_price#3))#17,17,2) AS sum_sales#18, MakeDecimal(sum(UnscaledValue(ss_sales_price#3))#17,17,2) AS _w0#19]

(22) Exchange
Input [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, _w0#19]
Arguments: hashpartitioning(i_category#14, i_brand#12, s_store_name#9, s_company_name#10, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(23) Sort [codegen id : 6]
Input [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, _w0#19]
Arguments: [i_category#14 ASC NULLS FIRST, i_brand#12 ASC NULLS FIRST, s_store_name#9 ASC NULLS FIRST, s_company_name#10 ASC NULLS FIRST], false, 0

(24) Window
Input [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, _w0#19]
Arguments: [avg(_w0#19) windowspecdefinition(i_category#14, i_brand#12, s_store_name#9, s_company_name#10, specifiedwindowframe(RowFrame, unboundedpreceding$(), unboundedfollowing$())) AS avg_monthly_sales#20], [i_category#14, i_brand#12, s_store_name#9, s_company_name#10]

(25) Filter [codegen id : 7]
Input [9]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, _w0#19, avg_monthly_sales#20]
Condition : CASE WHEN NOT (avg_monthly_sales#20 = 0.000000) THEN ((abs((sum_sales#18 - avg_monthly_sales#20)) / avg_monthly_sales#20) > 0.1000000000000000) END

(26) Project [codegen id : 7]
Output [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, avg_monthly_sales#20]
Input [9]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, _w0#19, avg_monthly_sales#20]

(27) TakeOrderedAndProject
Input [8]: [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, avg_monthly_sales#20]
Arguments: 100, [(sum_sales#18 - avg_monthly_sales#20) ASC NULLS FIRST, s_store_name#9 ASC NULLS FIRST], [i_category#14, i_class#13, i_brand#12, s_store_name#9, s_company_name#10, d_moy#7, sum_sales#18, avg_monthly_sales#20]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = ss_sold_date_sk#4 IN dynamicpruning#5
BroadcastExchange (32)
+- * Project (31)
   +- * Filter (30)
      +- * ColumnarToRow (29)
         +- Scan parquet spark_catalog.default.date_dim (28)


(28) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#6, d_year#21, d_moy#7]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), EqualTo(d_year,2000), GreaterThanOrEqual(d_date_sk,2451545), LessThanOrEqual(d_date_sk,2451910), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_moy:int>

(29) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#6, d_year#21, d_moy#7]

(30) Filter [codegen id : 1]
Input [3]: [d_date_sk#6, d_year#21, d_moy#7]
Condition : ((((isnotnull(d_year#21) AND (d_year#21 = 2000)) AND (d_date_sk#6 >= 2451545)) AND (d_date_sk#6 <= 2451910)) AND isnotnull(d_date_sk#6))

(31) Project [codegen id : 1]
Output [2]: [d_date_sk#6, d_moy#7]
Input [3]: [d_date_sk#6, d_year#21, d_moy#7]

(32) BroadcastExchange
Input [2]: [d_date_sk#6, d_moy#7]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=5]


