Support Questions
Find answers, ask questions, and share your expertise

Passing hive query result to variable

New Contributor

Hello,

I'm trying to save a query's result into a hivevar, as indicated in this page:

https://community.hortonworks.com/content/supportkb/151091/how-to-use-subquery-as-a-variable-in-hive...

My query is as follows:

SET value1 = 'OAL150508EU4';


SET value2 = 2018;

CREATE TEMPORARY TABLE IF NOT EXISTS temptable (cont int);


insert into temptable SELECT COUNT(*) FROM table1  WHERE field1 =   "${hiveconf:value1}" AND  "${hiveconf:value2}"= field2;

 set hivevar:variable1 = (select case when cont > 0 then 'TEST1' else 'Test2' end as cont_case from temptable);


select ${hivevar:variable1}

But I get the following error during the last select:

Unsupported SubQuery Expression Currently SubQuery expressions are only allowed as Where and Having Clause predicates

My current HDP version is 2.6. Is it possible in this version to save a query into a variable or is only working on the vesions indicated in the article?

0 REPLIES 0