hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mostafa Mokhtar (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HIVE-7985) With CBO enabled cross product is generated when a subquery is present
Date Thu, 04 Sep 2014 18:15:52 GMT

     [ https://issues.apache.org/jira/browse/HIVE-7985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mostafa Mokhtar updated HIVE-7985:
----------------------------------
    Description: 
This is a regression introduced in the latest build of the CBO branch.
Removing the subquery for item will remove the cross products

Query
{code}
select i_item_id,sum(ss_ext_sales_price) total_sales from store_sales, date_dim, item where
item.i_item_id in (select i.i_item_id from item i where i_color in ('purple','burlywood','indian'))
and ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk and d_year = 2001 and d_moy = 1
group by i_item_id;
{code}

{code}
Warning: Map Join MAPJOIN[38][bigTable=?] in task 'Map 1' is a cross product
Warning: Map Join MAPJOIN[39][bigTable=store_sales] in task 'Map 4' is a cross product
OK
STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 depends on stages: Stage-1

STAGE PLANS:
  Stage: Stage-1
    Tez
      Edges:
        Map 1 <- Map 3 (BROADCAST_EDGE)
        Map 4 <- Map 1 (BROADCAST_EDGE), Map 2 (BROADCAST_EDGE)
        Reducer 5 <- Map 4 (SIMPLE_EDGE)
      DagName: mmokhtar_20140904141313_9c253f7e-aad1-4ca4-9be1-ea45e3d34496:1
      Vertices:
        Map 1
            Map Operator Tree:
                TableScan
                  alias: item
                  filterExpr: (true and i_item_id is not null) (type: boolean)
                  Statistics: Num rows: 462000 Data size: 663862160 Basic stats: COMPLETE
Column stats: NONE
                  Filter Operator
                    predicate: i_item_id is not null (type: boolean)
                    Statistics: Num rows: 231000 Data size: 331931080 Basic stats: COMPLETE
Column stats: NONE
                    Map Join Operator
                      condition map:
                           Inner Join 0 to 1
                      condition expressions:
                        0 {i_item_sk} {i_item_id}
                        1 {d_date_sk}
                      keys:
                        0
                        1
                      outputColumnNames: _col0, _col1, _col25
                      input vertices:
                        1 Map 3
                      Statistics: Num rows: 254100 Data size: 365124192 Basic stats: COMPLETE
Column stats: NONE
                      Select Operator
                        expressions: _col0 (type: int), _col1 (type: string), _col25 (type:
int)
                        outputColumnNames: _col0, _col1, _col25
                        Statistics: Num rows: 254100 Data size: 365124192 Basic stats: COMPLETE
Column stats: NONE
                        Reduce Output Operator
                          sort order:
                          Statistics: Num rows: 254100 Data size: 365124192 Basic stats: COMPLETE
Column stats: NONE
                          value expressions: _col0 (type: int), _col1 (type: string), _col25
(type: int)
            Execution mode: vectorized
        Map 2
            Map Operator Tree:
                TableScan
                  alias: i
                  filterExpr: ((i_color) IN ('purple', 'burlywood', 'indian') and i_item_id
is not null) (type: boolean)
                  Statistics: Num rows: 462000 Data size: 663862160 Basic stats: COMPLETE
Column stats: NONE
                  Filter Operator
                    predicate: ((i_color) IN ('purple', 'burlywood', 'indian') and i_item_id
is not null) (type: boolean)
                    Statistics: Num rows: 115500 Data size: 165965540 Basic stats: COMPLETE
Column stats: NONE
                    Select Operator
                      expressions: i_item_id (type: string)
                      outputColumnNames: _col0
                      Statistics: Num rows: 115500 Data size: 165965540 Basic stats: COMPLETE
Column stats: NONE
                      Group By Operator
                        keys: _col0 (type: string)
                        mode: hash
                        outputColumnNames: _col0
                        Statistics: Num rows: 115500 Data size: 165965540 Basic stats: COMPLETE
Column stats: NONE
                        Reduce Output Operator
                          key expressions: _col0 (type: string)
                          sort order: +
                          Map-reduce partition columns: _col0 (type: string)
                          Statistics: Num rows: 115500 Data size: 165965540 Basic stats: COMPLETE
Column stats: NONE
            Execution mode: vectorized
        Map 3
            Map Operator Tree:
                TableScan
                  alias: date_dim
                  filterExpr: ((d_year = 2001) and (d_moy = 1)) (type: boolean)
                  Statistics: Num rows: 73049 Data size: 81741831 Basic stats: COMPLETE Column
stats: NONE
                  Filter Operator
                    predicate: ((d_year = 2001) and (d_moy = 1)) (type: boolean)
                    Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
                    Reduce Output Operator
                      sort order:
                      Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
                      value expressions: d_date_sk (type: int)
            Execution mode: vectorized
        Map 4
            Map Operator Tree:
                TableScan
                  alias: store_sales
                  Statistics: Num rows: 82510879939 Data size: 7203833257964 Basic stats:
COMPLETE Column stats: NONE
                  Map Join Operator
                    condition map:
                         Inner Join 0 to 1
                    condition expressions:
                      0 {ss_sold_date_sk} {ss_item_sk} {ss_ext_sales_price}
                      1 {_col0} {_col1} {_col25}
                    keys:
                      0
                      1
                    outputColumnNames: _col0, _col2, _col15, _col27, _col28, _col52
                    input vertices:
                      1 Map 1
                    Statistics: Num rows: 90761969664 Data size: 7924217282560 Basic stats:
COMPLETE Column stats: NONE
                    Filter Operator
                      predicate: ((_col2 = _col27) and (_col0 = _col52)) (type: boolean)
                      Statistics: Num rows: 22690492416 Data size: 1981054320640 Basic stats:
COMPLETE Column stats: NONE
                      Select Operator
                        expressions: _col15 (type: float), _col28 (type: string)
                        outputColumnNames: _col15, _col59
                        Statistics: Num rows: 22690492416 Data size: 1981054320640 Basic stats:
COMPLETE Column stats: NONE
                        Map Join Operator
                          condition map:
                               Left Semi Join 0 to 1
                          condition expressions:
                            0 {_col15} {_col59}
                            1
                          keys:
                            0 _col59 (type: string)
                            1 _col0 (type: string)
                          outputColumnNames: _col15, _col59
                          input vertices:
                            1 Map 2
                          Statistics: Num rows: 24959541248 Data size: 2179159818240 Basic
stats: COMPLETE Column stats: NONE
                          Select Operator
                            expressions: _col59 (type: string), _col15 (type: float)
                            outputColumnNames: _col0, _col1
                            Statistics: Num rows: 24959541248 Data size: 2179159818240 Basic
stats: COMPLETE Column stats: NONE
                            Group By Operator
                              aggregations: sum(_col1)
                              keys: _col0 (type: string)
                              mode: hash
                              outputColumnNames: _col0, _col1
                              Statistics: Num rows: 24959541248 Data size: 2179159818240 Basic
stats: COMPLETE Column stats: NONE
                              Reduce Output Operator
                                key expressions: _col0 (type: string)
                                sort order: +
                                Map-reduce partition columns: _col0 (type: string)
                                Statistics: Num rows: 24959541248 Data size: 2179159818240
Basic stats: COMPLETE Column stats: NONE
                                value expressions: _col1 (type: double)
            Execution mode: vectorized
        Reducer 5
            Reduce Operator Tree:
              Group By Operator
                aggregations: sum(VALUE._col0)
                keys: KEY._col0 (type: string)
                mode: mergepartial
                outputColumnNames: _col0, _col1
                Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic stats: COMPLETE
Column stats: NONE
                Select Operator
                  expressions: _col0 (type: string), _col1 (type: double)
                  outputColumnNames: _col0, _col1
                  Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic stats:
COMPLETE Column stats: NONE
                  File Output Operator
                    compressed: false
                    Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic stats:
COMPLETE Column stats: NONE
                    table:
                        input format: org.apache.hadoop.mapred.TextInputFormat
                        output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe

  Stage: Stage-0
    Fetch Operator
      limit: -1
      Processor Tree:
        ListSink
{code}


No cross product generated for this query
{code}
 select i_item_id,sum(ss_ext_sales_price) total_sales
 from
        store_sales,
        date_dim,
         item
where i_color in ('purple','burlywood','indian')
 and     ss_item_sk              = i_item_sk
 and     ss_sold_date_sk         = d_date_sk
 and     d_year                  = 2001
 and     d_moy                   = 1
 group by i_item_id;

{code}

  was:
Simplify join predicates for disjunctive predicates to avoid cross products.

For TPC-DS query 13 we generate a cross products.
The join predicate on (store_sales x customer_demographics) ,  (store_sales x household_demographics)
and (store_sales x customer_address) can be pull up to avoid the cross products


{code}
select avg(ss_quantity)
       ,avg(ss_ext_sales_price)
       ,avg(ss_ext_wholesale_cost)
       ,sum(ss_ext_wholesale_cost)
 from store_sales
     ,store
     ,customer_demographics
     ,household_demographics
     ,customer_address
     ,date_dim
 where store.s_store_sk = store_sales.ss_store_sk
 and  store_sales.ss_sold_date_sk = date_dim.d_date_sk and date_dim.d_year = 2001
 and((store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
  and customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
  and customer_demographics.cd_marital_status = 'M'
  and customer_demographics.cd_education_status = '4 yr Degree'
  and store_sales.ss_sales_price between 100.00 and 150.00
  and household_demographics.hd_dep_count = 3   
     )or
     (store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
  and customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
  and customer_demographics.cd_marital_status = 'D'
  and customer_demographics.cd_education_status = 'Primary'
  and store_sales.ss_sales_price between 50.00 and 100.00   
  and household_demographics.hd_dep_count = 1
     ) or 
     (store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
  and customer_demographics.cd_demo_sk = ss_cdemo_sk
  and customer_demographics.cd_marital_status = 'U'
  and customer_demographics.cd_education_status = 'Advanced Degree'
  and store_sales.ss_sales_price between 150.00 and 200.00 
  and household_demographics.hd_dep_count = 1  
     ))
 and((store_sales.ss_addr_sk = customer_address.ca_address_sk
  and customer_address.ca_country = 'United States'
  and customer_address.ca_state in ('KY', 'GA', 'NM')
  and store_sales.ss_net_profit between 100 and 200  
     ) or
     (store_sales.ss_addr_sk = customer_address.ca_address_sk
  and customer_address.ca_country = 'United States'
  and customer_address.ca_state in ('MT', 'OR', 'IN')
  and store_sales.ss_net_profit between 150 and 300  
     ) or
     (store_sales.ss_addr_sk = customer_address.ca_address_sk
  and customer_address.ca_country = 'United States'
  and customer_address.ca_state in ('WI', 'MO', 'WV')
  and store_sales.ss_net_profit between 50 and 250  
     ))
;

{code}


This is the plan currently generated without any predicate simplification 
{code}
Warning: Map Join MAPJOIN[59][bigTable=?] in task 'Map 8' is a cross product
Warning: Map Join MAPJOIN[58][bigTable=?] in task 'Map 8' is a cross product
Warning: Shuffle Join JOIN[29][tables = [$hdt$_5, $hdt$_6]] in Stage 'Reducer 2' is a cross
product
OK
STAGE DEPENDENCIES:
  Stage-1 is a root stage
  Stage-0 depends on stages: Stage-1

STAGE PLANS:
  Stage: Stage-1
    Tez
      Edges:
        Map 7 <- Map 8 (BROADCAST_EDGE)
        Map 8 <- Map 5 (BROADCAST_EDGE), Map 6 (BROADCAST_EDGE)
        Reducer 2 <- Map 1 (SIMPLE_EDGE), Map 4 (BROADCAST_EDGE), Map 7 (SIMPLE_EDGE)
        Reducer 3 <- Reducer 2 (SIMPLE_EDGE)
      DagName: mmokhtar_20140828155050_7059c24b-501b-4683-86c0-4f3c023f0b0e:1
      Vertices:
        Map 1 
            Map Operator Tree:
                TableScan
                  alias: customer_address
                  Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE
Column stats: NONE
                  Select Operator
                    expressions: ca_address_sk (type: int), ca_state (type: string), ca_country
(type: string)
                    outputColumnNames: _col0, _col1, _col2
                    Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE
Column stats: NONE
                    Reduce Output Operator
                      sort order: 
                      Statistics: Num rows: 40000000 Data size: 40595195284 Basic stats: COMPLETE
Column stats: NONE
                      value expressions: _col0 (type: int), _col1 (type: string), _col2 (type:
string)
            Execution mode: vectorized
        Map 4 
            Map Operator Tree:
                TableScan
                  alias: date_dim
                  filterExpr: ((d_year = 2001) and d_date_sk is not null) (type: boolean)
                  Statistics: Num rows: 73049 Data size: 81741831 Basic stats: COMPLETE Column
stats: NONE
                  Filter Operator
                    predicate: ((d_year = 2001) and d_date_sk is not null) (type: boolean)
                    Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
                    Select Operator
                      expressions: d_date_sk (type: int)
                      outputColumnNames: _col0
                      Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
                      Reduce Output Operator
                        key expressions: _col0 (type: int)
                        sort order: +
                        Map-reduce partition columns: _col0 (type: int)
                        Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
            Execution mode: vectorized
        Map 5 
            Map Operator Tree:
                TableScan
                  alias: household_demographics
                  Statistics: Num rows: 7200 Data size: 770400 Basic stats: COMPLETE Column
stats: NONE
                  Select Operator
                    expressions: hd_demo_sk (type: int), hd_dep_count (type: int)
                    outputColumnNames: _col0, _col1
                    Statistics: Num rows: 7200 Data size: 770400 Basic stats: COMPLETE Column
stats: NONE
                    Reduce Output Operator
                      sort order: 
                      Statistics: Num rows: 7200 Data size: 770400 Basic stats: COMPLETE Column
stats: NONE
                      value expressions: _col0 (type: int), _col1 (type: int)
            Execution mode: vectorized
        Map 6 
            Map Operator Tree:
                TableScan
                  alias: store
                  filterExpr: (true and s_store_sk is not null) (type: boolean)
                  Statistics: Num rows: 1704 Data size: 3256276 Basic stats: COMPLETE Column
stats: NONE
                  Filter Operator
                    predicate: s_store_sk is not null (type: boolean)
                    Statistics: Num rows: 852 Data size: 1628138 Basic stats: COMPLETE Column
stats: NONE
                    Select Operator
                      expressions: s_store_sk (type: int)
                      outputColumnNames: _col0
                      Statistics: Num rows: 852 Data size: 1628138 Basic stats: COMPLETE Column
stats: NONE
                      Reduce Output Operator
                        sort order: 
                        Statistics: Num rows: 852 Data size: 1628138 Basic stats: COMPLETE
Column stats: NONE
                        value expressions: _col0 (type: int)
            Execution mode: vectorized
        Map 7 
            Map Operator Tree:
                TableScan
                  alias: store_sales
                  filterExpr: (ss_store_sk is not null and ss_sold_date_sk is not null) (type:
boolean)
                  Statistics: Num rows: 82510879939 Data size: 7203833257964 Basic stats:
COMPLETE Column stats: NONE
                  Filter Operator
                    predicate: (ss_store_sk is not null and ss_sold_date_sk is not null) (type:
boolean)
                    Statistics: Num rows: 20627719985 Data size: 1800958314512 Basic stats:
COMPLETE Column stats: NONE
                    Select Operator
                      expressions: ss_sold_date_sk (type: int), ss_cdemo_sk (type: int), ss_hdemo_sk
(type: int), ss_addr_sk (type: int), ss_store_sk (type: int), ss_quantity (type: int), ss_sales_price
(type: float), ss_ext_sales_price (type: float), ss_ext_wholesale_cost (type: float), ss_net_profit
(type: float)
                      outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5, _col6,
_col7, _col8, _col9
                      Statistics: Num rows: 20627719985 Data size: 1800958314512 Basic stats:
COMPLETE Column stats: NONE
                      Map Join Operator
                        condition map:
                             Inner Join 0 to 1
                        condition expressions:
                          0 {_col0} {_col1} {_col2} {_col4} {_col5}
                          1 {_col0} {_col1} {_col2} {_col3} {_col5} {_col6} {_col7} {_col8}
{_col9}
                        keys:
                          0 _col3 (type: int)
                          1 _col4 (type: int)
                        outputColumnNames: _col0, _col1, _col2, _col4, _col5, _col6, _col7,
_col8, _col9, _col11, _col12, _col13, _col14, _col15
                        input vertices:
                          0 Map 8
                        Statistics: Num rows: 22690492416 Data size: 1981054320640 Basic stats:
COMPLETE Column stats: NONE
                        Filter Operator
                          predicate: (((_col8 = _col4) and ((_col0 = _col7) and ((_col1 =
'M') and ((_col2 = '4 yr Degree') and (_col12 BETWEEN 100 AND 150 and (_col5 = 3)))))) or
(((_col8 = _col4) and ((_col0 = _col7) and ((_col1 = 'D') and ((_col2 = 'Primary') and (_col12
BETWEEN 50 AND 100 and (_col5 = 1)))))) or ((_col8 = _col4) and ((_col0 = _col7) and ((_col1
= 'U') and ((_col2 = 'Advanced Degree') and (_col12 BETWEEN 150 AND 200 and (_col5 = 1))))))))
(type: boolean)
                          Statistics: Num rows: 1063616832 Data size: 92861921280 Basic stats:
COMPLETE Column stats: NONE
                          Select Operator
                            expressions: _col6 (type: int), _col9 (type: int), _col11 (type:
int), _col13 (type: float), _col14 (type: float), _col15 (type: float)
                            outputColumnNames: _col0, _col3, _col5, _col7, _col8, _col9
                            Statistics: Num rows: 1063616832 Data size: 92861921280 Basic
stats: COMPLETE Column stats: NONE
                            Reduce Output Operator
                              sort order: 
                              Statistics: Num rows: 1063616832 Data size: 92861921280 Basic
stats: COMPLETE Column stats: NONE
                              value expressions: _col0 (type: int), _col3 (type: int), _col5
(type: int), _col7 (type: float), _col8 (type: float), _col9 (type: float)
            Execution mode: vectorized
        Map 8 
            Map Operator Tree:
                TableScan
                  alias: customer_demographics
                  Statistics: Num rows: 1920800 Data size: 718379200 Basic stats: COMPLETE
Column stats: NONE
                  Select Operator
                    expressions: cd_demo_sk (type: int), cd_marital_status (type: string),
cd_education_status (type: string)
                    outputColumnNames: _col0, _col1, _col2
                    Statistics: Num rows: 1920800 Data size: 718379200 Basic stats: COMPLETE
Column stats: NONE
                    Map Join Operator
                      condition map:
                           Inner Join 0 to 1
                      condition expressions:
                        0 {_col0} {_col1} {_col2}
                        1 {_col0}
                      keys:
                        0 
                        1 
                      outputColumnNames: _col0, _col1, _col2, _col3
                      input vertices:
                        1 Map 6
                      Statistics: Num rows: 2112880 Data size: 790217152 Basic stats: COMPLETE
Column stats: NONE
                      Map Join Operator
                        condition map:
                             Inner Join 0 to 1
                        condition expressions:
                          0 {_col0} {_col1} {_col2} {_col3}
                          1 {_col0} {_col1}
                        keys:
                          0 
                          1 
                        outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                        input vertices:
                          1 Map 5
                        Statistics: Num rows: 2324168 Data size: 869238912 Basic stats: COMPLETE
Column stats: NONE
                        Reduce Output Operator
                          key expressions: _col3 (type: int)
                          sort order: +
                          Map-reduce partition columns: _col3 (type: int)
                          Statistics: Num rows: 2324168 Data size: 869238912 Basic stats:
COMPLETE Column stats: NONE
                          value expressions: _col0 (type: int), _col1 (type: string), _col2
(type: string), _col4 (type: int), _col5 (type: int)
            Execution mode: vectorized
        Reducer 2 
            Reduce Operator Tree:
              Join Operator
                condition map:
                     Inner Join 0 to 1
                condition expressions:
                  0 {VALUE._col0} {VALUE._col3} {VALUE._col5} {VALUE._col7} {VALUE._col8}
{VALUE._col9}
                  1 {VALUE._col0} {VALUE._col1} {VALUE._col2}
                outputColumnNames: _col0, _col3, _col5, _col7, _col8, _col9, _col16, _col17,
_col18
                Statistics: Num rows: 1169978496 Data size: 102148120576 Basic stats: COMPLETE
Column stats: NONE
                Filter Operator
                  predicate: (((_col3 = _col16) and ((_col18 = 'United States') and ((_col17)
IN ('KY', 'GA', 'NM') and _col9 BETWEEN 100 AND 200))) or (((_col3 = _col16) and ((_col18
= 'United States') and ((_col17) IN ('MT', 'OR', 'IN') and _col9 BETWEEN 150 AND 300))) or
((_col3 = _col16) and ((_col18 = 'United States') and ((_col17) IN ('WI', 'MO', 'WV') and
_col9 BETWEEN 50 AND 250))))) (type: boolean)
                  Statistics: Num rows: 219370968 Data size: 19152772608 Basic stats: COMPLETE
Column stats: NONE
                  Select Operator
                    expressions: _col0 (type: int), _col5 (type: int), _col7 (type: float),
_col8 (type: float)
                    outputColumnNames: _col0, _col5, _col7, _col8
                    Statistics: Num rows: 219370968 Data size: 19152772608 Basic stats: COMPLETE
Column stats: NONE
                    Map Join Operator
                      condition map:
                           Inner Join 0 to 1
                      condition expressions:
                        0 {_col5} {_col7} {_col8}
                        1 
                      keys:
                        0 _col0 (type: int)
                        1 _col0 (type: int)
                      outputColumnNames: _col5, _col7, _col8
                      input vertices:
                        1 Map 4
                      Statistics: Num rows: 241308080 Data size: 21068050432 Basic stats:
COMPLETE Column stats: NONE
                      Select Operator
                        expressions: _col5 (type: int), _col7 (type: float), _col8 (type:
float)
                        outputColumnNames: _col0, _col1, _col2
                        Statistics: Num rows: 241308080 Data size: 21068050432 Basic stats:
COMPLETE Column stats: NONE
                        Group By Operator
                          aggregations: avg(_col0), avg(_col1), avg(_col2), sum(_col2)
                          mode: hash
                          outputColumnNames: _col0, _col1, _col2, _col3
                          Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column
stats: NONE
                          Reduce Output Operator
                            sort order: 
                            Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column
stats: NONE
                            value expressions: _col0 (type: struct<count:bigint,sum:double,input:int>),
_col1 (type: struct<count:bigint,sum:double,input:float>), _col2 (type: struct<count:bigint,sum:double,input:float>),
_col3 (type: double)
        Reducer 3 
            Reduce Operator Tree:
              Group By Operator
                aggregations: avg(VALUE._col0), avg(VALUE._col1), avg(VALUE._col2), sum(VALUE._col3)
                mode: mergepartial
                outputColumnNames: _col0, _col1, _col2, _col3
                Statistics: Num rows: 1 Data size: 32 Basic stats: COMPLETE Column stats:
NONE
                Select Operator
                  expressions: _col0 (type: double), _col1 (type: double), _col2 (type: double),
_col3 (type: double)
                  outputColumnNames: _col0, _col1, _col2, _col3
                  Statistics: Num rows: 1 Data size: 32 Basic stats: COMPLETE Column stats:
NONE
                  File Output Operator
                    compressed: false
                    Statistics: Num rows: 1 Data size: 32 Basic stats: COMPLETE Column stats:
NONE
                    table:
                        input format: org.apache.hadoop.mapred.TextInputFormat
                        output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
                        serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe

  Stage: Stage-0
    Fetch Operator
      limit: -1
      Processor Tree:
        ListSink

Time taken: 7.681 seconds, Fetched: 227 row(s)

{code}


> With CBO enabled cross product is generated when a subquery is present
> ----------------------------------------------------------------------
>
>                 Key: HIVE-7985
>                 URL: https://issues.apache.org/jira/browse/HIVE-7985
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>    Affects Versions: 0.14.0
>            Reporter: Mostafa Mokhtar
>            Assignee: Laljo John Pullokkaran
>             Fix For: 0.14.0
>
>
> This is a regression introduced in the latest build of the CBO branch.
> Removing the subquery for item will remove the cross products
> Query
> {code}
> select i_item_id,sum(ss_ext_sales_price) total_sales from store_sales, date_dim, item
where item.i_item_id in (select i.i_item_id from item i where i_color in ('purple','burlywood','indian'))
and ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk and d_year = 2001 and d_moy = 1
group by i_item_id;
> {code}
> {code}
> Warning: Map Join MAPJOIN[38][bigTable=?] in task 'Map 1' is a cross product
> Warning: Map Join MAPJOIN[39][bigTable=store_sales] in task 'Map 4' is a cross product
> OK
> STAGE DEPENDENCIES:
>   Stage-1 is a root stage
>   Stage-0 depends on stages: Stage-1
> STAGE PLANS:
>   Stage: Stage-1
>     Tez
>       Edges:
>         Map 1 <- Map 3 (BROADCAST_EDGE)
>         Map 4 <- Map 1 (BROADCAST_EDGE), Map 2 (BROADCAST_EDGE)
>         Reducer 5 <- Map 4 (SIMPLE_EDGE)
>       DagName: mmokhtar_20140904141313_9c253f7e-aad1-4ca4-9be1-ea45e3d34496:1
>       Vertices:
>         Map 1
>             Map Operator Tree:
>                 TableScan
>                   alias: item
>                   filterExpr: (true and i_item_id is not null) (type: boolean)
>                   Statistics: Num rows: 462000 Data size: 663862160 Basic stats: COMPLETE
Column stats: NONE
>                   Filter Operator
>                     predicate: i_item_id is not null (type: boolean)
>                     Statistics: Num rows: 231000 Data size: 331931080 Basic stats: COMPLETE
Column stats: NONE
>                     Map Join Operator
>                       condition map:
>                            Inner Join 0 to 1
>                       condition expressions:
>                         0 {i_item_sk} {i_item_id}
>                         1 {d_date_sk}
>                       keys:
>                         0
>                         1
>                       outputColumnNames: _col0, _col1, _col25
>                       input vertices:
>                         1 Map 3
>                       Statistics: Num rows: 254100 Data size: 365124192 Basic stats:
COMPLETE Column stats: NONE
>                       Select Operator
>                         expressions: _col0 (type: int), _col1 (type: string), _col25
(type: int)
>                         outputColumnNames: _col0, _col1, _col25
>                         Statistics: Num rows: 254100 Data size: 365124192 Basic stats:
COMPLETE Column stats: NONE
>                         Reduce Output Operator
>                           sort order:
>                           Statistics: Num rows: 254100 Data size: 365124192 Basic stats:
COMPLETE Column stats: NONE
>                           value expressions: _col0 (type: int), _col1 (type: string),
_col25 (type: int)
>             Execution mode: vectorized
>         Map 2
>             Map Operator Tree:
>                 TableScan
>                   alias: i
>                   filterExpr: ((i_color) IN ('purple', 'burlywood', 'indian') and i_item_id
is not null) (type: boolean)
>                   Statistics: Num rows: 462000 Data size: 663862160 Basic stats: COMPLETE
Column stats: NONE
>                   Filter Operator
>                     predicate: ((i_color) IN ('purple', 'burlywood', 'indian') and i_item_id
is not null) (type: boolean)
>                     Statistics: Num rows: 115500 Data size: 165965540 Basic stats: COMPLETE
Column stats: NONE
>                     Select Operator
>                       expressions: i_item_id (type: string)
>                       outputColumnNames: _col0
>                       Statistics: Num rows: 115500 Data size: 165965540 Basic stats:
COMPLETE Column stats: NONE
>                       Group By Operator
>                         keys: _col0 (type: string)
>                         mode: hash
>                         outputColumnNames: _col0
>                         Statistics: Num rows: 115500 Data size: 165965540 Basic stats:
COMPLETE Column stats: NONE
>                         Reduce Output Operator
>                           key expressions: _col0 (type: string)
>                           sort order: +
>                           Map-reduce partition columns: _col0 (type: string)
>                           Statistics: Num rows: 115500 Data size: 165965540 Basic stats:
COMPLETE Column stats: NONE
>             Execution mode: vectorized
>         Map 3
>             Map Operator Tree:
>                 TableScan
>                   alias: date_dim
>                   filterExpr: ((d_year = 2001) and (d_moy = 1)) (type: boolean)
>                   Statistics: Num rows: 73049 Data size: 81741831 Basic stats: COMPLETE
Column stats: NONE
>                   Filter Operator
>                     predicate: ((d_year = 2001) and (d_moy = 1)) (type: boolean)
>                     Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
>                     Reduce Output Operator
>                       sort order:
>                       Statistics: Num rows: 18262 Data size: 20435178 Basic stats: COMPLETE
Column stats: NONE
>                       value expressions: d_date_sk (type: int)
>             Execution mode: vectorized
>         Map 4
>             Map Operator Tree:
>                 TableScan
>                   alias: store_sales
>                   Statistics: Num rows: 82510879939 Data size: 7203833257964 Basic stats:
COMPLETE Column stats: NONE
>                   Map Join Operator
>                     condition map:
>                          Inner Join 0 to 1
>                     condition expressions:
>                       0 {ss_sold_date_sk} {ss_item_sk} {ss_ext_sales_price}
>                       1 {_col0} {_col1} {_col25}
>                     keys:
>                       0
>                       1
>                     outputColumnNames: _col0, _col2, _col15, _col27, _col28, _col52
>                     input vertices:
>                       1 Map 1
>                     Statistics: Num rows: 90761969664 Data size: 7924217282560 Basic
stats: COMPLETE Column stats: NONE
>                     Filter Operator
>                       predicate: ((_col2 = _col27) and (_col0 = _col52)) (type: boolean)
>                       Statistics: Num rows: 22690492416 Data size: 1981054320640 Basic
stats: COMPLETE Column stats: NONE
>                       Select Operator
>                         expressions: _col15 (type: float), _col28 (type: string)
>                         outputColumnNames: _col15, _col59
>                         Statistics: Num rows: 22690492416 Data size: 1981054320640 Basic
stats: COMPLETE Column stats: NONE
>                         Map Join Operator
>                           condition map:
>                                Left Semi Join 0 to 1
>                           condition expressions:
>                             0 {_col15} {_col59}
>                             1
>                           keys:
>                             0 _col59 (type: string)
>                             1 _col0 (type: string)
>                           outputColumnNames: _col15, _col59
>                           input vertices:
>                             1 Map 2
>                           Statistics: Num rows: 24959541248 Data size: 2179159818240
Basic stats: COMPLETE Column stats: NONE
>                           Select Operator
>                             expressions: _col59 (type: string), _col15 (type: float)
>                             outputColumnNames: _col0, _col1
>                             Statistics: Num rows: 24959541248 Data size: 2179159818240
Basic stats: COMPLETE Column stats: NONE
>                             Group By Operator
>                               aggregations: sum(_col1)
>                               keys: _col0 (type: string)
>                               mode: hash
>                               outputColumnNames: _col0, _col1
>                               Statistics: Num rows: 24959541248 Data size: 2179159818240
Basic stats: COMPLETE Column stats: NONE
>                               Reduce Output Operator
>                                 key expressions: _col0 (type: string)
>                                 sort order: +
>                                 Map-reduce partition columns: _col0 (type: string)
>                                 Statistics: Num rows: 24959541248 Data size: 2179159818240
Basic stats: COMPLETE Column stats: NONE
>                                 value expressions: _col1 (type: double)
>             Execution mode: vectorized
>         Reducer 5
>             Reduce Operator Tree:
>               Group By Operator
>                 aggregations: sum(VALUE._col0)
>                 keys: KEY._col0 (type: string)
>                 mode: mergepartial
>                 outputColumnNames: _col0, _col1
>                 Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic stats:
COMPLETE Column stats: NONE
>                 Select Operator
>                   expressions: _col0 (type: string), _col1 (type: double)
>                   outputColumnNames: _col0, _col1
>                   Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic stats:
COMPLETE Column stats: NONE
>                   File Output Operator
>                     compressed: false
>                     Statistics: Num rows: 12479770624 Data size: 1089579909120 Basic
stats: COMPLETE Column stats: NONE
>                     table:
>                         input format: org.apache.hadoop.mapred.TextInputFormat
>                         output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
>                         serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe
>   Stage: Stage-0
>     Fetch Operator
>       limit: -1
>       Processor Tree:
>         ListSink
> {code}
> No cross product generated for this query
> {code}
>  select i_item_id,sum(ss_ext_sales_price) total_sales
>  from
>         store_sales,
>         date_dim,
>          item
> where i_color in ('purple','burlywood','indian')
>  and     ss_item_sk              = i_item_sk
>  and     ss_sold_date_sk         = d_date_sk
>  and     d_year                  = 2001
>  and     d_moy                   = 1
>  group by i_item_id;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message