Class ExecuteSQLRecord
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.AbstractExecuteSQL
org.apache.nifi.processors.standard.ExecuteSQLRecord
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@InputRequirement(INPUT_ALLOWED)
@Tags({"sql","select","jdbc","query","database","record"})
@CapabilityDescription("Executes provided SQL select query. Query result will be converted to the format specified by a Record Writer. Streaming is used so arbitrarily large result sets are supported. This processor can be scheduled to run on a timer, or cron expression, using the standard scheduling methods, or it can be triggered by an incoming FlowFile. If it is triggered by an incoming FlowFile, then attributes of that FlowFile will be available when evaluating the select query, and the query may use the ? to escape parameters. In this case, the parameters to use must exist as FlowFile attributes with the naming convention sql.args.N.type and sql.args.N.value, where N is a positive integer. The sql.args.N.type is expected to be a number indicating the JDBC Type. The content of the FlowFile is expected to be in UTF-8 format. FlowFile attribute \'executesql.row.count\' indicates how many rows were selected.")
@ReadsAttribute(attribute="sql.args.N.type",description="Incoming FlowFiles are expected to be parametrized SQL statements. The type of each Parameter is specified as an integer that represents the JDBC Type of the parameter. The following types are accepted: [LONGNVARCHAR: -16], [BIT: -7], [BOOLEAN: 16], [TINYINT: -6], [BIGINT: -5], [LONGVARBINARY: -4], [VARBINARY: -3], [BINARY: -2], [LONGVARCHAR: -1], [CHAR: 1], [NUMERIC: 2], [DECIMAL: 3], [INTEGER: 4], [SMALLINT: 5] [FLOAT: 6], [REAL: 7], [DOUBLE: 8], [VARCHAR: 12], [DATE: 91], [TIME: 92], [TIMESTAMP: 93], [VARCHAR: 12], [CLOB: 2005], [NCLOB: 2011]") @ReadsAttribute(attribute="sql.args.N.value",description="Incoming FlowFiles are expected to be parametrized SQL statements. The value of the Parameters are specified as sql.args.1.value, sql.args.2.value, sql.args.3.value, and so on. The type of the sql.args.1.value Parameter is specified by the sql.args.1.type attribute.") @ReadsAttribute(attribute="sql.args.N.format",description="This attribute is always optional, but default options may not always work for your data. Incoming FlowFiles are expected to be parametrized SQL statements. In some cases a format option needs to be specified, currently this is only applicable for binary data types, dates, times and timestamps. Binary Data Types (defaults to \'ascii\') - ascii: each string character in your attribute value represents a single byte. This is the format provided by Avro Processors. base64: the string is a Base64 encoded string that can be decoded to bytes. hex: the string is hex encoded with all letters in upper case and no \'0x\' at the beginning. Dates/Times/Timestamps - Date, Time and Timestamp formats all support both custom formats or named format (\'yyyy-MM-dd\',\'ISO_OFFSET_DATE_TIME\') as specified according to java.time.format.DateTimeFormatter. If not specified, a long value input is expected to be an unix epoch (milli seconds from 1970/1/1), or a string value in \'yyyy-MM-dd\' format for Date, \'HH:mm:ss.SSS\' for Time (some database engines e.g. Derby or MySQL do not support milliseconds and will truncate milliseconds), \'yyyy-MM-dd HH:mm:ss.SSS\' for Timestamp is used.")
@WritesAttribute(attribute="executesql.row.count",description="Contains the number of rows returned in the select query") @WritesAttribute(attribute="executesql.query.duration",description="Combined duration of the query execution time and fetch time in milliseconds") @WritesAttribute(attribute="executesql.query.executiontime",description="Duration of the query execution time in milliseconds") @WritesAttribute(attribute="executesql.query.fetchtime",description="Duration of the result set fetch time in milliseconds") @WritesAttribute(attribute="executesql.resultset.index",description="Assuming multiple result sets are returned, the zero based index of this result set.") @WritesAttribute(attribute="executesql.error.message",description="If processing an incoming flow file causes an Exception, the Flow File is routed to failure and this attribute is set to the exception message.") @WritesAttribute(attribute="fragment.identifier",description="If \'Max Rows Per Flow File\' is set then all FlowFiles 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="If \'Max Rows Per Flow File\' is set then 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. If Output Batch Size is set, then this attribute will not be populated.") @WritesAttribute(attribute="fragment.index",description="If \'Max Rows Per Flow File\' is set then the position of this FlowFile in the list of outgoing FlowFiles that were all derived from the same result set FlowFile. This can be used in conjunction with the fragment.identifier attribute to know which FlowFiles originated from the same query result set and in what order FlowFiles were produced") @WritesAttribute(attribute="input.flowfile.uuid",description="If the processor has an incoming connection, outgoing FlowFiles will have this attribute set to the value of the input FlowFile\'s UUID. If there is no incoming connection, the attribute will not be added.") @WritesAttribute(attribute="mime.type",description="Sets the mime.type attribute to the MIME Type specified by the Record Writer.") @WritesAttribute(attribute="record.count",description="The number of records output by the Record Writer.")
@SupportsSensitiveDynamicProperties
@DynamicProperty(name="sql.args.N.type",value="SQL type argument to be supplied",description="Incoming FlowFiles are expected to be parametrized SQL statements. The type of each Parameter is specified as an integer that represents the JDBC Type of the parameter. The following types are accepted: [LONGNVARCHAR: -16], [BIT: -7], [BOOLEAN: 16], [TINYINT: -6], [BIGINT: -5], [LONGVARBINARY: -4], [VARBINARY: -3], [BINARY: -2], [LONGVARCHAR: -1], [CHAR: 1], [NUMERIC: 2], [DECIMAL: 3], [INTEGER: 4], [SMALLINT: 5] [FLOAT: 6], [REAL: 7], [DOUBLE: 8], [VARCHAR: 12], [DATE: 91], [TIME: 92], [TIMESTAMP: 93], [VARCHAR: 12], [CLOB: 2005], [NCLOB: 2011]") @DynamicProperty(name="sql.args.N.value",value="Argument to be supplied",description="Incoming FlowFiles are expected to be parametrized SQL statements. The value of the Parameters are specified as sql.args.1.value, sql.args.2.value, sql.args.3.value, and so on. The type of the sql.args.1.value Parameter is specified by the sql.args.1.type attribute.") @DynamicProperty(name="sql.args.N.format",value="SQL format argument to be supplied",description="This attribute is always optional, but default options may not always work for your data. Incoming FlowFiles are expected to be parametrized SQL statements. In some cases a format option needs to be specified, currently this is only applicable for binary data types, dates, times and timestamps. Binary Data Types (defaults to \'ascii\') - ascii: each string character in your attribute value represents a single byte. This is the format provided by Avro Processors. base64: the string is a Base64 encoded string that can be decoded to bytes. hex: the string is hex encoded with all letters in upper case and no \'0x\' at the beginning. Dates/Times/Timestamps - Date, Time and Timestamp formats all support both custom formats or named format (\'yyyy-MM-dd\',\'ISO_OFFSET_DATE_TIME\') as specified according to java.time.format.DateTimeFormatter. If not specified, a long value input is expected to be an unix epoch (milli seconds from 1970/1/1), or a string value in \'yyyy-MM-dd\' format for Date, \'HH:mm:ss.SSS\' for Time (some database engines e.g. Derby or MySQL do not support milliseconds and will truncate milliseconds), \'yyyy-MM-dd HH:mm:ss.SSS\' for Timestamp is used.")
public class ExecuteSQLRecord
extends AbstractExecuteSQL
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.nifi.processors.standard.AbstractExecuteSQL
AbstractExecuteSQL.ContentOutputStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.nifi.components.PropertyDescriptorprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.components.PropertyDescriptorprivate static final Set<org.apache.nifi.processor.Relationship> Fields inherited from class org.apache.nifi.processors.standard.AbstractExecuteSQL
AUTO_COMMIT, CONTENT_OUTPUT_STRATEGY, DBCP_SERVICE, dbcpService, FETCH_SIZE, FRAGMENT_COUNT, FRAGMENT_ID, FRAGMENT_INDEX, INPUT_FLOWFILE_UUID, MAX_ROWS_PER_FLOW_FILE, OUTPUT_BATCH_SIZE, propDescriptors, QUERY_TIMEOUT, REL_FAILURE, REL_SUCCESS, relationships, RESULT_ERROR_MESSAGE, RESULT_QUERY_DURATION, RESULT_QUERY_EXECUTION_TIME, RESULT_QUERY_FETCH_TIME, RESULT_ROW_COUNT, RESULTSET_INDEX, SQL_POST_QUERY, SQL_PRE_QUERY, SQL_QUERY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SqlWriterconfigureSqlWriter(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile fileToProcess) protected org.apache.nifi.components.PropertyDescriptorgetSupportedDynamicPropertyDescriptor(String propertyDescriptorName) Methods inherited from class org.apache.nifi.processors.standard.AbstractExecuteSQL
executeConfigStatements, getQueries, getRelationships, getSupportedPropertyDescriptors, migrateProperties, onTrigger, setFlowFileEmptyResults, setupMethods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
RECORD_WRITER_FACTORY
public static final org.apache.nifi.components.PropertyDescriptor RECORD_WRITER_FACTORY -
NORMALIZE_NAMES
public static final org.apache.nifi.components.PropertyDescriptor NORMALIZE_NAMES -
PROPERTY_DESCRIPTORS
-
RELATIONSHIPS
-
-
Constructor Details
-
ExecuteSQLRecord
public ExecuteSQLRecord()
-
-
Method Details
-
configureSqlWriter
protected SqlWriter configureSqlWriter(org.apache.nifi.processor.ProcessSession session, org.apache.nifi.processor.ProcessContext context, org.apache.nifi.flowfile.FlowFile fileToProcess) - Specified by:
configureSqlWriterin classAbstractExecuteSQL
-
getSupportedDynamicPropertyDescriptor
protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) - Overrides:
getSupportedDynamicPropertyDescriptorin classorg.apache.nifi.components.AbstractConfigurableComponent
-