Class UpdateDatabaseTable

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.UpdateDatabaseTable
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@Tags({"metadata","jdbc","database","table","update","alter"}) @CapabilityDescription("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(INPUT_REQUIRED) public class UpdateDatabaseTable extends org.apache.nifi.processor.AbstractProcessor
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    protected static final Map<String,DatabaseAdapter>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    private static final List<org.apache.nifi.components.PropertyDescriptor>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.processor.Relationship
     
    static final org.apache.nifi.processor.Relationship
     
    protected static Set<org.apache.nifi.processor.Relationship>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    checkAndUpdateTableSchema(Connection conn, DatabaseAdapter databaseAdapter, RecordSchema schema, String catalogName, String schemaName, String tableName, boolean createIfNotExists, boolean translateFieldNames, NameNormalizer normalizer, boolean updateFieldNames, Set<String> primaryKeyColumnNames, boolean quoteTableName, boolean quoteColumnNames)
     
    protected Collection<org.apache.nifi.components.ValidationResult>
    customValidate(org.apache.nifi.components.ValidationContext validationContext)
     
    private String
    getJdbcUrl(Connection connection)
     
    Set<org.apache.nifi.processor.Relationship>
     
    protected List<org.apache.nifi.components.PropertyDescriptor>
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    private WriteResult
    updateRecords(RecordSchema inputRecordSchema, UpdateDatabaseTable.OutputMetadataHolder outputMetadataHolder, RecordReader reader, RecordSetWriter writer)
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate

    Methods inherited from interface org.apache.nifi.processor.Processor

    isStateful, migrateProperties, migrateRelationships
  • Field Details

    • CREATE_IF_NOT_EXISTS

      static final org.apache.nifi.components.AllowableValue CREATE_IF_NOT_EXISTS
    • FAIL_IF_NOT_EXISTS

      static final org.apache.nifi.components.AllowableValue FAIL_IF_NOT_EXISTS
    • ATTR_OUTPUT_TABLE

      static final String ATTR_OUTPUT_TABLE
      See Also:
    • RECORD_READER

      static final org.apache.nifi.components.PropertyDescriptor RECORD_READER
    • DBCP_SERVICE

      static final org.apache.nifi.components.PropertyDescriptor DBCP_SERVICE
    • CATALOG_NAME

      static final org.apache.nifi.components.PropertyDescriptor CATALOG_NAME
    • SCHEMA_NAME

      static final org.apache.nifi.components.PropertyDescriptor SCHEMA_NAME
    • TABLE_NAME

      static final org.apache.nifi.components.PropertyDescriptor TABLE_NAME
    • CREATE_TABLE

      static final org.apache.nifi.components.PropertyDescriptor CREATE_TABLE
    • PRIMARY_KEY_FIELDS

      static final org.apache.nifi.components.PropertyDescriptor PRIMARY_KEY_FIELDS
    • TRANSLATE_FIELD_NAMES

      static final org.apache.nifi.components.PropertyDescriptor TRANSLATE_FIELD_NAMES
    • TRANSLATION_STRATEGY

      public static final org.apache.nifi.components.PropertyDescriptor TRANSLATION_STRATEGY
    • TRANSLATION_PATTERN

      public static final org.apache.nifi.components.PropertyDescriptor TRANSLATION_PATTERN
    • UPDATE_FIELD_NAMES

      static final org.apache.nifi.components.PropertyDescriptor UPDATE_FIELD_NAMES
    • RECORD_WRITER_FACTORY

      static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER_FACTORY
    • QUOTE_COLUMN_IDENTIFIERS

      static final org.apache.nifi.components.PropertyDescriptor QUOTE_COLUMN_IDENTIFIERS
    • QUOTE_TABLE_IDENTIFIER

      static final org.apache.nifi.components.PropertyDescriptor QUOTE_TABLE_IDENTIFIER
    • QUERY_TIMEOUT

      static final org.apache.nifi.components.PropertyDescriptor QUERY_TIMEOUT
    • dbAdapters

      protected static final Map<String,DatabaseAdapter> dbAdapters
    • DB_TYPE

      static final org.apache.nifi.components.PropertyDescriptor DB_TYPE
    • properties

      private static final List<org.apache.nifi.components.PropertyDescriptor> properties
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • REL_FAILURE

      public static final org.apache.nifi.processor.Relationship REL_FAILURE
    • relationships

      protected static Set<org.apache.nifi.processor.Relationship> relationships
  • Constructor Details

    • UpdateDatabaseTable

      public UpdateDatabaseTable()
  • Method Details

    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • checkAndUpdateTableSchema

      private UpdateDatabaseTable.OutputMetadataHolder checkAndUpdateTableSchema(Connection conn, DatabaseAdapter databaseAdapter, RecordSchema schema, String catalogName, String schemaName, String tableName, boolean createIfNotExists, boolean translateFieldNames, NameNormalizer normalizer, boolean updateFieldNames, Set<String> primaryKeyColumnNames, boolean quoteTableName, boolean quoteColumnNames) throws IOException
      Throws:
      IOException
    • updateRecords

      private WriteResult updateRecords(RecordSchema inputRecordSchema, UpdateDatabaseTable.OutputMetadataHolder outputMetadataHolder, RecordReader reader, RecordSetWriter writer) throws IOException
      Throws:
      IOException
    • getJdbcUrl

      private String getJdbcUrl(Connection connection)