Best way to import Google Cloud SQL data into BigQuery

前端 未结 3 1175
不思量自难忘°
不思量自难忘° 2021-01-14 01:48

I have a database in a Cloud SQL instance. I would like to copy its content into BigQuery in order to perform analysis. It is not a requirement for me to continuously update

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 02:28

    BigQuery can directly query Cloud SQL through Cloud SQL federated queries. It introduces a new SQL function called EXTERNAL_QUERY(connection_id, external_sql), which run the external_sql in the Cloud SQL database specified by connection_id.

    You need to first create connection in BigQuery, then refer the connection_id in EXTERNAL_QUERY(). Following is a sample query to copy Cloud SQL data to BigQuery.

    INSERT
      demo.customers (column1)
    SELECT
       * 
    FROM
       EXTERNAL_QUERY("project.us.connection",
                      "SELECT column1 FROM mysql_table;");
    

提交回复
热议问题