BigQuery:如何将我的列中的某一列的类型从INTEGER更改为STRING? [英] BigQuery: How can I change the type of one of my column from INTEGER to STRING?
问题描述
我需要保留当前在Field 1中的数据,同时能够将字符串数据插入到该字段中。
我相信Google BigQuery目前不可能修改某列的类型。我认为我们可以对表格进行的唯一修改是在列中添加 Table.Update命令
那么最好的办法是什么?
我想这样做,但我希望有一个更好的解决方案:
- 选择STRING(
- 将结果导出到TempTable中
- 删除MyTable
将字段1中的字段1,字段2,字段3,字段1- 将TempTable复制到MyTable中
然后我可以在field1中插入字符串。 / p>
步骤1-4可以在单个原子步骤中完成。只需在查询中设置目标表并使用allow_large_results并使用write_truncate将结果写回原始表。这将更新您的表格。
In BigQuery, let say I have an existing table with X fields. Field 1 is currently an INTEGER but I would like to change it to a STRING.
I need to keep data that is currently in Field 1, while being able to insert string data into that field.
I believe that it is currently impossible in Google BigQuery to modify the type of a column. I think that the only modification that we can do to a table is add columns with the Table.Update command
So what would be the best way do to that?
I was thinking of doing this, but I would hope that there is a better solution:
- Select STRING(field1) as field1, field2, field3, fieldX from MyTable
- Export the result in a TempTable
- Delete MyTable
- Copy TempTable to MyTable
I would then be able to insert strings in field1.
Steps 1-4 can all be done in a single atomic step. Just set a destination table on your query and use allow_large_results and use write_truncate to write your results back to the original table. This will update your table in place.
这篇关于BigQuery:如何将我的列中的某一列的类型从INTEGER更改为STRING?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!