I get the following error output in hive when querying my Generic UDF: ERROR optimizer.ConstantPropagateProcFactory: Unable to evaluate org.apache.hadoop.hive.ql.udf.generic.GenericUDFMap@554286a4. Return value unrecoginizable.
I get the error in the log almost directly after I start my query but the query then continues and finally it returns a result that looks correct. But what does the error message mean and how to get rid of it?
My query file:
ADD JAR /myUDF.jar;
CREATE TEMPORARY FUNCTION get_state_values as 'com.udf.MyClass';
SELECT
id,
states['Test'] AS test
FROM (
SELECT
id,
get_state_values(my_key_value_input_map)) as states
FROM (
SELECT
id,
map('Test', 'Hello') as my_key_value_input_map
FROM myTable
) a
) b
Important parts of my udf java file:
//This UDF shall take a map as input and return another map as output
public class MyClass extends GenericUDF{
private Map<String, String> currentStates = new HashMap<String, String>();
MapObjectInspector _inputMap;
...
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
_inputMap = (MapObjectInspector) arguments[0];
...
return ObjectInspectorFactory.getStandardMapObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector,PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
public Object evaluate(DeferredObject[] arguments) throws HiveException {
Map<?, ?> inputMap = _inputMap.getMap(arguments[0].get());
if (inputMap != null) {
String value;
for (Map.Entry<?, ?> entry : inputMap.entrySet())
{
value = (entry.getValue() == null ? null : entry.getValue().toString());
currentStates.put(entry.getKey().toString(), value);
}
}
return currentStates;
}
public String getDisplayString(String[] children){return null;}
}