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.
For Transpose the data first of all we have to split the value data based on “;” once we split the value column then will get and array let's take the alias of that column is keyvalue. After that will unnest the array and split the data based '=' and will create 2 column (Key and value).
In the Schema section, enter the schema definition. Option 1: Use Add field and specify each field's name, type, and mode. Option 2: Click Edit as text and paste the schema in the form of a JSON array. When you use a JSON array, you generate the schema using the same process as creating a JSON schema file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With