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

Omit 'schema' as part of 'Table.{create,update}' when 'view_query` is set #1703

Merged
merged 3 commits into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gcloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def _build_resource(self):
if self.view_query is not None:
view = resource['view'] = {}
view['query'] = self.view_query
# Back-end rejects 'schema' when passing a query.
del resource['schema']

This comment was marked as spam.


return resource

Expand Down
11 changes: 1 addition & 10 deletions gcloud/bigquery/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,6 @@ def test_create_w_alternate_client(self):
'projectId': self.PROJECT,
'datasetId': self.DS_NAME,
'tableId': self.TABLE_NAME},
'schema': {'fields': [
{'name': 'full_name', 'type': 'STRING', 'mode': 'REQUIRED'},
{'name': 'age', 'type': 'INTEGER', 'mode': 'REQUIRED'}]},
'description': DESCRIPTION,
'friendlyName': TITLE,
'view': {'query': QUERY},
Expand Down Expand Up @@ -800,10 +797,7 @@ def test_update_w_alternate_client(self):
conn2 = _Connection(RESOURCE)
client2 = _Client(project=self.PROJECT, connection=conn2)
dataset = _Dataset(client1)
full_name = SchemaField('full_name', 'STRING', mode='REQUIRED')
age = SchemaField('age', 'INTEGER', mode='REQUIRED')
table = self._makeOne(self.TABLE_NAME, dataset=dataset,
schema=[full_name, age])
table = self._makeOne(self.TABLE_NAME, dataset=dataset)
table.default_table_expiration_ms = DEF_TABLE_EXP
table.location = LOCATION
table.expires = self.EXP_TIME
Expand All @@ -821,9 +815,6 @@ def test_update_w_alternate_client(self):
{'projectId': self.PROJECT,
'datasetId': self.DS_NAME,
'tableId': self.TABLE_NAME},
'schema': {'fields': [
{'name': 'full_name', 'type': 'STRING', 'mode': 'REQUIRED'},
{'name': 'age', 'type': 'INTEGER', 'mode': 'REQUIRED'}]},
'expirationTime': _millis(self.EXP_TIME),
'location': 'EU',
'view': {'query': QUERY},
Expand Down