Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NiFi: Hive dynamic variable

Solved Go to solution

NiFi: Hive dynamic variable

Rising Star

In Hive script, we can set the variable and use in query. Is there a way to achieve the similar behavior with ReplaceTextWithMapping prior to sending to PutHiveQL processor. If it was one query, I could use the ReplaceText, but for multiple queries with different binding arguments, I am wondering if we could do that with ReplaceTextWithMapping processor.

hive> set name='Kumar';
hive> set department='IT';
hive> select * from emp where last_name = '{name}' and dept_name = '${department}';
hive> select * from emp where last_name = '{name}'; 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: NiFi: Hive dynamic variable

Rising Star

I realized PutHiveQL supports parameterized Hive query and I went for that.

2 REPLIES 2

Re: NiFi: Hive dynamic variable

Expert Contributor

you can use expression language.

in you selecthiveql query you put your query as select * from tmp where last_name=${name}.. name will be replaced by the attribute value from your previous processors flow file. So add an updateAttribute before the selecthiveql processor and add attribute name with whatever value you want to set.

Highlighted

Re: NiFi: Hive dynamic variable

Rising Star

I realized PutHiveQL supports parameterized Hive query and I went for that.