Skip to content

Commit 1ce9bf9

Browse files
committed
Merge branch 'master' into test-class-not-runnning
2 parents 3920b33 + 1155958 commit 1ce9bf9

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

docs/source/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
0.3.2 / [TBD]
5+
------------------
6+
- Fix bug with querying for an array of floats (:issue:`123`)
7+
48
0.3.1 / 2018-02-13
59
------------------
610

pandas_gbq/gbq.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ def _parse_data(schema, rows):
720720
col_names = [str(field['name']) for field in fields]
721721
col_dtypes = [
722722
dtype_map.get(field['type'].upper(), object)
723+
if field['mode'] != 'repeated'
724+
else object
723725
for field in fields
724726
]
725727
page_array = np.zeros((len(rows),), dtype=lzip(col_names, col_dtypes))

pandas_gbq/tests/test_gbq.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,16 @@ def test_read_gbq_with_no_project_id_given_should_fail(self):
365365
gbq.read_gbq('SELECT 1')
366366

367367
def test_that_parse_data_works_properly(self):
368+
369+
from google.cloud.bigquery.table import Row
368370
test_schema = {'fields': [
369-
{'mode': 'NULLABLE', 'name': 'valid_string', 'type': 'STRING'}]}
370-
test_page = [{'f': [{'v': 'PI'}]}]
371+
{'mode': 'NULLABLE', 'name': 'column_x', 'type': 'STRING'}]}
372+
field_to_index = {'column_x': 0}
373+
values = ('row_value',)
374+
test_page = [Row(values, field_to_index)]
371375

372376
test_output = gbq._parse_data(test_schema, test_page)
373-
correct_output = DataFrame({'valid_string': ['PI']})
377+
correct_output = DataFrame({'column_x': ['row_value']})
374378
tm.assert_frame_equal(test_output, correct_output)
375379

376380
def test_read_gbq_with_invalid_private_key_json_should_fail(self):
@@ -973,6 +977,14 @@ def test_array_agg(self):
973977
tm.assert_frame_equal(df, DataFrame([["a", [1, 3]], ["b", [2]]],
974978
columns=["letter", "numbers"]))
975979

980+
def test_array_of_floats(self):
981+
query = """select [1.1, 2.2, 3.3] as a, 4 as b"""
982+
df = gbq.read_gbq(query, project_id=_get_project_id(),
983+
private_key=_get_private_key_path(),
984+
dialect='standard')
985+
tm.assert_frame_equal(df, DataFrame([[[1.1, 2.2, 3.3], 4]],
986+
columns=["a", "b"]))
987+
976988

977989
class TestToGBQIntegrationWithServiceAccountKeyPath(object):
978990
# Changes to BigQuery table schema may take up to 2 minutes as of May 2015

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def readme():
2929
name=NAME,
3030
version=versioneer.get_version(),
3131
cmdclass=versioneer.get_cmdclass(),
32-
description="Pandas interface to Google Big Query",
32+
description="Pandas interface to Google BigQuery",
3333
long_description=readme(),
3434
license='BSD License',
3535
author='The PyData Development Team',

0 commit comments

Comments
 (0)