SELECT bar.latitude, bar.longitude FROM
(SELECT parseCoordinates(latitude, longitude) as coord FROM foo) bar;

JVS

> SELECT parseCoordinates(latitude, longitude) AS lat, lng FROM foo;

On Jan 13, 2011, at 10:10 AM, Lars Francke wrote:

> Hello,
> 
> I'm looking for help with UDFs.
> 
> I need a UDF to do something like this:
> SELECT parseCoordinates(latitude, longitude) AS lat, lng FROM foo;
> 
> But I'm not sure how. I've implemented a UDF using GenericUDF
> returning a struct with two fields and that works as in me getting
> back a struct (e.g. "{"latitude":2.0,"longitude":10.0}") but that's
> still one field and I don't know how to split that back in two
> columns. I could obviously store that in an intermediate table but
> that seems like a hassle and I'd like to avoid it.
> 
> Any ideas how to do this properly?
> 
> I've tried things like:
> SELECT parseCoordinates(latitude, longitude) AS lat, lng FROM foo;
> SELECT parseCoordinates(latitude, longitude) AS (lat, lng) FROM foo;
> SELECT parseCoordinates(latitude, longitude) AS bar, bar.latitude AS
> lat, bar.longitude AS lng FROM foo;
> 
> etc. but I always get an error: FAILED: Error in semantic analysis: AS
> clause has an invalid number of aliases
> 
> Thanks a lot.
> 
> Cheers,
> Lars

Reply via email to