Hive 0.14.0.2.2.4.10-1:多插入 - 空分区

时间:2015-11-17 11:50:57

标签: hadoop hive

我正在尝试使用以下查询进行多插入。

From kiran.employee_part ep
insert overwrite table kiran.employee_ext_part
partition (pdept = 'gbm', pspm = 'ajay')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment  where ep.pdept = 'gbm' and ep.pspm = 'ajay'
insert overwrite table kiran.employee_ext_part
partition (pdept='rw' , pspm='prashanth')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='rw' and ep.pspm='prashanth'
insert overwrite table kiran.employee_ext_part
partition (pdept='test' , pspm='test')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='test' and ep.pspm='test'
insert overwrite table kiran.employee_ext_part partition (pdept='test1' , pspm='test1')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='test1' and ep.pspm='test1';

选择ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.com,其中ep.pdept =' test1&# 39;和ep.pspm =' test1' 查询没有按预期返回任何行。其余的选择查询重新排列了几行。执行上述查询后,我的整个kiran.employee_ext_part表变为NULL,如下所示。

hive> select * from employee_ext_part;
OK
employee_ext_part.id    employee_ext_part.name  employee_ext_part.dept  employee_ext_part.skill employee_ext_part.sal   employee_ext_part.mgr   employee_ext_part.spm   employee_ext_part.comment       employee_ext_part.pdept        employee_ext_part.pspm
NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    gbm     ajay
NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    rw      prashanth
NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    test    test
Time taken: 8.116 seconds, Fetched: 3 row(s)

如果我注释掉最后一个查询并执行它,那么表格将填充相应的值。

From kiran.employee_part ep
insert overwrite table kiran.employee_ext_part
partition (pdept = 'gbm', pspm = 'ajay')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment  where ep.pdept = 'gbm' and ep.pspm = 'ajay'
insert overwrite table kiran.employee_ext_part
partition (pdept='rw' , pspm='prashanth')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='rw' and ep.pspm='prashanth'
insert overwrite table kiran.employee_ext_part
partition (pdept='test' , pspm='test')
select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='test' and ep.pspm='test'
--insert overwrite table kiran.employee_ext_part
--partition (pdept='test1' , pspm='test1')
--select ep.id,ep.name,ep.dept,ep.skill,ep.sal,ep.mgr,ep.spm,ep.comment where ep.pdept='test1' and ep.pspm='test1'
;

hive> select * from employee_ext_part;
OK
employee_ext_part.id    employee_ext_part.name  employee_ext_part.dept  employee_ext_part.skill employee_ext_part.sal   employee_ext_part.mgr   employee_ext_part.spm   employee_ext_part.comment       employee_ext_part.pdept        employee_ext_part.pspm
11    devillers gbm     plsql   1000.0  brijesh ajay            NULL    gbm     ajay
12      fafdu   gbm     plsql   5000.0  kiran   ajay            NULL    gbm     ajay
13      steyn   gbm     ba      10000.0 sudeep  ajay            NULL    gbm     ajay
18      duminy  gbm     hr     100001.0 smith   ajay            NULL    gbm     ajay
15      albe    rw      testing 100.0   venu    prashanth       NULL    rw      prashanth
19      miller  rw      testing 1000.0  ram     prashanth       NULL    rw      prashanth
20      pointin rw      testing 8989.0  ram     prashanth       NULL    rw      prashanth
21      rhodes  rw      tesging 9090.0  ram     prashanth       NULL    rw      prashanth
15      albe    rw      testing 100.0   venu    prashanth       NULL    test    test
19      miller  rw      testing 1000.0  ram     prashanth       NULL    test    test
20      pointin rw      testing 8989.0  ram     prashanth       NULL    test    test
21      rhodes  rw      tesging 9090.0  ram     prashanth       NULL    test    test
Time taken: 0.295 seconds, Fetched: 12 row(s)

有人可以告诉我出了什么问题吗?当我们有一个在Multi Insert中返回NULL的查询或者我错过了什么时,它应该如何工作?

P.S - 对不起标题。无法正确对齐。

1 个答案:

答案 0 :(得分:0)

免责声明:我不是多表插入的忠实粉丝,特别是在多表的情况下 - 这是同一个表但不同的分区

如果您无法修复脚本,为什么不尝试更直接的内容,例如......

set hive.exec.dynamic.partition.mode =nonstrict ;

insert overwrite into table KIRAN.EMPLOYEE_EXT_PART
partition (PDEPT, PSPM)
select ID, NAME, DEPT, SKILL, SAL, MGR, SPM, COMMENT,
       PDEPT, PSPM
from KIRAN.EMPLOYEE_PART
--where ....
;