[
https://issues.apache.org/jira/browse/NIFI-4371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16553181#comment-16553181
]
ASF GitHub Bot commented on NIFI-4371:
--------------------------------------
Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2138#discussion_r204501609
--- Diff:
nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/AbstractHiveQLProcessor.java
---
@@ -75,6 +81,38 @@
.addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
.build();
+ public static final PropertyDescriptor QUERY_TIMEOUT = new
PropertyDescriptor.Builder()
+ .name("hive-query-timeout")
+ .displayName("Query timeout")
+ .description("Sets the number of seconds the driver will wait
for a query to execute. "
+ + "A value of 0 means no timeout. NOTE: Non-zero
values may not be supported by the driver.")
+ .defaultValue("0")
+ .required(true)
+ .addValidator(StandardValidators.INTEGER_VALIDATOR)
+ .expressionLanguageSupported(true)
+ .build();
+
+ @Override
+ protected Collection<ValidationResult>
customValidate(ValidationContext validationContext) {
+ final List<ValidationResult> problems = new ArrayList<>(1);
+
+ if(validationContext.getProperty(QUERY_TIMEOUT).isSet()
+ &&
!validationContext.getProperty(QUERY_TIMEOUT).isExpressionLanguagePresent()
+ &&
validationContext.getProperty(QUERY_TIMEOUT).asInteger() != 0) {
+ try(HiveStatement stmt = new HiveStatement(null, null, null)) {
+ stmt.setQueryTimeout(0);
--- End diff --
True (at least for older Apache Hive drivers), but it is a tad confusing to
see the if statement check for non-zero then test with zero.
Also, I can't find the discussion but I thought we were going to do similar
error handling in the setTimeout() method below as we do in the customValidate,
for when Expression Language is present but the driver doesn't support non-zero
values. IIRC it would allow a query timeout of zero if the driver didn't
support it, but if the user set it to a positive value and the driver didn't
support it, it would throw an error (akin to being invalid if found in
customValidate())?
> Add support for query timeout in Hive processors
> ------------------------------------------------
>
> Key: NIFI-4371
> URL: https://issues.apache.org/jira/browse/NIFI-4371
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Extensions
> Reporter: Pierre Villard
> Assignee: Pierre Villard
> Priority: Major
> Attachments: Screen Shot 2017-09-09 at 4.31.21 PM.png, Screen Shot
> 2017-09-09 at 6.38.51 PM.png, Screen Shot 2017-09-09 at 6.40.48 PM.png
>
>
> With HIVE-4924 it is possible to set a query timeout when executing a query
> against Hive (starting with Hive 2.1). Right now, NiFi is built using Hive
> 1.2.1 and this feature is not available by default (the method is not
> implemented in the driver). However, if building NiFi with specific profiles
> this feature can be used.
> The objective is to expose the query timeout parameter in the processor and
> enable expression language. If the version of the driver is not implementing
> the query timeout the processor will be in invalid state (unless expression
> language is used, and in this case, the flow file will be routed to the
> failure relationship).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)