-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support kms in haversine_distance macro (#340)
- Loading branch information
1 parent
6c1abd3
commit 4b58de9
Showing
10 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lat_1,lon_1,lat_2,lon_2,output | ||
48.864716,2.349014,52.379189,4.899431,430 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lat_1,lon_1,lat_2,lon_2,output | ||
48.864716,2.349014,52.379189,4.899431,267 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: test_haversine_distance_km | ||
tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected | ||
- name: test_haversine_distance_mi | ||
tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected |
23 changes: 23 additions & 0 deletions
23
integration_tests/models/geo/test_haversine_distance_km.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
with data as ( | ||
select * from {{ ref('data_haversine_km') }} | ||
), | ||
final as ( | ||
select | ||
output as expected, | ||
cast( | ||
{{ | ||
dbt_utils.haversine_distance( | ||
lat1='lat_1', | ||
lon1='lon_1', | ||
lat2='lat_2', | ||
lon2='lon_2', | ||
unit='km' | ||
) | ||
}} as numeric | ||
) as actual | ||
from data | ||
) | ||
select | ||
expected, | ||
round(actual,0) as actual | ||
from final |
39 changes: 39 additions & 0 deletions
39
integration_tests/models/geo/test_haversine_distance_mi.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
with data as ( | ||
select * from {{ ref('data_haversine_mi') }} | ||
), | ||
final as ( | ||
select | ||
output as expected, | ||
cast( | ||
{{ | ||
dbt_utils.haversine_distance( | ||
lat1='lat_1', | ||
lon1='lon_1', | ||
lat2='lat_2', | ||
lon2='lon_2', | ||
unit='mi' | ||
) | ||
}} as numeric | ||
) as actual | ||
from data | ||
|
||
union all | ||
|
||
select | ||
output as expected, | ||
cast( | ||
{{ | ||
dbt_utils.haversine_distance( | ||
lat1='lat_1', | ||
lon1='lon_1', | ||
lat2='lat_2', | ||
lon2='lon_2', | ||
) | ||
}} as numeric | ||
) as actual | ||
from data | ||
) | ||
select | ||
expected, | ||
round(actual,0) as actual | ||
from final |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters