asko created HIVE-9821:
--
Summary: Having the consistent physical execution plan , which
using explain command with disable CBO and enable CBO.
Key: HIVE-9821
URL: https://issues.apache.org/jira/browse/HIVE-9821
Project: Hive
Issue Type: Bug
Components: CBO
Affects Versions: 0.14.0
Reporter: asko
Priority: Critical
bq. Test case is( JOIN sub tree had been flatten after CBO in final plan stage
of calcite optimizer) :
{quote}
--set hive.cbo.enable=true;
--ANALYZE TABLE customer COMPUTE STATISTICS for columns;
--ANALYZE TABLE orders COMPUTE STATISTICS for columns;
--ANALYZE TABLE lineitem COMPUTE STATISTICS for columns;
--ANALYZE TABLE region COMPUTE STATISTICS for columns;
--ANALYZE TABLE supplier COMPUTE STATISTICS for columns;
--ANALYZE TABLE partsupp COMPUTE STATISTICS for columns;
--ANALYZE TABLE part COMPUTE STATISTICS for columns;
--ANALYZE TABLE nation COMPUTE STATISTICS for columns;
explain select
o_year, sum(case when nation = 'BRAZIL' then volume else 0.0 end) /
sum(volume) as mkt_share
from
(
select
year(o_orderdate) as o_year, l_extendedprice * (1-l_discount) as volume,
n2.n_name as nation
from
nation n1 join region r
on n1.n_regionkey = r.r_regionkey and r.r_name = 'AMERICA'
join customer c
on c.c_nationkey = n1.n_nationkey
join orders o
on c.c_custkey = o.o_custkey
join lineitem l
on l.l_orderkey = o.o_orderkey and o.o_orderdate = '1995-01-01'
and o.o_orderdate '1996-12-31'
join part p
on p.p_partkey = l.l_partkey and p.p_type = 'ECONOMY ANODIZED STEEL'
join supplier s
on s.s_suppkey = l.l_suppkey
join nation n2
on s.s_nationkey = n2.n_nationkey
) all_nation
group by o_year
order by o_year;
{quote}
bq. This test from had modified q8 in TPC-H_full . Uncomment could enable CBO.
twice run results are same :
{quote}
STAGE DEPENDENCIES:
Stage-1 is a root stage
Stage-2 depends on stages: Stage-1, Stage-7
Stage-3 depends on stages: Stage-2, Stage-10
Stage-4 depends on stages: Stage-3
Stage-5 depends on stages: Stage-4
Stage-7 is a root stage
Stage-9 is a root stage
Stage-10 depends on stages: Stage-9, Stage-12
Stage-12 is a root stage
Stage-0 depends on stages: Stage-5
STAGE PLANS:
Stage: Stage-1
Map Reduce
Map Operator Tree:
TableScan
alias: l
Statistics: Num rows: 27137974 Data size: 759863296 Basic stats:
COMPLETE Column stats: NONE
Filter Operator
predicate: ((l_partkey is not null and l_suppkey is not null) and
l_orderkey is not null) (type: boolean)
Statistics: Num rows: 3392247 Data size: 94982919 Basic stats:
COMPLETE Column stats: NONE
Select Operator
expressions: l_orderkey (type: int), l_partkey (type: int),
l_suppkey (type: int), l_extendedprice (type: double), l_discount (type: double)
outputColumnNames: _col0, _col1, _col2, _col3, _col4
Statistics: Num rows: 3392247 Data size: 94982919 Basic stats:
COMPLETE Column stats: NONE
Reduce Output Operator
key expressions: _col1 (type: int)
sort order: +
Map-reduce partition columns: _col1 (type: int)
Statistics: Num rows: 3392247 Data size: 94982919 Basic
stats: COMPLETE Column stats: NONE
value expressions: _col0 (type: int), _col2 (type: int),
_col3 (type: double), _col4 (type: double)
TableScan
alias: p
Statistics: Num rows: 928322 Data size: 24136384 Basic stats:
COMPLETE Column stats: NONE
Filter Operator
predicate: ((p_type = 'ECONOMY ANODIZED STEEL') and p_partkey is
not null) (type: boolean)
Statistics: Num rows: 232081 Data size: 6034109 Basic stats:
COMPLETE Column stats: NONE
Select Operator
expressions: p_partkey (type: int)
outputColumnNames: _col0
Statistics: Num rows: 232081 Data size: 6034109 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: 232081 Data size: 6034109 Basic stats:
COMPLETE Column stats: NONE
Reduce Operator Tree:
Join Operator
condition map:
Inner Join 0 to 1
keys:
0 _col1 (type: int)
1 _col0 (type: int)
outputColumnNames: _col0, _col2, _col3, _col4
Statistics: Num rows: 3731471 Data size: 104481213 Basic stats:
COMPLETE Column stats: NONE
File Output Operator
compressed: false
table:
input format: