== Physical Plan ==
* Sort (34)
+- * HashAggregate (33)
   +- Exchange (32)
      +- * HashAggregate (31)
         +- * Project (30)
            +- * BroadcastHashJoin Inner BuildRight (29)
               :- * Project (27)
               :  +- * BroadcastHashJoin Inner BuildLeft (26)
               :     :- BroadcastExchange (22)
               :     :  +- * Project (21)
               :     :     +- * BroadcastHashJoin Inner BuildLeft (20)
               :     :        :- BroadcastExchange (5)
               :     :        :  +- * Project (4)
               :     :        :     +- * Filter (3)
               :     :        :        +- * ColumnarToRow (2)
               :     :        :           +- Scan parquet default.item (1)
               :     :        +- * Filter (19)
               :     :           +- * HashAggregate (18)
               :     :              +- Exchange (17)
               :     :                 +- * HashAggregate (16)
               :     :                    +- * Project (15)
               :     :                       +- * BroadcastHashJoin Inner BuildRight (14)
               :     :                          :- * Filter (8)
               :     :                          :  +- * ColumnarToRow (7)
               :     :                          :     +- Scan parquet default.web_sales (6)
               :     :                          +- BroadcastExchange (13)
               :     :                             +- * Project (12)
               :     :                                +- * Filter (11)
               :     :                                   +- * ColumnarToRow (10)
               :     :                                      +- Scan parquet default.date_dim (9)
               :     +- * Filter (25)
               :        +- * ColumnarToRow (24)
               :           +- Scan parquet default.web_sales (23)
               +- ReusedExchange (28)


(1) Scan parquet default.item
Output [2]: [i_item_sk#1, i_manufact_id#2]
Batched: true
Location [not included in comparison]/{warehouse_dir}/item]
PushedFilters: [IsNotNull(i_manufact_id), EqualTo(i_manufact_id,350), IsNotNull(i_item_sk)]
ReadSchema: struct<i_item_sk:int,i_manufact_id:int>

(2) ColumnarToRow [codegen id : 1]
Input [2]: [i_item_sk#1, i_manufact_id#2]

(3) Filter [codegen id : 1]
Input [2]: [i_item_sk#1, i_manufact_id#2]
Condition : ((isnotnull(i_manufact_id#2) AND (i_manufact_id#2 = 350)) AND isnotnull(i_item_sk#1))

(4) Project [codegen id : 1]
Output [1]: [i_item_sk#1]
Input [2]: [i_item_sk#1, i_manufact_id#2]

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

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

(7) ColumnarToRow [codegen id : 3]
Input [3]: [ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6]

(8) Filter [codegen id : 3]
Input [3]: [ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6]
Condition : (isnotnull(ws_sold_date_sk#4) AND isnotnull(ws_item_sk#5))

(9) Scan parquet default.date_dim
Output [2]: [d_date_sk#7, d_date#8]
Batched: true
Location [not included in comparison]/{warehouse_dir}/date_dim]
PushedFilters: [IsNotNull(d_date), GreaterThanOrEqual(d_date,2000-01-27), LessThanOrEqual(d_date,2000-04-26), IsNotNull(d_date_sk)]
ReadSchema: struct<d_date_sk:int,d_date:date>

(10) ColumnarToRow [codegen id : 2]
Input [2]: [d_date_sk#7, d_date#8]

(11) Filter [codegen id : 2]
Input [2]: [d_date_sk#7, d_date#8]
Condition : (((isnotnull(d_date#8) AND (d_date#8 >= 10983)) AND (d_date#8 <= 11073)) AND isnotnull(d_date_sk#7))

(12) Project [codegen id : 2]
Output [1]: [d_date_sk#7]
Input [2]: [d_date_sk#7, d_date#8]

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

(14) BroadcastHashJoin [codegen id : 3]
Left keys [1]: [ws_sold_date_sk#4]
Right keys [1]: [d_date_sk#7]
Join condition: None

(15) Project [codegen id : 3]
Output [2]: [ws_item_sk#5, ws_ext_discount_amt#6]
Input [4]: [ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6, d_date_sk#7]

(16) HashAggregate [codegen id : 3]
Input [2]: [ws_item_sk#5, ws_ext_discount_amt#6]
Keys [1]: [ws_item_sk#5]
Functions [1]: [partial_avg(UnscaledValue(ws_ext_discount_amt#6))]
Aggregate Attributes [2]: [sum#10, count#11]
Results [3]: [ws_item_sk#5, sum#12, count#13]

(17) Exchange
Input [3]: [ws_item_sk#5, sum#12, count#13]
Arguments: hashpartitioning(ws_item_sk#5, 5), true, [id=#14]

(18) HashAggregate
Input [3]: [ws_item_sk#5, sum#12, count#13]
Keys [1]: [ws_item_sk#5]
Functions [1]: [avg(UnscaledValue(ws_ext_discount_amt#6))]
Aggregate Attributes [1]: [avg(UnscaledValue(ws_ext_discount_amt#6))#15]
Results [2]: [CheckOverflow((1.300000 * promote_precision(cast((avg(UnscaledValue(ws_ext_discount_amt#6))#15 / 100.0) as decimal(11,6)))), DecimalType(14,7), true) AS (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16, ws_item_sk#5 AS ws_item_sk#5#17]

(19) Filter
Input [2]: [(CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16, ws_item_sk#5#17]
Condition : isnotnull((CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16)

(20) BroadcastHashJoin [codegen id : 4]
Left keys [1]: [i_item_sk#1]
Right keys [1]: [ws_item_sk#5#17]
Join condition: None

(21) Project [codegen id : 4]
Output [2]: [i_item_sk#1, (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16]
Input [3]: [i_item_sk#1, (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16, ws_item_sk#5#17]

(22) BroadcastExchange
Input [2]: [i_item_sk#1, (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16]
Arguments: HashedRelationBroadcastMode(List(cast(input[0, int, true] as bigint)),false), [id=#18]

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

(24) ColumnarToRow
Input [3]: [ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6]

(25) Filter
Input [3]: [ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6]
Condition : ((isnotnull(ws_item_sk#5) AND isnotnull(ws_ext_discount_amt#6)) AND isnotnull(ws_sold_date_sk#4))

(26) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [i_item_sk#1]
Right keys [1]: [ws_item_sk#5]
Join condition: (cast(ws_ext_discount_amt#6 as decimal(14,7)) > (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16)

(27) Project [codegen id : 6]
Output [2]: [ws_sold_date_sk#4, ws_ext_discount_amt#6]
Input [5]: [i_item_sk#1, (CAST(1.3 AS DECIMAL(11,6)) * CAST(avg(ws_ext_discount_amt) AS DECIMAL(11,6)))#16, ws_sold_date_sk#4, ws_item_sk#5, ws_ext_discount_amt#6]

(28) ReusedExchange [Reuses operator id: 13]
Output [1]: [d_date_sk#7]

(29) BroadcastHashJoin [codegen id : 6]
Left keys [1]: [ws_sold_date_sk#4]
Right keys [1]: [d_date_sk#7]
Join condition: None

(30) Project [codegen id : 6]
Output [1]: [ws_ext_discount_amt#6]
Input [3]: [ws_sold_date_sk#4, ws_ext_discount_amt#6, d_date_sk#7]

(31) HashAggregate [codegen id : 6]
Input [1]: [ws_ext_discount_amt#6]
Keys: []
Functions [1]: [partial_sum(UnscaledValue(ws_ext_discount_amt#6))]
Aggregate Attributes [1]: [sum#19]
Results [1]: [sum#20]

(32) Exchange
Input [1]: [sum#20]
Arguments: SinglePartition, true, [id=#21]

(33) HashAggregate [codegen id : 7]
Input [1]: [sum#20]
Keys: []
Functions [1]: [sum(UnscaledValue(ws_ext_discount_amt#6))]
Aggregate Attributes [1]: [sum(UnscaledValue(ws_ext_discount_amt#6))#22]
Results [1]: [MakeDecimal(sum(UnscaledValue(ws_ext_discount_amt#6))#22,17,2) AS Excess Discount Amount #23]

(34) Sort [codegen id : 7]
Input [1]: [Excess Discount Amount #23]
Arguments: [Excess Discount Amount #23 ASC NULLS FIRST], true, 0

