From 98f8bddfff816c8b2f7995f8aa80acf4b58a1c92 Mon Sep 17 00:00:00 2001 From: Ashutosh Chauhan Date: Mon, 13 Apr 2015 16:28:23 -0700 Subject: [PATCH] HIVE-10327 : Remove ExprNodeNullDesc --- .../hive/ql/exec/ExprNodeEvaluatorFactory.java | 14 ++--- .../hive/ql/exec/ExprNodeGenericFuncEvaluator.java | 3 +- .../hadoop/hive/ql/exec/ExprNodeNullEvaluator.java | 47 --------------- .../hive/ql/exec/vector/VectorizationContext.java | 13 ++-- .../ql/optimizer/ConstantPropagateProcFactory.java | 32 ++++------ .../hadoop/hive/ql/optimizer/GroupByOptimizer.java | 7 +-- .../optimizer/PrunerExpressionOperatorFactory.java | 3 - .../hive/ql/optimizer/SimpleFetchOptimizer.java | 2 - .../calcite/translator/RexNodeConverter.java | 5 +- .../hive/ql/optimizer/lineage/ExprProcFactory.java | 3 +- .../hive/ql/optimizer/pcr/PcrExprProcFactory.java | 3 +- .../hadoop/hive/ql/parse/TableAccessAnalyzer.java | 6 +- .../hadoop/hive/ql/parse/TypeCheckProcFactory.java | 4 +- .../hadoop/hive/ql/plan/ExprNodeConstantDesc.java | 1 - .../hadoop/hive/ql/plan/ExprNodeNullDesc.java | 69 ---------------------- .../apache/hadoop/hive/ql/stats/StatsUtils.java | 12 +--- .../hive/ql/udf/generic/GenericUDFCoalesce.java | 2 +- .../hive/ql/udf/generic/GenericUDFGreatest.java | 1 + .../hive/ql/udf/generic/GenericUDFInstr.java | 2 +- .../hive/ql/udf/generic/GenericUDFLocate.java | 2 +- .../hive/ql/udf/generic/GenericUDFPrintf.java | 3 +- .../hive/ql/udf/generic/GenericUDFTranslate.java | 8 +-- .../hive/ql/udf/generic/GenericUDFUtils.java | 6 +- .../clientpositive/annotate_stats_filter.q.out | 4 +- ql/src/test/results/clientpositive/input6.q.out | 2 +- .../results/clientpositive/join_nullsafe.q.out | 10 ++-- .../subquery_notin_having.q.java1.7.out | 2 +- .../results/clientpositive/vector_coalesce.q.out | 6 +- .../hadoop/hive/serde2/io/HiveVarcharWritable.java | 7 +-- .../AbstractPrimitiveObjectInspector.java | 1 + .../primitive/WritableVoidObjectInspector.java | 5 ++ 31 files changed, 66 insertions(+), 219 deletions(-) delete mode 100644 ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeNullEvaluator.java delete mode 100644 ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeNullDesc.java diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java index ff0ddc8..f08321c 100755 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeEvaluatorFactory.java @@ -27,7 +27,8 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; +import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; +import org.apache.hadoop.io.NullWritable; /** * ExprNodeEvaluatorFactory. @@ -55,11 +56,6 @@ public static ExprNodeEvaluator get(ExprNodeDesc desc) throws HiveException { if (desc instanceof ExprNodeFieldDesc) { return new ExprNodeFieldEvaluator((ExprNodeFieldDesc) desc); } - // Null node, a constant node with value NULL and no type information - if (desc instanceof ExprNodeNullDesc) { - return new ExprNodeNullEvaluator((ExprNodeNullDesc) desc); - } - throw new RuntimeException( "Cannot find ExprNodeEvaluator for the exprNodeDesc = " + desc); } @@ -114,14 +110,14 @@ private static ExprNodeEvaluator iterate(ExprNodeEvaluator eval, EvaluatorContex private static class EvaluatorContext { - private final Map cached = + private final Map cached = new HashMap(); private boolean hasReference; public ExprNodeEvaluator getEvaluated(ExprNodeEvaluator eval) { - ExprNodeDesc.ExprNodeDescEqualityWrapper key = - new ExprNodeDesc.ExprNodeDescEqualityWrapper(eval.expr); + ExprNodeDesc.ExprNodeDescEqualityWrapper key = + new ExprNodeDesc.ExprNodeDescEqualityWrapper(eval.expr); ExprNodeEvaluator prev = cached.get(key); if (prev == null) { cached.put(key, eval); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java index b695bef..b09b706 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java @@ -78,9 +78,10 @@ public void prepare(int version) throws HiveException { } public boolean needsPrepare() { - return !(eval instanceof ExprNodeConstantEvaluator || eval instanceof ExprNodeNullEvaluator); + return !(eval instanceof ExprNodeConstantEvaluator); } + @Override public Object get() throws HiveException { if (!evaluated) { obj = eval.evaluate(rowObject, version); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeNullEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeNullEvaluator.java deleted file mode 100644 index 3aaf17c..0000000 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeNullEvaluator.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.ql.exec; - -import org.apache.hadoop.hive.ql.metadata.HiveException; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; -import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; - -// This function will not be used currently, since the function expressions -// change the void to the first matching argument -/** - * ExprNodeNullEvaluator. - * - */ -public class ExprNodeNullEvaluator extends ExprNodeEvaluator { - - public ExprNodeNullEvaluator(ExprNodeNullDesc expr) { - super(expr); - } - - @Override - public ObjectInspector initialize(ObjectInspector rowInspector) throws HiveException { - return outputOI = PrimitiveObjectInspectorFactory.writableVoidObjectInspector; - } - - @Override - protected Object _evaluate(Object row, int version) throws HiveException { - return null; - } -} diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java index df39218..48f34a9 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizationContext.java @@ -92,7 +92,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.GroupByDesc; import org.apache.hadoop.hive.ql.udf.SettableUDF; import org.apache.hadoop.hive.ql.udf.UDFConv; @@ -441,7 +440,7 @@ public VectorExpression getVectorExpression(ExprNodeDesc exprDesc, Mode mode) th ve = getGenericUdfVectorExpression(expr.getGenericUDF(), childExpressions, mode, exprDesc.getTypeInfo()); } - } else if (exprDesc instanceof ExprNodeNullDesc) { + } else if (exprDesc instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)exprDesc).getValue()) { ve = getConstantVectorExpression(null, exprDesc.getTypeInfo(), mode); } else if (exprDesc instanceof ExprNodeConstantDesc) { ve = getConstantVectorExpression(((ExprNodeConstantDesc) exprDesc).getValue(), exprDesc.getTypeInfo(), @@ -1450,7 +1449,7 @@ private VectorExpression getCastToDecimal(List childExpr, TypeInfo Object constantValue = ((ExprNodeConstantDesc) child).getValue(); HiveDecimal decimalValue = castConstantToDecimal(constantValue, child.getTypeInfo()); return getConstantVectorExpression(decimalValue, returnType, Mode.PROJECTION); - } else if (child instanceof ExprNodeNullDesc) { + } else if (child instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)child).getValue()) { return getConstantVectorExpression(null, returnType, Mode.PROJECTION); } if (isIntFamily(inputType)) { @@ -1477,7 +1476,7 @@ private VectorExpression getCastToString(List childExpr, TypeInfo Object constantValue = ((ExprNodeConstantDesc) child).getValue(); String strValue = castConstantToString(constantValue, child.getTypeInfo()); return getConstantVectorExpression(strValue, returnType, Mode.PROJECTION); - } else if (child instanceof ExprNodeNullDesc) { + } else if (child instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)child).getValue()) { return getConstantVectorExpression(null, returnType, Mode.PROJECTION); } if (inputType.equals("boolean")) { @@ -1564,7 +1563,7 @@ private VectorExpression getCastToDoubleExpression(Class udf, List childExpr) // Don't do constant folding here. Wait until the optimizer is changed to do it. // Family of related JIRAs: HIVE-7421, HIVE-7422, and HIVE-7424. return null; - } else if (child instanceof ExprNodeNullDesc) { + } else if (child instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)child).getValue()) { return getConstantVectorExpression(null, TypeInfoFactory.booleanTypeInfo, Mode.PROJECTION); } // Long and double are handled using descriptors, string needs to be specially handled. @@ -1620,7 +1619,7 @@ private VectorExpression getCastToLongExpression(List childExpr) Object constantValue = ((ExprNodeConstantDesc) child).getValue(); Long longValue = castConstantToLong(constantValue, child.getTypeInfo()); return getConstantVectorExpression(longValue, TypeInfoFactory.longTypeInfo, Mode.PROJECTION); - } else if (child instanceof ExprNodeNullDesc) { + } else if (child instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)child).getValue()) { return getConstantVectorExpression(null, TypeInfoFactory.longTypeInfo, Mode.PROJECTION); } // Float family, timestamp are handled via descriptor based lookup, int family needs diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java index f536ef6..3486cee 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java @@ -54,7 +54,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.FileSinkDesc; import org.apache.hadoop.hive.ql.plan.GroupByDesc; import org.apache.hadoop.hive.ql.plan.JoinCondDesc; @@ -84,11 +83,11 @@ import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils; -import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableConstantBooleanObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo; +import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils; -import org.apache.hadoop.io.BooleanWritable; +import org.apache.hadoop.io.NullWritable; import com.google.common.collect.ImmutableSet; @@ -140,7 +139,7 @@ public static ColumnInfo resolveColumn(RowSchema rs, * @return cast constant, or null if the type cast failed. */ private static ExprNodeConstantDesc typeCast(ExprNodeDesc desc, TypeInfo ti) { - if (desc instanceof ExprNodeNullDesc) { + if (desc instanceof ExprNodeConstantDesc && null == ((ExprNodeConstantDesc)desc).getValue()) { return null; } if (!(ti instanceof PrimitiveTypeInfo) || !(desc.getTypeInfo() instanceof PrimitiveTypeInfo)) { @@ -351,7 +350,7 @@ private static void propagate(GenericUDF udf, List newExprs, RowSc ExprNodeColumnDesc c = (ExprNodeColumnDesc) operand; ColumnInfo ci = resolveColumn(rs, c); if (ci != null) { - constants.put(ci, new ExprNodeNullDesc()); + constants.put(ci, new ExprNodeConstantDesc(ci.getType(), null)); } } } @@ -422,11 +421,8 @@ private static ExprNodeDesc shortcutFunction(GenericUDF udf, List return null; } ExprNodeDesc thenExpr = newExprs.get(1); - if (thenExpr instanceof ExprNodeNullDesc && (newExprs.size() == 2 || newExprs.get(2) instanceof ExprNodeNullDesc)) { - return thenExpr; - } ExprNodeDesc elseExpr = newExprs.size() == 3 ? newExprs.get(2) : - new ExprNodeConstantDesc(newExprs.get(2).getTypeInfo(),null); + new ExprNodeConstantDesc(newExprs.get(1).getTypeInfo(),null); ExprNodeDesc whenExpr = newExprs.get(0); if (whenExpr instanceof ExprNodeConstantDesc) { @@ -444,7 +440,7 @@ private static ExprNodeDesc shortcutFunction(GenericUDF udf, List } else if(thenVal.equals(elseVal)){ return thenExpr; } else if (thenVal instanceof Boolean && elseVal instanceof Boolean) { - return Boolean.TRUE.equals(thenVal) ? newExprs.get(0) : + return Boolean.TRUE.equals(thenVal) ? whenExpr : ExprNodeGenericFuncDesc.newInstance(new GenericUDFOPNot(), newExprs.subList(0, 1)); } else { return null; @@ -461,10 +457,6 @@ private static ExprNodeDesc shortcutFunction(GenericUDF udf, List return null; } ExprNodeDesc thenExpr = newExprs.get(2); - if (thenExpr instanceof ExprNodeNullDesc && (newExprs.size() == 3 || newExprs.get(3) instanceof ExprNodeNullDesc)) { - return thenExpr; - } - ExprNodeDesc elseExpr = newExprs.size() == 4 ? newExprs.get(3) : new ExprNodeConstantDesc(newExprs.get(2).getTypeInfo(),null); @@ -559,16 +551,14 @@ private static ExprNodeDesc evaluateFunction(GenericUDF udf, List } Object value = constant.getValue(); PrimitiveTypeInfo pti = (PrimitiveTypeInfo) constant.getTypeInfo(); - Object writableValue = + Object writableValue = null == value ? value : PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(pti) .getPrimitiveWritableObject(value); arguments[i] = new DeferredJavaObject(writableValue); argois[i] = ObjectInspectorUtils.getConstantObjectInspector(constant.getWritableObjectInspector(), writableValue); - } else if (desc instanceof ExprNodeNullDesc) { - argois[i] = desc.getWritableObjectInspector(); - arguments[i] = new DeferredJavaObject(((ExprNodeNullDesc) desc).getValue()); + } else if (desc instanceof ExprNodeGenericFuncDesc) { ExprNodeDesc evaluatedFn = foldExpr((ExprNodeGenericFuncDesc)desc); if (null == evaluatedFn || !(evaluatedFn instanceof ExprNodeConstantDesc)) { @@ -593,7 +583,7 @@ private static ExprNodeDesc evaluateFunction(GenericUDF udf, List return new ExprNodeConstantDesc(((PrimitiveObjectInspector) oi).getTypeInfo(), o); } - return new ExprNodeNullDesc(); + return new ExprNodeConstantDesc(null, TypeInfoFactory.getPrimitiveTypeInfoFromPrimitiveWritable(NullWritable.class)); } Class clz = o.getClass(); if (PrimitiveObjectInspectorUtils.isPrimitiveWritableClass(clz)) { @@ -686,7 +676,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. LOG.warn("Filter expression " + condn + " holds false!"); } } - if (newCondn instanceof ExprNodeNullDesc || (newCondn instanceof ExprNodeConstantDesc && ((ExprNodeConstantDesc)newCondn).getValue() == null)) { + if (newCondn instanceof ExprNodeConstantDesc && ((ExprNodeConstantDesc)newCondn).getValue() == null) { // where null is same as where false newCondn = new ExprNodeConstantDesc(Boolean.FALSE); } @@ -1027,7 +1017,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. List newExprs = new ArrayList(); for (ExprNodeDesc expr : exprs) { ExprNodeDesc newExpr = foldExpr(expr, constants, cppCtx, op, tag, false); - if (newExpr instanceof ExprNodeConstantDesc || newExpr instanceof ExprNodeNullDesc) { + if (newExpr instanceof ExprNodeConstantDesc) { LOG.info("expr " + newExpr + " fold from " + expr + " is removed."); continue; } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/GroupByOptimizer.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/GroupByOptimizer.java index 1e47fcb..af54286 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/GroupByOptimizer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/GroupByOptimizer.java @@ -55,7 +55,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.GroupByDesc; import org.apache.hadoop.hive.ql.plan.OperatorDesc; import org.apache.hadoop.hive.ql.plan.SelectDesc; @@ -340,9 +339,6 @@ protected GroupByOptimizerSortMatch checkSortGroupBy(Stack stack, } else { tableColsMapping.remove(outputColumnName); - if (selectCol instanceof ExprNodeNullDesc) { - newConstantCols.add(outputColumnName); - } if (selectCol instanceof ExprNodeConstantDesc) { // Lets see if this constant was folded because of optimization. String origCol = ((ExprNodeConstantDesc) selectCol).getFoldedFromCol(); @@ -380,8 +376,7 @@ protected GroupByOptimizerSortMatch checkSortGroupBy(Stack stack, } } // Constants and nulls are OK - else if ((expr instanceof ExprNodeConstantDesc) || - (expr instanceof ExprNodeNullDesc)) { + else if (expr instanceof ExprNodeConstantDesc) { continue; } else { return GroupByOptimizerSortMatch.NO_MATCH; diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerExpressionOperatorFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerExpressionOperatorFactory.java index e633fdc..306e714 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerExpressionOperatorFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/PrunerExpressionOperatorFactory.java @@ -30,7 +30,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; /** * Expression processor factory for pruning. Each processor tries to @@ -182,8 +181,6 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { if (nd instanceof ExprNodeConstantDesc) { return ((ExprNodeConstantDesc) nd).clone(); - } else if (nd instanceof ExprNodeNullDesc) { - return ((ExprNodeNullDesc) nd).clone(); } return new ExprNodeConstantDesc(((ExprNodeDesc)nd).getTypeInfo(), null); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java index 0328007..317454d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/SimpleFetchOptimizer.java @@ -64,7 +64,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.FetchWork; import org.apache.hadoop.hive.ql.plan.ListSinkDesc; import org.apache.hadoop.hive.ql.plan.OperatorDesc; @@ -262,7 +261,6 @@ private boolean checkExpressions(SelectOperator op) { private boolean checkExpression(ExprNodeDesc expr) { if (expr instanceof ExprNodeConstantDesc || - expr instanceof ExprNodeNullDesc|| expr instanceof ExprNodeColumnDesc) { return true; } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java index abd7afd..3d05161 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java @@ -63,7 +63,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDescUtils; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.udf.generic.GenericUDF; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseBinary; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseCompare; @@ -124,9 +123,7 @@ public RexNodeConverter(RelOptCluster cluster, List inpCtxLst, boolean } public RexNode convert(ExprNodeDesc expr) throws SemanticException { - if (expr instanceof ExprNodeNullDesc) { - return createNullLiteral(expr); - } else if (expr instanceof ExprNodeGenericFuncDesc) { + if (expr instanceof ExprNodeGenericFuncDesc) { return convert((ExprNodeGenericFuncDesc) expr); } else if (expr instanceof ExprNodeConstantDesc) { return convert((ExprNodeConstantDesc) expr); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/lineage/ExprProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/lineage/ExprProcFactory.java index 86d221d..c930b80 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/lineage/ExprProcFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/lineage/ExprProcFactory.java @@ -49,7 +49,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.OperatorDesc; /** @@ -136,7 +135,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, @Override public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { - assert (nd instanceof ExprNodeConstantDesc || nd instanceof ExprNodeNullDesc); + assert (nd instanceof ExprNodeConstantDesc); // Create a dependency that has no basecols Dependency dep = new Dependency(); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/pcr/PcrExprProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/pcr/PcrExprProcFactory.java index cbd4e6c..d5102bc 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/pcr/PcrExprProcFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/pcr/PcrExprProcFactory.java @@ -46,7 +46,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.serde2.SerDeException; import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; @@ -392,7 +391,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, @Override public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { - if (nd instanceof ExprNodeConstantDesc || nd instanceof ExprNodeNullDesc) { + if (nd instanceof ExprNodeConstantDesc) { return new NodeInfoWrapper(WalkState.CONSTANT, null, (ExprNodeDesc) nd); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TableAccessAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TableAccessAnalyzer.java index 01398f0..cc0a7d1 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TableAccessAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TableAccessAnalyzer.java @@ -45,7 +45,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.OperatorDesc; import org.apache.hadoop.hive.ql.plan.SelectDesc; @@ -291,8 +290,7 @@ private static boolean genColNameMap( continue; } - if ((colExpr instanceof ExprNodeConstantDesc) || - (colExpr instanceof ExprNodeNullDesc)) { + if (colExpr instanceof ExprNodeConstantDesc) { currColNames.remove(outputColName); continue; } else if (colExpr instanceof ExprNodeColumnDesc) { @@ -317,7 +315,7 @@ private static boolean genColNameMap( if (expr instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colExpr = (ExprNodeColumnDesc)expr; colList.add(colExpr.getColumn()); - } else if (expr instanceof ExprNodeConstantDesc || expr instanceof ExprNodeNullDesc) { + } else if (expr instanceof ExprNodeConstantDesc) { continue; } else { return null; diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java index a38511a..0e97530 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java @@ -59,7 +59,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.udf.SettableUDF; import org.apache.hadoop.hive.ql.udf.generic.GenericUDF; import org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseCompare; @@ -78,6 +77,7 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo; +import org.apache.hadoop.io.NullWritable; import org.apache.hive.common.util.DateUtils; import com.google.common.collect.Lists; @@ -240,7 +240,7 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx procCtx, return desc; } - return new ExprNodeNullDesc(); + return new ExprNodeConstantDesc(TypeInfoFactory.getPrimitiveTypeInfoFromPrimitiveWritable(NullWritable.class), null); } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeConstantDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeConstantDesc.java index b15df0f..89a175e 100755 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeConstantDesc.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeConstantDesc.java @@ -84,7 +84,6 @@ public Object getValue() { @Override public ConstantObjectInspector getWritableObjectInspector() { PrimitiveTypeInfo pti = (PrimitiveTypeInfo) getTypeInfo(); - PrimitiveCategory pc = pti.getPrimitiveCategory(); // Convert from Java to Writable Object writableValue = PrimitiveObjectInspectorFactory .getPrimitiveJavaObjectInspector(pti).getPrimitiveWritableObject( diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeNullDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeNullDesc.java deleted file mode 100644 index 25b16da..0000000 --- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeNullDesc.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.ql.plan; - -import java.io.Serializable; - -import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory; -import org.apache.hadoop.io.NullWritable; - -/** - * ExprNodeNullDesc. - * - */ -public class ExprNodeNullDesc extends ExprNodeDesc implements Serializable { - - private static final long serialVersionUID = 1L; - - public ExprNodeNullDesc() { - super(TypeInfoFactory - .getPrimitiveTypeInfoFromPrimitiveWritable(NullWritable.class)); - } - - public Object getValue() { - return null; - } - - @Override - public String toString() { - return "null"; - } - - @Override - public String getExprString() { - return "null"; - } - - @Override - public ExprNodeDesc clone() { - return new ExprNodeNullDesc(); - } - - @Override - public boolean isSame(Object o) { - if (!(o instanceof ExprNodeNullDesc)) { - return false; - } - if (!typeInfo.equals(((ExprNodeNullDesc) o).getTypeInfo())) { - return false; - } - - return true; - } -} diff --git a/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java index 508d880..10871e4 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java @@ -50,7 +50,6 @@ import org.apache.hadoop.hive.ql.plan.ExprNodeDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeFieldDesc; import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc; -import org.apache.hadoop.hive.ql.plan.ExprNodeNullDesc; import org.apache.hadoop.hive.ql.plan.Statistics; import org.apache.hadoop.hive.ql.plan.Statistics.State; import org.apache.hadoop.hive.ql.util.JavaDataModel; @@ -1151,13 +1150,6 @@ public static ColStatistics getColStatisticsFromExpression(HiveConf conf, Statis colType = engfd.getTypeString(); countDistincts = numRows; oi = engfd.getWritableObjectInspector(); - } else if (end instanceof ExprNodeNullDesc) { - - // null projection - ExprNodeNullDesc ennd = (ExprNodeNullDesc) end; - colName = ennd.getName(); - colType = "null"; - numNulls = numRows; } else if (end instanceof ExprNodeColumnListDesc) { // column list @@ -1473,7 +1465,7 @@ public static long safeMult(long a, double b) { double result = a * b; return (result > Long.MAX_VALUE) ? Long.MAX_VALUE : (long)result; } - + /** Bounded addition - overflows become MAX_VALUE */ public static long safeAdd(long a, long b) { try { @@ -1482,7 +1474,7 @@ public static long safeAdd(long a, long b) { return Long.MAX_VALUE; } } - + /** Bounded multiplication - overflows become MAX_VALUE */ public static long safeMult(long a, long b) { try { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFCoalesce.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFCoalesce.java index 8890e69..aa708ce 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFCoalesce.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFCoalesce.java @@ -25,7 +25,7 @@ /** * GenericUDF Class for SQL construct "COALESCE(a, b, c)". - * + * * NOTES: 1. a, b and c should have the same TypeInfo, or an exception will be * thrown. */ diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFGreatest.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFGreatest.java index e919345..e1eab89 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFGreatest.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFGreatest.java @@ -97,6 +97,7 @@ public String getDisplayString(String[] children) { return getStandardDisplayString(getFuncName(), children, ","); } + @Override protected String getFuncName() { return "greatest"; } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInstr.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInstr.java index 0a13ac9..0f7d4d6 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInstr.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInstr.java @@ -34,7 +34,7 @@ * Generic UDF for string function INSTR(str,substr). This mimcs * the function from MySQL * http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_instr - * + * *
  * usage:
  * INSTR(str, substr)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java
index 094f280..137eb3e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFLocate.java
@@ -34,7 +34,7 @@
  * Generic UDF for string function LOCATE(substr, str),
  * LOCATE(substr, str, start). This mimcs the function from MySQL
  * http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_locate
- * 
+ *
  * 
  * usage:
  * LOCATE(substr, str)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFPrintf.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFPrintf.java
index cb6dd62..e52e431 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFPrintf.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFPrintf.java
@@ -133,8 +133,9 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException {
       }
     }
     formatter.format(pattern.toString(), argumentList.toArray());
-
     resultText.set(sb.toString());
+    formatter.close();
+
     return resultText;
   }
 
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
index 4ac542f..2717f00 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTranslate.java
@@ -41,7 +41,7 @@
 /**
  * TRANSLATE(string input, string from, string to) is an equivalent function to translate in
  * PostGresSQL. See explain extended annotation below to read more about how this UDF works
- * 
+ *
  */
 @UDFType(deterministic = true)
 //@formatter:off
@@ -188,7 +188,7 @@ public Object evaluate(DeferredObject[] arguments) throws HiveException {
   /**
    * Pre-processes the from and to strings by calling {@link #populateMappings(Text, Text)} if
    * necessary.
-   * 
+   *
    * @param from
    *          from string to be used for translation
    * @param to
@@ -215,7 +215,7 @@ private void populateMappingsIfNecessary(Text from, Text to) {
 
   /**
    * Pre-process the from and to strings populate {@link #replacementMap} and {@link #deletionSet}.
-   * 
+   *
    * @param from
    *          from string to be used for translation
    * @param to
@@ -255,7 +255,7 @@ private void populateMappings(Text from, Text to) {
   /**
    * Translates the input string based on {@link #replacementMap} and {@link #deletionSet} and
    * returns the translated string.
-   * 
+   *
    * @param input
    *          input string to perform the translation on
    * @return translated string
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFUtils.java
index 09d2d1f..222e0e0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFUtils.java
@@ -175,7 +175,7 @@ private boolean update(ObjectInspector oi, boolean isUnionAll) throws UDFArgumen
        * that.
        */
       if (commonTypeInfo instanceof DecimalTypeInfo) {
-        if ((!FunctionRegistry.isExactNumericType((PrimitiveTypeInfo) oiTypeInfo)) || 
+        if ((!FunctionRegistry.isExactNumericType((PrimitiveTypeInfo) oiTypeInfo)) ||
             (!FunctionRegistry.isExactNumericType((PrimitiveTypeInfo) rTypeInfo))) {
           commonTypeInfo = TypeInfoFactory.doubleTypeInfo;
         }
@@ -204,8 +204,8 @@ public Object convertIfNecessary(Object o, ObjectInspector oi) {
 
     /**
      * Convert the return Object if necessary (when the ObjectInspectors of
-     * different possibilities are not all the same). If reuse is true, 
-     * the result Object will be the same object as the last invocation 
+     * different possibilities are not all the same). If reuse is true,
+     * the result Object will be the same object as the last invocation
      * (as long as the oi is the same)
      */
     public Object convertIfNecessary(Object o, ObjectInspector oi, boolean reuse) {
diff --git a/ql/src/test/results/clientpositive/annotate_stats_filter.q.out b/ql/src/test/results/clientpositive/annotate_stats_filter.q.out
index e8cd06d..aa66bc6 100644
--- a/ql/src/test/results/clientpositive/annotate_stats_filter.q.out
+++ b/ql/src/test/results/clientpositive/annotate_stats_filter.q.out
@@ -262,7 +262,7 @@ STAGE PLANS:
               predicate: zip is null (type: boolean)
               Statistics: Num rows: 1 Data size: 102 Basic stats: COMPLETE Column stats: COMPLETE
               Select Operator
-                expressions: state (type: string), locid (type: int), null (type: void), year (type: int)
+                expressions: state (type: string), locid (type: int), null (type: bigint), year (type: int)
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 1 Data size: 94 Basic stats: COMPLETE Column stats: COMPLETE
                 File Output Operator
@@ -721,7 +721,7 @@ STAGE PLANS:
               predicate: ((year = 2001) and year is null) (type: boolean)
               Statistics: Num rows: 1 Data size: 102 Basic stats: COMPLETE Column stats: COMPLETE
               Select Operator
-                expressions: state (type: string), locid (type: int), zip (type: bigint), null (type: void)
+                expressions: state (type: string), locid (type: int), zip (type: bigint), null (type: int)
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 1 Data size: 98 Basic stats: COMPLETE Column stats: COMPLETE
                 File Output Operator
diff --git a/ql/src/test/results/clientpositive/input6.q.out b/ql/src/test/results/clientpositive/input6.q.out
index 38c9fe1..5ed2767 100644
--- a/ql/src/test/results/clientpositive/input6.q.out
+++ b/ql/src/test/results/clientpositive/input6.q.out
@@ -35,7 +35,7 @@ STAGE PLANS:
               predicate: key is null (type: boolean)
               Statistics: Num rows: 12 Data size: 91 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: null (type: void), value (type: string)
+                expressions: null (type: string), value (type: string)
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 12 Data size: 91 Basic stats: COMPLETE Column stats: NONE
                 File Output Operator
diff --git a/ql/src/test/results/clientpositive/join_nullsafe.q.out b/ql/src/test/results/clientpositive/join_nullsafe.q.out
index 9bdfcbd..27ceae5 100644
--- a/ql/src/test/results/clientpositive/join_nullsafe.q.out
+++ b/ql/src/test/results/clientpositive/join_nullsafe.q.out
@@ -1523,9 +1523,9 @@ STAGE PLANS:
               predicate: key is null (type: boolean)
               Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
               Reduce Output Operator
-                key expressions: null (type: void)
+                key expressions: null (type: int)
                 sort order: +
-                Map-reduce partition columns: null (type: void)
+                Map-reduce partition columns: null (type: int)
                 Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
                 value expressions: value (type: int)
           TableScan
@@ -1535,9 +1535,9 @@ STAGE PLANS:
               predicate: value is null (type: boolean)
               Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
               Reduce Output Operator
-                key expressions: null (type: void)
+                key expressions: null (type: int)
                 sort order: +
-                Map-reduce partition columns: null (type: void)
+                Map-reduce partition columns: null (type: int)
                 Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
                 value expressions: key (type: int)
       Reduce Operator Tree:
@@ -1551,7 +1551,7 @@ STAGE PLANS:
           outputColumnNames: _col1, _col5
           Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
           Select Operator
-            expressions: null (type: void), _col1 (type: int), _col5 (type: int), null (type: void)
+            expressions: null (type: int), _col1 (type: int), _col5 (type: int), null (type: int)
             outputColumnNames: _col0, _col1, _col2, _col3
             Statistics: Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: NONE
             File Output Operator
diff --git a/ql/src/test/results/clientpositive/subquery_notin_having.q.java1.7.out b/ql/src/test/results/clientpositive/subquery_notin_having.q.java1.7.out
index 2d5b486..c1bbf0e 100644
--- a/ql/src/test/results/clientpositive/subquery_notin_having.q.java1.7.out
+++ b/ql/src/test/results/clientpositive/subquery_notin_having.q.java1.7.out
@@ -658,7 +658,7 @@ STAGE PLANS:
               predicate: p_mfgr is null (type: boolean)
               Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: null (type: void), p_retailprice (type: double)
+                expressions: null (type: string), p_retailprice (type: double)
                 outputColumnNames: _col0, _col1
                 Statistics: Num rows: 13 Data size: 1573 Basic stats: COMPLETE Column stats: NONE
                 Group By Operator
diff --git a/ql/src/test/results/clientpositive/vector_coalesce.q.out b/ql/src/test/results/clientpositive/vector_coalesce.q.out
index c63f2d1..02a4e62 100644
--- a/ql/src/test/results/clientpositive/vector_coalesce.q.out
+++ b/ql/src/test/results/clientpositive/vector_coalesce.q.out
@@ -21,7 +21,7 @@ STAGE PLANS:
               predicate: cdouble is null (type: boolean)
               Statistics: Num rows: 6144 Data size: 1320982 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: null (type: void), cstring1 (type: string), cint (type: int), cfloat (type: float), csmallint (type: smallint), COALESCE(null,cstring1,cint,cfloat,csmallint) (type: string)
+                expressions: null (type: double), cstring1 (type: string), cint (type: int), cfloat (type: float), csmallint (type: smallint), COALESCE(null,cstring1,cint,cfloat,csmallint) (type: string)
                 outputColumnNames: _col0, _col1, _col2, _col3, _col4, _col5
                 Statistics: Num rows: 6144 Data size: 1320982 Basic stats: COMPLETE Column stats: NONE
                 Limit
@@ -87,7 +87,7 @@ STAGE PLANS:
               predicate: ctinyint is null (type: boolean)
               Statistics: Num rows: 6144 Data size: 1320982 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: null (type: void), cdouble (type: double), cint (type: int), COALESCE(null,(cdouble + log2(cint)),0) (type: double)
+                expressions: null (type: tinyint), cdouble (type: double), cint (type: int), COALESCE(null,(cdouble + log2(cint)),0) (type: double)
                 outputColumnNames: _col0, _col1, _col2, _col3
                 Statistics: Num rows: 6144 Data size: 1320982 Basic stats: COMPLETE Column stats: NONE
                 Limit
@@ -153,7 +153,7 @@ STAGE PLANS:
               predicate: (cfloat is null and cbigint is null) (type: boolean)
               Statistics: Num rows: 3072 Data size: 660491 Basic stats: COMPLETE Column stats: NONE
               Select Operator
-                expressions: null (type: void), null (type: void), 0 (type: int)
+                expressions: null (type: float), null (type: bigint), 0.0 (type: float)
                 outputColumnNames: _col0, _col1, _col2
                 Statistics: Num rows: 3072 Data size: 660491 Basic stats: COMPLETE Column stats: NONE
                 Limit
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java
index a165b84..2e24730 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveVarcharWritable.java
@@ -17,14 +17,8 @@
  */
 package org.apache.hadoop.hive.serde2.io;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.hadoop.hive.common.type.HiveBaseChar;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
-import org.apache.hadoop.hive.shims.ShimLoader;
-import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.WritableComparable;
 
 public class HiveVarcharWritable extends HiveBaseCharWritable
@@ -74,6 +68,7 @@ public void enforceMaxLength(int maxLength) {
     set(getHiveVarchar(), maxLength);
   }
 
+  @Override
   public int compareTo(HiveVarcharWritable rhs) {
     return value.compareTo(rhs.value);
   }
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
index baa4a94..0cbd30e 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/AbstractPrimitiveObjectInspector.java
@@ -83,6 +83,7 @@ public String getTypeName() {
     return typeInfo.getTypeName();
   }
 
+  @Override
   public PrimitiveTypeInfo getTypeInfo() {
     return this.typeInfo;
   }
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableVoidObjectInspector.java b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableVoidObjectInspector.java
index f3f4838..8ffc91d 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableVoidObjectInspector.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/primitive/WritableVoidObjectInspector.java
@@ -46,4 +46,9 @@ public Object getWritableConstantValue() {
   public Object getPrimitiveJavaObject(Object o) {
     return null;
   }
+
+  @Override
+  public boolean equals(Object obj) {
+    return null != obj && obj instanceof WritableVoidObjectInspector;
+  }
 }
-- 
1.7.12.4 (Apple Git-37)