Google bigquery 为什么下面的Bigquery插入失败?

Google bigquery 为什么下面的Bigquery插入失败?,google-bigquery,python-3.6,Google Bigquery,Python 3.6,您好我正在尝试向表中插入一行,我成功地创建了表,如下所示: schema = [{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}] created = client.create_table(dataset='api_data_set_course_33', table='insert_test_333', schema=schema

您好我正在尝试向表中插入一行,我成功地创建了表,如下所示:

schema = [{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}]
created = client.create_table(dataset='api_data_set_course_33', table='insert_test_333', schema=schema)

print('Creation Result ',created)
然而,当我推这一行时,我得到了错误

rows =  [{'id': 'NzAzYmRiY', 'one': 'uno', 'two': 'dos'}]
inserted = client.push_rows('api_data_set_course_33','insert_test_333', rows, 'id')

print('Insertion Result ',inserted)
所以我不知道哪里出了问题,我真的很感谢大家的支持,帮助我完成这项任务 这是我正在测试的API:

这是我的完整代码:

schema = [{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}]
created = client.create_table(dataset='api_data_set_course_33', table='insert_test_333', schema=schema)

print('Creation Result ',created)

rows =  [{'id': 'NzAzYmRiY', 'one': 'uno', 'two': 'dos'}]
inserted = client.push_rows('api_data_set_course_33','insert_test_333', rows, 'id')

print('Insertion Result ',inserted)
输出:

Creation Result  True
Insertion Result  False
在收到反馈后,我尝试:

>>> client = get_client(project_id, service_account=service_account,private_key_file=key, readonly=False)
>>> schema = [{'name': 'foo', 'type': 'STRING', 'mode': 'nullable'},{'name': 'bar', 'type': 'FLOAT', 'mode': 'nullable'}]
>>> rows =  [{'id': 'NzAzYmRiY', 'foo': 'uno', 'bar': 'dos'}]
>>> inserted = client.push_rows('api_data_set_course_33','insert_test_333', rows, 'id')
>>> print(inserted)
False
而且:

>>> rows =  [{'id': 'NzAzYmRiY', 'foo': 'uno', 'bar': 45}]
>>> inserted = client.push_rows('api_data_set_course_33','insert_test_333', rows, 'id')
>>> print(inserted)
False

但是,我只得到了false

您的行字段名与架构字段名不匹配。请尝试以下方法:

rows =  [{'id': 'NzAzYmRiY', 'foo': 'uno', 'bar': 'dos'}]

为此,我建议使用官方的谷歌库:如果你能得到jobid,你可以用它来知道哪里出了问题。通常,架构与值类型不匹配。你需要找到更多的细节来深入研究这个问题。我也尝试过这个问题,但是我得到了错误,我用输出更新了问题,我希望,你可以帮助我找到问题