编译语句时出错:失败:ParseException行3:0缺少“靠近”处的“选择”处的所有行5:0行缺少了“靠近”处的“选择处”的全部

时间:2018-12-07 13:59:20

标签: sql impala

我正在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

然后出现以下错误

  

编译语句时出错:失败:ParseException行3:0   第5:0行在'select'附近缺少所有内容'0'在'select'附近缺少所有内容   

奇怪的是,我确定此查询之前可以正常工作,但现在似乎不再想要工作了。

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

由于某种原因,我无法复制该错误。很有可能是因为我们没有使用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 

答案 1 :(得分:0)

发生此问题是因为我试图在Hive编辑器而不是Impala中运行查询。