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

BUG: NotFoundException from to_gbq when replacing table in project different from project_id parameter #377

Closed
wnojopra opened this issue Aug 24, 2021 · 1 comment · Fixed by #455
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wnojopra
Copy link

Environment details

  • Programming language: python3
  • OS: Linux
  • Language runtime version: 3.9.2
  • Package version: 0.15.0

Steps to reproduce

Code Sample, a copy-pastable example

import pandas as pd

df = pd.DataFrame(
  {
    "A": pd.Series(1, index=list(range(2)))
  }
)

# 0) Start with an empty test_dataset. test_table does not exist at this point.


# 1) This successfully creates a table named test_table in dataset test_dataset in project willyn_data_project
df.to_gbq('willyn_data_project.test_dataset.test_table', project_id='willyn_job_project')

# 2) This fails with pandas_gbq.gbq.NotFoundException: Table does not exist
df.to_gbq('willyn_data_project.test_dataset.test_table', project_id='willyn_job_project', if_exists='replace')

Problem description

I am working on a project where researchers can write to a dataset in one GCP project, but must run query jobs in another. In the above code example, willyn_data_project is the name of the project that contains the dataset, and willyn_job_project is the name of the project where query jobs are executed.

When attempting to use if_exists='replace', we get the error pandas_gbq.gbq.NotFoundException: Table does not exist. I believe what is happening is we are attempting to delete a table from willyn_job_project, when we should be deleting a table in willyn_data_project.

My best guess would be this line in delete_and_recreate_table needs to be updated to use the correct project.

Expected Output

No error.

@wnojopra wnojopra added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 24, 2021
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-pandas API. label Aug 24, 2021
@tswast
Copy link
Collaborator

tswast commented Aug 25, 2021

Thanks for the report! I think you are right in that the wrong project ID is being used.

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Nov 23, 2021
@tswast tswast self-assigned this Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants