-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add support for altering BigQuery column types #2547
Add support for altering BigQuery column types #2547
Conversation
I just want to clarify my understanding of the implications: dbt only uses the In any case, I agree with your rationale (in #2546) that:
I'm a little uneasy that it requires replacing the entire table, but I guess that's the best of what they recommend. I'm still hopeful for support someday of |
Hey @jtcohen6, the reason I'm implementing this is because my team is planning to use dbt to handle some of our schema management and we have probably 90% of what we need already with the macros that currently exist. So considering there was an In terms of specific schema management use case, our dbt source tables get loaded through various mechanisms and schema changes get propagated through. These schema changes can then cause breaks in our downstream tables that are based on incremental loads. This doesn't mitigate that, but I've built a mini schema management tool that leverages dbt macros to allow us to fix / update schemas as needed. So for this particular macro, in the rare case where a data type got changed, we can use this macro to fix the downstream table's schema. |
Got it, that sounds reasonable—and cool that you're doing so much of it with dbt macros! If someone's going to be calling this method from an external tool, I think it's fair to say they've read through the codebase around adapter methods. I'd be in favor of adding an inline code comment, caveat usor, that quotes or paraphrases from the BQ docs:
|
Just to make sure we're on the same page, is adding that as a jinja comment to the top of the macro what you had in mind? |
Yes, that's exactly what I had in mind—a quick note and link to that BQ docs page, within a Jinja comment, at the top of the |
Hey @jtcohen6 any other changes needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azhard This looks great to me, thanks for adding the disclaimer. I played around with the run-operation locally. It's very cool (if a bit frightening) to be replacing the entire table in an atomic create or replace
statement just to change one column's type.
@beckjake I defer to you on any code style. Also, some unexpected test errors (Redshift on Circle, Postgres on Azure).
Looks like the redshift tests triggered a redshift bug, I'm just re-running that from failed. The postgres tests look like an issue I fixed a while ago, but this PR is pretty old so I assume it just hasn't pulled in the fix. I'm perfectly comfortable merging this in as it is once the redshift test passes. Nothing this PR changes should care about the OS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code all looks good to me
resolves #2546
Description
Implements functionality to alter BigQuery column types using dbt.
Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.