[
https://issues.apache.org/jira/browse/NIFI-7748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17308994#comment-17308994
]
Matt Burgess commented on NIFI-7748:
------------------------------------
IMO I'd rather implement NIFI-5151 and see if most of the use cases are
covered. Adding a record writer option might preclude the use of a prepared
statement so would make PutDatabaseRecord as slow as PutSQL. If you can
free-form a prepared statement we'd probably have to parse it looking for the
field names so we can set the objects in the right order on the
PreparedStatement.
The MySQL and PostgreSQL UPSERTs do things like ON DUPLICATE KEY and ON
CONFLICT already, so if there's a Phoenix-specific way to do it we could add it
to the adapter under NIFI-5151. I have a patch that basically just generates an
INSERT but uses UPSERT as the statement type (all other syntax stays the same).
Another option is to use a FreeFormRecordSetWriter upstream to create the
custom statements, then a GrokReader in PutDatabaseRecord to get a field (let's
call it "sql") for each line (see NIFI-6670 for more details), then you can set
the statement type to "use statement.type attribute" and ensure the
"statement.type" attribute on the flowfile is set to "SQL", and in
PutDatabaseRecord set the Field Containing SQL property to "sql". That will
execute all lines of SQL as one transaction, like PutSQL but with a single
flowfile.
> PutDatabaseRecord: Add an optional record writer: FreeFormRecordWriter
> -----------------------------------------------------------------------
>
> Key: NIFI-7748
> URL: https://issues.apache.org/jira/browse/NIFI-7748
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: DEOM Damien
> Priority: Major
>
> The PutDatabaseRecord processor should allow the user to create custom
> queries more easily.
> The FreeFormRecordWriter is very convenient, and could be added as an option
> (as a replacement for the very obscure 'SQL' statement.type)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)