我正在使用的数据有一个嵌套字段“位置”,如下所示:
"location": {
"city": "Amherst",
"region": "NS",
"country": "CA"
},
如何使用 Java API 指定嵌套字段的架构?
目前,我的代码如下所示:
List<TableFieldSchema> fields = new ArrayList<TableFieldSchema>();
TableFieldSchema fieldLocation = new TableFieldSchema();
fieldFoo.setName("location");
fieldFoo.setType("record");
TableFieldSchema fieldLocationCity = new TableFieldSchema();
fieldBar.setName("location.city");
fieldBar.setType("string");
...
fields.add(fieldLocation);
fields.add(fieldLocationCity);
TableSchema schema = new TableSchema();
schema.setFields(fields);
这不起作用,因为我收到以下错误:
CONFIG: {
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Record field location must have a schema."
}
],
"code": 400,
"message": "Record field location must have a schema."
}