== 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 default.catalog_sales (1)
                        :     :     :     :              :     :     :  +- * Project (8)
                        :     :     :     :              :     :     :     +- * Filter (7)
                        :     :     :     :              :     :     :        +- * ColumnarToRow (6)
                        :     :     :     :              :     :     :           +- Scan parquet default.web_sales (5)
                        :     :     :     :              :     :     +- BroadcastExchange (14)
                        :     :     :     :              :     :        +- * Project (13)
                        :     :     :     :              :     :           +- * Filter (12)
                        :     :     :     :              :     :              +- * ColumnarToRow (11)
                        :     :     :     :              :     :                 +- Scan parquet default.item (10)
                        :     :     :     :              :     +- ReusedExchange (17)
                        :     :     :     :              +- BroadcastExchange (23)
                        :     :     :     :                 +- * Filter (22)
                        :     :     :     :                    +- * ColumnarToRow (21)
                        :     :     :     :                       +- Scan parquet default.customer (20)
                        :     :     :     +- BroadcastExchange (32)
                        :     :     :        +- * Filter (31)
                        :     :     :           +- * ColumnarToRow (30)
                        :     :     :              +- Scan parquet default.store_sales (29)
                        :     :     +- BroadcastExchange (38)
                        :     :        +- * Filter (37)
                        :     :           +- * ColumnarToRow (36)
                        :     :              +- Scan parquet default.customer_address (35)
                        :     +- BroadcastExchange (44)
                        :        +- * Filter (43)
                        :           +- * ColumnarToRow (42)
                        :              +- Scan parquet default.store (41)
                        +- ReusedExchange (47)


(1) Scan parquet 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 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 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), [id=#17]

(15) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [item_sk#7]
Right keys [1]: [i_item_sk#14]
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#18]

(18) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [sold_date_sk#5]
Right keys [1]: [d_date_sk#18]
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#18]

(20) Scan parquet 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>

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

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

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

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

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

(26) 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]

(27) 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, [id=#22]

(28) 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]

(29) Scan parquet default.store_sales
Output [3]: [ss_customer_sk#23, ss_ext_sales_price#24, ss_sold_date_sk#25]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#25), dynamicpruningexpression(ss_sold_date_sk#25 IN dynamicpruning#26)]
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#23, ss_ext_sales_price#24, ss_sold_date_sk#25]

(31) Filter [codegen id : 7]
Input [3]: [ss_customer_sk#23, ss_ext_sales_price#24, ss_sold_date_sk#25]
Condition : isnotnull(ss_customer_sk#23)

(32) BroadcastExchange
Input [3]: [ss_customer_sk#23, ss_ext_sales_price#24, ss_sold_date_sk#25]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#27]

(33) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_customer_sk#19]
Right keys [1]: [ss_customer_sk#23]
Join condition: None

(34) Project [codegen id : 11]
Output [4]: [c_customer_sk#19, c_current_addr_sk#20, ss_ext_sales_price#24, ss_sold_date_sk#25]
Input [5]: [c_customer_sk#19, c_current_addr_sk#20, ss_customer_sk#23, ss_ext_sales_price#24, ss_sold_date_sk#25]

(35) Scan parquet default.customer_address
Output [3]: [ca_address_sk#28, ca_county#29, ca_state#30]
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#28, ca_county#29, ca_state#30]

(37) Filter [codegen id : 8]
Input [3]: [ca_address_sk#28, ca_county#29, ca_state#30]
Condition : ((isnotnull(ca_address_sk#28) AND isnotnull(ca_county#29)) AND isnotnull(ca_state#30))

(38) BroadcastExchange
Input [3]: [ca_address_sk#28, ca_county#29, ca_state#30]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, false] as bigint)),false), [id=#31]

(39) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_current_addr_sk#20]
Right keys [1]: [ca_address_sk#28]
Join condition: None

(40) Project [codegen id : 11]
Output [5]: [c_customer_sk#19, ss_ext_sales_price#24, ss_sold_date_sk#25, ca_county#29, ca_state#30]
Input [7]: [c_customer_sk#19, c_current_addr_sk#20, ss_ext_sales_price#24, ss_sold_date_sk#25, ca_address_sk#28, ca_county#29, ca_state#30]

(41) Scan parquet default.store
Output [2]: [s_county#32, s_state#33]
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#32, s_state#33]

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

(44) BroadcastExchange
Input [2]: [s_county#32, s_state#33]
Arguments: HashedRelationBroadcastMode(List(input[0, string, false], input[1, string, false]),false), [id=#34]

(45) BroadcastHashJoin [codegen id : 11]
Left keys [2]: [ca_county#29, ca_state#30]
Right keys [2]: [s_county#32, s_state#33]
Join condition: None

(46) Project [codegen id : 11]
Output [3]: [c_customer_sk#19, ss_ext_sales_price#24, ss_sold_date_sk#25]
Input [7]: [c_customer_sk#19, ss_ext_sales_price#24, ss_sold_date_sk#25, ca_county#29, ca_state#30, s_county#32, s_state#33]

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

(48) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [ss_sold_date_sk#25]
Right keys [1]: [d_date_sk#35]
Join condition: None

(49) Project [codegen id : 11]
Output [2]: [c_customer_sk#19, ss_ext_sales_price#24]
Input [4]: [c_customer_sk#19, ss_ext_sales_price#24, ss_sold_date_sk#25, d_date_sk#35]

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

(51) Exchange
Input [2]: [c_customer_sk#19, sum#37]
Arguments: hashpartitioning(c_customer_sk#19, 5), ENSURE_REQUIREMENTS, [id=#38]

(52) HashAggregate [codegen id : 12]
Input [2]: [c_customer_sk#19, sum#37]
Keys [1]: [c_customer_sk#19]
Functions [1]: [sum(UnscaledValue(ss_ext_sales_price#24))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_ext_sales_price#24))#39]
Results [1]: [cast(CheckOverflow((promote_precision(MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#24))#39,17,2)) / 50.00), DecimalType(21,6)) as int) AS segment#40]

(53) HashAggregate [codegen id : 12]
Input [1]: [segment#40]
Keys [1]: [segment#40]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#41]
Results [2]: [segment#40, count#42]

(54) Exchange
Input [2]: [segment#40, count#42]
Arguments: hashpartitioning(segment#40, 5), ENSURE_REQUIREMENTS, [id=#43]

(55) HashAggregate [codegen id : 13]
Input [2]: [segment#40, count#42]
Keys [1]: [segment#40]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#44]
Results [3]: [segment#40, count(1)#44 AS num_customers#45, (segment#40 * 50) AS segment_base#46]

(56) TakeOrderedAndProject
Input [3]: [segment#40, num_customers#45, segment_base#46]
Arguments: 100, [segment#40 ASC NULLS FIRST, num_customers#45 ASC NULLS FIRST], [segment#40, num_customers#45, segment_base#46]

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


(57) Scan parquet default.date_dim
Output [3]: [d_date_sk#18, d_year#47, d_moy#48]
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#18, d_year#47, d_moy#48]

(59) Filter [codegen id : 1]
Input [3]: [d_date_sk#18, d_year#47, d_moy#48]
Condition : ((((isnotnull(d_moy#48) AND isnotnull(d_year#47)) AND (d_moy#48 = 12)) AND (d_year#47 = 1998)) AND isnotnull(d_date_sk#18))

(60) Project [codegen id : 1]
Output [1]: [d_date_sk#18]
Input [3]: [d_date_sk#18, d_year#47, d_moy#48]

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

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#25 IN dynamicpruning#26
BroadcastExchange (66)
+- * Project (65)
   +- * Filter (64)
      +- * ColumnarToRow (63)
         +- Scan parquet default.date_dim (62)


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

(64) Filter [codegen id : 1]
Input [2]: [d_date_sk#35, d_month_seq#50]
Condition : (((isnotnull(d_month_seq#50) AND (d_month_seq#50 >= Subquery scalar-subquery#51, [id=#52])) AND (d_month_seq#50 <= Subquery scalar-subquery#53, [id=#54])) AND isnotnull(d_date_sk#35))

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

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

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


(67) Scan parquet default.date_dim
Output [3]: [d_month_seq#56, d_year#57, d_moy#58]
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#56, d_year#57, d_moy#58]

(69) Filter [codegen id : 1]
Input [3]: [d_month_seq#56, d_year#57, d_moy#58]
Condition : (((isnotnull(d_year#57) AND isnotnull(d_moy#58)) AND (d_year#57 = 1998)) AND (d_moy#58 = 12))

(70) Project [codegen id : 1]
Output [1]: [(d_month_seq#56 + 1) AS (d_month_seq + 1)#59]
Input [3]: [d_month_seq#56, d_year#57, d_moy#58]

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

(72) Exchange
Input [1]: [(d_month_seq + 1)#59]
Arguments: hashpartitioning((d_month_seq + 1)#59, 5), ENSURE_REQUIREMENTS, [id=#60]

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

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


(74) Scan parquet default.date_dim
Output [3]: [d_month_seq#61, d_year#62, d_moy#63]
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#61, d_year#62, d_moy#63]

(76) Filter [codegen id : 1]
Input [3]: [d_month_seq#61, d_year#62, d_moy#63]
Condition : (((isnotnull(d_year#62) AND isnotnull(d_moy#63)) AND (d_year#62 = 1998)) AND (d_moy#63 = 12))

(77) Project [codegen id : 1]
Output [1]: [(d_month_seq#61 + 3) AS (d_month_seq + 3)#64]
Input [3]: [d_month_seq#61, d_year#62, d_moy#63]

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

(79) Exchange
Input [1]: [(d_month_seq + 3)#64]
Arguments: hashpartitioning((d_month_seq + 3)#64, 5), ENSURE_REQUIREMENTS, [id=#65]

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


