Author: navis
Date: Thu Dec 18 07:14:58 2014
New Revision: 1646394
URL: http://svn.apache.org/r1646394
Log:
HIVE-9096 : GenericUDF may be left unclosed in PartitionPrune#visitCall()
(Niranjan Singh via Navis)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java?rev=1646394&r1=1646393&r2=1646394&view=diff
==============================================================================
---
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java
(original)
+++
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java
Thu Dec 18 07:14:58 2014
@@ -22,7 +22,10 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeField;
@@ -64,7 +67,7 @@ public class PartitionPrune {
public static class ExtractPartPruningPredicate extends
RexVisitorImpl<RexNode> {
-
+ private static final Log LOG =
LogFactory.getLog(ExtractPartPruningPredicate.class);
final RelOptHiveTable hiveTable;
final RelDataType rType;
final Set<String> partCols;
@@ -104,16 +107,29 @@ public class PartitionPrune {
return null;
}
- List<RexNode> args = new LinkedList<RexNode>();
- boolean argsPruned = false;
-
- GenericUDF hiveUDF = SqlFunctionConverter.getHiveUDF(call.getOperator(),
- call.getType(), call.operands.size());
- if (hiveUDF != null &&
- !FunctionRegistry.isDeterministic(hiveUDF)) {
- return null;
+ GenericUDF hiveUDF = null;
+ try {
+ hiveUDF = SqlFunctionConverter.getHiveUDF(call.getOperator(),
+ call.getType(), call.operands.size());
+ if (hiveUDF != null &&
+ !FunctionRegistry.isDeterministic(hiveUDF)) {
+ return null;
+ }
+ } finally {
+ if (hiveUDF != null) {
+ try {
+ hiveUDF.close();
+ } catch (IOException e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Exception in closing " + hiveUDF, e);
+ }
+ }
+ }
}
+ List<RexNode> args = new LinkedList<RexNode>();
+ boolean argsPruned = false;
+
for (RexNode operand : call.operands) {
RexNode n = operand.accept(this);
if (n != null) {