I am trying to use the bigquery python API to insert data into bigquery tables. More specifically the command:
errors = client.insert_rows(table, rows[i*BATCH_SIZE:])
The column gas_used in my table has a datatype INTEGER and is NULLABLE. But I get the following error while inserting rows with null values in gas_used.
[{'index': 0, 'errors': [{u'debugInfo': u'', u'reason': u'invalid', u'message': u'Cannot convert value to integer (bad value):', u'location': u'gas_used'}]}]
Here, is the schema of my table:
block_number,transaction_hash,type,trace_address,subtraces,transaction_position,from,to,value_wei,start_gas,input,gas_used,contract_address,output,error
and, here is the row which throws the error:
[('5000001', '0x2cfd7194877466e6adb87222e5876c4babf8bd59de299698fdce7f0a9a232932', 'call', '[]', '0', '11', '0x77cb68e788aa79640b8a613431cdb10d83208d47', '0x4b3ee0ac445d954f8bca68f9538d54e9633890f6', '349950000000000', '0', '0x', '', '', '', 'Out of gas')]
gas_used column is the fourth last column in the schema.
''? That doesn't look like a valid integer to me... - Elliott Brossard''is an empty string, not integer. You'd have to either replace it with aNonevalue or a specific 0 (zero). - Willian FuksNullnature of the integer and thus cannot use a specific value 0, but usingNoneis a good idea. I have updated the answer with a solution that I found. - Ankit Chiplunkar