diff --git a/google/cloud/bigquery/_helpers.py b/google/cloud/bigquery/_helpers.py index 68c6ea473911..181734f5b75e 100644 --- a/google/cloud/bigquery/_helpers.py +++ b/google/cloud/bigquery/_helpers.py @@ -75,7 +75,9 @@ def _string_from_json(value, _): _CELLDATA_FROM_JSON = { 'INTEGER': _int_from_json, + 'INT64': _int_from_json, 'FLOAT': _float_from_json, + 'FLOAT64': _float_from_json, 'BOOLEAN': _bool_from_json, 'TIMESTAMP': _datetime_from_json, 'DATE': _date_from_json, diff --git a/unit_tests/bigquery/test__helpers.py b/unit_tests/bigquery/test__helpers.py index bdf766ad2778..72a95e5f0dcc 100644 --- a/unit_tests/bigquery/test__helpers.py +++ b/unit_tests/bigquery/test__helpers.py @@ -284,6 +284,37 @@ def test_w_record_subfield(self): coerced = self._callFUT(rows, schema) self.assertEqual(coerced, expected) + def test_w_int64_float64(self): + # "Standard" SQL dialect uses 'INT64', 'FLOAT64'. + candidate = _Field('REQUIRED', 'candidate', 'STRING') + votes = _Field('REQUIRED', 'votes', 'INT64') + percentage = _Field('REQUIRED', 'percentage', 'FLOAT64') + schema = [candidate, votes, percentage] + rows = [ + {'f': [ + {'v': 'Phred Phlyntstone'}, + {'v': 8}, + {'v': 0.25}, + ]}, + {'f': [ + {'v': 'Bharney Rhubble'}, + {'v': 4}, + {'v': 0.125}, + ]}, + {'f': [ + {'v': 'Wylma Phlyntstone'}, + {'v': 20}, + {'v': 0.625}, + ]}, + ] + expected = [ + ('Phred Phlyntstone', 8, 0.25), + ('Bharney Rhubble', 4, 0.125), + ('Wylma Phlyntstone', 20, 0.625), + ] + coerced = self._callFUT(rows, schema) + self.assertEqual(coerced, expected) + class Test_ConfigurationProperty(unittest.TestCase):