编译语句时出错:失败:ParseException 行 3:0 在“”附近的 'select' 处缺少所有,行 5:0 在“”附近的 'select' 处缺少所有

Error while compiling statement: FAILED: ParseException line 3:0 missing ALL at 'select' near '' line 5:0 missing ALL at 'select' near ''

我是运行下面的查询Impala

select count(id) from (select s_id as id, m_id from hur_e_s_amer
union
select s_id, m_id from hur_e_s_emea
union
select r_id, m_id from hur_e_r_amer
union
select r_id, m_id from hur_e_r_emea
) t1
join (select m_id, d_date from hur_e_c_amer
union
select m_id, d_date from hur_e_c_emea
where d_date between '2018-04-09 00:00:00.0' and '2018-06-08 23:59:59.9'
) t2
on t1.m_id = t2.m_id

然后我收到以下错误

Error while compiling statement: FAILED: ParseException line 3:0 missing ALL at 'select' near '' line 5:0 missing ALL at 'select' near ''

奇怪的是,我确信这个查询以前工作正常,但现在似乎不想再工作了。

有什么想法吗?

出于某种原因,我无法复制错误。很可能是因为我们没有使用 Impala 版本(对于此类问题添加它总是有用的)。我最好的猜测是因为您没有在查询期间向列添加别名以匹配选择之间的模式。你能试试这个吗?

select count(t1.id) from (select s_id as id, m_id from hur_e_s_amer
union
select s_id as id, m_id from hur_e_s_emea
union
select r_id as id, m_id from hur_e_r_amer
union
select r_id as id, m_id from hur_e_r_emea
) t1
join (select m_id, d_date from hur_e_c_amer
union
select m_id, d_date from hur_e_c_emea
where d_date between '2018-04-09 00:00:00.0' and '2018-06-08 23:59:59.9'
) t2
on t1.m_id = t2.m_id 

出现此问题是因为我试图 运行 Hive 编辑器中的查询,而不是 Impala 中的查询。