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


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

(2) ColumnarToRow [codegen id : 2]
Input [3]: [ca_address_sk#1, ca_county#2, ca_state#3]

(3) Filter [codegen id : 2]
Input [3]: [ca_address_sk#1, ca_county#2, ca_state#3]
Condition : ((isnotnull(ca_address_sk#1) AND isnotnull(ca_county#2)) AND isnotnull(ca_state#3))

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

(5) ColumnarToRow [codegen id : 1]
Input [2]: [s_county#4, s_state#5]

(6) Filter [codegen id : 1]
Input [2]: [s_county#4, s_state#5]
Condition : (isnotnull(s_county#4) AND isnotnull(s_state#5))

(7) BroadcastExchange
Input [2]: [s_county#4, s_state#5]
Arguments: HashedRelationBroadcastMode(List(input[0, string, false], input[1, string, false]),false), [id=#6]

(8) BroadcastHashJoin [codegen id : 2]
Left keys [2]: [ca_county#2, ca_state#3]
Right keys [2]: [s_county#4, s_state#5]
Join condition: None

(9) Project [codegen id : 2]
Output [1]: [ca_address_sk#1]
Input [5]: [ca_address_sk#1, ca_county#2, ca_state#3, s_county#4, s_state#5]

(10) BroadcastExchange
Input [1]: [ca_address_sk#1]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#7]

(11) Scan parquet default.catalog_sales
Output [3]: [cs_bill_customer_sk#8, cs_item_sk#9, cs_sold_date_sk#10]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(cs_sold_date_sk#10), dynamicpruningexpression(cs_sold_date_sk#10 IN dynamicpruning#11)]
PushedFilters: [IsNotNull(cs_item_sk), IsNotNull(cs_bill_customer_sk)]
ReadSchema: struct<cs_bill_customer_sk:int,cs_item_sk:int>

(12) ColumnarToRow [codegen id : 3]
Input [3]: [cs_bill_customer_sk#8, cs_item_sk#9, cs_sold_date_sk#10]

(13) Filter [codegen id : 3]
Input [3]: [cs_bill_customer_sk#8, cs_item_sk#9, cs_sold_date_sk#10]
Condition : (isnotnull(cs_item_sk#9) AND isnotnull(cs_bill_customer_sk#8))

(14) Project [codegen id : 3]
Output [3]: [cs_sold_date_sk#10 AS sold_date_sk#12, cs_bill_customer_sk#8 AS customer_sk#13, cs_item_sk#9 AS item_sk#14]
Input [3]: [cs_bill_customer_sk#8, cs_item_sk#9, cs_sold_date_sk#10]

(15) Scan parquet default.web_sales
Output [3]: [ws_item_sk#15, ws_bill_customer_sk#16, ws_sold_date_sk#17]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ws_sold_date_sk#17), dynamicpruningexpression(ws_sold_date_sk#17 IN dynamicpruning#11)]
PushedFilters: [IsNotNull(ws_item_sk), IsNotNull(ws_bill_customer_sk)]
ReadSchema: struct<ws_item_sk:int,ws_bill_customer_sk:int>

(16) ColumnarToRow [codegen id : 4]
Input [3]: [ws_item_sk#15, ws_bill_customer_sk#16, ws_sold_date_sk#17]

(17) Filter [codegen id : 4]
Input [3]: [ws_item_sk#15, ws_bill_customer_sk#16, ws_sold_date_sk#17]
Condition : (isnotnull(ws_item_sk#15) AND isnotnull(ws_bill_customer_sk#16))

(18) Project [codegen id : 4]
Output [3]: [ws_sold_date_sk#17 AS sold_date_sk#18, ws_bill_customer_sk#16 AS customer_sk#19, ws_item_sk#15 AS item_sk#20]
Input [3]: [ws_item_sk#15, ws_bill_customer_sk#16, ws_sold_date_sk#17]

(19) Union

(20) ReusedExchange [Reuses operator id: 64]
Output [1]: [d_date_sk#21]

(21) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [sold_date_sk#12]
Right keys [1]: [d_date_sk#21]
Join condition: None

(22) Project [codegen id : 7]
Output [2]: [customer_sk#13, item_sk#14]
Input [4]: [sold_date_sk#12, customer_sk#13, item_sk#14, d_date_sk#21]

(23) Scan parquet default.item
Output [3]: [i_item_sk#22, i_class#23, i_category#24]
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>

(24) ColumnarToRow [codegen id : 6]
Input [3]: [i_item_sk#22, i_class#23, i_category#24]

(25) Filter [codegen id : 6]
Input [3]: [i_item_sk#22, i_class#23, i_category#24]
Condition : ((((isnotnull(i_category#24) AND isnotnull(i_class#23)) AND (i_category#24 = Women                                             )) AND (i_class#23 = maternity                                         )) AND isnotnull(i_item_sk#22))

(26) Project [codegen id : 6]
Output [1]: [i_item_sk#22]
Input [3]: [i_item_sk#22, i_class#23, i_category#24]

(27) BroadcastExchange
Input [1]: [i_item_sk#22]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#25]

(28) BroadcastHashJoin [codegen id : 7]
Left keys [1]: [item_sk#14]
Right keys [1]: [i_item_sk#22]
Join condition: None

(29) Project [codegen id : 7]
Output [1]: [customer_sk#13]
Input [3]: [customer_sk#13, item_sk#14, i_item_sk#22]

(30) Exchange
Input [1]: [customer_sk#13]
Arguments: hashpartitioning(customer_sk#13, 5), ENSURE_REQUIREMENTS, [id=#26]

(31) Sort [codegen id : 8]
Input [1]: [customer_sk#13]
Arguments: [customer_sk#13 ASC NULLS FIRST], false, 0

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

(33) ColumnarToRow [codegen id : 9]
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]

(34) Filter [codegen id : 9]
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]
Condition : (isnotnull(c_customer_sk#27) AND isnotnull(c_current_addr_sk#28))

(35) Exchange
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]
Arguments: hashpartitioning(c_customer_sk#27, 5), ENSURE_REQUIREMENTS, [id=#29]

(36) Sort [codegen id : 10]
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]
Arguments: [c_customer_sk#27 ASC NULLS FIRST], false, 0

(37) SortMergeJoin
Left keys [1]: [customer_sk#13]
Right keys [1]: [c_customer_sk#27]
Join condition: None

(38) Project
Output [2]: [c_customer_sk#27, c_current_addr_sk#28]
Input [3]: [customer_sk#13, c_customer_sk#27, c_current_addr_sk#28]

(39) HashAggregate
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]
Keys [2]: [c_customer_sk#27, c_current_addr_sk#28]
Functions: []
Aggregate Attributes: []
Results [2]: [c_customer_sk#27, c_current_addr_sk#28]

(40) HashAggregate
Input [2]: [c_customer_sk#27, c_current_addr_sk#28]
Keys [2]: [c_customer_sk#27, c_current_addr_sk#28]
Functions: []
Aggregate Attributes: []
Results [2]: [c_customer_sk#27, c_current_addr_sk#28]

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

(42) Project [codegen id : 11]
Output [1]: [c_customer_sk#27]
Input [3]: [ca_address_sk#1, c_customer_sk#27, c_current_addr_sk#28]

(43) Sort [codegen id : 11]
Input [1]: [c_customer_sk#27]
Arguments: [c_customer_sk#27 ASC NULLS FIRST], false, 0

(44) Scan parquet default.store_sales
Output [3]: [ss_customer_sk#30, ss_ext_sales_price#31, ss_sold_date_sk#32]
Batched: true
Location: InMemoryFileIndex []
PartitionFilters: [isnotnull(ss_sold_date_sk#32), dynamicpruningexpression(ss_sold_date_sk#32 IN dynamicpruning#33)]
PushedFilters: [IsNotNull(ss_customer_sk)]
ReadSchema: struct<ss_customer_sk:int,ss_ext_sales_price:decimal(7,2)>

(45) ColumnarToRow [codegen id : 13]
Input [3]: [ss_customer_sk#30, ss_ext_sales_price#31, ss_sold_date_sk#32]

(46) Filter [codegen id : 13]
Input [3]: [ss_customer_sk#30, ss_ext_sales_price#31, ss_sold_date_sk#32]
Condition : isnotnull(ss_customer_sk#30)

(47) ReusedExchange [Reuses operator id: 69]
Output [1]: [d_date_sk#34]

(48) BroadcastHashJoin [codegen id : 13]
Left keys [1]: [ss_sold_date_sk#32]
Right keys [1]: [d_date_sk#34]
Join condition: None

(49) Project [codegen id : 13]
Output [2]: [ss_customer_sk#30, ss_ext_sales_price#31]
Input [4]: [ss_customer_sk#30, ss_ext_sales_price#31, ss_sold_date_sk#32, d_date_sk#34]

(50) Exchange
Input [2]: [ss_customer_sk#30, ss_ext_sales_price#31]
Arguments: hashpartitioning(ss_customer_sk#30, 5), ENSURE_REQUIREMENTS, [id=#35]

(51) Sort [codegen id : 14]
Input [2]: [ss_customer_sk#30, ss_ext_sales_price#31]
Arguments: [ss_customer_sk#30 ASC NULLS FIRST], false, 0

(52) SortMergeJoin [codegen id : 15]
Left keys [1]: [c_customer_sk#27]
Right keys [1]: [ss_customer_sk#30]
Join condition: None

(53) Project [codegen id : 15]
Output [2]: [c_customer_sk#27, ss_ext_sales_price#31]
Input [3]: [c_customer_sk#27, ss_customer_sk#30, ss_ext_sales_price#31]

(54) HashAggregate [codegen id : 15]
Input [2]: [c_customer_sk#27, ss_ext_sales_price#31]
Keys [1]: [c_customer_sk#27]
Functions [1]: [partial_sum(UnscaledValue(ss_ext_sales_price#31))]
Aggregate Attributes [1]: [sum#36]
Results [2]: [c_customer_sk#27, sum#37]

(55) HashAggregate [codegen id : 15]
Input [2]: [c_customer_sk#27, sum#37]
Keys [1]: [c_customer_sk#27]
Functions [1]: [sum(UnscaledValue(ss_ext_sales_price#31))]
Aggregate Attributes [1]: [sum(UnscaledValue(ss_ext_sales_price#31))#38]
Results [1]: [cast(CheckOverflow((promote_precision(MakeDecimal(sum(UnscaledValue(ss_ext_sales_price#31))#38,17,2)) / 50.00), DecimalType(21,6), true) as int) AS segment#39]

(56) HashAggregate [codegen id : 15]
Input [1]: [segment#39]
Keys [1]: [segment#39]
Functions [1]: [partial_count(1)]
Aggregate Attributes [1]: [count#40]
Results [2]: [segment#39, count#41]

(57) Exchange
Input [2]: [segment#39, count#41]
Arguments: hashpartitioning(segment#39, 5), ENSURE_REQUIREMENTS, [id=#42]

(58) HashAggregate [codegen id : 16]
Input [2]: [segment#39, count#41]
Keys [1]: [segment#39]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#43]
Results [3]: [segment#39, count(1)#43 AS num_customers#44, (segment#39 * 50) AS segment_base#45]

(59) TakeOrderedAndProject
Input [3]: [segment#39, num_customers#44, segment_base#45]
Arguments: 100, [segment#39 ASC NULLS FIRST, num_customers#44 ASC NULLS FIRST], [segment#39, num_customers#44, segment_base#45]

===== Subqueries =====

Subquery:1 Hosting operator id = 11 Hosting Expression = cs_sold_date_sk#10 IN dynamicpruning#11
BroadcastExchange (64)
+- * Project (63)
   +- * Filter (62)
      +- * ColumnarToRow (61)
         +- Scan parquet default.date_dim (60)


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

(61) ColumnarToRow [codegen id : 1]
Input [3]: [d_date_sk#21, d_year#46, d_moy#47]

(62) Filter [codegen id : 1]
Input [3]: [d_date_sk#21, d_year#46, d_moy#47]
Condition : ((((isnotnull(d_moy#47) AND isnotnull(d_year#46)) AND (d_moy#47 = 12)) AND (d_year#46 = 1998)) AND isnotnull(d_date_sk#21))

(63) Project [codegen id : 1]
Output [1]: [d_date_sk#21]
Input [3]: [d_date_sk#21, d_year#46, d_moy#47]

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

Subquery:2 Hosting operator id = 15 Hosting Expression = ws_sold_date_sk#17 IN dynamicpruning#11

Subquery:3 Hosting operator id = 44 Hosting Expression = ss_sold_date_sk#32 IN dynamicpruning#33
BroadcastExchange (69)
+- * Project (68)
   +- * Filter (67)
      +- * ColumnarToRow (66)
         +- Scan parquet default.date_dim (65)


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

(66) ColumnarToRow [codegen id : 1]
Input [2]: [d_date_sk#34, d_month_seq#49]

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

(68) Project [codegen id : 1]
Output [1]: [d_date_sk#34]
Input [2]: [d_date_sk#34, d_month_seq#49]

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

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


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

(71) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#55, d_year#56, d_moy#57]

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

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

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

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

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

Subquery:5 Hosting operator id = 67 Hosting Expression = Subquery scalar-subquery#52, [id=#53]
* HashAggregate (83)
+- Exchange (82)
   +- * HashAggregate (81)
      +- * Project (80)
         +- * Filter (79)
            +- * ColumnarToRow (78)
               +- Scan parquet default.date_dim (77)


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

(78) ColumnarToRow [codegen id : 1]
Input [3]: [d_month_seq#60, d_year#61, d_moy#62]

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

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

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

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

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


