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:
- The Zero-Copy connector must be in the
CONNECTEDstate. See Set up the Salesforce Data Cloud Zero-Copy connector. - Your Salesforce administrator must have created and linked at least one Data Share to the connector. See Set up Salesforce Data Cloud for Zero-Copy.
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:
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.
The status field indicates whether the data share is available to mount or already mounted:
| Status | Description |
|---|---|
UNMOUNTED | Shared by Salesforce Data Cloud. No catalog-linked database has been created yet. |
MOUNTED | A catalog-linked database exists for this share. |
To parse the output into a tabular format:
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¶
- In Snowsight, navigate to Ingestion » Zero-Copy.
- Select the Available connectors tab and click your Salesforce connector.
- 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:
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_NAMEorSHARE_NAME_FILTER, each name must match a share returned bySYSTEM$ZEROCOPY_CONNECTOR_LIST_SHARESexactly, 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: IfTRUE, 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 isFALSE. See Migrate from the legacy Snowflake data share target.SALESFORCE_USER_FRIENDLY_NAME: IfTRUE(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__csuffix removed from the column names. For example,Case_Home__dllis also available asCase_Home, and itsAccountId__ccolumn asAccountId. 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:
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:
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:
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 exampleAccountId__c. The columns of a CIO view are the CIO’s dimension and measure names. - When
SALESFORCE_USER_FRIENDLY_NAMEisTRUE(the default), Snowflake also creates a short-named view without the object-type suffix and with the__csuffix 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 VIEWSandSHOW COLUMNSdisplay 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¶
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.
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:
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:
| Schedule | What it picks up | Default | How to view or change it |
|---|---|---|---|
| Discovery | New and removed data shares (schemas) and objects in each catalog-linked database. | Every 5 minutes, per catalog-linked database | Read |
| Table metadata refresh | The 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¶
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:
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:
- SYSTEM$CATALOG_LINK_STATUS returns the discovery status of the database, including objects that failed to load.
- SYSTEM$GET_CATALOG_LINKED_DATABASE_CONFIG returns the settings of the database, such as
sync_interval_secondsand whether discovery is suspended.
Create table as select (CTAS)¶
To persist query results as a native Snowflake table for use in dashboards, ML models, or data sharing:
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.
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.