Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! try co…
Browse files Browse the repository at this point in the history
…nverting the lon lat args for bq
  • Loading branch information
bastienboutonnet committed Mar 14, 2021
1 parent 2a6c334 commit fa915ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions macros/geo/haversine_distance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ The arguments should be float type.
{% set r_lat2 = dbt_utils.degrees_to_radians(lat2) %}
{% set r_lon1 = dbt_utils.degrees_to_radians(lon1) %}
{% set r_lon2 = dbt_utils.degrees_to_radians(lon2) %}
{# vanilla macro is in miles #}
{% set conversion_rate = '' %}
{% if unit == 'km' %}
{# we multiply miles result to get it in kms #}
{% set conversion_rate = '* 1.60934' %}
{% endif %}

2 * 3961 * asin(sqrt(pow(sin(({{r_lat2}} - {{r_lat1}}) / 2), 2) +
cos({{r_lat1}}) * cos({{r_lat2}}) *
Expand Down

0 comments on commit fa915ca

Please sign in to comment.