Configuring the Snowflake Connector for Google Analytics Raw Data using SQL¶
This topic provides information on configuring the Snowflake Connector for Google Analytics Raw Data through SQL.
Note
Snowflake Connector for Google Analytics Raw Data configuration is typically done using Snowsight. SQL configuration is considered an advanced configuration method and should only be used by those familiar with the underlying details of connector configuration.
To configure the connector using SQL statements, do the following:
Prepare a warehouse, data owner role and destination database.
Create Snowflake objects required for connecting to the GCP.
Note
In order to provision the connector and configure connection you will have to use stored procedures that are defined in the PUBLIC schema of the database that serves as an instance of the connector installation database.
Before calling these stored procedures, select that database as the database to use for the session.
For example, if that database is named snowflake_connector_for_google_analytics_raw_data, run the following command:
Prepare a warehouse, data owner role and destination database¶
Grant usage on specified warehouse and task execution permissions to the connector application.
Create the data owner role.
Create a destination database and schema.
You may also use an existing destination database and schema – especially if you’re re-installing the connector.
Add required grants on the destination database to the application.
(Optional) Transfer ownership of tables and views in the destination schema
If the connector was reinstalled and a previous destination schema is reused, ownership of all tables and views in destination schema must be transferred to the connector. The connector requires ownership privilege to manage grants on objects in schema and to recreate flattened views when schema of ingested table is changed.
To transfer the ownership call the
SYSTEM$GRANT_OWNERSHIP_TO_APPLICATIONfunction.The
SYSTEM$GRANT_OWNERSHIP_TO_APPLICATIONis a system function provided by Snowflake that allows the transfer of ownership of tables and views in a specified database or schema to the application. Only the ownership of regular tables and regular views is transferred, e.g. ownership of dynamic tables, external tables, materialized views, etc. won’t be transferred.The function has the following signature:
Where:
to_appSpecifies the name of the application to which the ownership of objects should be transferred.
should_copy_grantsIf
TRUEthen copy existing grants, otherwise revoke. Copying grants requiresMANAGE GRANTSpermission on the caller.from_databaseName of the database containing objects whose ownership should be changed.
from_schema(Optional) name of the schema containing objects whose ownership should be changed. If no schema is specified, ownership is transferred on tables and views in all schemas in the provided database. Objects in managed schemas are omitted during ownership transfer.
To execute the function the caller must meet one of the following conditions:
It has
MANAGE GRANTSpermission (e.g. ACCOUNTADMIN or SECURITYADMIN role), orIt contains role owning the application instance and role owning all objects to transfer the ownership. Objects on which the ownership is missing are omitted by the function.
For example, to transfer ownership to the connector that:
Was installed as
snowflake_connector_for_google_analytics_raw_dataUses the schema named
dest_db.dest_schemafor the Google Analytics data in Snowflake
Run the following command:
If needed, grant
DATA_READERapplication role to the role previously owning the data to prevent disruptions of existing pipelines using the data:Note that
DATA_READERapplication role won’t have any grants on tables and views in destination schema untilPROVISION_CONNECTORprocedure is run.
Provision the connector¶
Call the
PROVISION_CONNECTORprocedure.Pass the name of the warehouse, destination database and schema, and data owner role. These values are case-sensitive.
Create Snowflake objects required for connecting to the GCP¶
Create a security integration for your service account.
First, you need a service account key file. For details on how to create one see Configuring service account authentication for Google Cloud Platform (GCP)
Create a secret using the security integration.
Provide secret-related grants to the connector application.
Configure external access.
Keep in mind, that the path to the secret passed to
allowed_authentication_secretsis case-sensitive.
Configure connection with the GCP¶
Call the
CONFIGURE_CONNECTIONprocedure.Pass the name of the external access integration, the full path to the secret, and the name of the security integration. These values are case sensitive.
Check the connection status.
If there are no errors, you can follow Setting up data ingestion for your Snowflake Connector for Google Analytics Raw Data to enable your Google Analytics properties.