== 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 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)
                        :     :     :     :              :     +- BroadcastExchange (21)
                        :     :     :     :              :        +- * Project (20)
                        :     :     :     :              :           +- * Filter (19)
                        :     :     :     :              :              +- * ColumnarToRow (18)
                        :     :     :     :              :                 +- Scan parquet default.date_dim (17)
                        :     :     :     :              +- BroadcastExchange (27)
                        :     :     :     :                 +- * Filter (26)
                        :     :     :     :                    +- * ColumnarToRow (25)
                        :     :     :     :                       +- Scan parquet default.customer (24)
                        :     :     :     +- BroadcastExchange (36)
                        :     :     :        +- * Filter (35)
                        :     :     :           +- * ColumnarToRow (34)
                        :     :     :              +- Scan parquet default.store_sales (33)
                        :     :     +- BroadcastExchange (42)
                        :     :        +- * Filter (41)
                        :     :           +- * ColumnarToRow (40)
                        :     :              +- Scan parquet default.customer_address (39)
                        :     +- BroadcastExchange (48)
                        :        +- * Filter (47)
                        :           +- * ColumnarToRow (46)
                        :              +- Scan parquet default.store (45)
                        +- BroadcastExchange (55)
                           +- * Project (54)
                              +- * Filter (53)
                                 +- * ColumnarToRow (52)
                                    +- Scan parquet default.date_dim (51)


(1) Scan parquet default.catalog_sales
Output [3]: [cs_sold_date_sk#1, cs_bill_customer_sk#2, cs_item_sk#3]
Batched: true
Location [not included in comparison]/{warehouse_dir}/catalog_sales]
PushedFilters: [IsNotNull(cs_item_sk), IsNotNull(cs_sold_date_sk), IsNotNull(cs_bill_customer_sk)]
ReadSchema: struct<cs_sold_date_sk:int,cs_bill_customer_sk:int,cs_item_sk:int>

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

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

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

(5) Scan parquet default.web_sales
Output [3]: [ws_sold_date_sk#7, ws_item_sk#8, ws_bill_customer_sk#9]
Batched: true
Location [not included in comparison]/{warehouse_dir}/web_sales]
PushedFilters: [IsNotNull(ws_item_sk), IsNotNull(ws_sold_date_sk), IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_sold_date_sk:int,ws_item_sk:int,ws_bill_customer_sk:int>

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

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

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

(9) Union

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

(15) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [item_sk#6]
Right keys [1]: [i_item_sk#13]
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 default.date_dim
Output [3]: [d_date_sk#17, d_year#18, d_moy#19]
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#17, d_year#18, d_moy#19]

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

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

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

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

(24) Scan parquet default.customer
Output [2]: [c_customer_sk#21, c_current_addr_sk#22]
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#21, c_current_addr_sk#22]

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

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

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

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

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

(31) Exchange
Input [2]: [c_customer_sk#21, c_current_addr_sk#22]
Arguments: hashpartitioning(c_customer_sk#21, c_current_addr_sk#22, 5), true, [id=#24]

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

(33) Scan parquet default.store_sales
Output [3]: [ss_sold_date_sk#25, ss_customer_sk#26, ss_ext_sales_price#27]
Batched: true
Location [not included in comparison]/{warehouse_dir}/store_sales]
PushedFilters: [IsNotNull(ss_customer_sk), IsNotNull(ss_sold_date_sk)]
ReadSchema: struct<ss_sold_date_sk:int,ss_customer_sk:int,ss_ext_sales_price:decimal(7,2)>

(34) ColumnarToRow [codegen id : 7]
Input [3]: [ss_sold_date_sk#25, ss_customer_sk#26, ss_ext_sales_price#27]

(35) Filter [codegen id : 7]
Input [3]: [ss_sold_date_sk#25, ss_customer_sk#26, ss_ext_sales_price#27]
Condition : (isnotnull(ss_customer_sk#26) AND isnotnull(ss_sold_date_sk#25))

(36) BroadcastExchange
Input [3]: [ss_sold_date_sk#25, ss_customer_sk#26, ss_ext_sales_price#27]
Arguments: HashedRelationBroadcastMode(List(cast(input[1, int, false] as bigint)),false), [id=#28]

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

(38) Project [codegen id : 11]
Output [4]: [c_customer_sk#21, c_current_addr_sk#22, ss_sold_date_sk#25, ss_ext_sales_price#27]
Input [5]: [c_customer_sk#21, c_current_addr_sk#22, ss_sold_date_sk#25, ss_customer_sk#26, ss_ext_sales_price#27]

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

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

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

(43) BroadcastHashJoin [codegen id : 11]
Left keys [1]: [c_current_addr_sk#22]
Right keys [1]: [ca_address_sk#29]
Join condition: None

(44) Project [codegen id : 11]
Output [5]: [c_customer_sk#21, ss_sold_date_sk#25, ss_ext_sales_price#27, ca_county#30, ca_state#31]
Input [7]: [c_customer_sk#21, c_current_addr_sk#22, ss_sold_date_sk#25, ss_ext_sales_price#27, ca_address_sk#29, ca_county#30, ca_state#31]

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

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

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

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

(50) Project [codegen id : 11]
Output [3]: [c_customer_sk#21, ss_sold_date_sk#25, ss_ext_sales_price#27]
Input [7]: [c_customer_sk#21, ss_sold_date_sk#25, ss_ext_sales_price#27, ca_county#30, ca_state#31, s_county#33, s_state#34]

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

(53) Filter [codegen id : 10]
Input [2]: [d_date_sk#17, d_month_seq#36]
Condition : (((isnotnull(d_month_seq#36) AND (d_month_seq#36 >= Subquery scalar-subquery#37, [id=#38])) AND (d_month_seq#36 <= Subquery scalar-subquery#39, [id=#40])) AND isnotnull(d_date_sk#17))

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

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

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

(57) Project [codegen id : 11]
Output [2]: [c_customer_sk#21, ss_ext_sales_price#27]
Input [4]: [c_customer_sk#21, ss_sold_date_sk#25, ss_ext_sales_price#27, d_date_sk#17]

(58) HashAggregate [codegen id : 11]
Input [2]: [c_customer_sk#21, ss_ext_sales_price#27]
Keys [1]: [c_customer_sk#21]
Functions [1]: [partial_sum(UnscaledValue(ss_ext_sales_price#27))]
Aggregate Attributes [1]: [sum#42]
Results [2]: [c_customer_sk#21, sum#43]

(59) Exchange
Input [2]: [c_customer_sk#21, sum#43]
Arguments: hashpartitioning(c_customer_sk#21, 5), true, [id=#44]

(60) HashAggregate [codegen id : 12]
Input [2]: [c_customer_sk#21, sum#43]
Keys [1]: [c_customer_sk#21]
Functions [1]: [sum(UnscaledValue(ss_ext_sales_price#27))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_ext_sales_price#27))#45]
Results [1]: [cast(CheckOverflow((promote_precision(MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#27))#45,17,2)) / 50.00), DecimalType(21,6), true) as int) AS segment#46]

(61) HashAggregate [codegen id : 12]
Input [1]: [segment#46]
Keys [1]: [segment#46]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#47]
Results [2]: [segment#46, count#48]

(62) Exchange
Input [2]: [segment#46, count#48]
Arguments: hashpartitioning(segment#46, 5), true, [id=#49]

(63) HashAggregate [codegen id : 13]
Input [2]: [segment#46, count#48]
Keys [1]: [segment#46]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#50]
Results [3]: [segment#46, count(1)#50 AS num_customers#51, (segment#46 * 50) AS segment_base#52]

(64) TakeOrderedAndProject
Input [3]: [segment#46, num_customers#51, segment_base#52]
Arguments: 100, [segment#46 ASC NULLS FIRST, num_customers#51 ASC NULLS FIRST], [segment#46, num_customers#51, segment_base#52]

===== Subqueries =====

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


(65) Scan parquet default.date_dim
Output [3]: [d_month_seq#36, d_year#18, d_moy#19]
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#36, d_year#18, d_moy#19]

(67) Filter [codegen id : 1]
Input [3]: [d_month_seq#36, d_year#18, d_moy#19]
Condition : (((isnotnull(d_year#18) AND isnotnull(d_moy#19)) AND (d_year#18 = 1998)) AND (d_moy#19 = 12))

(68) Project [codegen id : 1]
Output [1]: [(d_month_seq#36 + 1) AS (d_month_seq + 1)#53]
Input [3]: [d_month_seq#36, d_year#18, d_moy#19]

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

(70) Exchange
Input [1]: [(d_month_seq + 1)#53]
Arguments: hashpartitioning((d_month_seq + 1)#53, 5), true, [id=#54]

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

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


(72) Scan parquet default.date_dim
Output [3]: [d_month_seq#36, d_year#18, d_moy#19]
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#36, d_year#18, d_moy#19]

(74) Filter [codegen id : 1]
Input [3]: [d_month_seq#36, d_year#18, d_moy#19]
Condition : (((isnotnull(d_year#18) AND isnotnull(d_moy#19)) AND (d_year#18 = 1998)) AND (d_moy#19 = 12))

(75) Project [codegen id : 1]
Output [1]: [(d_month_seq#36 + 3) AS (d_month_seq + 3)#55]
Input [3]: [d_month_seq#36, d_year#18, d_moy#19]

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

(77) Exchange
Input [1]: [(d_month_seq + 3)#55]
Arguments: hashpartitioning((d_month_seq + 3)#55, 5), true, [id=#56]

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


