使用Jobs.query通过API查询Bigquery表(简单SELECT * from [...]
)时,我将其作为架构返回:
"schema": {
"fields": [
{
"name": "all",
"type": "INTEGER",
"mode": "NULLABLE"
},
{
"name": "timestamp",
"type": "TIMESTAMP",
"mode": "NULLABLE"
},
{
"name": "last_timestamp",
"type": "TIMESTAMP",
"mode": "NULLABLE"
},
{
"name": "unique",
"type": "INTEGER",
"mode": "NULLABLE"
},...
但实际的架构(由Tables.get正确返回)是:
"schema": {
"fields": [
{
"name": "all",
"type": "INTEGER",
"mode": "REQUIRED",
"description": "All searches"
},
{
"name": "timestamp",
"type": "TIMESTAMP",
"mode": "REQUIRED",
"description": "Time of processing"
},
{
"name": "last_timestamp",
"type": "TIMESTAMP",
"mode": "REQUIRED",
"description": "Last event"
},
{
"name": "unique",
"type": "INTEGER",
"mode": "REQUIRED",
"description": "Unique users"
},
我在填写电子表格的应用程序脚本中使用查询结果,并且我希望使用架构中的描述字段作为列名。我可以使用Table.get
来获取真实的架构,但我想了解为什么我会在第一个查询中获得不完整的架构。
答案 0 :(得分:1)
Jobs.query API为您提供查询结果的架构(在后台的临时表中保存)。在此表中 - 没有字段的描述,即使它们的类型,模式等是从查询表中涉及的模式派生的
来自另一方的Tables.get API - 实际上返回表的架构,这就是为什么你会看到关于这个表的所有内容,包括描述。