Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion gcloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def _build_resource(self):
'projectId': self._dataset.project,
'datasetId': self._dataset.name,
'tableId': self.name},
'schema': {'fields': _build_schema_resource(self._schema)},
}
if self.description is not None:
resource['description'] = self.description
Expand All @@ -419,6 +418,10 @@ def _build_resource(self):
if self.view_query is not None:
view = resource['view'] = {}
view['query'] = self.view_query
elif self._schema:
resource['schema'] = {
'fields': _build_schema_resource(self._schema)
}

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