Explore data products from Salesforce Data Cloud

This topic describes how to list available Salesforce data products, mount them as catalog-linked databases, and query the shared data in Snowflake.

Before performing the steps in this topic:

List shared data products

After your Salesforce administrator links a Data Share to the Snowflake V2 Data Share Target, call SYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARES to see what’s available:

SELECT SYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARES('my_db.my_schema.my_sfdc_connector');

The function returns a JSON array. Each element represents one shared data product. The name field is the value you pass as SHARE_NAME or SHARE_NAME_FILTER when creating a catalog-linked database.

[
  {
    "name": "contact_v1",
    "status": "UNMOUNTED",
    "catalog_linked_databases": []
  },
  {
    "name": "opportunity_v1",
    "status": "MOUNTED",
    "catalog_linked_databases": [ { "name": "MARKETINGSHARE" } ]
  }
]

The status field indicates whether the data share is available to mount or already mounted:

StatusDescription
UNMOUNTEDShared by Salesforce Data Cloud. No catalog-linked database has been created yet.
MOUNTEDA catalog-linked database exists for this share.

To parse the output into a tabular format:

WITH raw AS (
  SELECT PARSE_JSON(
    SYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARES('my_db.my_schema.my_sfdc_connector')
  ) AS json_data
)
SELECT
  f.value:name::STRING                                              AS share_name,
  f.value:status::STRING                                           AS status,
  CASE
    WHEN ARRAY_SIZE(f.value:catalog_linked_databases) > 0
    THEN f.value:catalog_linked_databases[0]:name::STRING
    ELSE NULL
  END                                                              AS mounted_database
FROM raw,
LATERAL FLATTEN(INPUT => json_data) f;

Create a catalog-linked database

Mounting a share creates a catalog-linked database that contains the shared data as queryable schemas. Snowflake automatically creates views on top of them.

You can mount using the Snowsight UI or SQL.

Using Snowsight

  1. In Snowsight, navigate to Ingestion » Zero-Copy.
  2. Select the Available connectors tab and click your Salesforce connector.
  3. On the Catalog linked databases tab, click Mount all data shares.

The catalog-linked database is created immediately.

Using SQL

Create the database with CREATE DATABASE … LINKED_ZEROCOPY_CONNECTOR:

-- (Recommended) Mount all shares — each share becomes a schema
CREATE DATABASE my_sfdc_db
  LINKED_ZEROCOPY_CONNECTOR = (
    CONNECTOR_NAME = 'my_db.my_schema.my_sfdc_connector',
    ALL_SHARES = TRUE
  );

-- Mount a filtered set of shares
CREATE DATABASE my_sfdc_db
  LINKED_ZEROCOPY_CONNECTOR = (
    CONNECTOR_NAME = 'my_db.my_schema.my_sfdc_connector',
    SHARE_NAME_FILTER = ('share1', 'share2')
  );

-- Mount a single share
CREATE DATABASE my_sfdc_db
  LINKED_ZEROCOPY_CONNECTOR = (
    CONNECTOR_NAME = 'my_db.my_schema.my_sfdc_connector',
    SHARE_NAME = 'my_share'
  );

-- Mount all shares, setting the optional properties
CREATE DATABASE my_sfdc_db
  LINKED_ZEROCOPY_CONNECTOR = (
    CONNECTOR_NAME = 'my_db.my_schema.my_sfdc_connector',
    ALL_SHARES = TRUE,
    SYNC_INTERVAL_SECONDS = 300,
    LEGACY_SALESFORCE_SCHEMA_ALIAS = FALSE,
    SALESFORCE_USER_FRIENDLY_NAME = TRUE
  );

Specify exactly one of ALL_SHARES = TRUE, SHARE_NAME, or SHARE_NAME_FILTER:

  • Each data share becomes one schema in the catalog-linked database, named after the share.
  • With ALL_SHARES = TRUE, Snowflake adds a schema when a data share is linked to the data share target in Salesforce and removes it when the share is unlinked. See Data freshness and refresh.
  • With SHARE_NAME or SHARE_NAME_FILTER, each name must match a share returned by SYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARES exactly, including case.
  • Changing the selector after the database is created isn’t supported. To mount a different set of shares, create another catalog-linked database.

The connector must be in the CONNECTED state. The role that runs the statement needs the CREATE DATABASE privilege on the account and the USAGE privilege on the connector. For details, see Salesforce Data Cloud Zero-Copy connector: Security and privileges.

The following properties are optional. For the full syntax, see CREATE DATABASE (zero-copy connector-linked).

  • SYNC_INTERVAL_SECONDS: How often Snowflake looks for new and removed data shares and objects. The default for a Salesforce connector is 300 seconds (5 minutes), and the value can range from 30 to 86400 seconds (1 day). See Data freshness and refresh.
  • LEGACY_SALESFORCE_SCHEMA_ALIAS: If TRUE, Snowflake also exposes each mounted share under its Data Cloud V1 schema name, schema_<share_name>, so that a three-part reference written against the database created from the legacy target still resolves after you swap in the catalog-linked database. The default is FALSE. See Migrate from the legacy Snowflake data share target.
  • SALESFORCE_USER_FRIENDLY_NAME: If TRUE (the default), Snowflake also exposes a short-named view for each object, with the object-type suffix (__dll, __dlm, or __cio) removed from the view name and the __c suffix removed from the column names. For example, Case_Home__dll is also available as Case_Home, and its AccountId__c column as AccountId. See View and column names.

You can change these three properties after you create the database. See Change the view-shape options.

To confirm the database was created:

SHOW DATABASES LIKE 'MY_SFDC_DB%';

Change the view-shape options

You can change LEGACY_SALESFORCE_SCHEMA_ALIAS and SALESFORCE_USER_FRIENDLY_NAME after you create the database with ALTER DATABASE … UPDATE LINKED_ZEROCOPY_CONNECTOR, the same statement that changes the sync interval. You can set one option or several in a single statement:

-- Start exposing the Data Cloud V1 alias schemas
ALTER DATABASE my_sfdc_db UPDATE LINKED_ZEROCOPY_CONNECTOR
  SET LEGACY_SALESFORCE_SCHEMA_ALIAS = TRUE;

-- Stop exposing the short-named views
ALTER DATABASE my_sfdc_db UPDATE LINKED_ZEROCOPY_CONNECTOR
  SET SALESFORCE_USER_FRIENDLY_NAME = FALSE;

To run these statements, you need the MODIFY privilege on the catalog-linked database, or ownership of it. Changing CONNECTOR_NAME, SHARE_NAME, SHARE_NAME_FILTER, or ALL_SHARES isn’t supported. The added or removed views appear shortly after the statement, not immediately.

The schema_<share_name> schemas that LEGACY_SALESFORCE_SCHEMA_ALIAS = TRUE adds contain the full-named views only, not the short-named views. Snowflake drops them when you set the option back to FALSE.

To see the values currently in effect, use SYSTEM$GET_ZEROCOPY_CONNECTOR_LINKED_DATABASE_CONFIG:

SELECT SYSTEM$GET_ZEROCOPY_CONNECTOR_LINKED_DATABASE_CONFIG('my_sfdc_db');
{
  "zerocopy_connector": "MY_DB.MY_SCHEMA.MY_SFDC_CONNECTOR",
  "zerocopy_partner_type": "SALESFORCE",
  "legacy_salesforce_schema_alias": false,
  "salesforce_user_friendly_name": true
}

The sync interval isn’t part of that output. To read it, use SYSTEM$GET_CATALOG_LINKED_DATABASE_CONFIG, which returns sync_interval_seconds along with the other properties every catalog-linked database carries.

Explore the data

Data model overview

When you mount a share, each data share appears as a schema within the catalog-linked database. Within each schema, Salesforce data objects are exposed as views. Snowflake creates and maintains these views; query the views, not the tables they read from.

The catalog-linked database is read-only, and the data stays in Salesforce Data Cloud. Snowflake doesn’t copy it.

Which objects get a view

Snowflake creates one view for each of the following objects in a data share:

  • Each data lake object (DLO) that your Salesforce administrator added to the data share. These views have names that end in __dll.
  • Each data model object (DMO) in the data share. These views have names that end in __dlm.
  • Each calculated insight object (CIO) in the data share. These views have names that end in __cio.

A DLO that’s part of the share only because a shared DMO is mapped to it doesn’t get a view of its own. Its data is available through the DMO’s view. To query that DLO directly, ask your Salesforce administrator to add it to the data share.

View and column names

  • Each object always has a full-named view whose name is the object’s API name in Data Cloud, for example Case_Home__dll. Its columns use the Data Cloud field names, for example AccountId__c. The columns of a CIO view are the CIO’s dimension and measure names.
  • When SALESFORCE_USER_FRIENDLY_NAME is TRUE (the default), Snowflake also creates a short-named view without the object-type suffix and with the __c suffix removed from column names. No short-named view is created when two objects in the same schema would get the same short name (compared without regard to case) or when the short name would be the same as a full-named view’s name. In those cases, use the full-named view.
  • SHOW VIEWS and SHOW COLUMNS display view and column names in the case they have in Data Cloud. Catalog-linked databases created from a Zero-Copy connector are case-insensitive by default, so you can use these names without double quotes and in any case.
  • Each view’s comment is the object’s description in Data Cloud, or the object’s label if it has no description. Column comments come from the field descriptions and labels in the same way. Snowflake updates the comments when they change in Data Cloud.

Discover schemas and views

-- Data shares are mounted as schemas in the catalog-linked database
SHOW SCHEMAS IN DATABASE my_sfdc_db;

-- Views are the queryable layer — use these for all queries
SHOW VIEWS IN SCHEMA my_sfdc_db.my_share_schema;

-- Inspect columns before querying
SHOW COLUMNS IN VIEW my_sfdc_db.my_share_schema.ssot__Account__dlm;

Note

A view appears shortly after its object is discovered. For a new catalog-linked database with many objects, this can take several minutes. If SHOW VIEWS doesn’t list a view you expect, see Troubleshoot the Salesforce Data Cloud Zero-Copy connector.

Query the data

Query Salesforce data via the views in each schema. The view names are determined by what your Salesforce administrator included in the Data Share.

-- Query a Data Lake Object (DLO)
SELECT * FROM my_sfdc_db.my_share_schema.Case_Home__dll LIMIT 10;

-- Query a Data Model Object (DMO)
SELECT * FROM my_sfdc_db.my_share_schema.ssot__PriceBook__dlm LIMIT 10;

-- Query a Calculated Insights Object (CIO)
SELECT * FROM my_sfdc_db.my_share_schema.Product_Sku_Aggregation__cio LIMIT 10;

Replace my_sfdc_db, my_share_schema, and the view names with the actual values returned by SHOW SCHEMAS and SHOW VIEWS in your environment.

Snowflake can’t read objects that aren’t stored in the Salesforce lakehouse, such as an external DLO or a DMO mapped to an external DLO. Ask your Salesforce administrator to remove them from the data share. See Set up Salesforce Data Cloud for Zero-Copy.

Restrictions

  • The catalog-linked database is read-only. Loading or changing data in it, and creating, altering, renaming, or dropping views in it, aren’t supported. To build your own views or tables over the data, create them in a regular database. See Create table as select (CTAS).
  • Only the views are accessible. The tables that the views read from aren’t accessible.
  • Renaming or swapping objects into or out of the catalog-linked database, and replicating the database, aren’t supported.

Grant access to other roles

To let other roles query the data, grant USAGE on the catalog-linked database and its schemas, and SELECT on the views:

GRANT USAGE ON DATABASE my_sfdc_db TO ROLE analyst;
GRANT USAGE ON ALL SCHEMAS IN DATABASE my_sfdc_db TO ROLE analyst;
GRANT SELECT ON ALL VIEWS IN DATABASE my_sfdc_db TO ROLE analyst;

Snowflake keeps these grants when it updates a view. A schema or view that Snowflake adds later, for example when your Salesforce administrator shares a new object, doesn’t receive grants made with ON ALL. Rerun the GRANT ... ON ALL statements after new schemas or views appear.

The owner role of the catalog-linked database must keep the USAGE privilege on the connector. For details, see Salesforce Data Cloud Zero-Copy connector: Security and privileges.

Data freshness and refresh

Two schedules determine when changes in Salesforce Data Cloud appear in Snowflake:

ScheduleWhat it picks upDefaultHow to view or change it
DiscoveryNew and removed data shares (schemas) and objects in each catalog-linked database.Every 5 minutes, per catalog-linked database

Read sync_interval_seconds from SYSTEM$GET_CATALOG_LINKED_DATABASE_CONFIG. Change it with ALTER DATABASE … UPDATE LINKED_ZEROCOPY_CONNECTOR (30 to 86400 seconds). Run a discovery cycle immediately with SYSTEM$SYNC_ZEROCOPY_OBJECTS.

Table metadata refreshThe latest table metadata for objects that Snowflake has already discovered, so queries reflect changes committed in Salesforce.Every 30 seconds, per connector

Read it with SYSTEM$GET_ZEROCOPY_METADATA_AUTO_REFRESH_INTERVAL. Change it with SYSTEM$SET_ZEROCOPY_METADATA_AUTO_REFRESH_INTERVAL (30 seconds to 1 day).

So a new object in a share first needs a discovery cycle (up to the sync interval, 5 minutes by default), and its view appears shortly afterwards. New rows in an object that already has a view appear after the next table metadata refresh. Queries don’t check Salesforce Data Cloud for newer table metadata; they read the table metadata from the most recent refresh.

Change the discovery interval or run discovery now

-- Look for new shares and objects every 2 minutes
ALTER DATABASE my_sfdc_db UPDATE LINKED_ZEROCOPY_CONNECTOR
  SET SYNC_INTERVAL_SECONDS = 120;

-- Run a discovery cycle now, for example right after your Salesforce administrator adds an object
SELECT SYSTEM$SYNC_ZEROCOPY_OBJECTS('my_sfdc_db');

SYSTEM$SYNC_ZEROCOPY_OBJECTS returns right away, and doesn’t refresh the table metadata of objects that are already discovered. Both statements require the MODIFY privilege on the catalog-linked database, or ownership of it. To pause and resume scheduled discovery, use ALTER DATABASE … SUSPEND DISCOVERY and RESUME DISCOVERY, which require the OWNERSHIP privilege on the database. While discovery is suspended, Snowflake also stops updating the views.

Change the table metadata refresh interval

The table metadata refresh interval belongs to the connector, so it applies to every catalog-linked database created from that connector:

SELECT SYSTEM$GET_ZEROCOPY_METADATA_AUTO_REFRESH_INTERVAL('my_db.my_schema.my_sfdc_connector');

SELECT SYSTEM$SET_ZEROCOPY_METADATA_AUTO_REFRESH_INTERVAL('my_db.my_schema.my_sfdc_connector', '5m');

Specify a single value with one unit, such as '30s', '5m', '10 minutes', '1h', or '1d'. The value must be between 30 seconds and 1 day. Setting the interval requires the MODIFY privilege on the connector.

Check status

The functions that work on any catalog-linked database also work on catalog-linked databases created from a Zero-Copy connector:

SELECT SYSTEM$CATALOG_LINK_STATUS('my_sfdc_db');

Create table as select (CTAS)

To persist query results as a native Snowflake table for use in dashboards, ML models, or data sharing:

CREATE DATABASE IF NOT EXISTS my_ctas_db;
USE DATABASE my_ctas_db;

-- Snapshot a Salesforce data model object into a native Snowflake table
CREATE OR REPLACE TABLE account_snapshot AS
SELECT *
FROM my_sfdc_db.my_share_schema.ssot__Account__dlm;

SELECT * FROM account_snapshot LIMIT 10;

Drop a catalog-linked database

All catalog-linked databases must be dropped before you can disconnect or drop the connector. Catalog-linked databases do not support UNDROP.

DROP DATABASE my_sfdc_db;

Dropping and recreating a catalog-linked database doesn’t change the data it shows, because the data comes from Salesforce, and it removes the grants on the database. If data looks stale or a view is missing, see Troubleshoot the Salesforce Data Cloud Zero-Copy connector instead.