Search code examples
apache-nifi

Inserting SQL script into PutSQL-processor


I have a CREATE TABLE SQL script in a PutSQL-Processor.

So far I have identified no other way to set the SQL script than to do it manually. Is there an option to get and set the SQL script for a processor automatically at runtime?

My ideal process would look like this:

  1. Success message of previous processor
  2. Get SQL file from a specific GitHub branch (or from a local file) and insert it into the PutSQL-processor
  3. Run PutSQL-processor

Solution

  • By default, PutSQL reads the contents of an incoming FlowFile as the SQL command to run.

    So you could use InvokeHTTP to pull a file down over HTTP, or GetFile to get a local file from the filesystem, or ListFTP+FetchFTP to get a file from FTP.

    As long as the contents of the file are valid SQL statements, you can send this straight in to PutSQL and it will run the SQL.