Skip to main content

UpdateDatabaseTable

Description

This processor uses a JDBC connection and incoming records to generate any database table changes needed to support the incoming records. It expects a 'flat' record layout, meaning none of the top-level record fields has nested fields that are intended to become columns themselves.

Tags

alter, database, jdbc, metadata, table, update

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Record Reader *record-readerController Service:
RecordReaderFactory

Implementations:
AvroReader
CEFReader
CSVReader
ExcelReader
GrokReader
JsonPathReader
JsonTreeReader
ReaderLookup
ScriptedReader
Syslog5424Reader
SyslogReader
WindowsEventLogReader
XMLReader
YamlTreeReader
The service for reading incoming flow files. The reader is only used to determine the schema of the records, the actual records will not be processed.
Database Connection Pooling Service *updatedatabasetable-dbcp-serviceController Service:
DBCPService

Implementations:
DBCPConnectionPoolLookup
DBCPConnectionPool
HikariCPConnectionPool
SnowflakeConnectionService
The Controller Service that is used to obtain connection(s) to the database
Database Typedb-typeGeneric
  • Generic
  • Oracle
  • Oracle 12+
  • MS SQL 2012+
  • MS SQL 2008
  • MySQL
  • PostgreSQL
  • Phoenix
The type/flavor of database, used for generating database-specific code. In many cases the Generic type should suffice, but some databases (such as Oracle) require custom SQL clauses.
Catalog Nameupdatedatabasetable-catalog-nameThe name of the catalog that the statement should update. This may not apply for the database that you are updating. In this case, leave the field empty. Note that if the property is set and the database is case-sensitive, the catalog name must match the database's catalog name exactly.

Supports Expression Language, using FlowFile attributes and Environment variables.
Schema Nameupdatedatabasetable-schema-nameThe name of the database schema that the table belongs to. This may not apply for the database that you are updating. In this case, leave the field empty. Note that if the property is set and the database is case-sensitive, the schema name must match the database's schema name exactly.

Supports Expression Language, using FlowFile attributes and Environment variables.
Table Name *updatedatabasetable-table-nameThe name of the database table to update. If the table does not exist, then it will either be created or an error thrown, depending on the value of the Create Table property.

Supports Expression Language, using FlowFile attributes and Environment variables.
Create Table Strategy *updatedatabasetable-create-tableFail If Not Exists
  • Create If Not Exists
  • Fail If Not Exists
Specifies how to process the target table when it does not exist (create it, fail, e.g.).
Primary Key Fieldsupdatedatabasetable-primary-keysA comma-separated list of record field names that uniquely identifies a row in the database. This property is only used if the specified table needs to be created, in which case the Primary Key Fields will be used to specify the primary keys of the newly-created table. IMPORTANT: Primary Key Fields must match the record field names exactly unless 'Quote Column Identifiers' is false and the database allows for case-insensitive column names. In practice it is best to specify Primary Key Fields that exactly match the record field names, and those will become the column names in the created table.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Create Table Strategy has a value of Create If Not Exists
Translate Field Names *updatedatabasetable-translate-field-namestrue
  • true
  • false
If true, the Processor will attempt to translate field names into the corresponding column names for the table specified, for the purposes of determining whether the field name exists as a column in the target table. NOTE: If the target table does not exist and is to be created, this property is ignored and the field names will be used as-is. If false, the field names must match the column names exactly, or the column may not be found and instead an error my be reported that the column already exists.
Update Field Names *updatedatabasetable-update-field-namesfalse
  • true
  • false
This property indicates whether to update the output schema such that the field names are set to the exact column names from the specified table. This should be used if the incoming record field names may not match the table's column names in terms of upper- and lower-case. For example, this property should be set to true if the output FlowFile is destined for Oracle e.g., which expects the field names to match the column names exactly. NOTE: The value of the 'Translate Field Names' property is ignored when updating field names; instead they are updated to match the column name as returned by the database.
Record Writer *updatedatabasetable-record-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
Specifies the Controller Service to use for writing results to a FlowFile. The Record Writer should use Inherit Schema to emulate the inferred schema behavior, i.e. an explicit schema need not be defined in the writer, and will be supplied by the same logic used to infer the schema from the column types. If Create Table Strategy is set 'Create If Not Exists', the Record Writer's output format must match the Record Reader's format in order for the data to be placed in the created table location. Note that this property is only used if 'Update Field Names' is set to true and the field names do not all match the column names exactly. If no update is needed for any field names (or 'Update Field Names' is false), the Record Writer is not used and instead the input FlowFile is routed to success or failure without modification.

This property is only considered if:
  • the property Update Field Names has a value of true
Quote Table Identifiersupdatedatabasetable-quoted-table-identifiersfalse
  • true
  • false
Enabling this option will cause the table name to be quoted to support the use of special characters in the table name and/or forcing the value of the Table Name property to match the target table name exactly.
Quote Column Identifiersupdatedatabasetable-quoted-column-identifiersfalse
  • true
  • false
Enabling this option will cause all column names to be quoted, allowing you to use reserved words as column names in your tables and/or forcing the record field names to match the column names exactly.
Query Timeout *updatedatabasetable-query-timeout0Sets the number of seconds the driver will wait for a query to execute. A value of 0 means no timeout. NOTE: Non-zero values may not be supported by the driver.

Supports Expression Language, using FlowFile attributes and Environment variables.

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureA FlowFile containing records routed to this relationship if the record could not be transmitted to the database.
successA FlowFile containing records routed to this relationship after the record has been successfully transmitted to the database.

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
mime.typeSets the mime.type attribute to the MIME Type specified by the Record Writer, only if a Record Writer is specified and Update Field Names is 'true'.
output.pathThis attribute is written on the flow files routed to the 'success' and 'failure' relationships, and contains the path on the file system to the table (or partition location if the table is partitioned).
output.tableThis attribute is written on the flow files routed to the 'success' and 'failure' relationships, and contains the target table name.
record.countSets the number of records in the FlowFile, only if a Record Writer is specified and Update Field Names is 'true'.

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

This component does not specify system resource considerations.

See Also