查询UDF时出现ERROR optimizer.ConstantPropagateProcFactory

时间:2016-05-02 09:18:26

标签: java hive udf

在查询我的Generic UDF时,我在hive中收到以下错误输出: 错误optimizer.ConstantPropagateProcFactory:无法评估org.apache.hadoop.hive.ql.udf.generic.GenericUDFMap@554286a4。返回值无法记录。

我在启动查询后几乎直接在日志中得到错误但查询然后继续,最后它返回看起来正确的结果。但错误信息意味着什么以及如何摆脱它?

我的查询文件:

    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

我的udf java文件的重要部分:

    //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;}
    }

0 个答案:

没有答案