Exemple #1
0
 def test_type_conversion(self):
     # All BigQuery Types should be cast into appropriate numpy types
     sample_input = [('1.095292800E9', 'TIMESTAMP'),
              ('false', 'BOOLEAN'),
              ('2', 'INTEGER'),
              ('3.14159', 'FLOAT'),
              ('Hello World', 'STRING')]
     actual_output = [gbq._parse_entry(result[0],result[1]) for result in sample_input]
     sample_output = [np.datetime64('2004-09-16T00:00:00.000000Z'),
               np.bool(False),
               np.int('2'),
               np.float('3.14159'),
               'Hello World']
     self.assertEqual(actual_output, sample_output, 'A format conversion failed')
Exemple #2
0
 def test_should_return_bigquery_strings_as_python_strings(self):
     result = gbq._parse_entry('STRING', 'STRING')
     tm.assert_equal(result, 'STRING')
Exemple #3
0
 def test_should_return_bigquery_booleans_as_python_booleans(self):
     result = gbq._parse_entry('false', 'BOOLEAN')
     tm.assert_equal(result, False)
Exemple #4
0
 def test_should_return_bigquery_timestamps_as_numpy_datetime(self):
     result = gbq._parse_entry('0e9', 'TIMESTAMP')
     tm.assert_equal(result, np.datetime64('1970-01-01T00:00:00Z'))
Exemple #5
0
 def test_should_return_bigquery_floats_as_python_floats(self):
     result = gbq._parse_entry(1, 'FLOAT')
     tm.assert_equal(result, float(1))
Exemple #6
0
 def test_should_return_bigquery_integers_as_python_floats(self):
     result = gbq._parse_entry(1, 'INTEGER')
     tm.assert_equal(result, float(1))
Exemple #7
0
 def test_should_return_bigquery_timestamps_as_numpy_datetime(self):
     result = gbq._parse_entry("0e9", "TIMESTAMP")
     tm.assert_equal(result, np.datetime64("1970-01-01T00:00:00Z"))
 def test_should_return_bigquery_booleans_as_python_booleans(self):
     result = gbq._parse_entry('false', 'BOOLEAN')
     tm.assert_equal(result, False)
 def test_should_return_bigquery_timestamps_as_numpy_datetime(self):
     result = gbq._parse_entry('0e9', 'TIMESTAMP')
     tm.assert_equal(result, np.datetime64('1970-01-01T00:00:00Z'))
 def test_should_return_bigquery_floats_as_python_floats(self):
     result = gbq._parse_entry(1, 'FLOAT')
     tm.assert_equal(result, float(1))
 def test_should_return_bigquery_integers_as_python_floats(self):
     result = gbq._parse_entry(1, 'INTEGER')
     tm.assert_equal(result, float(1))
Exemple #12
0
 def test_should_return_bigquery_strings_as_python_strings(self):
     result = gbq._parse_entry('STRING', 'STRING')
     tm.assert_equal(result, 'STRING')