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

Fix bigquery copy materialization #910

Merged
merged 5 commits into from
Oct 11, 2023
Merged

Conversation

m-sche
Copy link
Contributor

@m-sche m-sche commented Sep 6, 2023

resolves #820

Problem

Since dbt 1.5, bigquery's materialization='copy' does not work due to changed structure of model.refs and the introduction of model versioning. It used to be an array of arrays in 1.4, since 1.5 it is an array of dictionaries.

The ref macro currently accepts one mandatory positional argument (name), one optional positional argument (package), and one optional keyword argument (version).

Model versioning docs: https://docs.getdbt.com/docs/collaborate/govern/model-versions
Ref macro arguments docs: https://docs.getdbt.com/reference/dbt-jinja-functions/ref#advanced-ref-usage

Solution

This PR adapts to the new structure of model.refs and allows for an optional version argument.

A functional test has been added to test if a very simple copy/incremental materialization works. This test should catch similar issues in the future. The test fails if executed against the current code and passes when executed against the fixed code in this PR. The test is heavily inspired by test_simple_copy.sql test from this repository.

A similar solution was discussed in #820 but the discussion got stale, hence this PR, but I am keen on receiving any feedback!

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

@m-sche m-sche requested a review from a team as a code owner September 6, 2023 11:47
@m-sche m-sche requested a review from nathaniel-may September 6, 2023 11:47
@cla-bot
Copy link

cla-bot bot commented Sep 6, 2023

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @m-sche-sky

@cla-bot cla-bot bot added the cla:yes label Sep 6, 2023
@m-sche
Copy link
Contributor Author

m-sche commented Sep 6, 2023

Added a changie entry and fixed an account from which the commits were created

@m-sche
Copy link
Contributor Author

m-sche commented Sep 20, 2023

From my point of view, this PR is ready for review, please let me know if there's anything missing :)

@dataders dataders added ok to test ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering labels Oct 9, 2023
@mikealfare mikealfare merged commit 2c1d4ea into dbt-labs:main Oct 11, 2023
22 checks passed
@dbeatty10
Copy link
Contributor

@mikealfare and @dataders:

I just added backport labels for 1.5 and 1.6 per #820 (comment).

What else do we need to do to create backport PRs for these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ok to test ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ADAP-695] [Regression] Error when use REF inside COPY materialization
4 participants