Skip to main content

ListDatabaseTables

Description

Generates a set of flow files, each containing attributes corresponding to metadata about a table from a database connection. Once metadata about a table has been fetched, it will not be fetched again until the Refresh Interval (if set) has elapsed, or until state has been manually cleared.

Tags

database, jdbc, list, sql, table

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
Database Connection Pooling Service *list-db-tables-db-connectionController Service:
DBCPService

Implementations:
DBCPConnectionPoolLookup
DBCPConnectionPool
HikariCPConnectionPool
SnowflakeConnectionService
The Controller Service that is used to obtain connection to database
Cataloglist-db-tables-catalogThe name of a catalog from which to list database tables. The name must match the catalog name as it is stored in the database. If the property is not set, the catalog name will not be used to narrow the search for tables. If the property is set to an empty string, tables without a catalog will be listed.
Schema Patternlist-db-tables-schema-patternA pattern for matching schemas in the database. Within a pattern, "%" means match any substring of 0 or more characters, and "_" means match any one character. The pattern must match the schema name as it is stored in the database. If the property is not set, the schema name will not be used to narrow the search for tables. If the property is set to an empty string, tables without a schema will be listed.
Table Name Patternlist-db-tables-name-patternA pattern for matching tables in the database. Within a pattern, "%" means match any substring of 0 or more characters, and "_" means match any one character. The pattern must match the table name as it is stored in the database. If the property is not set, all tables will be retrieved.
Table Typeslist-db-tables-typesTABLEA comma-separated list of table types to include. For example, some databases support TABLE and VIEW types. If the property is not set, tables of all types will be returned.
Include Count *list-db-include-countfalse
  • true
  • false
Whether to include the table's row count as a flow file attribute. This affects performance as a database query will be generated for each table in the retrieved list.
Record Writerrecord-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
Specifies the Record Writer to use for creating the listing. If not specified, one FlowFile will be created for each entity that is listed. If the Record Writer is specified, all entities will be written to a single FlowFile instead of adding attributes to individual FlowFiles.
Refresh Interval *list-db-refresh-interval0 secThe amount of time to elapse before resetting the processor state, thereby causing all current tables to be listed. During this interval, the processor may continue to run, but tables that have already been listed will not be re-listed. However new/added tables will be listed as the processor runs. A value of zero means the state will never be automatically reset, the user must Clear State manually.

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
successAll FlowFiles that are received are routed to success

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
db.table.catalogContains the name of the catalog to which the table belongs (may be null)
db.table.countContains the number of rows in the table
db.table.fullnameContains the fully-qualifed table name (possibly including catalog, schema, etc.)
db.table.nameContains the name of a database table from the connection
db.table.remarksContains the name of a database table from the connection
db.table.schemaContains the name of the schema to which the table belongs (may be null)
db.table.typeContains the type of the database table from the connection. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM"

State Management

ScopeDescription
CLUSTERAfter performing a listing of tables, the timestamp of the query is stored. This allows the Processor to not re-list tables the next time that the Processor is run. Specifying the refresh interval in the processor properties will indicate that when the processor detects the interval has elapsed, the state will be reset and tables will be re-listed as a result. This processor is meant to be run on the primary node only.

Restricted

This component is not restricted.

Input Requirement

This component does not allow an incoming relationship.

Example Use Cases Involving Other Components

Multiprocessor Use Case 1

Perform a full load of a database, retrieving all rows from all tables, or a specific set of tables.

Components Involved

  • ListDatabaseTables
    1. Configure the "Database Connection Pooling Service" property to specify a Connection Pool that is applicable for interacting with your database.
    2. Leave the RecordWriter property unset.
    3. Set the "Catalog" property to the name of the database Catalog; leave it empty to include all catalogs.
    4. Set the "Schema Pattern" property to a Java Regular Expression that matches all database Schemas that should be included; leave it empty to include all Schemas.
    5. Set the "Table Name Pattern" property to a Java Regular Expression that matches the names of all tables that should be included; leave it empty to include all Tables.
    6. Connect the "success" relationship to GenerateTableFetch.
  • GenerateTableFetch
    1. Configure the "Database Connection Pooling Service" property to specify the same Connection Pool that was used in ListDatabaseTables.
    2. Set the "Database Type" property to match the appropriate value for your RDBMS vendor.
    3. Set "Table Name" to ${db.table.fullname}
    4. Leave the RecordWriter property unset.
    5. Connect the "success" relationship to ExecuteSQLRecord.
  • ExecuteSQLRecord
    1. Configure the "Database Connection Pooling Service" property to specify the same Connection Pool that was used in ListDatabaseTables.
    2. Configure the "Record Writer" property to specify a Record Writer that is appropriate for the desired output data type.
    3. Leave the "SQL select query" unset.
    4. Connect the "success" relationship to the next Processor in the flow.

System Resource Considerations

This component does not specify system resource considerations.

See Also