Hive UDF找不到UNKNOWN的ObjectInspector

时间:2019-02-18 04:14:27

标签: hive

我有一个简单的UDF,可以最小化Oracle解码功能,

import org.apache.hadoop.hive.ql.exec.UDF;

public class OracleDecodeUDF extends UDF {

    public Object evaluate(Object... args) {
        if (args.length <= 2) {
            throw new IllegalArgumentException("Expected number of OracleDecodeUDF arguments should be greater then 2, actual is " + args.length);
        }

        if (args[0] == null) {
            return null;
        }

        Object defaultValue = null;
        if (args.length % 2 == 0) {
            defaultValue = args[args.length - 1];
        }

        for (int i = 1; i <=  (args.length - 1) / 2; i++) {
            if (args[0].equals(args[i * 2 - 1])) return args[i * 2];
        }

        return defaultValue;
    }



}

当我在Hive中部署并调用该函数时,会出现一条错误消息:

Hive UDF Cannot find ObjectInspector for UNKNOWN

我不知道问题出在哪里,Hive不支持Object,不是具体类型:String,Integer..etc

0 个答案:

没有答案
相关问题