具有JavaStringObjectInspector的Hive UDF

时间:2019-10-07 02:01:04

标签: hadoop hive hive-udf

我正在用蜂巢编写UDF

public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
        if (arguments.length != 2) {
            throw new UDFArgumentLengthException(UDF_NAME + " requires 2 arguments.");
        }
        SubTypeInspector = (JavaStringObjectInspector) arguments[1];
        length = (DoubleObjectInspector) arguments[2];
         -------------
         ------------
}

上面的代码给出了以下错误 编译语句时出错:失败:ClassCastException org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableConstantStringObjectInspector无法转换为org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaStringObjectInspector

使用StringObjectInspector进行类型转换可以正常工作。 请帮助我了解StringObjectInspector和JavaStringObjectInspector之间的区别

0 个答案:

没有答案