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 errors out when using BigQuery datasets that begin with underscores #873

Closed
ghost opened this issue Jul 23, 2018 · 3 comments
Closed
Labels
bigquery bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!

Comments

@ghost
Copy link

ghost commented Jul 23, 2018

In BigQuery, datasets that begin with underscores are hidden in the UI and API. As a result, when DBT checks for the existence of a dataset, it doesn't find it, tries to create it, then errors out because the dataset already exists. There are a couple of ways to handle this:

  1. Prevent it by checking for the existence of the dataset by a different method, or
  2. Handle the exception being thrown by BigQuery.

Prevent the Exception

I think this can be fixed by adding include_all=True as a parameter in list_datasets() and changing the create_schema method to check for the existence of the dataset id in the output of get_existing_schemas instead of using get_dataset

Handle the Exception

When this occurs, BigQuery responds with a 409 response code: 409 POST https://www.googleapis.com/bigquery/v2/projects/<project_id>/datasets: Already Exists: Dataset <project_id>:<table_name>
create_schema could be modified to interpret a 409 response code as success.

@drewbanin
Copy link
Contributor

Thanks @rsmichaeldunn! This feature is news to me. Should be pretty straightforward to pass the include_all param in here

@drewbanin drewbanin added bug Something isn't working bigquery good_first_issue Straightforward + self-contained changes, good for new contributors! labels Jul 23, 2018
@ghost
Copy link
Author

ghost commented Jul 23, 2018

It was news to me too. I was wondering where on earth my missing dataset was. I haven't found it documented by Google anywhere, and there's only one stackoverflow article on it that I found: https://stackoverflow.com/questions/19524516/dataset-with-name-starting-with-an-underscore-doesnt-show-up-in-google-bigquery

@drewbanin
Copy link
Contributor

Fixed in #954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
Development

No branches or pull requests

1 participant