Search code examples
apache-nifi

Executing SQL CREATE statements via CRON in order


I want to execute 5 SQL CREATE TABLE statements in a specific order with Apache Nifi. Once the first table has been successfully created, I want the second processor to create the next table and so on.

I have been able to execute CREATE statements with a PutSQL-processor, but I am having trouble to get it running as a CRON job because PutSQL requires an upstream connection which I don't have for the first of my 5 PutSQL-processors. The other 4 run after the previous finished which works great.

Is there a trick so that the first PutSQL-processor doesn't need an upstream connection, or is there a "dummy"-processor which I can use to send a CRON/timed success-message to my first PutSQL-processor which then starts working?


Solution

  • You could use ExecuteSQL for which the incoming relationship is optional.

    https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.12.1/org.apache.nifi.processors.standard.ExecuteSQL/index.html

    If you want to use PutSQL, you can use GenerateFlowFile on a CRON schedule to kick a single flow file out at the specific time to trigger PutSQL.