如何在java中获取基本对象检查器的字段名

如何在java中获取基本对象检查器的字段名,java,hive,user-defined-functions,hiveql,object-inspector,Java,Hive,User Defined Functions,Hiveql,Object Inspector,我试图为我为hiveql环境创建的UDF解决这个问题 public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 1) { throw new UDFArgumentException("Usage : multiple_prop(primitive var) ");

我试图为我为hiveql环境创建的UDF解决这个问题

public ObjectInspector initialize(ObjectInspector[] arguments)
            throws UDFArgumentException {
    if (arguments.length != 1) {
        throw new UDFArgumentException("Usage : multiple_prop(primitive var) ");
    }
    // This will be an string
    moi = (PrimitiveObjectInspector) arguments[0];

    ArrayList structFieldNames = new ArrayList();
    ArrayList structFieldObjectInspectors = new ArrayList();

    structFieldNames.add("fields name"); <-- Issue is here
完成此操作后,我想从hive中将此udf称为:

CREATE TEMPORARY FUNCTION step AS 'UDFpack.prop_step2';
select 
step(bit) as sd
from my_table

我希望如果在上面的选择中,我这样做了:sd.bit,我会得到'bit'的值

这根本不可能。传递给UDF(ObjectInspector)的信息不包含其名称。这就是为什么您可以看到输出列名被更改为_col0,_col1。。在蜂巢计划的中间阶段。我对此也很恼火,认为这是蜂巢的疏忽

一种解决方法是将您的输入放入一个结构并对其进行解析


i、 e步骤(名为_struct('bit',bit)),然后可以在自定义项中获取结构的字段名。但这并不是那么好

你能展示更多让我们了解你的问题吗。在最后一个问题中,您的意思是
structObjectInspectors
,还是应该是
structFieldObjectInspectors
?我在任何地方都看不到varialble
structObjectInspectors
。好的,我会尝试添加其余的代码,尽管我认为它与这个具体任务并不相关。另外,stackoverflow在长代码方面有点问题,它一直在寻找每一段代码的描述,以便能够发布它,所以我不得不省略一些部分<代码>structObjectInspector没有出现在这段代码中,我的意思是,如果“moi”是一个
structObjectInspector
而不是
primitiveObjectInspector
任务,那么就很容易完成。
CREATE TEMPORARY FUNCTION step AS 'UDFpack.prop_step2';
select 
step(bit) as sd
from my_table