Skip to content

Commit 4f08f43

Browse files
datadersjtcohen6
andauthored
power and pow are synonyms (except in for some dialects) (#354)
* power and pow are synonyms (except in TSQL) * contrib * power is more crossdb friendly than pow Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
1 parent a729044 commit 4f08f43

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# dbt-utils Next
2+
3+
14
# dbt-utils v0.7.0 (unreleased)
25
## Breaking changes
36

@@ -46,6 +49,7 @@ If you were relying on the position to match up your optional arguments, this ma
4649

4750
## Under the hood
4851
* Update the default implementation of concat macro to use `||` operator ([#373](https://github.com/fishtown-analytics/dbt-utils/pull/314) [@ChristopheDuong](https://github.com/ChristopheDuong)). Note this may be a breaking change for spark users.
52+
- Use `power()` instead of `pow()` in `generate_series()` and `haversine_distance()` as they are synonyms in most SQL dialects, but some dialects only have `power()` ([#354](https://github.com/fishtown-analytics/dbt-utils/pull/354) from [@swanderz](https://github.com/swanderz))
4953

5054
# dbt-utils v0.6.6
5155

macros/sql/generate_series.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
select
3131

3232
{% for i in range(n) %}
33-
p{{i}}.generated_number * pow(2, {{i}})
33+
p{{i}}.generated_number * power(2, {{i}})
3434
{% if not loop.last %} + {% endif %}
3535
{% endfor %}
3636
+ 1

macros/sql/haversine_distance.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ The arguments should be float type.
2323
{{ exceptions.raise_compiler_error("unit input must be one of 'mi' or 'km'. Got " ~ unit) }}
2424
{% endif %}
2525

26-
2 * 3961 * asin(sqrt(pow((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +
26+
2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +
2727
cos(radians({{lat1}})) * cos(radians({{lat2}})) *
28-
pow((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}
28+
power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}
2929

3030
{%- endmacro %}
3131

@@ -43,9 +43,9 @@ The arguments should be float type.
4343
{% else %}
4444
{{ exceptions.raise_compiler_error("unit input must be one of 'mi' or 'km'. Got " ~ unit) }}
4545
{% endif %}
46-
2 * 3961 * asin(sqrt(pow(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +
46+
2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +
4747
cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *
48-
pow(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}
48+
power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}
4949

5050
{%- endmacro %}
5151

0 commit comments

Comments
 (0)