Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haversine distance macro doesn't support kms #338

Closed
1 of 5 tasks
joellabes opened this issue Feb 21, 2021 · 2 comments · Fixed by #340
Closed
1 of 5 tasks

Haversine distance macro doesn't support kms #338

joellabes opened this issue Feb 21, 2021 · 2 comments · Fixed by #340
Labels
bug Something isn't working triage

Comments

@joellabes
Copy link
Contributor

Describe the bug

The macro to calculate the haversine distance between two points always returns its result in miles, which isn't useful for people who use the metric system

Steps to reproduce

Expected results

  • The option to get results in either miles or kilometres (or even kilometers)

Actual results

  • Results in miles

System information

The contents of your packages.yml file:

packages:
  - package: fishtown-analytics/dbt_utils
    version: 0.6.3
  
  - package: fishtown-analytics/audit_helper
    version: 0.3.0

  - package: fishtown-analytics/codegen
    version: 0.3.1

  - package: fishtown-analytics/redshift
    version: 0.4.1

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

0.19.0 (dbt Cloud)

Additional context

The great circle calculator linked from the original macro's source says to use 6373km as the radius of the Earth, which is as good a number as any

Are you interested in contributing the fix?

Yes, but not for a while.

@joellabes joellabes added bug Something isn't working triage labels Feb 21, 2021
@bastienboutonnet
Copy link
Contributor

bastienboutonnet commented Feb 23, 2021

We've taken an approach on this to just wrap that macro in another macro that divides the results of the original haversine macro by 1.60934

May not be super exact but since we're already in the realm of non exact things that might work out.

I'd be happy to PR the haversine data macro and maybe make it take a param for km or mi

@joellabes
Copy link
Contributor Author

Resolved by #340!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants