-
Notifications
You must be signed in to change notification settings - Fork 163
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
init push or pytest conversion of override_database for bigquery #165
Conversation
I have ran the conversion script and started playing around with the script to try and get it to work and have a question about weather or not there are additonal changes we might have to make around getting the env variables since these aren't just replacing values from dbt-core confftest.py current log from when I run a test:
|
…s (commented out tests)
…mcknight/convert_override_test
…_bigquery_database_override test working on getting the rest to work for first test
…ormation from configs
…mcknight/convert_override_test
…mcknight/convert_override_test
…mcknight/convert_override_test
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.
Env var: We actually don't use BIGQUERY_TEST_DATABASE
anywhere else. In the service_account
profile, we use project_id
, pulled out of the service account JSON. For oauth
connections, we use the default configured via gcloud config
. I think we could swing this test without that env var, too—but I'm open to leaving it in if you think it's better that way.
Organization of test cases: I wouldn't expect this test case to land in tests/functional/adapter
, I would only expect that to be test cases that are pulled from dbt-tests-adapter
. I might expect this test case to land in tests/functional/<topic_area>/test_override_database/...
Finally: We can also delete the legacy test (tests/integration/override_database_test
), right?
{%- if target.type == 'bigquery' -%} | ||
{{ config(project=var('alternate_db')) }} | ||
{%- else -%} | ||
{{ config(database=var('alternate_db')) }} | ||
{%- endif -%} |
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.
This works either way, dbt-bigquery
recognizes project + database as aliases for one another. Good to test that the alias works though!
run_dbt(["seed"]) | ||
assert len(run_dbt(["run"])) == 4 | ||
check_relations_equal_with_relations(project.adapter, [ | ||
project.adapter.Relation.create(database=os.getenv("BIGQUERY_TEST_DATABASE"), schema=project.test_schema, identifier="seed"), |
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.
We could either:
- Replace
database=os.getenv("BIGQUERY_TEST_DATABASE")
withdatabase=project.database
- Remove the
database
argument entirely, and fix a v1.1 regression ([CT-604]get_columns_in_relation
when database is missing #180) by restoring support for using defaultdatabase
/schema
when unspecified inget_columns_in_relation
"database": os.getenv("BIGQUERY_TEST_ALT_DATABASE"), | ||
"test": { | ||
"subfolder": { | ||
"database": os.getenv("BIGQUERY_TEST_DATABASE") |
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.
You could replace this env var pretty straightforwardly with either of the following.
More like what users would actually write in their projects:
"database": os.getenv("BIGQUERY_TEST_DATABASE") | |
"database": "{{ target.database }}" |
More like what this is doing currently:
"database": os.getenv("BIGQUERY_TEST_DATABASE") | |
"database": project.database |
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.
I think the target.database works more as that part of the function doesn't generally have access to project and when i tried to tap it it gave recursive dependency issues.
Do we have any big overarching topics we would want to put them in or would just the override_database folder be that topic curious if this is something that will be same across all adapters and we have any discussion on it? I'm fine removing it if we were only using it to test this use case, I know we also have the dbt-dev account and the alt account still so that covers these cases well for ci/cd and we still have the no access account to test against for that use case. would just need to make sure we remove it from bigquery eventually. and yes plan to delete the older test once this is working its nice to have them to fall back on and compare post conversion. |
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.
LGTM! Glad to see all things related to compare different database object resolved!
# backwards compatibility: fill in with defaults if not specified | ||
database = database or conn.credentials.database | ||
schema = schema or conn.credentials.schema |
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.
To discuss: Backporting this piece to 1.1.latest
, to resolve #180. Let's just add a test case for the regression case as well. It's really just calling adapter.get_columns_in_relation
on a Relation
that's missing database
/schema
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.
Do we want this test in the test_bigquery_adapter section using the magic mock?
…-labs#165) * init push or pytest conversion of override_database for bigquery * tests are currently passing, need to implement some test changes overs (commented out tests) * implemented a vew versions of the check_realations_equal test on test_bigquery_database_override test working on getting the rest to work for first test * trying to grab local env to test against need to find way to grab information from configs * attempting to move over to using check_relations_equal_with_relations * ordering of models * post pair update * debugged test, had passing locally * adding change to conftest to see if it passes tests in ci/cd * removing conftest change * trying ci/cd after some changes * trying to take into account CT-604, remove old test, remove BIGQUERY_TEST_DATABASE env * moving override_database out of adapter folder up one
resolves #164
Description
Converting the BigQuery implementation of override_database to the new pytest format
Checklist
CHANGELOG.md
and added information about my change to the "dbt-bigquery next" section.