- All Implemented Interfaces:
- ConfigurableComponent, Processor
@TriggerSerially
@InputRequirement(value=INPUT_ALLOWED)
@Tags(value={"sql","select","jdbc","query","database","fetch","generate"})
@SeeAlso(value={QueryDatabaseTable.class,ExecuteSQL.class,ListDatabaseTables.class})
@CapabilityDescription(value="Generates SQL select queries that fetch \"pages\" of rows from a table. The partition size property, along with the table\'s row count, determine the size and number of pages and generated FlowFiles. In addition, incremental fetching can be achieved by setting Maximum-Value Columns, which causes the processor to track the columns\' maximum values, thus only fetching rows whose columns\' values exceed the observed maximums. This processor is intended to be run on the Primary Node only.\n\nThis processor can accept incoming connections; the behavior of the processor is different whether incoming connections are provided:\n - If no incoming connection(s) are specified, the processor will generate SQL queries on the specified processor schedule. Expression Language is supported for many fields, but no FlowFile attributes are available. However the properties will be evaluated using the Variable Registry.\n - If incoming connection(s) are specified and no FlowFile is available to a processor task, no work will be performed.\n - If incoming connection(s) are specified and a FlowFile is available to a processor task, the FlowFile\'s attributes may be used in Expression Language for such fields as Table Name and others. However, the Max-Value Columns and Columns to Return fields must be empty or refer to columns that are available in each specified table.")
@Stateful(scopes=CLUSTER,
description="After performing a query on the specified table, the maximum values for the specified column(s) will be retained for use in future executions of the query. This allows the Processor to fetch only those records that have max values greater than the retained values. This can be used for incremental fetching, fetching of newly added rows, etc. To clear the maximum values, clear the state of the processor per the State Management documentation")
@WritesAttribute(attribute="generatetablefetch.sql.error",description="If the processor has incoming connections, and processing an incoming FlowFile causes a SQL Exception, the FlowFile is routed to failure and this attribute is set to the exception message.") @WritesAttribute(attribute="generatetablefetch.tableName",description="The name of the database table to be queried.") @WritesAttribute(attribute="generatetablefetch.columnNames",description="The comma-separated list of column names used in the query.") @WritesAttribute(attribute="generatetablefetch.whereClause",description="Where clause used in the query to get the expected rows.") @WritesAttribute(attribute="generatetablefetch.maxColumnNames",description="The comma-separated list of column names used to keep track of data that has been returned since the processor started running.") @WritesAttribute(attribute="generatetablefetch.limit",description="The number of result rows to be fetched by the SQL statement.") @WritesAttribute(attribute="generatetablefetch.offset",description="Offset to be used to retrieve the corresponding partition.") @WritesAttribute(attribute="fragment.identifier",description="All FlowFiles generated from the same query result set will have the same value for the fragment.identifier attribute. This can then be used to correlate the results.") @WritesAttribute(attribute="fragment.count",description="This is the total number of FlowFiles produced by a single ResultSet. This can be used in conjunction with the fragment.identifier attribute in order to know how many FlowFiles belonged to the same incoming ResultSet.") @WritesAttribute(attribute="fragment.index",description="This is the position of this FlowFile in the list of outgoing FlowFiles that were all generated from the same execution. This can be used in conjunction with the fragment.identifier attribute to know which FlowFiles originated from the same execution and in what order FlowFiles were produced")
@DynamicProperty(name="initial.maxvalue.<max_value_column>",
value="Initial maximum value for the specified column",
expressionLanguageScope=FLOWFILE_ATTRIBUTES,
description="Specifies an initial max value for max value columns. Properties should be added in the format `initial.maxvalue.<max_value_column>`. This value is only used the first time the table is accessed (when a Maximum Value Column is specified). In the case of incoming connections, the value is only used the first time for each table specified in the FlowFiles.")
public class GenerateTableFetch
extends AbstractDatabaseFetchProcessor