@Tags(value={"metadata","jdbc","database","table","update","alter"}) @CapabilityDescription(value="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.") @WritesAttribute(attribute="output.table",description="This attribute is written on the flow files routed to the \'success\' and \'failure\' relationships, and contains the target table name.") @WritesAttribute(attribute="output.path",description="This 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).") @WritesAttribute(attribute="mime.type",description="Sets 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\'.") @WritesAttribute(attribute="record.count",description="Sets the number of records in the FlowFile, only if a Record Writer is specified and Update Field Names is \'true\'.") @InputRequirement(value=INPUT_REQUIRED) public class UpdateDatabaseTable extends AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
private static class |
UpdateDatabaseTable.OutputMetadataHolder |
| Constructor and Description |
|---|
UpdateDatabaseTable() |
| Modifier and Type | Method and Description |
|---|---|
private UpdateDatabaseTable.OutputMetadataHolder |
checkAndUpdateTableSchema(Connection conn,
DatabaseAdapter databaseAdapter,
RecordSchema schema,
String catalogName,
String schemaName,
String tableName,
boolean createIfNotExists,
boolean translateFieldNames,
boolean updateFieldNames,
Set<String> primaryKeyColumnNames,
boolean quoteTableName,
boolean quoteColumnNames) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
private String |
getJdbcUrl(Connection connection) |
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private WriteResult |
updateRecords(RecordSchema inputRecordSchema,
UpdateDatabaseTable.OutputMetadataHolder outputMetadataHolder,
RecordReader reader,
RecordSetWriter writer) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validatestatic final AllowableValue CREATE_IF_NOT_EXISTS
static final AllowableValue FAIL_IF_NOT_EXISTS
static final String ATTR_OUTPUT_TABLE
static final PropertyDescriptor RECORD_READER
static final PropertyDescriptor DBCP_SERVICE
static final PropertyDescriptor CATALOG_NAME
static final PropertyDescriptor SCHEMA_NAME
static final PropertyDescriptor TABLE_NAME
static final PropertyDescriptor CREATE_TABLE
static final PropertyDescriptor PRIMARY_KEY_FIELDS
static final PropertyDescriptor TRANSLATE_FIELD_NAMES
static final PropertyDescriptor UPDATE_FIELD_NAMES
static final PropertyDescriptor RECORD_WRITER_FACTORY
static final PropertyDescriptor QUOTE_COLUMN_IDENTIFIERS
static final PropertyDescriptor QUOTE_TABLE_IDENTIFIER
static final PropertyDescriptor QUERY_TIMEOUT
static final PropertyDescriptor DB_TYPE
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
protected static final Map<String,DatabaseAdapter> dbAdapters
private static final List<PropertyDescriptor> propertyDescriptors
protected static Set<Relationship> relationships
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponentpublic void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate UpdateDatabaseTable.OutputMetadataHolder checkAndUpdateTableSchema(Connection conn, DatabaseAdapter databaseAdapter, RecordSchema schema, String catalogName, String schemaName, String tableName, boolean createIfNotExists, boolean translateFieldNames, boolean updateFieldNames, Set<String> primaryKeyColumnNames, boolean quoteTableName, boolean quoteColumnNames) throws IOException
IOExceptionprivate WriteResult updateRecords(RecordSchema inputRecordSchema, UpdateDatabaseTable.OutputMetadataHolder outputMetadataHolder, RecordReader reader, RecordSetWriter writer) throws IOException
IOExceptionprivate String getJdbcUrl(Connection connection)
Copyright © 2023 Apache NiFi Project. All rights reserved.