Skip to content

Commit ad45010

Browse files
committed
Making updates per jreback's requested changes
1 parent c21f999 commit ad45010

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

docs/source/changelog.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Changelog
66

77
- Resolve issue where the optional ``--noauth_local_webserver`` command line argument would not be propagated during the authentication process. (:issue:`35`)
88
- Drop support for Python 3.4 (:issue:`40`)
9+
- When using ```to_gbq``` if ```if_exists``` is set to ```append```, dataframe needs to contain only a subset of the fields in the BigQuery schema. (:issue: `24`)
10+
911

1012
0.1.6 / 2017-05-03
1113
------------------
@@ -14,10 +16,6 @@ Changelog
1416

1517
0.1.5 / 2017-04-20
1618
------------------
17-
- When using ```to_gbq``` if ```if_exists``` is set to ```append```, dataframe needs to contain only a subset of the fields in the BigQuery schema. GH#24
18-
19-
0.1.4 / 2017-03-17
20-
------------------
2119

2220
- ``InvalidIndexColumn`` will be raised instead of ``InvalidColumnOrder`` in ``read_gbq`` when the index column specified does not exist in the BigQuery schema. (:issue:`6`)
2321

pandas_gbq/gbq.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,17 @@ def schema(self, dataset_id, table_id):
563563
Obtain from BigQuery the field names and field types
564564
for the table defined by the parameters
565565
566-
:param str dataset_id: Name of the BigQuery dataset for the table
567-
:param str table_id: Name of the BigQuery table
566+
Parameters
567+
----------
568+
dataset_id : str
569+
Name of the BigQuery dataset for the table
570+
table_id : str
571+
Name of the BigQuery table
568572
569-
:return: Fields representing the schema
570-
:rtype: list of dicts
573+
Returns
574+
-------
575+
list of dicts
576+
Fields representing the schema
571577
"""
572578

573579
try:
@@ -596,13 +602,20 @@ def verify_schema(self, dataset_id, table_id, schema):
596602
the schema passed in and indicate whether all fields in the former
597603
are present in the latter. Order is not considered.
598604
599-
:param str dataset_id: Name of the BigQuery dataset for the table
600-
:param str table_id: Name of the BigQuery table
601-
:param list(dict) schema: Schema for comparison. Each item should have
605+
Parameters
606+
----------
607+
dataset_id :str
608+
Name of the BigQuery dataset for the table
609+
table_id : str
610+
Name of the BigQuery table
611+
schema : list(dict)
612+
Schema for comparison. Each item should have
602613
a 'name' and a 'type'
603614
604-
:return: Whether the schemas match
605-
:rtype: bool
615+
Returns
616+
-------
617+
bool
618+
Whether the schemas match
606619
"""
607620

608621
fields_remote = sorted(self.schema(dataset_id, table_id),
@@ -618,13 +631,20 @@ def schema_is_subset(self, dataset_id, table_id, schema):
618631
the schema passed in and indicate whether a subset of the fields in
619632
the former are present in the latter. Order is not considered.
620633
621-
:param str dataset_id: Name of the BigQuery dataset for the table
622-
:param str table_id: Name of the BigQuery table
623-
:param list(dict) schema: Schema for comparison. Each item should have
634+
Parameters
635+
----------
636+
dataset_id : str
637+
Name of the BigQuery dataset for the table
638+
table_id : str
639+
Name of the BigQuery table
640+
schema : list(dict)
641+
Schema for comparison. Each item should have
624642
a 'name' and a 'type'
625643
626-
:return: Whether the passed schema is a subset
627-
:rtype: bool
644+
Returns
645+
-------
646+
bool
647+
Whether the passed schema is a subset
628648
"""
629649

630650
fields_remote = self.schema(dataset_id, table_id)

pandas_gbq/tests/test_gbq.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ def test_upload_data_if_table_exists_append(self):
10721072
private_key=_get_private_key_path())
10731073

10741074
def test_upload_subset_columns_if_table_exists_append(self):
1075-
# For pull request #24
1075+
# Issue 24: Upload is succesful if dataframe has columns
1076+
# which are a subset of the current schema
10761077
test_id = "16"
10771078
test_size = 10
10781079
df = make_mixed_dataframe_v2(test_size)
@@ -1283,7 +1284,7 @@ def test_verify_schema_ignores_field_mode(self):
12831284
self.dataset_prefix + "1", TABLE_ID + test_id, test_schema_2)
12841285

12851286
def test_retrieve_schema(self):
1286-
# For pull request #24
1287+
# Issue #24 schema function returns the schema in biquery
12871288
test_id = "15"
12881289
test_schema = {'fields': [{'name': 'A', 'type': 'FLOAT'},
12891290
{'name': 'B', 'type': 'FLOAT'},
@@ -1296,7 +1297,8 @@ def test_retrieve_schema(self):
12961297
assert expected == actual, 'Expected schema used to create table'
12971298

12981299
def test_schema_is_subset_passes_if_subset(self):
1299-
# For pull request #24
1300+
# Issue #24 schema_is_subset indicates whether the schema of the
1301+
# dataframe is a subset of the schema of the bigquery table
13001302
test_id = '16'
13011303

13021304
table_name = TABLE_ID + test_id

0 commit comments

Comments
 (0)