当SELECT * from [...]
使用Jobs.query通过API查询Bigquery表(简单)时,我将其返回为架构:
"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
来获取真实的模式,但是我想了解为什么我在第一次查询时就得到了一个不完整的模式。
Jobs.query API为您提供查询结果的架构(保存在后台的临时表中)。在此表中-即使字段的类型,模式等是从查询表所涉及的架构派生的,也没有字段的描述
另一面的Tables.get API-实际上会返回表的架构,这就是为什么您看到此表的所有信息,包括说明的原因。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句