- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Need a processor to test if a table sql exists and return the flowfile
- Labels:
-
Apache NiFi
Created ‎06-29-2018 10:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
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.
Created ‎06-29-2018 03:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
