【发布时间】:2019-04-03 00:16:54
【问题描述】:
我正在尝试将重复记录的 col 类型从 STRING 更改为 TIMESTAMP。这里有 BQ 文档的一些建议 (manually-changing-schemas)。但是,我遇到的每个推荐建议都有问题。
这是一个示例架构:
{
'name' => 'id',
'type' => 'STRING',
'mode' => 'REQUIRED'
},
{
'name' => 'name',
'type' => 'STRING',
'mode' => 'REQUIRED'
},
// many more fields including nested records and repeated records
{
'name' => 'locations',
'type' => 'RECORD',
'mode' => 'REPEATED',
'fields' => [
{
'name' => 'city',
'type' => 'STRING',
'mode' => 'REQUIRED'
},
{
'name' => 'updated_at',
'type' => 'STRING', // ** want this as TIMESTAMP **
'mode' => 'REQUIRED'
},
]
}
使用查询的问题:
我认为我们必须 UNNEST 重复记录,将字段转换为每个重复记录的时间戳,然后以某种方式重新创建行以插入新表。
将表格导出为 JSON 的问题:
当以 JSON 格式导出表格时,它会导出数据的原始 json 表示形式(如我们所料,带有地图和字典)。
但是,我们无法将该原始数据导入回 BQ:
BigQuery 不支持 JSON 格式的地图或字典。例如, "product_categories": {"my_product": 40.0} 无效,但是 "product_categories": {"column1": "my_product" , "column2": 40.0} 是 有效。
https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-json#limitations
任何建议将不胜感激!
【问题讨论】:
标签: google-bigquery