Hive UNION ALL 提示 Schema of both sides of union should match.

感谢分享:http://blog.csdn.net/jinjiating/article/details/18009503

select * from
(select tokenid 
from sm_play where dt=140108
union all
select device_token 
from mda_dbs_passport_device)tmp;

FAILED: SemanticException 6:5 Schema of both sides of union should match. tmp-subquery2 does not have the field tokenid. Error encountered near token 'mda_dbs_passport_device'

原因:union all两边表的列名不一致

select * from
(select tokenid 
from sm_play where dt=140108
union all
select device_token as tokenid
from mda_dbs_passport_device)tmp;



我的语句:
CREATE VIEW IF NOT EXISTS xxx.xxx AS
SELECT 
   a.xxx AS aaa,
   b.xxx AS bbb
FROM xxx a
LEFT JOIN xxx b
UNION ALL

SELECT 

  NULL,

  c.xxx

FROM xxx c

改成

CREATE VIEW IF NOT EXISTS xxx.xxx AS
SELECT 
   a.xxx AS aaa,
   b.xxx AS bbb
FROM xxx a
LEFT JOIN xxx b
UNION ALL

SELECT 

  NULL AS aaa,

  c.xxx AS bbb

FROM xxx c

本站公众号
   欢迎关注本站公众号,获取更多程序园信息
开发小院