0

I am running the following query in 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

and then I am getting the following error

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

The strange thing is I am sure this query was working correctly before but it now doesnt seem to want to work any more.

Any ideas?

Taylrl
  • 3,601
  • 6
  • 33
  • 44

2 Answers2

0

For some reason I cannot replicate the error. Most probably because we are not using the Impala version (it would be always useful add it for this kind of quesitons). My best guess is because you are not adding aliases to the columns during the query to match the schemas between the selects. can you try this ?

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 
Taylrl
  • 3,601
  • 6
  • 33
  • 44
hlagos
  • 7,690
  • 3
  • 23
  • 41
0

This problem occurred because I was trying to run the query in the Hive editor, not the Impala one.

Taylrl
  • 3,601
  • 6
  • 33
  • 44