Do you need to replace an entire catalog (project) or schema reference and essentially have the same tables now in a new service account or project? This article will help guide you through the process.
Please read through all steps and note there are breaking changes that need to be resolved in order to complete this process.
BigQuery:
Edit Database Connection Settings:
- If you’re switching to a new project, edit your existing database connection by removing the old Service Account JSON key and upload the JSON key for the new service account.
- Edit the
Default Dataset
to the new project and include the old project in theInclude Other Projects
parameter. This allows you to see both projects in the same model while you fix any breaking changes to content. - In the
Include Schemas
parameter, be sure to include the schemas from both projects that need to be viewed in the model. - Make sure to hit
Update
at the bottom of the page for the change to actually happen! - You may generate an error like this one:
- if this happens, make sure that the new service account or project has the same user permissions as the old one.
Model Changes
-
Copy and paste the contents of the view files from the old connection (these are the view files that are now above the schema folders in the IDE) into the new view files that were generated when the connection was modified.
Note, if you use the
included_schema
orincluded_views
parameters in the model file, hold off on prepending or changing the schema name until the old view files’ content has been copied over to all the respective new views. Otherwise you won’t be able to see the logic in those files. If you have a github repo setup then you can use that instead as a reference. -
Three options for fixing the broken content references:
a. Use the content validator to fix broken references. This option is best if you do not have much content already pointing to the old files.
b. Use therenamed_from
parameter in the new view file to reference the old view name. This points any content tied to the old view files to the new view file.
c. Use thealiases
parameter in the new view file to reference the old view name. -
Once you have made all reference changes then you can modify the included views and schemas parameter to declutter the IDE file navigation. You may also edit the connection again to not have the old project or schemas included.
If you start this process and want to revert the changes, it’s possible to revert the connection to the way it was, reset the model to previous working version and then refresh the schema on that model.