@SeeAlso(value=SelectHiveQL.class) @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"sql","hive","put","database","update","insert"}) @CapabilityDescription(value="Executes a HiveQL DDL/DML command (UPDATE, INSERT, e.g.). The content of an incoming FlowFile is expected to be the HiveQL command to execute. The HiveQL command may use the ? to escape parameters. In this case, the parameters to use must exist as FlowFile attributes with the naming convention hiveql.args.N.type and hiveql.args.N.value, where N is a positive integer. The hiveql.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.") @ReadsAttribute(attribute="hiveql.args.N.type",description="Incoming FlowFiles are expected to be parametrized HiveQL statements. The type of each Parameter is specified as an integer that represents the JDBC Type of the parameter.") @ReadsAttribute(attribute="hiveql.args.N.value",description="Incoming FlowFiles are expected to be parametrized HiveQL statements. The value of the Parameters are specified as hiveql.args.1.value, hiveql.args.2.value, hiveql.args.3.value, and so on. The type of the hiveql.args.1.value Parameter is specified by the hiveql.args.1.type attribute.") public class PutHiveQL extends AbstractHiveQLProcessor
| Modifier and Type | Field and Description |
|---|---|
static PropertyDescriptor |
BATCH_SIZE |
static PropertyDescriptor |
CHARSET |
private static Pattern |
HIVEQL_TYPE_ATTRIBUTE_PATTERN |
private static Pattern |
NUMBER_PATTERN |
private static List<PropertyDescriptor> |
propertyDescriptors |
static Relationship |
REL_FAILURE |
static Relationship |
REL_RETRY |
static Relationship |
REL_SUCCESS |
private static Set<Relationship> |
relationships |
HIVE_DBCP_SERVICE| Constructor and Description |
|---|
PutHiveQL() |
| Modifier and Type | Method and Description |
|---|---|
private String |
getHiveQL(ProcessSession session,
FlowFile flowFile,
Charset charset)
Determines the HiveQL statement that should be executed for the given FlowFile
|
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
setParameter(PreparedStatement stmt,
String attrName,
int parameterIndex,
String parameterValue,
int jdbcType)
Determines how to map the given value to the appropriate JDBC data type and sets the parameter on the
provided PreparedStatement
|
private void |
setParameters(PreparedStatement stmt,
Map<String,String> attributes)
Sets all of the appropriate parameters on the given PreparedStatement, based on the given FlowFile attributes.
|
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTruecustomValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validatepublic static final PropertyDescriptor BATCH_SIZE
public static final PropertyDescriptor CHARSET
public static final Relationship REL_SUCCESS
public static final Relationship REL_RETRY
public static final Relationship REL_FAILURE
private static final Pattern HIVEQL_TYPE_ATTRIBUTE_PATTERN
private static final Pattern NUMBER_PATTERN
private static final List<PropertyDescriptor> propertyDescriptors
private static final Set<Relationship> relationships
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorpublic void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate String getHiveQL(ProcessSession session, FlowFile flowFile, Charset charset)
session - the session that can be used to access the given FlowFileflowFile - the FlowFile whose HiveQL statement should be executedprivate void setParameters(PreparedStatement stmt, Map<String,String> attributes) throws SQLException
stmt - the statement to set the parameters onattributes - the attributes from which to derive parameter indices, values, and typesSQLException - if the PreparedStatement throws a SQLException when the appropriate setter is calledprivate void setParameter(PreparedStatement stmt, String attrName, int parameterIndex, String parameterValue, int jdbcType) throws SQLException
stmt - the PreparedStatement to set the parameter onattrName - the name of the attribute that the parameter is coming from - for logging purposesparameterIndex - the index of the HiveQL parameter to setparameterValue - the value of the HiveQL parameter to setjdbcType - the JDBC Type of the HiveQL parameter to setSQLException - if the PreparedStatement throws a SQLException when calling the appropriate setterCopyright © 2016 Apache NiFi Project. All rights reserved.