diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java index 2fb9a52..849f69b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/PartitionPrune.java @@ -22,7 +22,10 @@ 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 static class ExtractPartPruningPredicate extends RexVisitorImpl { - + private static final Log LOG = LogFactory.getLog(ExtractPartPruningPredicate.class); final RelOptHiveTable hiveTable; final RelDataType rType; final Set partCols; @@ -106,12 +109,24 @@ public RexNode visitCall(RexCall call) { List args = new LinkedList(); boolean argsPruned = false; - - GenericUDF hiveUDF = SqlFunctionConverter.getHiveUDF(call.getOperator(), + GenericUDF hiveUDF = null; + try { + hiveUDF = SqlFunctionConverter.getHiveUDF(call.getOperator(), call.getType(), call.operands.size()); - if (hiveUDF != null && + if (hiveUDF != null && !FunctionRegistry.isDeterministic(hiveUDF)) { - return null; + return null; + } + } finally { + if (hiveUDF != null) { + try { + hiveUDF.close(); + } catch (IOException e) { + if (LOG != null && LOG.isDebugEnabled()) { + LOG.debug("Exception in closing " + hiveUDF, e); + } + } + } } for (RexNode operand : call.operands) {