Search code examples
sqlgoogle-bigqueryddlalter-table

How to change the description of a field nested in a struct via the DDL in BigQuery?


Let's say I have the following table:

CREATE OR REPLACE TABLE tmp.table_description_test AS (
  SELECT
    1 AS a,
    STRUCT(2 AS c, 3 AS d) AS b
)

Adding a description for a or b is easy:

ALTER TABLE tmp.table_description_test ALTER COLUMN a
SET OPTIONS (description = 'description of a');
ALTER TABLE tmp.table_description_test ALTER COLUMN b
SET OPTIONS (description = 'description of b');

But how can I add/change a description for the nested fields?

KGk91y1

ALTER TABLE tmp.table_description_test ALTER COLUMN b.c
SET OPTIONS (description = 'description of b.c');

Does not work:

Syntax error: Unexpected "." at [1:54] 

Solution

  • Based on my understanding, we cannot use a BigQuery alter DDL statement to modify nested columns. As a simple workaround you can consider using BigQuery UI to add description to the column.

    Example:

    image

    If you want this feature to be implemented, you can open a new feature request on the issue tracker. You can also take a look at the stack thread also.