gpt4 book ai didi

google-bigquery - 解决错误 : returned "Output field used as input"

转载 作者:行者123 更新时间:2023-12-04 21:12:47 26 4
gpt4 key购买 nike

我正在尝试使用 Python 创建一个 BigQuery 表。其他操作(查询、检索表体等)工作正常,但是在尝试创建表时我遇到了错误:

apiclient.errors.HttpError: https://www.googleapis.com/bigquery/v2/projects/marechal-consolidation/datasets/marechal_results/tables?alt=json returned "Output field used as input">



这是我正在执行的命令:

projectId = 'xxxx'
dataSet = 'marechal_results'
with open(filePath+'tableStructure.json') as data_file:
structure = json.load(data_file)
table_result = tables.insert(projectId=projectId, datasetId=dataSet, body=structure).execute()

JSON 表:
{
"kind": "bigquery#table",

"tableReference": {
"projectId": "xxxx",
"tableId": "xxxx",
"datasetId": "xxxx"
},

"type": "table",
"schema": {
"fields": [
{
"mode": "REQUIRED",
"type": "STRING",
"description": "Company",
"name": "COMPANY"
},
{
"mode": "REQUIRED",
"type": "STRING",
"description": "Currency",
"name": "CURRENCY"
}
// bunch of other fields follow...
]
}
}

为什么我会收到此错误?

编辑:这是我作为参数传递的 JSON 对象:
{
"kind": "bigquery#table",
"type": "TABLE",
"tableReference": {
"projectId": "xxxx",
"tableId": "xxxx",
"datasetId": "xxxx"
},
"schema": {
"fields": [
{
"type": "STRING",
"name": "COMPANY"
},
{
"type": "STRING",
"name": "YEAR"
},
{
"type": "STRING",
"name": "COUNTRY_ISO"
},
{
"type": "STRING",
"name": "COUNTRY"
},
{
"type": "STRING",
"name": "COUNTRY_GROUP"
},
{
"type": "STRING",
"name": "REGION"
},
{
"type": "STRING",
"name": "AREA"
},
{
"type": "STRING",
"name": "BU"
},
{
"type": "STRING",
"name": "REFERENCE"
},
{
"type": "FLOAT",
"name": "QUANTITY"
},
{
"type": "FLOAT",
"name": "NET_SALES"
},
{
"type": "FLOAT",
"name": "GROSS_SALES"
},
{
"type": "STRING",
"name": "FAM_GRP"
},
{
"type": "STRING",
"name": "FAMILY"
},
{
"type": "STRING",
"name": "PRESENTATION"
},
{
"type": "STRING",
"name": "ORIG_FAMILY"
},
{
"type": "FLOAT",
"name": "REF_PRICE"
},
{
"type": "STRING",
"name": "CODE1"
},
{
"type": "STRING",
"name": "CODE4"
}
]
}
}

最佳答案

这可能为时已晚,无法帮助您,但希望它可以帮助像我这样的下一个可怜的灵魂。我花了一段时间才弄清楚“用作输入的输出字段”是什么意思。

尽管 API 为请求(输入)和响应(输出)指定了相同的对象,但某些字段只允许出现在响应中。在文档中,您将看到以“仅输出”为前缀的描述。通过查看您的表定义,我看到您有 "type": "TABLE"并且“类型”被列为“仅输出”属性。所以我认为如果你删除它,那么这个错误就会消失。这是文档的链接:https://cloud.google.com/bigquery/docs/reference/rest/v2/tables

如果他们告诉您违规所在的领域,这会有所帮助。

关于google-bigquery - 解决错误 : returned "Output field used as input",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30968095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com