Vincenty distance in hive

Viewed 58

I am able to calculate vincenty distance in presto but for one of my case, I want to calculate vincenty distance in the hive. I searched, but I am unable to find anything. Is there any way to calculate vincenty distance in the hive.

1 Answers

It seems that you can use the next code also with Impala, but also with HIVE. Thus, in HIVE will be slower.

select
  2 * asin(
      sqrt(
        cos(radians(lat1)) *
        cos(radians(lat2)) *
        pow(sin(radians((lon1 - lon2)/2)), 2)
            +
        pow(sin(radians((lat1 - lat2)/2)), 2)

      )
    ) * 6371 distance_km
  from my_table;

Credits: https://godatadriven.com/blog/distance-calculation-with-impala-or-hive/

Related