创建两张表,以emp表和dept表为例:
create table emp(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int
)row format delimited fields terminated by '\t';
加载数据:
load data local inpath '/home/hadoop/data/emp.txt' overwrite into table emp;
CREATE TABLE dept(
deptno int,
dname string,
loc string
)row format delimited fields terminated by '\t';
加载数据:
load data local inpath '/home/bigdata/testdata/dept.txt' overwrite into table dept;
执行计划解读:
首先设置set hive.auto.convert.join=false;Hive默认是true
explain select e.empno, e.ename, d.dname from emp e join dept d on e.deptno=d.deptno;
输出信息如下:
STAGE DEPENDENCIES:
Stage-1 is a root stage
Stage-0 depends on stages: Stage-1
STAGE PLANS:
Stage: Stage-