Skip to main content
CaioFalco
Gold ⭐️
Sep 3, 2020 2:31 PM UTC
Solved

How to split the output flow file from ExecuteSQL (query perform joins)?

Hello.
I'm using an ExecuteSQL Processor to extract data from Oracle DB. The query has multiple joins and returns a large number of fields.

The problem is that ExecuteSQL Processor returns a single flow file (avro format) that is huge. 

I want to split the flow file (based in a number of rows, for example) and then merge them at the proper moment.

I have read about QueryDatabaseTable and GenerateFetchTable which are processors that can split the output flow files but looks like these processors aren't able to perform joins..

 

Does anyone knows a workaround?

CaioFalco
CaioFalcoAnswer
Gold ⭐️
Sep 10, 2020 7:54 PM UTC

Maybe I have found a solution..

I'm gonna use the ExecuteSQL to do a "select insert" query.. The query will perform the joins and load the data into a table. Then the QueryDatabaseTable will read from the new table.. That way I'll be able to use the "Max Rows Per Floe File" property.

9 replies

Faerballert
Gold ⭐️
Sep 3, 2020 7:10 PM UTC

At ExecuteSQL Processor is a property named by "Max Rows Per Flow File".

There you can set how much rows each Flow File should be contain and later you can merge them like you wanted cause the flow files get an fragment attribute.

Translate
CaioFalco
CaioFalcoAuthor
Gold ⭐️
Sep 3, 2020 8:21 PM UTC

There is no such a option at ExecuteSQL..

CaioFalco_0-1599164411538.png

 

Perhaps you're using a newer version of NiFi: Mine is 1.5.0.3.1.2.0-7

Translate
SagarKanani
Gold ⭐️
Sep 4, 2020 7:12 AM UTC

You should use ListDatabaseTable and generatetablefetch to perform an incremental load. If you are joining the tables, you can do a replacetext after generatetablefetch to add the join query and then feed the flowfile to execute sql. You can split the amount of data in generatetablefetch. 

OR 

You can use splitrecord / splitcontent to split the single avro to multiple smaller files and then use mergecontent to merge them back if required.

Hope this helps. If the comment helps you to find a solution or move forward, please accept it as a solution for other community members

Translate