Skip to content

Commit fa915ca

Browse files
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! try converting the lon lat args for bq
1 parent 2a6c334 commit fa915ca

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

macros/geo/haversine_distance.sql

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ The arguments should be float type.
3535
{% set r_lat2 = dbt_utils.degrees_to_radians(lat2) %}
3636
{% set r_lon1 = dbt_utils.degrees_to_radians(lon1) %}
3737
{% set r_lon2 = dbt_utils.degrees_to_radians(lon2) %}
38+
{# vanilla macro is in miles #}
39+
{% set conversion_rate = '' %}
40+
{% if unit == 'km' %}
41+
{# we multiply miles result to get it in kms #}
42+
{% set conversion_rate = '* 1.60934' %}
43+
{% endif %}
3844

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

0 commit comments

Comments
 (0)