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

dbt utils v1.0.0-rc1 #733

Merged
merged 31 commits into from
Dec 1, 2022
Merged

dbt utils v1.0.0-rc1 #733

merged 31 commits into from
Dec 1, 2022

Conversation

joellabes
Copy link
Contributor

This is a:

  • documentation update
  • bug fix with no breaking changes
  • new functionality
  • a breaking change

All pull requests from community contributors should target the main branch (default).

Description & motivation

Full migration guide to come

Checklist

  • This code is associated with an Issue which has been triaged and accepted for development.
  • I have verified that these changes work locally on the following warehouses (Note: it's okay if you do not have access to all warehouses, this helps us understand what has been covered)
    • BigQuery
    • Postgres
    • Redshift
    • Snowflake
  • I followed guidelines to ensure that my changes will work on "non-core" adapters by:
    • dispatching any new macro(s) so non-core adapters can also use them (e.g. the star() source)
    • using the limit_zero() macro in place of the literal string: limit 0
    • using dbt.type_* macros instead of explicit datatypes (e.g. dbt.type_timestamp() instead of TIMESTAMP
  • I have updated the README.md (if applicable)
  • I have added tests & descriptions to my models (and macros if applicable)
  • I have added an entry to CHANGELOG.md

deanna-minnick and others added 30 commits October 3, 2022 15:05
* Correct link from README to the CONTRIBUTING guide. (#687)

* fix typo (#688)

Co-authored-by: Alex Malins <22991362+alexmalins@users.noreply.github.com>

* Change `escape_single_quotes` Reference in Pivot Macro (#692)

* Update pivot.sql

* Changelog Updates

Co-authored-by: Liam O'Boyle <github@elyobo.net>
Co-authored-by: Alex Malins <github@alexmalins.com>
Co-authored-by: Alex Malins <22991362+alexmalins@users.noreply.github.com>
Co-authored-by: zachoj10 <zjosephson@gmail.com>
* fix syntax errors

* remove whitespace in seed file
* added prefix dbt. on cross db macros

* Also prefix for new macro

* Adding changelog change

* Squashed commit of the following:

commit 5eba82b
Author: Deanna Minnick <deanna.e.minnick@gmail.com>
Date:   Wed Oct 12 10:30:42 2022 -0400

    remove whitespace in seed file

commit 7a2a5e3
Author: Deanna Minnick <deanna.e.minnick@gmail.com>
Date:   Wed Oct 12 10:22:07 2022 -0400

    fix syntax errors

Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* Remove obsolete condition argument from expression_is_true

* Improve docs

* Improve docs
* Update star.sql

* Update star.sql

* feat: add testing to star macro 

column encased in quotes functionality

* chore: update schema.yml

* Update star.sql

* chore: update star.sql and schema.yml

* chore: update star.sql to trim blank space

* Update README.md

* Update README.md

adds example usage of star macro's quote_identifiers argument

Co-authored-by: crlough <connor.lough@pitchbook.com>
* Feature/safe divide (#697)

* add safe_divide documentation

* add safe_divide macro

* add integration test for safe_divide macro

* moved macro and documentation to new SQL generator section

Co-authored-by: Grace Goheen <graciegoheen@gmail.com>

* Revert "Feature/safe divide (#697)" (#702)

This reverts commit f368cec.

* Quick nitpicks (#718)

I was doing some studying on these and spotted some stuff. One verb conjugation and a consistency in macro description

Co-authored-by: deanna-minnick <41010575+deanna-minnick@users.noreply.github.com>
Co-authored-by: Grace Goheen <graciegoheen@gmail.com>
Co-authored-by: ian-fahey-dbt <107962364+ian-fahey-dbt@users.noreply.github.com>
* feat: add query_results_as_single_value.sql macro

* chore: update the macro definition

Current error to work through: "failed to find conversion function from unknown to text"

* chore: update test

* chore: final edits

* chore: remove extra model reference

* chore: update return() to handle BigQuery

* chore: README.md, macro updates

* feat: factoring in first review changes

* chore: updates to testing

* chore: updates tests

* chore: update test for bigquery

* chore: update cast for bigquery

* Use example with a single record in readme

* Add default value when no record found

* test when no results are found

* Rename test file

* Add test definitions

* Fix incorrect ref

* And another one

* Update test_get_query_results_as_single_value.sql

* cast strings as strings

* Put arg in right place

* Update test_get_query_results_as_single_value.sql

* switch to limit zero for BQ

* Update test_get_query_results_as_single_value.sql

* quote column name in arg

* snowflake wont let you safe cast something to itself

* warning to future readers [skip ci]

* Add singular test to check for multi row/multi column setup

* forgot to save comment [skip ci]

* Rename to get_single_value

Co-authored-by: crlough-gitkraken <loughondata@protonmail.com>
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* WIP changing recency test

* Add tests

* cast to timestamp for bq

* forgot the curlies

* avoid lateral column aliasing

* ts not dt

* cast source as timestamp

* don't cast inside test

* cast as date instead of truncate

* Update recency.sql

* log bq events

* store pg artifacts

* int tests dir

* Correctly store artifacts

* try casting to date or datetime

* order of operations more like order of ooperations

* dt -> ts

* Do I really have to cast this?

* Revert "Do I really have to cast this?"

This reverts commit 21e2c0d.
* Change star() behaviour when no columns returned

* Code review: return a * in compile mode
@joellabes
Copy link
Contributor Author

@dbeatty10 even though we discussed doing the release candidate from main, I didn't do that because those last two PRs weren't fully resolved yet and I figured it'd be easier to unwind anything you didn't agree with if it wasn't already on main.

This PR is everything that's changed - either you or I have already reviewed each change independently, but might be useful for us to do one more check of the cohesive whole. Happy to either jump on a call or do it async as you prefer

Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Answer

🤓 This definitely feels like an answer:

image

The Review

either you or I have already reviewed each change independently, but might be useful for us to do one more check of the cohesive whole

👍 But in all seriousness, if each change has already been reviewed by a maintainer, then I'm all for merging as-is.

I'm assuming that doing so would allow all dev work going forward to be on the main branch again?

Proposed follow-up item

As a follow-up item, it would be worth viewing each of the PRs that were merged to the utils-v1 branch and confirm their associated issues are closed.

@joellabes
Copy link
Contributor Author

I'm assuming that doing so would allow all dev work going forward to be on the main branch again?

Indeed! Our long national nightmare is finally over 🎉

confirm their associated issues are closed.

Good idea 🫡

@joellabes joellabes merged commit eb12922 into main Dec 1, 2022
@joellabes joellabes deleted the utils-v1 branch December 6, 2022 00:16
@Vignesh-Pitchaiah
Copy link

Vignesh-Pitchaiah commented Nov 2, 2023

Can you use distinct in inner model, cause it will improve the sql and optimize the search:

with recency as (

    select 

      {{ select_gb_cols }}
      {% if ignore_time_component %}
        cast(max({{ field }}) as date) as most_recent
      {%- else %}
        max({{ field }}) as most_recent
      {%- endif %}

    from {{ model }}

    {{ groupby_gb_cols }}

)

select

    {{ select_gb_cols }}
    most_recent,
    {{ threshold }} as threshold

from recency
where most_recent < {{ threshold }}

@dbeatty10
Copy link
Contributor

@Vignesh-Pitchaiah that sounds like a either a feature request or bug report related to the recency generic test.

Could you open an issue here with all the relevant details?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants