I am trying to do an select with sub-queries using hive.
In foos table have the following columns:
foo1,
foo2,
foo3_input
Is what I want
select foo1, foo2, foo3 from foos;
Is what I will execute
select foo1, foo2, foo3_input from foos;
for each foo3 in a row I would like to execute the following query
foo3 = select bar1 from bars where (foo3_input) between val1 and val2;
Is there any possible way to construct this query?
select
a.foo1,
a.foo2,
b.bar1
from
(
(select foo1, foo2, foo3_input from foos) a
left outer join
(select bar1, foo3_input from bars ) b
on a.foo3_input = b.foo3_input
)tmp
where b.foo3_input between a.foo1, a.foo2
;
[edit]
select
a.foo1,
a.foo2,
b.bar1
from
(
(select foo1, foo2, foo3_input from foos) a
full outer join
(select bar1, val1, var2 from bars ) b
)tmp
where a.foo3_input between b.val1, b.val2
;
"Hive does not support IN, EXISTS or subqueries in the WHERE clause."
See this https://issues.apache.org/jira/browse/HIVE-1799
See this for where clause in hive https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SubQueries#LanguageManualSubQueries-SubqueriesintheWHEREClause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With