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

Remove extraneous whitespace #529

Merged
merged 12 commits into from
Mar 29, 2022
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- `star()` will only alias columns if a prefix/suffix is provided, to allow the unmodified output to still be used in `group by` clauses etc. [#468](https://github.com/dbt-labs/dbt-utils/pull/468)
- The `sequential_values` test is now compatible with quoted columns [#479](https://github.com/dbt-labs/dbt-utils/pull/479)
- `pivot()` escapes values containing apostrophes [#503](https://github.com/dbt-labs/dbt-utils/pull/503)
- `date_trunc` and `datediff` default macros now have whitespace control to assist with linting and readability [#529](https://github.com/dbt-labs/dbt-utils/pull/529)

## Contributors:
- [grahamwetzler](https://github.com/grahamwetzler) (#473)
Expand All @@ -34,6 +35,7 @@
- [jelstongreen](https://github.com/jelstongreen) (#468)
- [armandduijn](https://github.com/armandduijn) (#479)
- [mdutoo](https://github.com/mdutoo) (#503)
- [sunriselong](https://github.com/sunriselong) (#529)


# dbt-utils v0.8.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ For compatibility details between versions of dbt-core and dbt-utils, [see this
- [insert_by_period](#insert_by_period-source)

----
=======
### Generic Tests
#### equal_rowcount ([source](macros/generic_tests/equal_rowcount.sql))
Asserts that two relations have the same number of rows.
Expand Down
8 changes: 4 additions & 4 deletions macros/cross_db_utils/date_trunc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
{{ return(adapter.dispatch('date_trunc', 'dbt_utils') (datepart, date)) }}
{%- endmacro %}

{% macro default__date_trunc(datepart, date) %}
{% macro default__date_trunc(datepart, date) -%}
date_trunc('{{datepart}}', {{date}})
{% endmacro %}
{%- endmacro %}

{% macro bigquery__date_trunc(datepart, date) %}
{% macro bigquery__date_trunc(datepart, date) -%}
timestamp_trunc(
cast({{date}} as timestamp),
{{datepart}}
)

{% endmacro %}
{%- endmacro %}
16 changes: 8 additions & 8 deletions macros/cross_db_utils/datediff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
{% endmacro %}


{% macro default__datediff(first_date, second_date, datepart) %}
{% macro default__datediff(first_date, second_date, datepart) -%}

datediff(
{{ datepart }},
{{ first_date }},
{{ second_date }}
)

{% endmacro %}
{%- endmacro %}


{% macro bigquery__datediff(first_date, second_date, datepart) %}
{% macro bigquery__datediff(first_date, second_date, datepart) -%}

datetime_diff(
cast({{second_date}} as datetime),
cast({{first_date}} as datetime),
{{datepart}}
)

{% endmacro %}
{%- endmacro %}

{% macro postgres__datediff(first_date, second_date, datepart) %}
{% macro postgres__datediff(first_date, second_date, datepart) -%}

{% if datepart == 'year' %}
(date_part('year', ({{second_date}})::date) - date_part('year', ({{first_date}})::date))
Expand Down Expand Up @@ -55,12 +55,12 @@
{{ exceptions.raise_compiler_error("Unsupported datepart for macro datediff in postgres: {!r}".format(datepart)) }}
{% endif %}

{% endmacro %}
{%- endmacro %}


{# redshift should use default instead of postgres #}
{% macro redshift__datediff(first_date, second_date, datepart) %}
{% macro redshift__datediff(first_date, second_date, datepart) -%}

{{ return(dbt_utils.default__datediff(first_date, second_date, datepart)) }}

{% endmacro %}
{%- endmacro %}