查询udf时出错optimizer.constantpropagateprocfactory

slwdgvem  于 2021-06-29  发布在  Hive
关注(0)|答案(0)|浏览(442)

当查询我的通用udf时,我在配置单元中得到以下错误输出:error optimizer.constantpropagateprocfactory:unable to evaluate 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;}
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题