FAQ
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> ...

Search Discussions

  • Steven Wong at Oct 19, 2010 at 6:48 pm
    Your Hive version is not latest trunk, right? I suspect the error is fixed in HIVE-1378 in trunk.


    From: lei liu
    Sent: Tuesday, October 19, 2010 1:41 AM
    To: hive-user@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> ...
  • Howell, Nathan at Oct 19, 2010 at 9:17 pm
    Try returning a non-empty string from getDisplayString, I've run across this issue before.

    I use a helper class that looks similar to this Scala function:

    override def getDisplayString (children: Array[String]): String =
    children.mkString("FunctionName(", ", ", ")")

    From: Steven Wong
    Sent: Tuesday, October 19, 2010 11:48 AM
    To: user@hive.apache.org; hive-user@hadoop.apache.org
    Subject: RE: I define one UDF function, the UDf retunr List ,but When I use ResultSet to receive result hive throw exception

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


    From: lei liu
    Sent: Tuesday, October 19, 2010 1:41 AM
    To: hive-user@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> ...

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categorieshive, hadoop
postedOct 19, '10 at 8:41a
activeOct 19, '10 at 9:17p
posts3
users3
websitehive.apache.org

People

Translate

site design / logo © 2022 Grokbase