2
votes

I am trying to create a connection to a Cloud SQL database in another GCP project in Big Query. It will not allow me. I am getting the message:

CloudSQL instances must be in the same project as the query connection.

How do I get around this? Is my only option to copy the data from one project to another?

1
It can be explained because the resources are in different projects as the error message states. Please refer to the following links to know more about how to Working with connections.Mathew Bellamy
The federated queries only work in the same project because when you create the External Data Source in Bigquery you use the Cloud SQL connection name (project_id:region:instance_name) which is valid only internally in a project, so there is no way to query the Cloud SQL database from Bigquery that is in another project unless you create a replica of your database in the second project where Bigquery lives. For this you can visit the following site Introduction to external datasourcesMathew Bellamy

1 Answers

0
votes

There is a bad workaround. Create a view with the request to your Cloud SQL database in the same project as your Cloud SQL instance, and query this view from another project.

The problem (and why it's a bad workaround) is that you can't customize the Cloud SQL query. In fact, you should create a view for each table, and then create your query with all the views to achieve your joins and other SQL manipulation that you want.