Matt Burgess created NIFI-3704:
----------------------------------

             Summary: Add PutDatabaseRecord processor
                 Key: NIFI-3704
                 URL: https://issues.apache.org/jira/browse/NIFI-3704
             Project: Apache NiFi
          Issue Type: New Feature
          Components: Extensions
            Reporter: Matt Burgess


With the inclusion of NIFI-1280, which added Controller Services for 
RecordReaders and RecordWriters, we could now support a processor that reads 
records in, generates SQL statements for those records (with a specified verb 
such as INSERT, UPDATE, DELETE, etc.), and can execute all the records in one 
flow file as a batch. This would allow the processor to use a single 
PreparedStatement and, for a flow file containing multiple records, would be 
able to execute them all at once. This is in contrast to PutSQL which handles 
batches across flow files (if fragmented transactions are enabled) or with a 
discrete set (by taking at most a specified number of flow files at a time).

This processor (called PutDatabaseRecord) would effectively act like the 
combination of ConvertJSONToSQL and PutSQL, with the added features of being 
able to take records in an arbitrary format (given that there is a RecordReader 
implementation for that format) such as Avro, JSON, CSV, etc. and execute all 
the statements for the flow file at once.

Another improvement upon what can be done in ConvertJSONToSQL would be to 
support BEGIN, COMMIT, and SQL verbs. This could be accomplished by adding an 
AllowableValue to the dropdown, letting the user select "Use statement.type 
Attribute". If this was selected, then the verb would be expected to be in the 
value of the "statement.type" attribute of the incoming flow file.  Note that 
this may supercede or deprecate the need for NIFI-3676, unless this capability 
is also desired for that processor.

For BEGIN and COMMIT verbs, the contents of the record(s) are not needed, as 
the type itself should be enough to generate the appropriate SQL commands. For 
the "SQL" Statement type, the processor could either expect the flow file to 
contain a SQL statement (so the RecordReader would not be used), or it could 
expect a field called "sql" that contains the SQL statement as its value.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to