diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d8720ffacb..2a684c2bca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# dbt-utils Next + + # dbt-utils v0.7.0 (unreleased) ## Breaking changes @@ -46,6 +49,7 @@ If you were relying on the position to match up your optional arguments, this ma ## Under the hood * 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. +- 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)) # dbt-utils v0.6.6 diff --git a/macros/sql/generate_series.sql b/macros/sql/generate_series.sql index 54dcfad7dc9..efcbd8acf32 100644 --- a/macros/sql/generate_series.sql +++ b/macros/sql/generate_series.sql @@ -30,7 +30,7 @@ select {% for i in range(n) %} - p{{i}}.generated_number * pow(2, {{i}}) + p{{i}}.generated_number * power(2, {{i}}) {% if not loop.last %} + {% endif %} {% endfor %} + 1 diff --git a/macros/sql/haversine_distance.sql b/macros/sql/haversine_distance.sql index f4d541465e1..70f276ecfcd 100644 --- a/macros/sql/haversine_distance.sql +++ b/macros/sql/haversine_distance.sql @@ -23,9 +23,9 @@ The arguments should be float type. {{ exceptions.raise_compiler_error("unit input must be one of 'mi' or 'km'. Got " ~ unit) }} {% endif %} - 2 * 3961 * asin(sqrt(pow((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) + + 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) + cos(radians({{lat1}})) * cos(radians({{lat2}})) * - pow((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }} + power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }} {%- endmacro %} @@ -43,9 +43,9 @@ The arguments should be float type. {% else %} {{ exceptions.raise_compiler_error("unit input must be one of 'mi' or 'km'. Got " ~ unit) }} {% endif %} - 2 * 3961 * asin(sqrt(pow(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) + + 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) + cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) * - pow(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }} + power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }} {%- endmacro %}