Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive multiple subqueries

Tags:

subquery

hive

I'm using Hive 0.9.0 and I'm trying to execute query i.e.

`SELECT a.id, b.user FROM (SELECT...FROM a_table) a, (SELECT...FROM b_table) b WHERE a.date   = b.date;`

but it returns error "loop (...)+ does not match input....". Does Hive support multiple subqueries in FROM just like Oracle DB?

like image 523
Valery Yesypenko Avatar asked Feb 18 '13 11:02

Valery Yesypenko


2 Answers

Multiple subqueries allowed in hive.

I tested with below code,it works.

    select * from (select id from test where id>10) a 
join (select id from test where id>20) b on a.id=b.id;

Please post your exact code so that I can give relevant solution.

like image 123
Balaswamy Vaddeman Avatar answered Sep 20 '22 13:09

Balaswamy Vaddeman


join subqueries is supported Absolutely.

I think the key problem is that u use SELECT...FROM.

The correct syntax is SELECT * FROM

SELECT a.id, b.user 
FROM 
(SELECT * FROM a_table) a 
JOIN (SELECT * FROM b_table) b ON a.date = b.date;
like image 34
pensz Avatar answered Sep 23 '22 13:09

pensz