Skip to content

to_gbq doesn't respect location argument when it also creates dataset #213

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

Closed
robertlacok opened this issue Sep 10, 2018 · 2 comments
Closed

Comments

@robertlacok
Copy link
Contributor

robertlacok commented Sep 10, 2018

When trying to use the to_gbq method to both create dataset and the table, the method fails when setting the location other than US.

The reason is that the location is not respected when creating dataset, so it defaults to US. However, trying to launch a LoadJob with location='EU' when the dataset is in the US leads to failure.

Steps to reproduce:

to_gbq(df, 'my_dataset.my_table', google_cloud_project, location='EU')

where my_dataset doesn't exist.

I can try fixing it by passing the location argument down to constructors of _Table and _Dataset, and then here in the create method of _Dataset doing something like:

if self.location is not None:
    dataset.location = self.location

If you OK it I will test and submit a PR. Is there a better way?

@max-sixty
Copy link
Contributor

Thanks for the report and diagnosis @robertlacok

@tswast - what do you think about a) a function arg b) part of the config c) part of the class you recently added?

@tswast
Copy link
Collaborator

tswast commented Sep 11, 2018

We've already got the function argument for location 😄 (added in #177). I think it's more a matter of plumbing it through to the dataset object.

@robertlacok Yes, PRs welcome!

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

No branches or pull requests

3 participants