我正在尝试更改重复记录的 col 类型STRING
to TIMESTAMP
。 BQ 文档提供了一些建议(手动更改模式 https://cloud.google.com/bigquery/docs/manually-changing-schemas#changing_a_columns_data_type)。但是,我对每条推荐的建议都遇到了问题。
这是一个示例架构:
{
'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'
},
]
}
使用查询的问题:
我认为我们必须取消重复记录,将字段转换为每个重复记录的时间戳,然后以某种方式重新创建行以插入到新表中。
将表导出为 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 https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-json#limitations
任何建议将不胜感激!