FAQ
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;
}
}

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupuser @
categorieshive, hadoop
postedNov 2, '10 at 4:46p
activeNov 2, '10 at 7:12p
posts3
users2
websitehive.apache.org

2 users in discussion

Tim Robertson: 2 posts Edward Capriolo: 1 post

People

Translate

site design / logo © 2021 Grokbase