Your Hive version is not latest trunk, right? I suspect the error is fixed in 
HIVE-1378 in trunk.


From: lei liu [mailto:liulei...@gmail.com]
Sent: Tuesday, October 19, 2010 1:41 AM
To: hive-u...@hadoop.apache.org
Subject: I define one UDF function, the UDf retunr List ,but When I use 
ResultSet to receive result hive throw exception

I define one UDF function, like as below :
public class TestUDF extends GenericUDF{

    private ObjectInspector[] argumentOIs;

    @Override
    public Object evaluate(DeferredObject[] arguments) throws HiveException {
      ArrayList<DoubleWritable[]> result = new ArrayList<DoubleWritable[]>();
      DoubleWritable[] bin = new DoubleWritable[2];
      bin[0] = new DoubleWritable(0);
      bin[1] = new DoubleWritable(1);
      result.add(bin);
     return result;
    }

    @Override
    public String getDisplayString(String[] children) {
        // TODO Auto-generated method stub
        return "";
    }

    @Override
    public ObjectInspector initialize(ObjectInspector[] arguments)
            throws UDFArgumentException {
        argumentOIs = arguments;

        ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
        foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
        foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
        ArrayList<String> fname = new ArrayList<String>();
        fname.add("x");
        fname.add("y");

        return 
ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorFactory.getStandardStructObjectInspector(fname,
 foi)) ;
    }

}


When I run  "select id,  test(age) from test1" statement and use ResultSet to 
receive result, hive throw below  exception:
Returning Thrift schema: Schema(fieldSchemas:[FieldSchema(name:id, type:i32, 
comment:null), FieldSchema(name:_c1, type:list<struct<x:double,y:double>>, 
comment:null)], properties:null)
2010-10-19 16:36:22,493 INFO  service.HiveServer 
(HiveServer.java:getThriftSchema(213)) - Returning schema: 
Schema(fieldSchemas:[FieldSchema(name:id, type:i32, comment:null), 
FieldSchema(name:_c1, type:list<struct<x:double,y:double>>, comment:null)], 
properties:null)
org.apache.hadoop.hive.serde2.dynamic_type.ParseException: Encountered "struct" 
at line 1, column 29.
Was expecting one of:
    "bool" ...
    "i16" ...
    "i32" ...
    "i64" ...
    "double" ...
    "string" ...
    "map" ...
    "list" ...
    "set" ...
    <IDENTIFIER> ...

Reply via email to