googleapis / googleapis/google-cloud-go
bigquery: unpredictable or poorly documented errors for checking if a table exists
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 1.6k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 109
Description
**Is your feature request related to a problem? Please describe.**
When using to bigquery package it is important to check if a table exists or not before starting to insert rows into it. To do this, the doc string for dataset.Table() recommends:
```
Table creates a handle to a BigQuery table in the dataset. To determine if a table exists, call Table.Metadata. If the table does not already exist, use Table.Create to create it.
```
If you call Metadata() on a table pointer that is returned from dataset.Table() you get a Metadata pointer and an error. If that table doesn't exist the metadata pointer is nil and the error reads: `googleapi: Error 404: Not found: Table , notFound`
However, how can I verify that the error is because of the table not being found, and not something like a dropped network connection?
**Describe the solution you'd like**
There should be an error defined by the bigquery client library such as `bigquery.TableNotFound`
**Describe alternatives you've considered**
The only option I see here is to string search for "404" or "Not found"
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.