diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFWhen.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFWhen.java index 554af2c..28a568d 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFWhen.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFWhen.java @@ -26,9 +26,10 @@ /** * GenericUDF Class for SQL construct "CASE a WHEN b THEN c [ELSE f] END". - * - * NOTES: 1. a and b should have the same TypeInfo, or an exception will be - * thrown. 2. c and f should have the same TypeInfo, or an exception will be + * + * NOTES: 1. a and b should have the same TypeInfo or a common base type, otherwise an exception + * will be thrown. + * 2. c and f should have the same TypeInfo or a common base type, otherwise an exception will be * thrown. */ public class GenericUDFWhen extends GenericUDF { @@ -39,7 +40,7 @@ public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentTypeException { argumentOIs = arguments; - returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver(); + returnOIResolver = new GenericUDFUtils.ReturnObjectInspectorResolver(true); for (int i = 0; i + 1 < arguments.length; i += 2) { if (!arguments[i].getTypeName().equals(serdeConstants.BOOLEAN_TYPE_NAME)) {