skip to Main Content

I have a table called temp with columns name,age.

I need to update the schema, the new structure should be name,details,age.

I can achieve the above using

bq update proj:dataset.temp file/schema.json

And also i need the age column at last after the details.
Although im providing the columns in the proper order in json file, the bq update simply adding the new column after age. Json file is give below

[
{

    "name": "name",
    "type": "STRING",
    "mode": "NULLABLE"
},
{
    "name": "details",
    "type": "STRING",
    "mode": "NULLABLE"
},
{
    "name": "age",
    "type": "INTEGER",
    "mode": "NULLABLE"
}
]

Is there any way to bring the age column to the very last

2

Answers


  1. BigQuery update is set to arrange JSON schema alphabetically by default, to make it easier for users to find specific columns that they need. I wasn’t able to find any document that explicitly guides us how to preserve the column order as written in a JSON file.

    Kindly look into this resources for further information.

    Alternatively, you can submit this to our Issue tracking system and product feature requests.

    Login or Signup to reply.
  2. Adding a new column may cause to append new column at the end of the table, without touching the existing columns.

    To force a new order you have to recreate table – drop it and create with new schema. It the table contains some data which can not be lost consider making a "backup" – copying a result to a another table before recreation and inserting them after.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search