yigitozmen
yigitozmen

Reputation: 957

Delete schema from Bigquery with python client

I'm trying to remove schema from table with python, but I get error.

table.schema = (
    bigquery.SchemaField('Name', 'STRING'),
    bigquery.SchemaField('Age', 'INTEGER'),
    bigquery.SchemaField('Weight', 'FLOAT'),
    bigquery.SchemaField('TEST', 'FLOAT'),
)
table.schema.remove('TEST')
table.update()

It returns an error: ValueError: list.remove(x): x not in list

How can I remove unwanted schemas from table?

Upvotes: 0

Views: 187

Answers (1)

Nhan Nguyen
Nhan Nguyen

Reputation: 410

I think table.schema is a list of SchemaField, not a dictionary, so remove('TEST') won't work. Maybe something like this instead:

table.schema = [field for field in table.schema if field.name != 'TEST']

Upvotes: 1

Related Questions