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

NiFi Flow File Attribute not getting populated in the flow when file fetched from GitHub

NiFi Flow File Attribute not getting populated in the flow when file fetched from GitHub

New Contributor

Hi,


I am fetching some HQL files from GitHub using InvokeHTTP processor and executing the SQL using PutHiveQL processor. The challenge is that the HQL files are having reference of some nifi attributes and those attribute values are not getting populated but those attributes are present in the flow file.


Example:


HQL file content:

select * from tbl_sales where load_date='${load_date}';

 

InvokeHTTP processor response:

select * from tbl_sales where load_date='${load_date}';


My understanding is that once the response comes to nifi then it renders the flow file content and it should automatically populate the date value (eg. '2021-04-14') instead of the string reference i.e. '${load_date}'

 

I need your expertise to confirm if it is the expected behaviour of nifi that it should only be getting the HQL content as it is and not rendering it to the actual attribute value. If not then can somebody please help how to get this attribute value populated?

 

Here is the screenshot of the flow:

Screen Shot 2021-04-14 at 8.09.55 PM.png

 

Thanks!

 

3 REPLIES 3

Re: NiFi Flow File Attribute not getting populated in the flow when file fetched from GitHub

Super Guru

Unfortunately variables cannot be inside other dynamic parameters.   It is already rendered by then.

 

What you can do is store this part 

select * from tbl_sales where load_date=

then updateattribute

query

${result:append( "'" +${load_date} +"'")}

Re: NiFi Flow File Attribute not getting populated in the flow when file fetched from GitHub

New Contributor

@TimothySpann Thanks for your response.

 

Actually, the use case I am working on is having multiple flow file attributes.

 

Additionally, 

1. The solution you have suggested is treating the result as an attribute but in our case, the result is the flow file content.

2. For multiple attributes this solution is very complicated.

 

Appreciate it if you can suggest something.

 

Thanks!

 

 

Re: NiFi Flow File Attribute not getting populated in the flow when file fetched from GitHub

Super Guru

QueryRecordProcessor grabs fields from content

You can also add attributes there

 

You can also add attributes via updaterecord

 

https://www.datainmotion.dev/2020/12/smart-stocks-with-flank-nifi-kafka.html