使用python API将可空整数插入bigquery时出错

时间:2018-05-02 09:08:52

标签: python python-2.7 google-bigquery

我正在尝试使用bigquery python API将数据插入bigquery表。更具体地说,命令:

errors = client.insert_rows(table, rows[i*BATCH_SIZE:])

我的表中的 gas_used 列的数据类型为INTEGER,并且为NULLABLE。但是在 gas_used 中插入具有空值的行时出现以下错误。

  

[{' index':0,'错误':[{u' debugInfo':u'',u' reason& #39;:你没有','消息':你无法将价值转换为整数(不良价值):',u' location': U' gas_used'}]}]

这是我桌子的架构:

block_number,transaction_hash,type,trace_address,subtraces,transaction_position,from,to,value_wei,start_gas,input,gas_used,contract_address,output,error

并且,这是抛出错误的行:

[('5000001', '0x2cfd7194877466e6adb87222e5876c4babf8bd59de299698fdce7f0a9a232932', 'call', '[]', '0', '11', '0x77cb68e788aa79640b8a613431cdb10d83208d47', '0x4b3ee0ac445d954f8bca68f9538d54e9633890f6', '349950000000000', '0', '0x', '', '', '', 'Out of gas')]

gas_used 列是架构中的第四列。

1 个答案:

答案 0 :(得分:0)

正如William Fuks提到的,我必须提到Null Integer为None0。我宁愿保留整数的Null性质,所以更喜欢使用`Nonè

我读了this帖子,现在正在上传一个字典列表,同时删除了空的键。

相关问题