== Physical Plan ==
TakeOrderedAndProject (56)
+- * HashAggregate (55)
   +- Exchange (54)
      +- * HashAggregate (53)
         +- * HashAggregate (52)
            +- Exchange (51)
               +- * HashAggregate (50)
                  +- * Project (49)
                     +- * BroadcastHashJoin Inner BuildRight (48)
                        :- * Project (46)
                        :  +- * BroadcastHashJoin Inner BuildRight (45)
                        :     :- * Project (40)
                        :     :  +- * BroadcastHashJoin Inner BuildRight (39)
                        :     :     :- * Project (34)
                        :     :     :  +- * BroadcastHashJoin Inner BuildRight (33)
                        :     :     :     :- * HashAggregate (28)
                        :     :     :     :  +- Exchange (27)
                        :     :     :     :     +- * HashAggregate (26)
                        :     :     :     :        +- * Project (25)
                        :     :     :     :           +- * BroadcastHashJoin Inner BuildRight (24)
                        :     :     :     :              :- * Project (19)
                        :     :     :     :              :  +- * BroadcastHashJoin Inner BuildRight (18)
                        :     :     :     :              :     :- * 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)
                        :     :     :     :              :     +- ReusedExchange (17)
                        :     :     :     :              +- BroadcastExchange (23)
                        :     :     :     :                 +- * Filter (22)
                        :     :     :     :                    +- * ColumnarToRow (21)
                        :     :     :     :                       +- Scan parquet spark_catalog.default.customer (20)
                        :     :     :     +- BroadcastExchange (32)
                        :     :     :        +- * Filter (31)
                        :     :     :           +- * ColumnarToRow (30)
                        :     :     :              +- Scan parquet spark_catalog.default.store_sales (29)
                        :     :     +- BroadcastExchange (38)
                        :     :        +- * Filter (37)
                        :     :           +- * ColumnarToRow (36)
                        :     :              +- Scan parquet spark_catalog.default.customer_address (35)
                        :     +- BroadcastExchange (44)
                        :        +- * Filter (43)
                        :           +- * ColumnarToRow (42)
                        :              +- Scan parquet spark_catalog.default.store (41)
                        +- ReusedExchange (47)


(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), dynamicpruningexpression(cs_sold_date_sk#3 IN dynamicpruning#4)]
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#5, cs_bill_customer_sk#1 AS customer_sk#6, cs_item_sk#2 AS item_sk#7]
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#8, ws_bill_customer_sk#9, ws_sold_date_sk#10]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#10), dynamicpruningexpression(ws_sold_date_sk#10 IN dynamicpruning#4)]
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#8, ws_bill_customer_sk#9, ws_sold_date_sk#10]

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

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

(9) Union

(10) Scan parquet spark_catalog.default.item
Output [3]: [i_item_sk#14, i_class#15, i_category#16]
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#14, i_class#15, i_category#16]

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

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

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

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

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

(17) ReusedExchange [Reuses operator id: 61]
Output [1]: [d_date_sk#17]

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

(19) Project [codegen id : 6]
Output [1]: [customer_sk#6]
Input [3]: [sold_date_sk#5, customer_sk#6, d_date_sk#17]

(20) Scan parquet spark_catalog.default.customer
Output [2]: [c_customer_sk#18, c_current_addr_sk#19]
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>

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

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

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

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

(25) Project [codegen id : 6]
Output [2]: [c_customer_sk#18, c_current_addr_sk#19]
Input [3]: [customer_sk#6, c_customer_sk#18, c_current_addr_sk#19]

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

(27) Exchange
Input [2]: [c_customer_sk#18, c_current_addr_sk#19]
Arguments: hashpartitioning(c_customer_sk#18, c_current_addr_sk#19, 5), ENSURE_REQUIREMENTS, [plan_id=3]

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

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

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

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

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

(33) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_customer_sk#18]
Right keys [1]: [ss_customer_sk#20]
Join type: Inner
Join condition: None

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

(35) 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>

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

(37) 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))

(38) 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=5]

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

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

(41) 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>

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

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

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

(45) 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

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

(47) ReusedExchange [Reuses operator id: 66]
Output [1]: [d_date_sk#29]

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

(49) Project [codegen id : 11]
Output [2]: [c_customer_sk#18, ss_ext_sales_price#21]
Input [4]: [c_customer_sk#18, ss_ext_sales_price#21, ss_sold_date_sk#22, d_date_sk#29]

(50) HashAggregate [codegen id : 11]
Input [2]: [c_customer_sk#18, ss_ext_sales_price#21]
Keys [1]: [c_customer_sk#18]
Functions [1]: [partial_sum(UnscaledValue(ss_ext_sales_price#21))]
Aggregate Attributes [1]: [sum#30]
Results [2]: [c_customer_sk#18, sum#31]

(51) Exchange
Input [2]: [c_customer_sk#18, sum#31]
Arguments: hashpartitioning(c_customer_sk#18, 5), ENSURE_REQUIREMENTS, [plan_id=7]

(52) HashAggregate [codegen id : 12]
Input [2]: [c_customer_sk#18, sum#31]
Keys [1]: [c_customer_sk#18]
Functions [1]: [sum(UnscaledValue(ss_ext_sales_price#21))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_ext_sales_price#21))#32]
Results [1]: [cast((MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#21))#32,17,2) / 50) as int) AS segment#33]

(53) HashAggregate [codegen id : 12]
Input [1]: [segment#33]
Keys [1]: [segment#33]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#34]
Results [2]: [segment#33, count#35]

(54) Exchange
Input [2]: [segment#33, count#35]
Arguments: hashpartitioning(segment#33, 5), ENSURE_REQUIREMENTS, [plan_id=8]

(55) HashAggregate [codegen id : 13]
Input [2]: [segment#33, count#35]
Keys [1]: [segment#33]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#36]
Results [3]: [segment#33, count(1)#36 AS num_customers#37, (segment#33 * 50) AS segment_base#38]

(56) TakeOrderedAndProject
Input [3]: [segment#33, num_customers#37, segment_base#38]
Arguments: 100, [segment#33 ASC NULLS FIRST, num_customers#37 ASC NULLS FIRST], [segment#33, num_customers#37, segment_base#38]

===== Subqueries =====

Subquery:1 Hosting operator id = 1 Hosting Expression = cs_sold_date_sk#3 IN dynamicpruning#4
BroadcastExchange (61)
+- * Project (60)
   +- * Filter (59)
      +- * ColumnarToRow (58)
         +- Scan parquet spark_catalog.default.date_dim (57)


(57) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_date_sk#17, d_year#39, d_moy#40]
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>

(58) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#17, d_year#39, d_moy#40]

(59) Filter [codegen id : 1]
Input [3]: [d_date_sk#17, d_year#39, d_moy#40]
Condition : ((((isnotnull(d_moy#40) AND isnotnull(d_year#39)) AND (d_moy#40 = 12)) AND (d_year#39 = 1998)) AND isnotnull(d_date_sk#17))

(60) Project [codegen id : 1]
Output [1]: [d_date_sk#17]
Input [3]: [d_date_sk#17, d_year#39, d_moy#40]

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

Subquery:2 Hosting operator id = 5 Hosting Expression = ws_sold_date_sk#10 IN dynamicpruning#4

Subquery:3 Hosting operator id = 29 Hosting Expression = ss_sold_date_sk#22 IN dynamicpruning#23
BroadcastExchange (66)
+- * Project (65)
   +- * Filter (64)
      +- * ColumnarToRow (63)
         +- Scan parquet spark_catalog.default.date_dim (62)


(62) Scan parquet spark_catalog.default.date_dim
Output [2]: [d_date_sk#29, d_month_seq#41]
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>

(63) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#29, d_month_seq#41]

(64) Filter [codegen id : 1]
Input [2]: [d_date_sk#29, d_month_seq#41]
Condition : (((isnotnull(d_month_seq#41) AND (d_month_seq#41 >= Subquery scalar-subquery#42, [id=#43])) AND (d_month_seq#41 <= Subquery scalar-subquery#44, [id=#45])) AND isnotnull(d_date_sk#29))

(65) Project [codegen id : 1]
Output [1]: [d_date_sk#29]
Input [2]: [d_date_sk#29, d_month_seq#41]

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

Subquery:4 Hosting operator id = 64 Hosting Expression = Subquery scalar-subquery#42, [id=#43]
* HashAggregate (73)
+- Exchange (72)
   +- * HashAggregate (71)
      +- * Project (70)
         +- * Filter (69)
            +- * ColumnarToRow (68)
               +- Scan parquet spark_catalog.default.date_dim (67)


(67) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_month_seq#46, d_year#47, d_moy#48]
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>

(68) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#46, d_year#47, d_moy#48]

(69) Filter [codegen id : 1]
Input [3]: [d_month_seq#46, d_year#47, d_moy#48]
Condition : (((isnotnull(d_year#47) AND isnotnull(d_moy#48)) AND (d_year#47 = 1998)) AND (d_moy#48 = 12))

(70) Project [codegen id : 1]
Output [1]: [(d_month_seq#46 + 1) AS (d_month_seq + 1)#49]
Input [3]: [d_month_seq#46, d_year#47, d_moy#48]

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

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

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

Subquery:5 Hosting operator id = 64 Hosting Expression = Subquery scalar-subquery#44, [id=#45]
* HashAggregate (80)
+- Exchange (79)
   +- * HashAggregate (78)
      +- * Project (77)
         +- * Filter (76)
            +- * ColumnarToRow (75)
               +- Scan parquet spark_catalog.default.date_dim (74)


(74) Scan parquet spark_catalog.default.date_dim
Output [3]: [d_month_seq#50, d_year#51, d_moy#52]
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>

(75) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#50, d_year#51, d_moy#52]

(76) Filter [codegen id : 1]
Input [3]: [d_month_seq#50, d_year#51, d_moy#52]
Condition : (((isnotnull(d_year#51) AND isnotnull(d_moy#52)) AND (d_year#51 = 1998)) AND (d_moy#52 = 12))

(77) Project [codegen id : 1]
Output [1]: [(d_month_seq#50 + 3) AS (d_month_seq + 3)#53]
Input [3]: [d_month_seq#50, d_year#51, d_moy#52]

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

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

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


