tylertreat/BigQuery-Python

Error while creating tables.

caterpillars opened this issue · 10 comments

Hi,

I am new to big query, and i am trying to create a test table into big query using this BigQuery-Python. I was able to query an existing table, but get the following error while trying to create/delete tables.

ERROR:root:Cannot create table sample.my_table
Http Error:

Could you please advice on what might be wrong?

Thanks!

Can you post the code you're using please?

Sure. I just copy your example and change the dataset name to mine. Here is the code:

Create a new table.

schema = [
{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},
{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}
]
created = client.create_table('sample', 'my_table', schema)

The error I got is:

ERROR:root:Cannot create table sample.my_table
Http Error:

Thanks!

@caterpillars This is sort of tangential, but it looks like there might be a bug in the error logging code. Can you try changing e.message (on this line) to e.content. Hopefully this will show what the actual error is.

Thanks! I did that and found out the error is because of insufficient permission. Here is the error message:

ERROR:root:Cannot create table sample.my_table
Http Error: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}

I configured my project in bigquery and the python as in the example. Is there anything else I can check and change to make this work?

Thanks

Does the error only occur when creating a table in the dataset? Can you query any existing tables in the dataset? Can you create datasets?

Ensure that the project id and service account match your credentials and that those credentials have the proper permissions for the project.

I can query existing tables from python just fine and I am (my email) has 'is owner' access of the project. The service account I am using has 'can edit' access of this project. Is there anything else I can check?

Thanks!

Here is the screenshot of the credentials on this project. I saw two service accounts on this projects. Will this be a problem?

image

get_client defaults to a read-only client. If you want write access, make sure you're setting readonly=False.

client = get_client('my-project', service_account='my-service-account', private_key=key,
                    readonly=False)

Ah.. that's why. I didn't notice that. Thanks a lot for you help! I tested create/delete datasets as well. It works. Thanks!

Cool!