Support Questions

Find answers, ask questions, and share your expertise

NiFi: Hive dynamic variable

avatar
Expert Contributor

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

avatar
Expert Contributor

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

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

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.

avatar
Expert Contributor

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