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

Response from table update is incompatible with Google's Python SDK #293

Open
mastizada opened this issue Apr 9, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@mastizada
Copy link

mastizada commented Apr 9, 2024

What happened?

When table schema is updated, it calls BigQuery.updateTable with PATCH method. With bigquery-emulator, it is returning the updated schema, however, google-cloud-bigquery plugin expects tableReference with tableId in the response. Link to the plugin function.

What did you expect to happen?

To have [tableReference][tableId] in the response.

How can we reproduce it (as minimally and precisely as possible)?

Install the python plugin: $ pip install google-cloud-bigquery (tested on latest version, 3.20.1, and old version 2.34.3).

Execute the following code:

from google.auth.credentials import AnonymousCredentials
from google.cloud import bigquery

client = bigquery.Client(client_options={"api_endpoint": "http://0.0.0.0:9050"}, credentials=AnonymousCredentials())

# change project id, dataset name and table name
table_ref = ".".join([GCP_PROJECT_ID, DATASET_NAME, TABLE_NAME])
table = client.get_table(table_ref)

# slightly modify `table.schema`
table = client.update_table(table, ["schema"])

It will give the following error:
KeyError: 'Resource lacks required identity information:["tableReference"]["tableId"]'

Anything else we need to know?

No response

@mastizada mastizada added the bug Something isn't working label Apr 9, 2024
@ohaibbq
Copy link
Contributor

ohaibbq commented Apr 14, 2024

It seems to me that the PATCH /projects/{project]/datasets/{dataset}/tables/{table} endpoint has numerous problems.

We currently decode the request body into a bigquery.Table. For example, if we are updating the description, we'd end up with a bigquery.Table with only the description set.

The newTable metadata is then passed along to metadata.Table.Update, but is unused, resulting in a no-op.

The response for the request handler only contains the contents of r.newTable, so in this case it'd be only be the description, no other fields.

As an aside, its worth noting that the emulator does not currently support updating a table's schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants