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

[Bigquery] unit test tests + support for complex types #1031

Merged
merged 13 commits into from
Feb 9, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Nov 21, 2023

resolves #1090
docs dbt-labs/docs.getdbt.com/#

Problem

Solution

  • Adds test implementations for base tests around unit testing
  • expands coverage for safe_cast macro.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@cla-bot cla-bot bot added the cla:yes label Nov 21, 2023
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-bigquery contributing guide.

@MichelleArk MichelleArk changed the title first pass: unit test typing unit test typing tests + support for complex types Dec 4, 2023
@MichelleArk MichelleArk changed the title unit test typing tests + support for complex types unit test typing tests + support for single-level arrays & json Dec 4, 2023
@github-christophe-oudar
Copy link
Contributor

Quick question, are the STRUCTs supported? If not, is planned as well? Thanks!

@MichelleArk MichelleArk changed the title unit test typing tests + support for single-level arrays & json [Bigquery] unit test typing tests + support for single-level arrays & json Feb 5, 2024
@MichelleArk
Copy link
Contributor Author

MichelleArk commented Feb 6, 2024

@github-christophe-oudar - sorry for the delayed response but short answer is - yes!

🎩 @jtcohen6 and I were just tophatting the syntax today! Here's an example:

-- models/test_my_model.sql
unit_tests:
  - name: test_my_model
    model: model_b
    given:
      - input: ref('model_a')
        rows:
          - my_field: 'struct(1 as id, "bleu" as color)'
    expect:
      rows:
        - my_field: 'struct(1 as id, "blanc&rouge" as color)'

& here are the logs for a failed test!

image

@MichelleArk MichelleArk changed the title [Bigquery] unit test typing tests + support for single-level arrays & json [Bigquery] unit test tests + support for complex types Feb 6, 2024
@MichelleArk
Copy link
Contributor Author

@github-christophe-oudar
Copy link
Contributor

@MichelleArk, great! I saw the commit yesterday 🚀
I'm watching the PR and I'll test it once it's merged on the main branch 👍 (maybe before locally if I find some time to tinker)

@MichelleArk MichelleArk marked this pull request as ready for review February 9, 2024 15:37
@MichelleArk MichelleArk requested a review from a team as a code owner February 9, 2024 15:37
@mikealfare mikealfare merged commit ea3abee into main Feb 9, 2024
15 checks passed
@mikealfare mikealfare deleted the adapter-unit-test-types branch February 9, 2024 16:48
@github-christophe-oudar
Copy link
Contributor

Just wanted a quick follow up here to say that we're already using unit tests in production beside for the models using UDFs.
My coworker will soon release an article about our usage 👍

@martynydbt
Copy link
Contributor

Looking forward to reading it! @github-christophe-oudar Thank you for sharing!

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

Successfully merging this pull request may close these issues.

[Unit Testing] Support primative types + objects and arrays in dbt-bigquery
4 participants