为什么以下Bigquery插入失败? [英] why the following Bigquery insertion is failing?

查看:47
本文介绍了为什么以下Bigquery插入失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我试图在表中插入一行,我成功创建了如下表:

Hello I am trying to insert one row into a table, I succesfully created the table as follows:

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)

但是,当我按下该行时,我得到了False,

However when I push the row I got False,

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:

So I don't have idea what is wrong, I really would like to appreciate support to overcome this task This is the API that I am testing:

https://github.com/tylertreat/BigQuery-Python

这是我完整的代码:

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

但是我只有假的

推荐答案

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

Your row field names don't match your schema field names. Try this instead:

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

这篇关于为什么以下Bigquery插入失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆