My dataflow is as follow:
My purpose is to create a table from a csv file and then put the data in this table. Everything is working good but I need to check if the table is created before storing the csv file. So I used the Execute SQL to run this query:
select count(table_name) from information_schema.tables where table_name='warranty'
But it returns only the number of rows and not the flowfile. My test is if number of row is one so I execute the rest. So I need to use dataflow which can check if the table is well created and execute the other processors if not it stop every thing. Can you help me plz I know that i can find another way but don't find ideas.
Thank you for your help.
As of NiFi 1.5.0 (via NIFI-4522), you can issue a SQL query in PutSQL while still retaining the incoming flow file contents. For your case, you could send the CSV file to PutSQL and execute a "CREATE TABLE IF NOT EXISTS" statement, which will create the table the first time but allow the CSV to proceed to the "real" destination processor, likely PutDatabaseRecord.