Skip to content
Advertisement

In Hive, how to convert an array of string to an array of numeric numbers

I have a hive table that looks like the following:

I want the result to be the following:

I need to convert them into an array of float so that I can use them in ST_Constains(ST_MultiPolygon(), st_point()) to determine if a point is in an area.

I am new to Hive, not sure if that is possible, any help would be very appreciated.

Advertisement

Answer

You can explode array, cast value, collect array again. Demo:

Result:

See also this answer about sorting array in the query https://stackoverflow.com/a/57392965/2700344

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement