# Resolving schema changes for de-identified views

If you enable view de-identification, then you might need to rescynchronize out-of-sync view schemas.

## Identifying out-of-sync schema data <a href="#bigquery-resync-views-identify-out-of-sync" id="bigquery-resync-views-identify-out-of-sync"></a>

Tonic Structural uses the schema metadata from the `INFORMATION_SCHEMAS` metadata tables to display a view’s schema and to manage its schema changes.

For performance reasons, Structural assumes this schema metadata is accurate.

However, schema metadata for BigQuery views might be out of sync with the actual results of querying the view. This can occur for various reasons, but is typically because the query definition is written in such a way that changes to referenced tables result in changes to the schema of the query results.

Data generation jobs ignore and issue a warning for any views that have out-of-date schema metadata.

Before you can de-identify the affected views, you must manually resynchronize the schema metadata in BigQuery.

## Resynchronizing logical views <a href="#bigquery-resynch-logical-views" id="bigquery-resynch-logical-views"></a>

For logical views, schema metadata is not automatically updated during the lifecycle of the view.

If the underlying schema of the logical view has changed, then to trigger a refresh, you must either change or recreate the view definition.

### **Changing the view query** <a href="#bigquery-resynch-logical-views-update-query" id="bigquery-resynch-logical-views-update-query"></a>

To trigger a schema refresh, use the BigQuery user interface to modify the view query, then save the view.

No-op changes do trigger schema metadata refreshes.

However, saving the view without modifying the query does not trigger a refresh.

### **Recreating the view definition** <a href="#biqquery-resynch-logical-view-recreate-definition" id="biqquery-resynch-logical-view-recreate-definition"></a>

To recreate the view, run the following command:

`"CREATE OR REPLACE VIEW '{project}.{dataset}.{view}' OPTIONS({options}) AS ({view_query})"`

The full DDL for a view is in the the following table: `{dataset}.INFORMATION_SCHEMA.TABLES`

## Resynchronizing materialized views <a href="#bigquery-resynch-materialized-views" id="bigquery-resynch-materialized-views"></a>

For materialized views, refreshes automatically synchronize the schema metadata.

For details on how to configure automatic refreshes and trigger manual refreshes of materialized views, go to [the BigQuery documentation](https://cloud.google.com/bigquery/docs/materialized-views-manage#refresh).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/setting-up-your-database/google-bigquery/bigquery-views-resolve-schema-changes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
