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


(1) Scan parquet default.catalog_sales
Output [9]: [cs_bill_customer_sk#1, cs_bill_cdemo_sk#2, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#9), dynamicpruningexpression(cs_sold_date_sk#9 IN dynamicpruning#10)]
PushedFilters: [IsNotNull(cs_bill_cdemo_sk), IsNotNull(cs_bill_customer_sk), IsNotNull(cs_item_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_bill_cdemo_sk:int,cs_item_sk:int,cs_quantity:int,cs_list_price:decimal(7,2),cs_sales_price:decimal(7,2),cs_coupon_amt:decimal(7,2),cs_net_profit:decimal(7,2)>

(2) ColumnarToRow [codegen id : 7]
Input [9]: [cs_bill_customer_sk#1, cs_bill_cdemo_sk#2, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9]

(3) Filter [codegen id : 7]
Input [9]: [cs_bill_customer_sk#1, cs_bill_cdemo_sk#2, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9]
Condition : ((isnotnull(cs_bill_cdemo_sk#2) AND isnotnull(cs_bill_customer_sk#1)) AND isnotnull(cs_item_sk#3))

(4) Scan parquet default.customer_demographics
Output [4]: [cd_demo_sk#11, cd_gender#12, cd_education_status#13, cd_dep_count#14]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_demographics]
PushedFilters: [IsNotNull(cd_gender), IsNotNull(cd_education_status), EqualTo(cd_gender,F), EqualTo(cd_education_status,Unknown             ), IsNotNull(cd_demo_sk)]
ReadSchema: struct<cd_demo_sk:int,cd_gender:string,cd_education_status:string,cd_dep_count:int>

(5) ColumnarToRow [codegen id : 1]
Input [4]: [cd_demo_sk#11, cd_gender#12, cd_education_status#13, cd_dep_count#14]

(6) Filter [codegen id : 1]
Input [4]: [cd_demo_sk#11, cd_gender#12, cd_education_status#13, cd_dep_count#14]
Condition : ((((isnotnull(cd_gender#12) AND isnotnull(cd_education_status#13)) AND (cd_gender#12 = F)) AND (cd_education_status#13 = Unknown             )) AND isnotnull(cd_demo_sk#11))

(7) Project [codegen id : 1]
Output [2]: [cd_demo_sk#11, cd_dep_count#14]
Input [4]: [cd_demo_sk#11, cd_gender#12, cd_education_status#13, cd_dep_count#14]

(8) BroadcastExchange
Input [2]: [cd_demo_sk#11, cd_dep_count#14]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#15]

(9) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cs_bill_cdemo_sk#2]
Right keys [1]: [cd_demo_sk#11]
Join condition: None

(10) Project [codegen id : 7]
Output [9]: [cs_bill_customer_sk#1, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14]
Input [11]: [cs_bill_customer_sk#1, cs_bill_cdemo_sk#2, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_demo_sk#11, cd_dep_count#14]

(11) Scan parquet default.customer
Output [5]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_month#19, c_birth_year#20]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [In(c_birth_month, [1,12,2,6,8,9]), IsNotNull(c_customer_sk), IsNotNull(c_current_cdemo_sk), IsNotNull(c_current_addr_sk)]
ReadSchema: struct<c_customer_sk:int,c_current_cdemo_sk:int,c_current_addr_sk:int,c_birth_month:int,c_birth_year:int>

(12) ColumnarToRow [codegen id : 2]
Input [5]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_month#19, c_birth_year#20]

(13) Filter [codegen id : 2]
Input [5]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_month#19, c_birth_year#20]
Condition : (((c_birth_month#19 IN (1,6,8,9,12,2) AND isnotnull(c_customer_sk#16)) AND isnotnull(c_current_cdemo_sk#17)) AND isnotnull(c_current_addr_sk#18))

(14) Project [codegen id : 2]
Output [4]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_year#20]
Input [5]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_month#19, c_birth_year#20]

(15) BroadcastExchange
Input [4]: [c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_year#20]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#21]

(16) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cs_bill_customer_sk#1]
Right keys [1]: [c_customer_sk#16]
Join condition: None

(17) Project [codegen id : 7]
Output [11]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_year#20]
Input [13]: [cs_bill_customer_sk#1, cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_customer_sk#16, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_year#20]

(18) Scan parquet default.customer_demographics
Output [1]: [cd_demo_sk#22]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_demographics]
PushedFilters: [IsNotNull(cd_demo_sk)]
ReadSchema: struct<cd_demo_sk:int>

(19) ColumnarToRow [codegen id : 3]
Input [1]: [cd_demo_sk#22]

(20) Filter [codegen id : 3]
Input [1]: [cd_demo_sk#22]
Condition : isnotnull(cd_demo_sk#22)

(21) BroadcastExchange
Input [1]: [cd_demo_sk#22]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#23]

(22) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [c_current_cdemo_sk#17]
Right keys [1]: [cd_demo_sk#22]
Join condition: None

(23) Project [codegen id : 7]
Output [10]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_current_addr_sk#18, c_birth_year#20]
Input [12]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_current_cdemo_sk#17, c_current_addr_sk#18, c_birth_year#20, cd_demo_sk#22]

(24) Scan parquet default.customer_address
Output [4]: [ca_address_sk#24, ca_county#25, ca_state#26, ca_country#27]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [In(ca_state, [IN,MS,ND,NM,OK,VA]), IsNotNull(ca_address_sk)]
ReadSchema: struct<ca_address_sk:int,ca_county:string,ca_state:string,ca_country:string>

(25) ColumnarToRow [codegen id : 4]
Input [4]: [ca_address_sk#24, ca_county#25, ca_state#26, ca_country#27]

(26) Filter [codegen id : 4]
Input [4]: [ca_address_sk#24, ca_county#25, ca_state#26, ca_country#27]
Condition : (ca_state#26 IN (MS,IN,ND,OK,NM,VA) AND isnotnull(ca_address_sk#24))

(27) BroadcastExchange
Input [4]: [ca_address_sk#24, ca_county#25, ca_state#26, ca_country#27]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#28]

(28) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [c_current_addr_sk#18]
Right keys [1]: [ca_address_sk#24]
Join condition: None

(29) Project [codegen id : 7]
Output [12]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_birth_year#20, ca_county#25, ca_state#26, ca_country#27]
Input [14]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_current_addr_sk#18, c_birth_year#20, ca_address_sk#24, ca_county#25, ca_state#26, ca_country#27]

(30) ReusedExchange [Reuses operator id: 48]
Output [1]: [d_date_sk#29]

(31) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cs_sold_date_sk#9]
Right keys [1]: [d_date_sk#29]
Join condition: None

(32) Project [codegen id : 7]
Output [11]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, ca_county#25, ca_state#26, ca_country#27]
Input [13]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cs_sold_date_sk#9, cd_dep_count#14, c_birth_year#20, ca_county#25, ca_state#26, ca_country#27, d_date_sk#29]

(33) Scan parquet default.item
Output [2]: [i_item_sk#30, i_item_id#31]
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>

(34) ColumnarToRow [codegen id : 6]
Input [2]: [i_item_sk#30, i_item_id#31]

(35) Filter [codegen id : 6]
Input [2]: [i_item_sk#30, i_item_id#31]
Condition : isnotnull(i_item_sk#30)

(36) BroadcastExchange
Input [2]: [i_item_sk#30, i_item_id#31]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#32]

(37) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [cs_item_sk#3]
Right keys [1]: [i_item_sk#30]
Join condition: None

(38) Project [codegen id : 7]
Output [11]: [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, ca_country#27, ca_state#26, ca_county#25]
Input [13]: [cs_item_sk#3, cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, ca_county#25, ca_state#26, ca_country#27, i_item_sk#30, i_item_id#31]

(39) Expand [codegen id : 7]
Input [11]: [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, ca_country#27, ca_state#26, ca_county#25]
Arguments: [[cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, ca_country#27, ca_state#26, ca_county#25, 0], [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, ca_country#27, ca_state#26, null, 1], [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, ca_country#27, null, null, 3], [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#31, null, null, null, 7], [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, null, null, null, null, 15]], [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37]

(40) HashAggregate [codegen id : 7]
Input [12]: [cs_quantity#4, cs_list_price#5, cs_sales_price#6, cs_coupon_amt#7, cs_net_profit#8, cd_dep_count#14, c_birth_year#20, i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37]
Keys [5]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37]
Functions [7]: [partial_avg(cast(cs_quantity#4 as decimal(12,2))), partial_avg(cast(cs_list_price#5 as decimal(12,2))), partial_avg(cast(cs_coupon_amt#7 as decimal(12,2))), partial_avg(cast(cs_sales_price#6 as decimal(12,2))), partial_avg(cast(cs_net_profit#8 as decimal(12,2))), partial_avg(cast(c_birth_year#20 as decimal(12,2))), partial_avg(cast(cd_dep_count#14 as decimal(12,2)))]
Aggregate Attributes [14]: [sum#38, count#39, sum#40, count#41, sum#42, count#43, sum#44, count#45, sum#46, count#47, sum#48, count#49, sum#50, count#51]
Results [19]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37, sum#52, count#53, sum#54, count#55, sum#56, count#57, sum#58, count#59, sum#60, count#61, sum#62, count#63, sum#64, count#65]

(41) Exchange
Input [19]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37, sum#52, count#53, sum#54, count#55, sum#56, count#57, sum#58, count#59, sum#60, count#61, sum#62, count#63, sum#64, count#65]
Arguments: hashpartitioning(i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37, 5), ENSURE_REQUIREMENTS, [id=#66]

(42) HashAggregate [codegen id : 8]
Input [19]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37, sum#52, count#53, sum#54, count#55, sum#56, count#57, sum#58, count#59, sum#60, count#61, sum#62, count#63, sum#64, count#65]
Keys [5]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, spark_grouping_id#37]
Functions [7]: [avg(cast(cs_quantity#4 as decimal(12,2))), avg(cast(cs_list_price#5 as decimal(12,2))), avg(cast(cs_coupon_amt#7 as decimal(12,2))), avg(cast(cs_sales_price#6 as decimal(12,2))), avg(cast(cs_net_profit#8 as decimal(12,2))), avg(cast(c_birth_year#20 as decimal(12,2))), avg(cast(cd_dep_count#14 as decimal(12,2)))]
Aggregate Attributes [7]: [avg(cast(cs_quantity#4 as decimal(12,2)))#67, avg(cast(cs_list_price#5 as decimal(12,2)))#68, avg(cast(cs_coupon_amt#7 as decimal(12,2)))#69, avg(cast(cs_sales_price#6 as decimal(12,2)))#70, avg(cast(cs_net_profit#8 as decimal(12,2)))#71, avg(cast(c_birth_year#20 as decimal(12,2)))#72, avg(cast(cd_dep_count#14 as decimal(12,2)))#73]
Results [11]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, avg(cast(cs_quantity#4 as decimal(12,2)))#67 AS agg1#74, avg(cast(cs_list_price#5 as decimal(12,2)))#68 AS agg2#75, avg(cast(cs_coupon_amt#7 as decimal(12,2)))#69 AS agg3#76, avg(cast(cs_sales_price#6 as decimal(12,2)))#70 AS agg4#77, avg(cast(cs_net_profit#8 as decimal(12,2)))#71 AS agg5#78, avg(cast(c_birth_year#20 as decimal(12,2)))#72 AS agg6#79, avg(cast(cd_dep_count#14 as decimal(12,2)))#73 AS agg7#80]

(43) TakeOrderedAndProject
Input [11]: [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, agg1#74, agg2#75, agg3#76, agg4#77, agg5#78, agg6#79, agg7#80]
Arguments: 100, [ca_country#34 ASC NULLS FIRST, ca_state#35 ASC NULLS FIRST, ca_county#36 ASC NULLS FIRST, i_item_id#33 ASC NULLS FIRST], [i_item_id#33, ca_country#34, ca_state#35, ca_county#36, agg1#74, agg2#75, agg3#76, agg4#77, agg5#78, agg6#79, agg7#80]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = cs_sold_date_sk#9 IN dynamicpruning#10
BroadcastExchange (48)
+- * Project (47)
   +- * Filter (46)
      +- * ColumnarToRow (45)
         +- Scan parquet default.date_dim (44)


(44) Scan parquet default.date_dim
Output [2]: [d_date_sk#29, d_year#81]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), EqualTo(d_year,1998), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int>

(45) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#29, d_year#81]

(46) Filter [codegen id : 1]
Input [2]: [d_date_sk#29, d_year#81]
Condition : ((isnotnull(d_year#81) AND (d_year#81 = 1998)) AND isnotnull(d_date_sk#29))

(47) Project [codegen id : 1]
Output [1]: [d_date_sk#29]
Input [2]: [d_date_sk#29, d_year#81]

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


