Thanks Edward.  I'll poke around there.


On Tue, Nov 2, 2010 at 6:40 PM, Edward Capriolo <edlinuxg...@gmail.com> wrote:
> On Tue, Nov 2, 2010 at 12:47 PM, Tim Robertson
> <timrobertson...@gmail.com> wrote:
>> Hi all,
>>
>> Is the following a valid UDF please?
>>
>> When I run it I get the following so I presume not:
>> hive> select toGoogleCoords(latitude,longitude,1) from
>> raw_occurrence_record limit 100;
>> FAILED: Error in semantic analysis:
>> java.lang.IllegalArgumentException: Error: name expected at the
>> position 7 of 'struct<>' but '>' is found.
>>
>> Is it possible to return an Array from a UDF?
>>
>> Thanks for any pointers,
>> Tim
>>
>>
>>
>>
>> public class GoogleTileCoordsUDF extends UDF {
>>
>>  public IntWritable[] evaluate(Text latitude, Text longitude,
>> IntWritable zoomLevel) {
>>    if (latitude == null
>>                || longitude == null
>>                || zoomLevel == null) {
>>      return null;
>>    }
>>
>>    double lat = Double.parseDouble(latitude.toString());
>>    double lng = Double.parseDouble(longitude.toString());
>>
>>    Point p = GoogleTileUtil.toTileXY(lat, lng, zoomLevel.get());
>>
>>    if (p==null) {
>>      return null;
>>    }
>>
>>    IntWritable[] xy = new IntWritable[2];
>>    xy[0]=new IntWritable(p.x);
>>    xy[1]=new IntWritable(p.y);
>>    return xy;
>>  }
>> }
>>
>
> I believe a UDF can not return an Array type. You may have to use the
> GenericUDF interface for that.
>

Reply via email to