Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Alter statement in sql to alter child column description of Record type

Hi,

I am trying to alter the column description of child attributes inside RECORD type using sql statement. Unfortunately i was not successful in accessing the child attributes using sql. Appreciate your help with this.

 

Solved Solved
0 2 1,229
1 ACCEPTED SOLUTION

BigQuery does not support altering the column description of child attributes within a RECORD type using an ALTER TABLE SQL statement. The ALTER TABLE functionality is limited to top-level schema modifications and does not extend to nested field descriptions.

To update the description of a nested field, you can use the following approach:

  1. Export the current table schema to a JSON file using the bq command-line tool:

     
    bq show --schema --format=prettyjson [PROJECT_ID]:[DATASET].[TABLE] > [SCHEMA_FILE].json
  2. Manually edit the JSON file to include the new descriptions for the nested fields.

  3. Update the table schema with the modified JSON file:

     
    bq update [PROJECT_ID]:[DATASET].[TABLE] [SCHEMA_FILE].json

This method allows you to modify the schema without affecting the existing data in your table. It's recommended to back up your data before performing schema updates and to test any changes in a non-production environment first.

View solution in original post

2 REPLIES 2

BigQuery does not support altering the column description of child attributes within a RECORD type using an ALTER TABLE SQL statement. The ALTER TABLE functionality is limited to top-level schema modifications and does not extend to nested field descriptions.

To update the description of a nested field, you can use the following approach:

  1. Export the current table schema to a JSON file using the bq command-line tool:

     
    bq show --schema --format=prettyjson [PROJECT_ID]:[DATASET].[TABLE] > [SCHEMA_FILE].json
  2. Manually edit the JSON file to include the new descriptions for the nested fields.

  3. Update the table schema with the modified JSON file:

     
    bq update [PROJECT_ID]:[DATASET].[TABLE] [SCHEMA_FILE].json

This method allows you to modify the schema without affecting the existing data in your table. It's recommended to back up your data before performing schema updates and to test any changes in a non-production environment first.

Thank you