== Physical Plan ==
TakeOrderedAndProject (64)
+- * HashAggregate (63)
   +- Exchange (62)
      +- * HashAggregate (61)
         +- * HashAggregate (60)
            +- Exchange (59)
               +- * HashAggregate (58)
                  +- * Project (57)
                     +- * BroadcastHashJoin Inner BuildRight (56)
                        :- * Project (50)
                        :  +- * BroadcastHashJoin Inner BuildRight (49)
                        :     :- * Project (44)
                        :     :  +- * BroadcastHashJoin Inner BuildRight (43)
                        :     :     :- * Project (38)
                        :     :     :  +- * BroadcastHashJoin Inner BuildRight (37)
                        :     :     :     :- * HashAggregate (32)
                        :     :     :     :  +- Exchange (31)
                        :     :     :     :     +- * HashAggregate (30)
                        :     :     :     :        +- * Project (29)
                        :     :     :     :           +- * BroadcastHashJoin Inner BuildRight (28)
                        :     :     :     :              :- * Project (23)
                        :     :     :     :              :  +- * BroadcastHashJoin Inner BuildRight (22)
                        :     :     :     :              :     :- * Project (16)
                        :     :     :     :              :     :  +- * BroadcastHashJoin Inner BuildRight (15)
                        :     :     :     :              :     :     :- Union (9)
                        :     :     :     :              :     :     :  :- * Project (4)
                        :     :     :     :              :     :     :  :  +- * Filter (3)
                        :     :     :     :              :     :     :  :     +- * ColumnarToRow (2)
                        :     :     :     :              :     :     :  :        +- Scan parquet spark_catalog.default.catalog_sales (1)
                        :     :     :     :              :     :     :  +- * Project (8)
                        :     :     :     :              :     :     :     +- * Filter (7)
                        :     :     :     :              :     :     :        +- * ColumnarToRow (6)
                        :     :     :     :              :     :     :           +- Scan parquet spark_catalog.default.web_sales (5)
                        :     :     :     :              :     :     +- BroadcastExchange (14)
                        :     :     :     :              :     :        +- * Project (13)
                        :     :     :     :              :     :           +- * Filter (12)
                        :     :     :     :              :     :              +- * ColumnarToRow (11)
                        :     :     :     :              :     :                 +- Scan parquet spark_catalog.default.item (10)
                        :     :     :     :              :     +- BroadcastExchange (21)
                        :     :     :     :              :        +- * Project (20)
                        :     :     :     :              :           +- * Filter (19)
                        :     :     :     :              :              +- * ColumnarToRow (18)
                        :     :     :     :              :                 +- Scan parquet spark_catalog.default.date_dim (17)
                        :     :     :     :              +- BroadcastExchange (27)
                        :     :     :     :                 +- * Filter (26)
                        :     :     :     :                    +- * ColumnarToRow (25)
                        :     :     :     :                       +- Scan parquet spark_catalog.default.customer (24)
                        :     :     :     +- BroadcastExchange (36)
                        :     :     :        +- * Filter (35)
                        :     :     :           +- * ColumnarToRow (34)
                        :     :     :              +- Scan parquet spark_catalog.default.store_sales (33)
                        :     :     +- BroadcastExchange (42)
                        :     :        +- * Filter (41)
                        :     :           +- * ColumnarToRow (40)
                        :     :              +- Scan parquet spark_catalog.default.customer_address (39)
                        :     +- BroadcastExchange (48)
                        :        +- * Filter (47)
                        :           +- * ColumnarToRow (46)
                        :              +- Scan parquet spark_catalog.default.store (45)
                        +- BroadcastExchange (55)
                           +- * Project (54)
                              +- * Filter (53)
                                 +- * ColumnarToRow (52)
                                    +- Scan parquet spark_catalog.default.date_dim (51)


(1) Scan parquet spark_catalog.default.catalog_sales
Output [3]: [cs_bill_customer_sk#1, cs_item_sk#2, cs_sold_date_sk#3]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#3)]
PushedFilters: [IsNotNull(cs_item_sk), IsNotNull(cs_bill_customer_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_item_sk:int>

(2) ColumnarToRow [codegen id : 1]
Input [3]: [cs_bill_customer_sk#1, cs_item_sk#2, cs_sold_date_sk#3]

(3) Filter [codegen id : 1]
Input [3]: [cs_bill_customer_sk#1, cs_item_sk#2, cs_sold_date_sk#3]
Condition : (isnotnull(cs_item_sk#2) AND isnotnull(cs_bill_customer_sk#1))

(4) Project [codegen id : 1]
Output [3]: [cs_sold_date_sk#3 AS sold_date_sk#4, cs_bill_customer_sk#1 AS customer_sk#5, cs_item_sk#2 AS item_sk#6]
Input [3]: [cs_bill_customer_sk#1, cs_item_sk#2, cs_sold_date_sk#3]

(5) Scan parquet spark_catalog.default.web_sales
Output [3]: [ws_item_sk#7, ws_bill_customer_sk#8, ws_sold_date_sk#9]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#9)]
PushedFilters: [IsNotNull(ws_item_sk), IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_item_sk:int,ws_bill_customer_sk:int>

(6) ColumnarToRow [codegen id : 2]
Input [3]: [ws_item_sk#7, ws_bill_customer_sk#8, ws_sold_date_sk#9]

(7) Filter [codegen id : 2]
Input [3]: [ws_item_sk#7, ws_bill_customer_sk#8, ws_sold_date_sk#9]
Condition : (isnotnull(ws_item_sk#7) AND isnotnull(ws_bill_customer_sk#8))

(8) Project [codegen id : 2]
Output [3]: [ws_sold_date_sk#9 AS sold_date_sk#10, ws_bill_customer_sk#8 AS customer_sk#11, ws_item_sk#7 AS item_sk#12]
Input [3]: [ws_item_sk#7, ws_bill_customer_sk#8, ws_sold_date_sk#9]

(9) Union

(10) Scan parquet spark_catalog.default.item
Output [3]: [i_item_sk#13, i_class#14, i_category#15]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_category), IsNotNull(i_class), EqualTo(i_category,Women                                             ), EqualTo(i_class,maternity                                         ), IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_class:string,i_category:string>

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

(12) Filter [codegen id : 3]
Input [3]: [i_item_sk#13, i_class#14, i_category#15]
Condition : ((((isnotnull(i_category#15) AND isnotnull(i_class#14)) AND (i_category#15 = Women                                             )) AND (i_class#14 = maternity                                         )) AND isnotnull(i_item_sk#13))

(13) Project [codegen id : 3]
Output [1]: [i_item_sk#13]
Input [3]: [i_item_sk#13, i_class#14, i_category#15]

(14) BroadcastExchange
Input [1]: [i_item_sk#13]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [plan_id=1]

(15) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [item_sk#6]
Right keys [1]: [i_item_sk#13]
Join type: Inner
Join condition: None

(16) Project [codegen id : 6]
Output [2]: [sold_date_sk#4, customer_sk#5]
Input [4]: [sold_date_sk#4, customer_sk#5, item_sk#6, i_item_sk#13]

(17) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#16, d_year#17, d_moy#18]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_moy), IsNotNull(d_year), EqualTo(d_moy,12), EqualTo(d_year,1998), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_year:int,d_moy:int>

(18) ColumnarToRow [codegen id : 4]
Input [3]: [d_date_sk#16, d_year#17, d_moy#18]

(19) Filter [codegen id : 4]
Input [3]: [d_date_sk#16, d_year#17, d_moy#18]
Condition : ((((isnotnull(d_moy#18) AND isnotnull(d_year#17)) AND (d_moy#18 = 12)) AND (d_year#17 = 1998)) AND isnotnull(d_date_sk#16))

(20) Project [codegen id : 4]
Output [1]: [d_date_sk#16]
Input [3]: [d_date_sk#16, d_year#17, d_moy#18]

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

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

(23) Project [codegen id : 6]
Output [1]: [customer_sk#5]
Input [3]: [sold_date_sk#4, customer_sk#5, d_date_sk#16]

(24) Scan parquet spark_catalog.default.customer
Output [2]: [c_customer_sk#19, c_current_addr_sk#20]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer]
PushedFilters: [IsNotNull(c_customer_sk), IsNotNull(c_current_addr_sk)]
ReadSchema: struct<c_customer_sk:int,c_current_addr_sk:int>

(25) ColumnarToRow [codegen id : 5]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]

(26) Filter [codegen id : 5]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Condition : (isnotnull(c_customer_sk#19) AND isnotnull(c_current_addr_sk#20))

(27) BroadcastExchange
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=3]

(28) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [customer_sk#5]
Right keys [1]: [c_customer_sk#19]
Join type: Inner
Join condition: None

(29) Project [codegen id : 6]
Output [2]: [c_customer_sk#19, c_current_addr_sk#20]
Input [3]: [customer_sk#5, c_customer_sk#19, c_current_addr_sk#20]

(30) HashAggregate [codegen id : 6]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Keys [2]: [c_customer_sk#19, c_current_addr_sk#20]
Functions: []
Aggregate Attributes: []
Results [2]: [c_customer_sk#19, c_current_addr_sk#20]

(31) Exchange
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Arguments: hashpartitioning(c_customer_sk#19, c_current_addr_sk#20, 5), ENSURE_REQUIREMENTS, [plan_id=4]

(32) HashAggregate [codegen id : 11]
Input [2]: [c_customer_sk#19, c_current_addr_sk#20]
Keys [2]: [c_customer_sk#19, c_current_addr_sk#20]
Functions: []
Aggregate Attributes: []
Results [2]: [c_customer_sk#19, c_current_addr_sk#20]

(33) Scan parquet spark_catalog.default.store_sales
Output [3]: [ss_customer_sk#21, ss_ext_sales_price#22, ss_sold_date_sk#23]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#23)]
PushedFilters: [IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_ext_sales_price:decimal(7,2)>

(34) ColumnarToRow [codegen id : 7]
Input [3]: [ss_customer_sk#21, ss_ext_sales_price#22, ss_sold_date_sk#23]

(35) Filter [codegen id : 7]
Input [3]: [ss_customer_sk#21, ss_ext_sales_price#22, ss_sold_date_sk#23]
Condition : isnotnull(ss_customer_sk#21)

(36) BroadcastExchange
Input [3]: [ss_customer_sk#21, ss_ext_sales_price#22, ss_sold_date_sk#23]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=5]

(37) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_customer_sk#19]
Right keys [1]: [ss_customer_sk#21]
Join type: Inner
Join condition: None

(38) Project [codegen id : 11]
Output [4]: [c_customer_sk#19, c_current_addr_sk#20, ss_ext_sales_price#22, ss_sold_date_sk#23]
Input [5]: [c_customer_sk#19, c_current_addr_sk#20, ss_customer_sk#21, ss_ext_sales_price#22, ss_sold_date_sk#23]

(39) Scan parquet spark_catalog.default.customer_address
Output [3]: [ca_address_sk#24, ca_county#25, ca_state#26]
Batched: true
Location [not included in comparison]/{warehouse_dir}/customer_address]
PushedFilters: [IsNotNull(ca_address_sk), IsNotNull(ca_county), IsNotNull(ca_state)]
ReadSchema: struct<ca_address_sk:int,ca_county:string,ca_state:string>

(40) ColumnarToRow [codegen id : 8]
Input [3]: [ca_address_sk#24, ca_county#25, ca_state#26]

(41) Filter [codegen id : 8]
Input [3]: [ca_address_sk#24, ca_county#25, ca_state#26]
Condition : ((isnotnull(ca_address_sk#24) AND isnotnull(ca_county#25)) AND isnotnull(ca_state#26))

(42) BroadcastExchange
Input [3]: [ca_address_sk#24, ca_county#25, ca_state#26]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [plan_id=6]

(43) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_current_addr_sk#20]
Right keys [1]: [ca_address_sk#24]
Join type: Inner
Join condition: None

(44) Project [codegen id : 11]
Output [5]: [c_customer_sk#19, ss_ext_sales_price#22, ss_sold_date_sk#23, ca_county#25, ca_state#26]
Input [7]: [c_customer_sk#19, c_current_addr_sk#20, ss_ext_sales_price#22, ss_sold_date_sk#23, ca_address_sk#24, ca_county#25, ca_state#26]

(45) Scan parquet spark_catalog.default.store
Output [2]: [s_county#27, s_state#28]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store]
PushedFilters: [IsNotNull(s_county), IsNotNull(s_state)]
ReadSchema: struct<s_county:string,s_state:string>

(46) ColumnarToRow [codegen id : 9]
Input [2]: [s_county#27, s_state#28]

(47) Filter [codegen id : 9]
Input [2]: [s_county#27, s_state#28]
Condition : (isnotnull(s_county#27) AND isnotnull(s_state#28))

(48) BroadcastExchange
Input [2]: [s_county#27, s_state#28]
Arguments: HashedRelationBroadcastMode(List(input[0, string, false], input[1, string, false]),false), [plan_id=7]

(49) BroadcastHashJoin [codegen id : 11]
Left keys [2]: [ca_county#25, ca_state#26]
Right keys [2]: [s_county#27, s_state#28]
Join type: Inner
Join condition: None

(50) Project [codegen id : 11]
Output [3]: [c_customer_sk#19, ss_ext_sales_price#22, ss_sold_date_sk#23]
Input [7]: [c_customer_sk#19, ss_ext_sales_price#22, ss_sold_date_sk#23, ca_county#25, ca_state#26, s_county#27, s_state#28]

(51) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#29, d_month_seq#30]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_month_seq), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_month_seq:int>

(52) ColumnarToRow [codegen id : 10]
Input [2]: [d_date_sk#29, d_month_seq#30]

(53) Filter [codegen id : 10]
Input [2]: [d_date_sk#29, d_month_seq#30]
Condition : (((isnotnull(d_month_seq#30) AND (d_month_seq#30 >= Subquery scalar-subquery#31, [id=#32])) AND (d_month_seq#30 <= Subquery scalar-subquery#33, [id=#34])) AND isnotnull(d_date_sk#29))

(54) Project [codegen id : 10]
Output [1]: [d_date_sk#29]
Input [2]: [d_date_sk#29, d_month_seq#30]

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

(56) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [ss_sold_date_sk#23]
Right keys [1]: [d_date_sk#29]
Join type: Inner
Join condition: None

(57) Project [codegen id : 11]
Output [2]: [c_customer_sk#19, ss_ext_sales_price#22]
Input [4]: [c_customer_sk#19, ss_ext_sales_price#22, ss_sold_date_sk#23, d_date_sk#29]

(58) HashAggregate [codegen id : 11]
Input [2]: [c_customer_sk#19, ss_ext_sales_price#22]
Keys [1]: [c_customer_sk#19]
Functions [1]: [partial_sum(UnscaledValue(ss_ext_sales_price#22))]
Aggregate Attributes [1]: [sum#35]
Results [2]: [c_customer_sk#19, sum#36]

(59) Exchange
Input [2]: [c_customer_sk#19, sum#36]
Arguments: hashpartitioning(c_customer_sk#19, 5), ENSURE_REQUIREMENTS, [plan_id=9]

(60) HashAggregate [codegen id : 12]
Input [2]: [c_customer_sk#19, sum#36]
Keys [1]: [c_customer_sk#19]
Functions [1]: [sum(UnscaledValue(ss_ext_sales_price#22))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_ext_sales_price#22))#37]
Results [1]: [cast((MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#22))#37,17,2) / 50) as int) AS segment#38]

(61) HashAggregate [codegen id : 12]
Input [1]: [segment#38]
Keys [1]: [segment#38]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#39]
Results [2]: [segment#38, count#40]

(62) Exchange
Input [2]: [segment#38, count#40]
Arguments: hashpartitioning(segment#38, 5), ENSURE_REQUIREMENTS, [plan_id=10]

(63) HashAggregate [codegen id : 13]
Input [2]: [segment#38, count#40]
Keys [1]: [segment#38]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#41]
Results [3]: [segment#38, count(1)#41 AS num_customers#42, (segment#38 * 50) AS segment_base#43]

(64) TakeOrderedAndProject
Input [3]: [segment#38, num_customers#42, segment_base#43]
Arguments: 100, [segment#38 ASC NULLS FIRST, num_customers#42 ASC NULLS FIRST], [segment#38, num_customers#42, segment_base#43]

===== Subqueries =====

Subquery:1 Hosting operator id = 53 Hosting Expression = Subquery scalar-subquery#31, [id=#32]
* HashAggregate (71)
+- Exchange (70)
   +- * HashAggregate (69)
      +- * Project (68)
         +- * Filter (67)
            +- * ColumnarToRow (66)
               +- Scan parquet spark_catalog.default.date_dim (65)


(65) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_month_seq#44, d_year#45, d_moy#46]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), IsNotNull(d_moy), EqualTo(d_year,1998), EqualTo(d_moy,12)]
ReadSchema: struct<d_month_seq:int,d_year:int,d_moy:int>

(66) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#44, d_year#45, d_moy#46]

(67) Filter [codegen id : 1]
Input [3]: [d_month_seq#44, d_year#45, d_moy#46]
Condition : (((isnotnull(d_year#45) AND isnotnull(d_moy#46)) AND (d_year#45 = 1998)) AND (d_moy#46 = 12))

(68) Project [codegen id : 1]
Output [1]: [(d_month_seq#44 + 1) AS (d_month_seq + 1)#47]
Input [3]: [d_month_seq#44, d_year#45, d_moy#46]

(69) HashAggregate [codegen id : 1]
Input [1]: [(d_month_seq + 1)#47]
Keys [1]: [(d_month_seq + 1)#47]
Functions: []
Aggregate Attributes: []
Results [1]: [(d_month_seq + 1)#47]

(70) Exchange
Input [1]: [(d_month_seq + 1)#47]
Arguments: hashpartitioning((d_month_seq + 1)#47, 5), ENSURE_REQUIREMENTS, [plan_id=11]

(71) HashAggregate [codegen id : 2]
Input [1]: [(d_month_seq + 1)#47]
Keys [1]: [(d_month_seq + 1)#47]
Functions: []
Aggregate Attributes: []
Results [1]: [(d_month_seq + 1)#47]

Subquery:2 Hosting operator id = 53 Hosting Expression = Subquery scalar-subquery#33, [id=#34]
* HashAggregate (78)
+- Exchange (77)
   +- * HashAggregate (76)
      +- * Project (75)
         +- * Filter (74)
            +- * ColumnarToRow (73)
               +- Scan parquet spark_catalog.default.date_dim (72)


(72) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_month_seq#48, d_year#49, d_moy#50]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_year), IsNotNull(d_moy), EqualTo(d_year,1998), EqualTo(d_moy,12)]
ReadSchema: struct<d_month_seq:int,d_year:int,d_moy:int>

(73) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#48, d_year#49, d_moy#50]

(74) Filter [codegen id : 1]
Input [3]: [d_month_seq#48, d_year#49, d_moy#50]
Condition : (((isnotnull(d_year#49) AND isnotnull(d_moy#50)) AND (d_year#49 = 1998)) AND (d_moy#50 = 12))

(75) Project [codegen id : 1]
Output [1]: [(d_month_seq#48 + 3) AS (d_month_seq + 3)#51]
Input [3]: [d_month_seq#48, d_year#49, d_moy#50]

(76) HashAggregate [codegen id : 1]
Input [1]: [(d_month_seq + 3)#51]
Keys [1]: [(d_month_seq + 3)#51]
Functions: []
Aggregate Attributes: []
Results [1]: [(d_month_seq + 3)#51]

(77) Exchange
Input [1]: [(d_month_seq + 3)#51]
Arguments: hashpartitioning((d_month_seq + 3)#51, 5), ENSURE_REQUIREMENTS, [plan_id=12]

(78) HashAggregate [codegen id : 2]
Input [1]: [(d_month_seq + 3)#51]
Keys [1]: [(d_month_seq + 3)#51]
Functions: []
Aggregate Attributes: []
Results [1]: [(d_month_seq + 3)#51]


