-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test data and test for haversine
too many curly brackets make params be strings pass strings remove round to see if this was the problem let's try casting round the output field instead add commas cast the macro result directly rename expected to output is it a rounding error swap the units what is going on... throw a log to see what we get remove curlies try computing in a CTE first' add comma I'm sleeping... fixup! I'm sleeping... rename in CTE dont quote? fix macro and separate unit in two tests fix yaml indent fix indentation in schema yaml alias the field clean up fixup! clean up make the macro log stuff remove logging in test macro remove the select star
- Loading branch information
1 parent
250eb00
commit cf3c822
Showing
8 changed files
with
68 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,4 @@ seeds: | |
|
||
sql: | ||
data_events_20180103: | ||
+schema: events | ||
+schema: events |
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 |
23 changes: 23 additions & 0 deletions
23
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,23 @@ | ||
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 | ||
) | ||
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