Google Sheets

Google Sheets is a spreadsheet program included as part of the free, web-based Google Docs Editors suite offered by Google.

Prerequisites

You will need to enable, or have access to, the Google Drive API and the Google Sheets API.

You will also need to be able to create, or have access to, user OAuth credentials or a Service Account.

Authentication methods

OAuth (User Created)

This method uses your own Google Project to authorize access, and is the most secure method since your own OAuth credentials are used.

To generate credentials:

  1. Click "Create Credentials" and choose "OAuth Client ID" as the type

  2. Choose "Web Application" as the application type

  3. Add a redirect URI of the form https://apps-api.c1.<region>.<cloud-vendor>.app.snowflake.com/oauth/complete-secret

If you're unsure what value to for the redirect URI, the following Snowflake query will construct it for your account: select 'https://'||t.value:host::varchar||'/oauth/complete-secret' as URI from table(flatten(input => parse_json(system$allowlist()))) as t where t.value:host::varchar LIKE 'apps-api%';

  1. Click Create, and use the generated Client ID and Secret during Omnata connection creation.

  1. In the Omnata App, Create a Connection and follow the instructions to create and authorise the integration.

Service Account

To use a service account:

  1. Create a service account in the appropriate GCP project

  2. Create a new key:

  3. Download the JSON file, copy its contents, and provide it during connection configuration

  4. On the details tab of the service account, copy the email address of the service account

  5. Open the sheet that you want to sync to/from, and invite the service account as viewer/editor by email address

Inbound Syncs

For each inbound sync, a single spreadsheet is selected and multiple sheets can be included in the sync.

Sheets need to be structured like a database table. The top row are the headers with data below, with no merged cells or blank space.

Supported Sync Strategies

  • Full Refresh

Outbound Syncs

Supported Targets

With the Google Sheets app, you copy the contents of a Snowflake table/view into a Google Sheet.

Supported Sync Strategies

  • Replace (a full replacement of sheet contents)

Functions

GET_SPREADSHEET_METADATA

Gets metadata about a Google Sheet

Parameters:

  • CONNECTION_SLUG (VARCHAR): The slug of the connection to query

  • SPREADSHEET_ID (VARCHAR): The ID of the spreadsheet

Example:

select (OMNATA_GOOGLE_SHEETS_PLUGIN.UDFS.GET_SPREADSHEET_METADATA(
                CONNECTION_SLUG=>'my_google_sheets_connection',
                SPREADSHEET_ID => 'spreadsheet_id')

LIST_SPREADSHEETS

Returns a list of spreadsheets

Parameters:

  • CONNECTION_SLUG (VARCHAR): The slug of the connection to query

Example:

Returns a list of spreadsheets with name like...

select * 
from table(OMNATA_GOOGLE_SHEETS_PLUGIN.UDFS.LIST_SPREADSHEETS(
                CONNECTION_SLUG=>'my_google_sheets_connection'))
where Name like '%my_spreadsheet_name%';

LIST_SPREADSHEET_SHEETS

Returns a list of spreadsheets

Parameters:

  • CONNECTION_SLUG (VARCHAR): The slug of the connection to query

  • SPREADSHEET_ID (VARCHAR): The ID of the spreadsheet

Example:

Returns the list of sheets in a spreadsheet

select * 
from table(OMNATA_GOOGLE_SHEETS_PLUGIN.UDFS.LIST_SPREADSHEETS(
                CONNECTION_SLUG=>'my_google_sheets_connection',
                SPREADSHEET_ID => 'spreadsheet_id'));

READ_SHEET

Returns the contents of a sheet

Parameters:

  • CONNECTION_SLUG (VARCHAR): The slug of the connection to query

  • SPREADSHEET_ID (VARCHAR): The ID of the spreadsheet

  • SHEET_NAME (VARCHAR): The name of the sheet

Example:

Returns the contents of a sheet

select * 
from table(OMNATA_GOOGLE_SHEETS_PLUGIN.UDFS.READ_SHEET(
        CONNECTION_SLUG => 'my_google_sheets_connection',
        SPREADSHEET_ID => 'spreadsheet_id',
        SHEET_NAME => 'Sheet1'));

Last updated