© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. CarruthersBuilding the Snowflake Data Cloudhttps://doi.org/10.1007/978-1-4842-8593-0_14

14. Snowflake Data Cloud by Example

Andrew Carruthers1  
(1)
Birmingham, UK
 

This chapter discusses implementing two paradigms: Snowflake Data Exchange and Snowflake Marketplace . Both are underpinned by Snowflake Secure Data Sharing, which we delve into first. You know from Chapter 1 that Snowflake Data Exchange and Snowflake Marketplace are similar in concept but serve different target audiences. Secure Direct Data Share underpins both Snowflake Data Exchange and Snowflake Marketplace. Chapter 3 explained how data shares are implemented using micro-partitions. Let’s investigate use cases via hands-on practical examples.

For Secure Direct Data Share , we continue our investigation using command-line scripts; but for Snowflake Data Exchange and Snowflake Marketplace, there is no approved command-line approach for configuration. Instead, and in line with the Snowflake-approved approach, we use Snowsight. Furthermore, to participate in Snowflake Marketplace, there is a formal engagement process to endure with a commitment to producing specific data sets, not to be undertaken lightly. More information is at https://other-docs.snowflake.com/en/marketplace/becoming-a-provider.html#step-1-submit-a-request-to-join-the-snowflake-data-marketplace .

Two separate Snowflake accounts are required for this chapter. For ease of testing, please ensure both are in the same cloud service provider and region. The data share examples will not work otherwise! Using a single email address, multiple trial Snowflake accounts may be provisioned at https://signup.snowflake.com .

Snowflake is constantly evolving, and screenshots may be enhanced or reorganized between writing and publication. However, the general content and navigation are sure to remain relevant. Be aware that some details may change. Due to space constraints, I have not explored every option available for every feature but instead focused on what is believed to be the core capabilities resulting in end-to-end data provision and consumption.

Note

Terminology and product positioning have changed since inception. Please refer to the documentation for the latest information.

For an overview of the three product offerings discussed in this chapter, please also refer to the documentation at https://docs.snowflake.com/en/user-guide/data-sharing-product-offerings.html#overview-of-the-product-offerings-for-secure-data-sharing .

This chapter is what I would have liked to have at the outset of my Snowflake journey, a blueprint to get started, investigate further, and build out into a comprehensive, secure, business-focused solution.

By the end of this chapter, you will be equipped to implement pragmatic solutions immediately useful to your organization’s internal and external facing needs.

A bold claim. Let’s get started!

Overview

Let’s start by reviewing our objectives in the context of Snowflake’s platform, as shown in Figure 14-1.

A schematic of the snowflake's platform with data source and data consumers at each end. The platform consists of 6 icons labeled data engineering, data lake, data warehouse, data science, data application, and data sharing. Logos of google cloud, A W S, and azure are below the platform.

Figure 14-1

Snowflake platform

Earlier chapters explained how to ingest data into Snowflake by presenting data for usage using a common pattern: data ingestion on the left and data consumption on the right. Recognizing we have not addressed data science and data applications, both are better served by other authors and media, not the least due to space constraints in this book.

Our focus now shifts to data sharing, the final part of our journey to interacting with internal and external consumers. In support, we should know where Snowflake has established its presence, as Figure 14-2 shows.

A world map with locations marked for A W S, azure, and G C P. Dotted double-headed arrows mark the path between the locations.

Figure 14-2

Snowflake locations

The latest Snowflake location information is at https://docs.snowflake.com/en/user-guide/intro-regions.html .

We must be aware of Snowflake’s presence for various reasons, not the least of which are costs when moving data between cloud service providers (CSPs) and regions, see documentation at https://docs.snowflake.com/en/user-guide/billing-data-transfer.html#data-transfer-billing-use-cases .

Let’s consider the purpose of Secure Direct Data Share, Data Exchange, and Data Marketplace. Figure 14-3 compares options and provides context for this chapter.

A three-part schematic for direct share, data exchange, and snowflake data marketplace respectively. Direct share with your account to other accounts. Data exchange of your account sharing to multiple accounts. Snowflake data marketplace of your account, marketplace, and sectors such as business, demographic, and more connected together.

Figure 14-3

Snowflake data interchange options

Secure Direct Data Share

If the receiving Snowflake account is in a different region or hosted in a different CSP than the primary, then you must replicate first before sharing, as Figure 14-4 illustrates.

A schematic of A W S, E U Dublin region, and London region. In the Dublin region, primary account shares to consumer A. In the London region, the primary account shares with consumer X and consumer Y. The primary account of the London region is replicated from the Dublin region.

Figure 14-4

Replicate before share

In the same CSP and region, either Secure Direct Data Share or replication may be used, as illustrated in Figure 14-5.

A schematic of the A W S cloud region that consists of a provider account and a consumer account. Provider account contains database and share. The consumer account contains a database. The database consists of output schema and view. The share contains a view. View section is connected throughout.

Figure 14-5

Shared data conceptual model

Why Data Share?

We mostly work in environments where data silos predominate, and legacy thinking pervades our conversations, stifling innovation and preventing true data democratization. Consequently, we may only have access to curated data sets via limited access paths or, worse still, partial data sets from which to derive meaningful answers. Without wishing to repeat Chapter 2, we are largely stuck with the legacy paradigm born in the 1980s of FTP/SFTP, API, ETL/ELT, and most recently, cloud storage. Yes, it is surprising to see the latest emergent technology considered a legacy. But the stark reality is that many organizations have wrapped up cloud storage in legacy constructs because these are both familiar and well understood.

I recognize the irony. Most of this book has been concerned with ingesting data via legacy techniques. But the reality on the ground (at the time of writing) is that most organizations are not yet willing to move away from their comfort zone and embrace the new data-sharing paradigm.

I hope you are among those willing to consider a trial and then adopt what is considered the future of data interchange . Snowflake has envisioned a new paradigm, Secure Direct Data Share, where service on demand is seamless and transparent, and data access is available out of the box. Secure Direct Data Share is a built-in, highly secure, core Snowflake capability reliant on cloud storage to share data with internal business colleagues, partners, and Snowflake customers.

Note

The aim is to streamline data access by implementing frictionless interfaces while retaining data security and system integrity regardless of location.

Suitable for all applications , Secure Direct Data Share explicitly controls customers’ access to shared data. It is a great way to securely and safely monetize your data while always retaining full control.

Data sharing removes barriers, regardless of cloud, region, workload, or organizational domain, and gives instant access through a single copy of data. The number of data copies is set to rise from 9:1 to 10:1. Reusing a single copy of data should cause everyone to sit up and pay attention. Data sharing is a true game-changer.

Data sharing enables business continuity by eliminating disruptions and delivering a seamless customer experience, with no more processing chains or single points of failure from source to destination. Utilizing Snowflake’s global data mesh guarantees consistent, reliable delivery with full security embedded.

Incorporating object tagging gains the distributed benefit of our organization’s perspective on data categorization applied consistently across all uses of the subject data. Cross-domain governance is more easily managed centrally and consistently rather than distributed or fragmented across geographically disparate teams; one consistent implementation pattern and multiple aspects satisfy all use cases.

How to Data Share

Shares are a first-order object whose declaration and management are typically performed using the ACCOUNTADMIN role, the use of which should be tightly restricted. Snowflake provides instructions on devolving entitlement to lower privileged roles at https://docs.snowflake.com/en/user-guide/security-access-privileges-shares.html#enabling-non-accountadmin-roles-to-perform-data-sharing-tasks . In our view, devolving entitlement should not be done lightly as the law of unintended consequences quickly follows https://en.wikipedia.org/wiki/Unintended_consequences . I recommend that share entitlement is not devolved.

Let’s set our context by reusing our TEST database and using the ACCOUNTADMIN role .
USE ROLE      accountadmin;
USE DATABASE  TEST;
USE WAREHOUSE COMPUTE_WH;
USE SCHEMA    public;
Let’s create btsdc_share.
CREATE OR REPLACE SHARE btsdc_share;
With our share in place, let’s assign entitlement enabling the share to access objects.
USE ROLE securityadmin;
GRANT USAGE ON DATABASE TEST            TO SHARE btsdc_share;
GRANT USAGE ON SCHEMA   TEST.test_owner TO SHARE btsdc_share;

To identify shares.

SHOW shares;
Set context , switch role to test_object_role.
USE ROLE      test_object_role;
USE DATABASE  TEST;
USE SCHEMA    TEST.test_owner;
Create a test table.
CREATE OR REPLACE TABLE csv_test
(
id     NUMBER,
label  VARCHAR(30)
);
Now grant SELECT privilege on test table to share, noting test_object_role does not have entitlement to use share btsdc_share; therefore, we must use securityadmin.
USE ROLE securityadmin;
GRANT SELECT ON TEST.test_owner.csv_test TO SHARE btsdc_share;
We can see entitlement granted to a share.
SHOW GRANTS TO SHARE btsdc_share;
Attempting to enable an account outside the CSP or region or an invalid account identifier results in this error.
SQL compilation error: Following accounts cannot be added to this share: <account_name>.
To enable an account in the same CSP and region to access our share, we execute the following commands , recognizing each share may be accessed by many accounts, not just the one used in our example.
USE ROLE accountadmin;
ALTER SHARE btsdc_share SET
ACCOUNTS = <your_consumer_account>,
COMMENT  = 'Test share to Account';
And to remove an account from a share.
ALTER SHARE btsdc_share REMOVE ACCOUNT = <your_consumer_account>;

Replacing <your_consumer_account> with a consumer account in the same CSP and region.

To identify your Snowflake account, select current_account();.

We have created a share, assigned entitlement, and enabled another account in the same CSP and region to import the share. To do so, we must switch to the consumer Snowflake account and prepare a database.
USE ROLE accountadmin;
In the next command, replace <your_provider_account> with the name of the Snowflake provider account used to create the share.
CREATE OR REPLACE DATABASE btsdc_import_share
FROM SHARE <your_provider_account>.btsdc_share
COMMENT = 'Imported btsdc_share';
As a temporary measure and to prove imported shared objects exist, grant to SYSADMIN. This step illustrates an important point. Role-based access control (RBAC) is not carried forward with the share. They must be rebuilt in the recipient account. I strongly recommend giving due consideration to provisioning roles and entitlement for imported shares, which are not further explained here in the interests of brevity.
USE ROLE securityadmin;
GRANT IMPORTED PRIVILEGES ON DATABASE btsdc_import_share TO ROLE sysadmin;
We switch to the SYSADMIN role. Ensure imported objects can be seen in the share.
USE ROLE sysadmin;
SHOW SCHEMAS IN DATABASE btsdc_import_share;
SHOW TABLES IN SCHEMA btsdc_import_share.test_owner;
Let’s assume we need to share another table, switch back to our provider account, set our context, and add another table.
USE ROLE      test_object_role;
USE DATABASE  TEST;
USE SCHEMA    TEST.test_owner;
CREATE OR REPLACE TABLE csv_test_2
(
id     NUMBER,
label  VARCHAR(30)
);
USE ROLE securityadmin;
GRANT SELECT ON TABLE TEST.test_owner.csv_test_2 TO SHARE btsdc_share;
SHOW GRANTS TO SHARE btsdc_share;
Now switch back to our consumer account and check whether the table has been shared.
SHOW TABLES IN SCHEMA btsdc_import_share.test_owner;

We should see the new table csv_test_2 in our imported share. Naturally, all other share consumers can also see the new table.

Further information on consuming from shares is at https://docs.snowflake.com/en/user-guide/data-share-consumers.html#data-consumers .

Data Share Summary

Consumers may create a single database per share. An inbound database must be created before the share can be queried, and created databases can be renamed and dropped. As stated, roles and entitlement are not currently carried forward with the share. They must be rebuilt in the recipient account. However, row-level security, column-level security, external tokenization, and data masking policies are honored.

Managing the share is trivial. Adding and removing objects from the share does not require much effort, and all share consumers also receive the same shared objects.

Most importantly, no data is copied. Metadata alone enables the secure sharing of data in underlying storage. Since no data is copied from the provider account, the Snowflake consumer account is not charged for storage.

Only the most recent micro-partitions are available in the share. The Time Travel feature is not supported for objects imported via a share, although it is supported for the original objects. Not all schema object types can be shared, and for those shareable object types, their secure counterparts must be used to preserve strict control of access to data. Further information is at https://docs.snowflake.com/en/user-guide/data-sharing-provider.html#working-with-shares .

Reader Accounts

Reader accounts are provisioned for organizations who are not yet Snowflake customers enabling data query but not upload, update, or delete of data. A key advantage of reader accounts is reduced data integration cost with direct access to live, ready-to-query data.

For Snowflake customers, the compute cost is paid for by the consuming account. For non-Snowflake consumers using a reader account, consumption is paid for by the provider.

We do not provide an in-depth study of reader accounts but instead refer to Snowflake documentation at https://docs.snowflake.com/en/user-guide/data-sharing-reader-create.html#managing-reader-accounts .

Tracking Usage

Before investigating data access, we must be mindful of latency when accessing Snowflake’s Account Usage views. For query_history, latency can be up to 45 minutes, and for access_history, up to 3 hours. Latency is not a major consideration for tracking usage as the information is not of critical importance. More information is at https://docs.snowflake.com/en/sql-reference/account-usage.html#account-usage-views .

Access History

At the time of writing, the access_history view is a public preview and subject to change; therefore, the following code sample is indicative only. Documentation is at https://docs.snowflake.com/en/user-guide/access-history.html#access-history .

It is not currently possible to track consumer activity through the Snowflake Account Usage store. Each account tracks its own usage, for which these SQL statements may prove useful.

First, enable access to the Account Usage store.
USE ROLE securityadmin;
GRANT IMPORTED PRIVILEGES ON DATABASE snowflake TO ROLE test_object_role;
Revert to the test_object_role.
USE ROLE      test_object_role;
USE WAREHOUSE TEST_WH;
USE DATABASE  TEST;
USE SCHEMA    TEST.test_owner;
Create some test data.
INSERT INTO csv_test VALUES
(1, 'aaa'),
(2, 'bbb'),
(3, 'ccc');
Create a view v_access_history. You may wish to modify this to suit your needs.
CREATE OR REPLACE SECURE VIEW v_access_history AS
SELECT qh.query_text,
       qh.user_name||' -> '||qh.role_name||' -> '||qh.warehouse_name  AS user_info,
       qh.database_name||'.'||qh.schema_name||' -> '||qh.query_type||' -> '||qh.execution_status AS object_query,
       ah.query_start_time,
       ah.direct_objects_accessed,
       ah.base_objects_accessed,
       ah.objects_modified,
       ah.query_id
FROM   snowflake.account_usage.access_history ah,
       snowflake.account_usage.query_history  qh
WHERE  ah.query_id                            = qh.query_id
ORDER BY ah.query_start_time DESC;
If a Data Sharing provider account shares objects to a Data Sharing consumer accounts through a share, then for:
  • Data Sharing provider accounts: The queries and logs on the shared objects executed in the provider account are not visible to Data Sharing consumer accounts.

  • Data Sharing consumer accounts: The queries on the data share executed in the consumer account are logged and only visible to the consumer account, not the Data Sharing provider account. The base tables accessed by the data share are not logged.

Data Sharing Usage

Snowflake is developing a suite of monitoring views where we can track shared data usage. Current monitoring capability is quite limited and does not allow identifying the rows accessed by any specific query. The latency may be up to two days.

Please also refer to Snowflake documentation at https://docs.snowflake.com/en/sql-reference/data-sharing-usage.html .

Both classic and Snowsight browsers provide access to the Data Sharing Usage views. The classic view is shown in Figure 14-6.

A screenshot of a new worksheet with a search bar to find database objects. The data sharing usage is highlighted under the snowflake option.

Figure 14-6

Data sharing usage views

I recommend periodic checks of Data Sharing Usage views. The following are sample queries.
USE ROLE      test_object_role;
USE WAREHOUSE TEST_WH;
USE DATABASE  snowflake;
USE SCHEMA    snowflake.data_sharing_usage;
We expect zero rows unless shares have been consumed.
SELECT *
FROM   snowflake.data_sharing_usage.listing_consumption_daily;
SELECT *
FROM   snowflake.data_sharing_usage.listing_events_daily;
Intriguingly, during testing, history has been retained for prior implementation of Data Exchange .
SELECT *
FROM   snowflake.data_sharing_usage.listing_telemetry_daily;

Centralized Cost Monitoring

This section explores the potential for implementing a common cost monitoring pattern using data share and local tables.

Note

It is assumed that all code in this chapter has been run to this point.

Conceptual Model

Building upon the code developed in Chapter 6, let’s propose an extension to (almost) plug-and-play capability. Figure 14-7 illustrates a conceptual model of how a centralized cost monitoring share-based implementation may operate.

A schematic of the A W S cloud region that consists of a provider account A, provider account B, and a consumer account. Provider accounts contain databases with monitor schema and share with U D T F. A consumer account contains database a, and database b with import schema and U D T F and reporting database with reporting schema.

Figure 14-7

Conceptual model

Figure 14-7 shows two provider accounts (A & B) with a common suite of baselined reporting components deployed in a monitor schema. Each view overlays the provider Account Usage store or information schema with tabular SQL user-defined functions (UDTFs) , one per view. Each provider account shares its UDTFs, and the consumer account imports each share into a separate database, one per provider.

Taking advantage of UDTF capability to return a result set, scheduling via a task in the consumer account calls each UDTF inserting data into its own tables, one for each UDTF.

In the reporting database, result sets from each provider account reporting component are joined using views for common reporting.

Cost Monitoring Setup

Taking advantage of our share configuration , let’s extend functionality by implementing components to demonstrate how centralized cost monitoring can be delivered.

Grant entitlement to both executes and create tasks.
USE ROLE accountadmin;
GRANT EXECUTE TASK ON ACCOUNT TO ROLE test_object_role;
USE ROLE securityadmin;
GRANT CREATE TASK ON SCHEMA TEST.test_owner TO ROLE test_object_role;
Set context.
USE ROLE      test_object_role;
USE WAREHOUSE TEST_WH;
USE DATABASE  TEST;
USE SCHEMA    TEST.test_owner;

Let’s assume we want to report warehouse credit consumption by the warehouse for the previous day. In practice, we may want a more sophisticated view, but for our example, this will suffice.

CREATE OR REPLACE SECURE VIEW v_warehouse_spend COPY GRANTS
AS
SELECT wmh.warehouse_name,
       SUM ( wmh.credits_used )             AS credits_used,
       EXTRACT ( 'YEAR',  wmh.start_time )||
       EXTRACT ( 'MONTH', wmh.start_time )||
       EXTRACT ( 'DAY',   wmh.start_time )  AS spend_date
FROM   snowflake.account_usage.warehouse_metering_history wmh
WHERE  TO_DATE ( spend_date, 'YYYYMMDD' ) = current_date() -1
GROUP BY wmh.warehouse_name,
         spend_date
ORDER BY spend_date DESC, wmh.warehouse_name ASC;
Prove v_warehouse_spend returns results.
SELECT * FROM v_warehouse_spend;

We should see results from our Snowflake activity. We may also see unexpected rows from serverless compute.

We cannot add v_warehouse_spend directly to our share; otherwise, we receive this error: “SQL compilation error: A view or function being shared cannot reference objects from other databases.” The error is caused by referencing the Snowflake database but using the TEST database for sharing. Instead, we must use a task to extract data into a table in the TEST database and then share the table.

Create a table named warehouse_spend_hist to hold the view output.
CREATE OR REPLACE TABLE warehouse_spend_hist
(
warehouse_name VARCHAR(255),
credits_used   NUMBER(18,6),
spend_date     VARCHAR(10),
last_updated   TIMESTAMP_NTZ DEFAULT current_timestamp()::TIMESTAMP_NTZ NOT NULL
);
Now create a task named task_load_warehouse_spend_hist, which runs once daily to load the warehouse_spend_hist table with the previous day’s spend data. The schedule has been set to 1 minute for testing purposes only with a once per day (at 01:00) execution schedule commented out for later use. CRON was used to demonstrate an alternative method of scheduling.
CREATE OR REPLACE TASK task_load_warehouse_spend_hist
WAREHOUSE = TEST_WH
SCHEDULE  = 'USING CRON * * * * * UTC'
--SCHEDULE  = 'USING CRON 0 1 * * * UTC'
AS
INSERT INTO warehouse_spend_hist
SELECT warehouse_name,
       credits_used,
       spend_date,
       current_timestamp()::TIMESTAMP_NTZ
FROM   v_warehouse_spend;
Ensure task is registered.
SHOW tasks;
Enable task_load_warehouse_spend_hist but be sure to SUSPEND after the first run.
ALTER TASK task_load_warehouse_spend_hist RESUME;
Check next_run to ensure that the task is running.
SELECT timestampdiff ( second, current_timestamp, scheduled_time ) as next_run,
       scheduled_time,
       current_timestamp,
       name,
       state
FROM   TABLE ( information_schema.task_history())
WHERE  state = 'SCHEDULED'
ORDER BY completed_time DESC;
When the run is complete, suspend the task.
ALTER TASK task_load_warehouse_spend_hist SUSPEND;
Note

Failure to suspend the task results in duplicate data.

When testing is complete, reset the task schedule to run once daily, and resume the task.

We could add warehouse_spend_hist to our share, but instead, to expand our knowledge, I prefer to create a fn_get_warehouse_spend UDTF. We must create UDTF as a SECURE function. For more information, see the documentation at https://docs.snowflake.com/en/sql-reference/udf-secure.html#secure-udfs .

Note

There is no COPY GRANTS clause for functions. Entitlement must be redone if a function is redefined.

CREATE OR REPLACE SECURE FUNCTION fn_get_warehouse_spend()
RETURNS TABLE ( warehouse_name VARCHAR,
                credits_used   NUMBER(18,6),
                spend_date     VARCHAR,
                last_updated   TIMESTAMP )
AS
$$
   SELECT warehouse_name,
          credits_used,
          spend_date,
          last_updated
   FROM   warehouse_spend_hist
$$
;
And prove secure function fn_get_warehouse_spend() returns data.
SELECT warehouse_name,
       credits_used,
       spend_date ,
       last_updated
FROM   TABLE ( fn_get_warehouse_spend());

We should see the result set from our earlier SELECT from warehouse_spend_hist noting the credits_used attribute has been coerced to NUMBER (18,6).

We are now ready to add the fn_get_warehouse_spend UDTF to our share.
USE ROLE securityadmin;
GRANT USAGE ON FUNCTION TEST.test_owner.fn_get_warehouse_spend() TO SHARE btsdc_share;
Prove the fn_get_warehouse_spend UDTF has been added to btsdc_share.
SHOW GRANTS TO SHARE btsdc_share;

Reporting Database Setup

Switch to the Snowflake consumer account and create a new reporting database, report, with the report_owner schema and entitlement to use btsdc_import_share.
USE ROLE sysadmin;
CREATE OR REPLACE DATABASE report DATA_RETENTION_TIME_IN_DAYS = 90;
CREATE OR REPLACE SCHEMA   report.report_owner;
USE ROLE securityadmin;
CREATE OR REPLACE ROLE report_owner_role;
GRANT ROLE report_owner_role TO ROLE securityadmin;
GRANT USAGE   ON DATABASE  report              TO ROLE report_owner_role;
GRANT USAGE   ON WAREHOUSE compute_wh          TO ROLE report_owner_role;
GRANT OPERATE ON WAREHOUSE compute_wh          TO ROLE report_owner_role;
GRANT USAGE   ON SCHEMA    report.report_owner TO ROLE report_owner_role;
GRANT CREATE TABLE             ON SCHEMA report.report_owner TO ROLE report_owner_role;
GRANT CREATE VIEW              ON SCHEMA report.report_owner TO ROLE report_owner_role;
GRANT CREATE SEQUENCE          ON SCHEMA report.report_owner TO ROLE report_owner_role;
GRANT CREATE STREAM            ON SCHEMA report.report_owner TO ROLE report_owner_role;
GRANT CREATE MATERIALIZED VIEW ON SCHEMA report.report_owner TO ROLE report_owner_role;
GRANT IMPORTED PRIVILEGES ON DATABASE btsdc_import_share TO ROLE report_owner_role;
Set the context to the new reporting database.
USE ROLE      report_owner_role;
USE DATABASE  report;
USE WAREHOUSE compute_wh;
USE SCHEMA    report.report_owner;
Prove we can access the fn_get_warehouse_spend UDTF. For later extension, add UNION with SELECT from subsequent data sources.
SELECT 'Provider Account A' AS source_account,
       warehouse_name,
       credits_used,
       spend_date,
       last_updated                       AS source_last_updated,
       current_timestamp()::TIMESTAMP_NTZ AS insert_timestamp
FROM   TABLE ( btsdc_import_share.test_owner.fn_get_warehouse_spend());
Create target table to persist source account data.
CREATE OR REPLACE TABLE source_warehouse_spend_hist
(
source_account      VARCHAR(255),
warehouse_name      VARCHAR(255),
credits_used        NUMBER(18,6),
spend_date          VARCHAR(10),
source_last_updated TIMESTAMP_NTZ,
insert_timestamp    TIMESTAMP_NTZ DEFAULT current_timestamp()::TIMESTAMP_NTZ NOT NULL
);
Create a wrapper view for share and UDTF.
CREATE OR REPLACE SECURE VIEW v_source_warehouse_spend COPY GRANTS
AS
SELECT 'Provider Account A' AS source_account,
       warehouse_name,
       credits_used,
       spend_date,
       last_updated                       AS source_last_updated,
       current_timestamp()::TIMESTAMP_NTZ AS insert_timestamp
FROM   TABLE ( btsdc_import_share.test_owner.fn_get_warehouse_spend());
Insert reporting data.
INSERT INTO source_warehouse_spend_hist
SELECT * FROM v_source_warehouse_spend;

I leave it for you to create a task to schedule data ingestion from the source. Note the dependency upon data extracted into the originating table.

Replication

Replication has been discussed throughout the book. Now, let’s work through setting up replication.

Note

We do not discuss replication in the context of full disaster recovery (DR) implementation; we simply use DR as a target account.

This example uses two accounts: primary and disaster recovery (DR). It replicates a database from Primary to DR. Figure 14-8 illustrates the scenario.

A schematic of the A W S E U Dublin region and E U London region. The primary account of the Dublin region is replicated to the D R account of the London region.

Figure 14-8

Database replication from primary to DR

While we can configure replication in the Snowflake user interface, we contend deeper understanding is gained from working through command line invocation recognizing any automation we develop works through scripts and not using the interface. In other words, our replication strategy depends on more than a single user interface-driven strategy, probably with complex dependencies including failover, failback, and client redirect.

Not every object type is currently available for replication. Please refer to the documentation at https://docs.snowflake.com/en/user-guide/database-replication-intro.html#replicated-database-objects . Replication has further limitations. For example, RBAC is not replicated; therefore, the receiving account must implement RBAC locally; databases with external tables cannot be replicated; databases created from shares cannot be replicated.

This example illustrates simple database replication in support of data shares and is not a full treatise on failover and failback, which falls beyond the scope of this book. Also, note there are cost implications to replicating data across accounts, CSPs, and regions.

Using the primary account, we must identify accounts in our organization enabled for replication.
USE ROLE accountadmin;
SHOW REPLICATION ACCOUNTS;

We need two (or more) accounts enabled for replication. Your organization may prefer each account to be enabled individually, in which case a Snowflake support ticket should be raised. Response times are usually very short. Otherwise, Snowflake support can assign accounts the ORGADMIN role, as documented at https://docs.snowflake.com/en/user-guide/organizations-manage-accounts.html#enabling-accounts-for-replication .

Once ORGADMIN has been enabled for your account, then self-service to enable replication is possible.
USE ROLE orgadmin;
SHOW ORGANIZATION ACCOUNTS;
SELECT current_account();
In the next SQL statement , replace <your_account> with the response from the preceding SQL statement.
SELECT system$global_account_set_parameter ( '<your_account>', 'ENABLE_ACCOUNT_DATABASE_REPLICATION', 'true' );
Re-check replication is enabled.
USE ROLE accountadmin;
SHOW REPLICATION ACCOUNTS;
With replication enabled in the primary account, you can now enable replication to the DR account by replacing <your_database> with your chosen database to replicate recalling limitations mentioned. Also, replace <your_target_account> with your chosen target account to receive a replica. Documentation is at https://docs.snowflake.com/en/user-guide/database-replication-config.html#step-2-promoting-a-local-database-to-serve-as-a-primary-database .
ALTER DATABASE <your_database> ENABLE REPLICATION TO ACCOUNTS <your_target_account>;
While strictly speaking beyond the scope of our immediate aims, we might also enable failover for our primary database.
ALTER DATABASE <your_database> ENABLE FAILOVER TO ACCOUNTS <your_target_account>;
Next, log in to the second account and view databases available for import.
SHOW REPLICATION DATABASES;

You should see <your_database> in the list of available databases for import. Note that is_primary is “true”.

Let’s create the replica. Replace <your_database> with your chosen database but respect the convention to retain naming conventions back to the source.
CREATE DATABASE <your_database>
AS REPLICA OF <your_account>.<your_database>
DATA_RETENTION_TIME_IN_DAYS = 90;
Check that our new database has been imported correctly by running this SQL statement.
SHOW REPLICATION DATABASES;

And refreshing the left-hand pane of our browser where our new database is listed.

With our database replicated, we have two remaining tasks: create and apply a security model and then share desired objects, which I leave you to complete.

Finally, we may wish to remove our replicated database.
DROP DATABASE <your_database>;

Data Exchange

Now that we understand data sharing, let’s investigate Data Exchange, the internal nexus for colleagues, partners, and customers to collaborate, where our citizen scientists discover and self-serve available data sets. Please refer to the Snowflake documentation at https://docs.snowflake.com/en/user-guide/data-exchange.html#data-exchange .

Utilizing Snowflake’s built-in capabilities, Data Exchange is its internal place where data is published to consumers—the people and organizations in and outside the publishing organization boundary.

Data Exchange is limited to 20 accounts for each listing across all CSPs and regions. Consideration must be given to creating a data share topology that does not replicate data silos but meets business needs and facilitates the delivery of successful business outcomes. Throughout this section, there is repeated reference to working with our business colleagues when developing our data exchanges. Only through collaboration will organizations benefit from the power and flexibility that Data Exchange offers. But equally, if done badly, it results in frustration and disillusionment with Data Exchange as a capability.

Request Data Exchange

Data Exchange is not enabled by default. Please contact Snowflake support to enable Data Exchange for your account. Your support ticket should contain the following.
  • Business case, team, and/or participants in the Data Exchange: An example might be, “We are developing content for distribution throughout our organization and wish to run a proof-of-concept using Data Exchange.”

  • Data Exchange name (without spaces): XYZ_CORP_DX

  • Public Data Exchange name: XYZ Corporation Data Exchange

  • Your administrative account URL: for example, https://<account>.eu-west-2.aws.snowflakecomputing.com

  • Your account locator: Run SELECT current_account();

Enabling Data Exchange can take 48 hours.

Snowsight

This section moves from the classic console to use Snowsight , the future-state Snowflake console, because there is no approved command-line approach to implementing Data Exchange features.

If using AWS PrivateLink or Azure Private Link, you may need to create a CNAME record as described in the documentation at https://other-docs.snowflake.com/en/marketplace/intro.html#introduction-to-the-snowflake-data-marketplace .

Figure 14-9 highlights the button to click.

A screenshot of the highlighted snowsight icon on the bar of a tab.

Figure 14-9

Enable Snowsight

A new browser window and login dialog appear alongside our existing classic console. Log in, accept the prompt to import tabs, and take a moment to familiarize yourself with the new look and feel.

On the day of writing, Snowflake released Snowsight as generally available, prompting migration to the new user interface with a button on the left-hand side of the browser to revert to the classic console. You may need to click the Home button before progressing to investigate Data Exchange , as shown in Figure 14-10.

A screenshot of a worksheet tab, where the home button is highlighted.

Figure 14-10

Home button

Accessing Data Exchange

When ready, change your role to ACCOUNTADMIN by clicking your login name. Then click Home ➤ Data ➤ Private Sharing, as shown in Figure 14-11.

A screenshot of the admin bar with the data option highlighted. The private sharing button is highlighted under the data option.

Figure 14-11

Data Exchange navigation

We are now presented with all private data exchanges shared with our account, as shown in Figure 14-12. Two shares provided by Snowflake overlay the imported Snowflake databases created when our account is provisioned. The corresponding data exchange entry is also removed if a sample database has been deleted.

A screenshot of the data exchange tab where the option of manage exchanges is highlighted on the top.

Figure 14-12

Data Exchange Shared With Me

I leave the investigation of data from direct shares for your investigation and focus on XYZ Corporation Data Exchange, our fictional data exchange ready for configuration.

Note

To administer the private exchange, use the ACCOUNTADMIN role.

We may have multiple data exchanges for our organization, which appear alongside our initial data exchange, as shown in Figure 14-12.

Tony Robbins said, “Complexity is the enemy of execution.” I strongly recommend a simple approach to data exchange is adopted by provisioning the minimal number of data exchanges necessary to meet business objectives while retaining meaningful data isolation boundaries.

Managing Data Exchange

In contrast to data share, accounts may be in any region or CSP. Beware of egress charges, however.

Note

All Data Exchange members may publish and consume the data sets of other members, but only the owner account can administer members.

Before proceeding, a brief reminder of our intent is to configure one-to-many data sharing in a designated group from a single central Snowflake account, as shown in Figure 14-13. In the following discussion, there is a single publisher account with admin privilege to manage exchanges and several consumer accounts without admin privilege. The distinction is evident in the request made to Snowflake support to provision Data Exchange, as illustrated in Figure 4-12.

A schematic of the data exchange for data sharing with a designated group. Your account represented by a circle is connected to surrounding circles via double-headed arrows.

Figure 14-13

Data Exchange topology

We can now manage our data exchange by adding and removing Snowflake accounts. Click Manage Exchanges ➤ XYZ Corporation Data Exchange, as shown in Figure 14-14.

A screenshot of the manage exchange tab where the X Y Z corporation data exchange with admin as a provider in the exchange role is highlighted.

Figure 14-14

Manage exchanges

Figure 14-15 shows two data exchange member accounts, in this example, those used to configure Secure Direct Data Share discussed previously in this chapter.

A screenshot of the X Y Z corporation data exchange tab. Under members, account number, A D 77003; region, A W S U S east north Virginia; and exchange role, consumer; is highlighted.

Figure 14-15

Manage members and assign roles

Adding a new member to our data exchange is simple. Click the Add Member button, populate with the Snowflake account URL, and select the role, as shown in Figure 14-16. By default, both Consumer and Provider are enabled, which may not be appropriate for your data exchange where one-way traffic may be preferred. Populate the account with a valid URL noting the user interface validates the entered URL, set the appropriate role, and then click the Add button. Accounts may be located in any CSP or region.

A screenshot of add member tab with a section for an account name, and role as consumer and provider.

Figure 14-16

Add account and role(s)

Selecting an existing data exchange member enables their role to be changed, or clicking the three-dotted box allows removal from the data exchange.

If you selected the data exchange owner, you would see the Admin role checked and grayed out. It is not possible to reassign data exchange ownership. This is a Snowflake support function.

We might also wish to add a provider profile, which is useful for informing consumers of our organization’s contact information.

Add Standard Data Listing

With data exchange members added to our data exchange, let’s consider how to manage data sets in the data exchange. We have already encountered the two roles available, which are self-explanatory: providers and consumers.

Data exchange supports two types of listing.
  • Standard: As soon as the data is published, all consumers have immediate access to the data.

  • Personalized: Consumers must request access to the data for subsequent approval, or data is shared with a subset of consumer accounts.

From the main menu bar, click Share Data, as shown in Figure 14-17.

A screenshot of the shared with me tab. The share data option is highlighted, with a drop-down menu with options, share with other accounts, and publish to X Y Z corporation data exchange.

Figure 14-17

Share data

After which, a new dialog opens, as shown in Figure 14-18. Populate the listing title and select the desired listing type. The “See how it works” links provide useful contextual information. I recommend you investigate both links.

A screenshot of the create listing tab. A section for the title of the listing and how the will consumer access the data product. The options are standard or personalized.

Figure 14-18

Create listing

In our example, we use Test Listing as our title, select Standard, then click Next. The title is presented in preview form requiring further information, as shown in Figure 14-19. Note additional tabs for Consumer Requests and Settings for your further investigation.

Note

Once a listing has been published, changing the listing type is impossible.

Unpublishing a listing reverts to preview format, which is discussed later.

A screenshot of the test listing. The required information below the listing is as follows. Basic information, details, data product, business needs, sample S Q L queries, and region availability.

Figure 14-19

Listing details

I strongly recommend your business colleagues are actively involved in the creation of content to populate the listing details. Each listing is a showcase and shop front for your organization’s internal colleagues and selected external customers; therefore, well-crafted descriptions and documentation representing approved messaging are essential.

Some callouts for further consideration.
  • The terms of service requires your organization’s legal team’s input and approval before publication.

  • Sample SQL Queries should sufficiently represent consumers to gain insight and pique their interest in using your data.

  • Limit query runtime and data sets as the provider account pays for consumption costs.

  • Protect your data model by provisioning access to views in preference to tables.

Although each entry is self-explanatory, there is a lot to consider when provisioning objects into our data exchange. We do not dwell on populating. I leave them for your further investigation.

When complete , click Publish Listing.

Manage Shared Data

In the pop-up dialog box shown in Figure 14-20, we may choose to manage our shared data by clicking Manage Shared Data .

A screenshot of the listing going live. The text reads your listing is visible to consumers in all regions. You must attach a secure share in each region in order for consumers in those regions to gain immediate access to your data. The options below are to manage shared data and set it up later.

Figure 14-20

Manage shared data dialog

According to the regions enabled in Figure 14-21, there are options to make our shared data available in consumer accounts. Note the requirement to log in to each account. Simply select the required region in the drop-down box where further options become available (not shown).

A screenshot of the manage shared data tab with region and configuration. Under region, A W S Europe, Ireland is chosen. Under configuration, a sign-in option for account and user is given.

Figure 14-21

Enable Data Share

When complete, click Done. The listing banner changes to show two new buttons— View on Exchange and Live, as shown in Figure 14-22.

A screenshot of the test listing tab. The highlighted view on exchange option is live.

Figure 14-22

Listing management options

Clicking View on Exchanges provides a single page view of listings with summary information which I leave for your further investigation. Navigating to Home ➤ Data ➤ Private Sharing, as shown in Figure 14-12, displays a second listing alongside the original (not shown).

Unpublish a Data Listing

The second option, Live, allows you to unpublish a listing noting existing consumers retain access, as shown in Figure 14-23.

A screenshot of the unpublish listing tab. The text reads test listing will no longer be visible in the X Y Z corporation data exchange, existing consumers of your data will continue to have access to it. The options of cancel and unpublish are given below.

Figure 14-23

Unpublish listing dialog

Unpublished listings revert to preview status, as shown in Figure 14-19.

Accessing Data

Assuming we have shared our new data listing with our second snowflake account region, we can view it in our second Snowflake account. Log in and navigate to Home ➤ Data ➤ Private Sharing ➤ Test Listing. Figure 14-24 illustrates the dialog box now enabled in the consumer account.

A screenshot contains options for free unlimited search with query data and view database.

Figure 14-24

Consumer account accessing data

The View Database screen (not shown) displays the Database Details tab by default. There is a second tab for Schemas. I leave these for your further investigation as the content is self-explanatory. Note the context menu navigates to Home ➤ Data ➤ Databases.

In common with Secure Direct Data Share, RBAC is not imported with shares. You may need to set your browser role to ACCOUNTADMIN or configure a new role with IMPORT SHARE privilege.

Click the Get Data button. Figure 14-25 shows the opportunity to assign a role, which should be pre-created.

A screenshot of the test listing tab. The add roles drop-down menu is highlighted under the create database section.

Figure 14-25

Import share and assign RBAC

If the chosen role does not have sufficient entitlement, the following error occurs.
Your selected role (SYSADMIN) cannot get data. Choose a role that has the IMPORT SHARE privilege to get this data or please contact your account administrator.
Insufficient privilege to accept DATA_EXCHANGE_LISTING terms.
Once RBAC entitlement considerations have been resolved, the dialog in Figure 14-26 is displayed.

A screenshot of the path to source data, to data is ready to query with a query data button.

Figure 14-26

Query data

A new browser tab opens pre-populated with the sample query and comments from the listing Usage Examples. Add warehouse to execute the sample query and execute.

Data Exchange Summary

The following are other menu options.
  • Shared By My Account lists each created listing, whether published or not.

  • Requests lists inbound and outbound data requests along with approval status.

  • Reader Accounts allows providers to share data with consumers who are not already Snowflake customers without requiring the consumers to become Snowflake customers. See documentation for further information at https://docs.snowflake.com/en/user-guide/data-sharing-reader-create.html .

Having walked through hands-on examples of configuring and accessing objects provisioned via Data Exchange using a Standard Listing, I leave you to develop data access paths for your user community to interact with provisioned data sets.

Provisioning steps for Personalized listings are broadly the same as for Standard Listings, except the consumer must request access to the data set, and the provider must approve the request. These steps are self-explanatory.

Snowflake Marketplace

Now that you understand Data Exchange, the internal nexus for colleagues, partners, and customers to collaborate, let’s investigate Snowflake Marketplace, the external nexus for individual and business collaboration. It is a worldwide environment where our citizen scientists discover and self-serve available data sets. Please refer to Snowflake documentation at https://other-docs.snowflake.com/en/data-marketplace.html#snowflake-data-marketplace and further summary information at www.snowflake.com/data-marketplace/ .

At this point, you may be asking how Data Exchange and Snowflake Marketplace differ, so I offer these broad comparisons.
  • Data Exchange is focused on closed groups with a maximum of 20 participant accounts. Snowflake Marketplace is global in scope with unlimited participation.

  • Data Exchange is thematic in approach with either a single or limited topics. Snowflake Marketplace has a general approach where all themes and topics are available ubiquitously.

Both Data Exchange and Snowflake Marketplace are evolving rapidly where the boundaries and scope are converging and overlapping. You see an example later in this chapter.

In the same manner as Data Exchange and utilizing Secure Direct Data Sharing capability, organizations create listings on the Snowflake Marketplace, the single Internet location for seamless data interchange. The same security and real-time features remain though the scope of Snowflake Marketplace is external partners and consumers instead of internally focused, as is the case for Data Exchange.

Further information on joining the Snowflake Marketplace or requesting new data sets is at https://other-docs.snowflake.com/en/marketplace/intro.html#how-do-i-request-new-data-or-data-providers-to-be-added-to-the-data-marketplace .

Snowflake claims over 500 listings from more than 160 vendors representing a 76% increase in usage in the six months leading up to June 2021, along with new usage-based purchase options enabling consumers to transact entirely on the Snowflake Marketplace. For more information, see Snowflake news at www.snowflake.com/news/snowflake-accelerates-data-collaboration-with-more-than-500-listings-in-snowflake-data-marketplace-and-announces-monetization-in-the-data-cloud/ .

Becoming a data provider involves populating an online form to enroll in the Snowflake Partner Network . For organizations, this step will likely involve your procurement, legal, and data governance teams as a minimum, along with a clearly articulated and approved proposal on organizational objectives.

Snowflake Marketplace offers standard, sample/purchase, and personalized data listings. This exploration implements a standard data listing while leaving the personalized data listing for you to investigate further.

When writing this book, Snowflake Marketplace was undergoing significant changes, many of which relate to navigation. Although I have attempted to reflect the latest information, further changes will probably render the navigation outdated, but the core data entry screens remain intact.

Setting up as a Provider

When ready, change the role to ACCOUNTADMIN by clicking your login name. Then click Home ➤ Data ➤ Provider Studio, as shown in Figure 14-27. The direct URL is https://app.snowflake.com/provider-studio .

A screenshot of the snowflake marketplace navigation option. Provider studio is highlighted under the data menu.

Figure 14-27

Snowflake marketplace navigation

If our account has not been entitled to participate in the Snowflake Marketplace, the message shown in Figure 14-28 appears, contact your Snowflake account executive, or fill out the form at https://other-docs.snowflake.com/en/marketplace/becoming-a-provider.html#step-1-submit-a-request-to-join-the-snowflake-data-marketplace .

A screenshot of the permission required tab. The text reads to manage listing in snowflake data marketplace, select a role with current permissions or contact your account administrator.

Figure 14-28

Permission denied

Assuming your account has been approved to participate in the Snowflake Marketplace, the next step is to create a profile, as shown in Figure 14-29.

A screenshot of the snowflake data marketplace profile set up tab. The text reads publish data tp the snowflake data marketplace. A set-up profile button is placed below.

Figure 14-29

Set up profile

We are now required to populate our profile. Note the subset of fields shown in Figure 14-30.

A screenshot of the create profile tab. The queries to be filled below are company icon, company name, company description, and consumer contact email. The options at the bottom are save draft, cancel, and next.

Figure 14-30

Set up profile

Add Standard Data Listing

Snowflake Inc. requires content in Microsoft Word for its operations team to review and approve prior to creating the first listing. This is Snowflake Inc.’s standard practice.

For all listing types (see Figure 14-31), prospective consumers must register their interest by populating contact/company information.

There is an overlap with Data Exchange insofar as private listings may be made on Snowflake Marketplace, and long term, it is possible Data Exchange will be folded into Snowflake Marketplace.

Snowflake Marketplace listings attract a rebate on credits consumed by usage.

When the profile is populated, click Next. The screen shown in Figure 14-31 should appear.

A screenshot of the create listing tab. The queries below are what's the title of the listing, who can discover the listing, anyone on the marketplace or only specified consumers; how will consumers access the data product, standard, purchase with a free sample or personalized. Below are the options for cancel and next.

Figure 14-31

Listing information

Snowflake Marketplace supports three types of listing.
  • Standard: As soon as the data is published, all consumers have immediate access to the data.

  • Purchase with free sample: Upgrade to full data set upon payment.

  • Personalized: Consumers must request access to the data for subsequent approval, or data is shared with a subset of consumer accounts.

Once the listing has been created (not shown but very similar to creating a Data Exchange listing), there is one further consideration.

There is one further consideration. Consumption analysis may indicate data set publication may best be focused on particular regions; therefore, I recommend analyzing available data before publishing to all regions.

Let’s decide how our listing will be published, as shown in Figure 14-32. The options are automatically published upon the Snowflake operations team’s approval. We might prefer to set up multiple listings and decide to coordinate release as part of our marketing strategy.

A screenshot of the publish setting tab. The publishing options are automatic and manual. The manual option is selected. Below, there are options for cancel and save.

Figure 14-32

Publish setting

Accessing Snowflake Marketplace

We are now presented with the most recent data sets made available via the Snowflake Marketplace, as shown in Figure 14-33. Your content will differ.

A screenshot of the snowflake marketplace content tab, with four different company content. The I T S unemployment data by the local area and Insig A I filing D B global data have a personalized section highlighted.

Figure 14-33

Snowflake marketplace content

Immediately we can see the distinct difference between internal Data Exchange and external Snowflake Marketplace. The two listings are standard and personalized as outlined.

Using Snowflake Marketplace

A closer reading of the Standard data set listing shown in Figure 14-33 illustrates the marketplace nature of published data. Both are sample data sets.

To gain experience with Snowflake Marketplace, click Home ➤ Marketplace or select Providers, as shown in Figure 14-34.

A screenshot of highlighted providers drop-down menu in a tab.

Figure 14-34

Select provider

Then scroll down and select Snowflake Inc., where the user interface refreshes to display the content shown in Figure 14-35.

A screenshot of the snowflake inc financial data tab. The quarterly financial statements are highlighted in the data tab.

Figure 14-35

Snowflake Inc. financial data

Note content may also be searched by category and business need.

Content can also be referenced directly from the corresponding URL https://app.snowflake.com/marketplace/listings/Snowflake%20Inc . You see one or more published data sets.

Selecting a data set results in a detailed screen similar to the one seen when consuming Data Exchange content, which I consider sufficiently familiar to not require further explanation. from our work

Managing Snowflake Marketplace

Assuming all obligations have been met and our request to become an approved data provider ( https://spn.snowflake.com/s/become-a-partner ) to the Snowflake Marketplace is successful, we may now participate in the Snowflake Marketplace. Our participation may impose restrictions according to the type and nature of the data we provide.

Note

Listings must always comply with relevant laws and contractual obligations. We must have legal and contractual rights to share data.

In contrast to data share, but common with data exchange, be aware of egress charges. And like Data Exchange, there is no approved command line approach to implementing Snowflake Marketplace features.

Before proceeding, a brief reminder of our intent is to configure our Snowflake account to publish data into the Snowflake Marketplace and/or to consume data from third parties sharing data in the Snowflake Marketplace, as shown in Figure 14-36.

A schematic of the snowflake data marketplace has three parts. The parts from right to left are as follows. Sectors such as business, demographic, weather, health, S A A S, and more. Snowflake data marketplace. Your account.

Figure 14-36

Snowflake marketplace topology

Accessing Data

To access a data set, we might be required to validate our email address when selecting a listing, as shown in Figure 14-37.

A screenshot of the verify email address tab. The text below reads your user account email verified. To submit a request please check your inbox to complete account verification first. Options for the close, update the email address, and resend verification email are placed below.

Figure 14-37

Verify email

Otherwise, data should immediately become available for download, as shown in Figure 14-38. The database to be created (in this example, FINANCIAL_STATEMENTS_SHARE) can be overwritten; if done so, I recommend a naming convention be established to facilitate tracing back to the source.

A screenshot of the import database tab. The database financial statement share is highlighted along with the add roles drop-down menu. Below the drop-down menu, a question reads which roles in addition to S Y S admin can access this database. S Y S admin is highlighted in the question.

Figure 14-38

Import database

The Add Roles dialog allows another existing role with IMPORT SHARE entitlement in your Snowflake account to access the imported database.

Then click Get Data.

If all is well, our data is imported into a new database and made available for use; otherwise, you may see an error.

A screenshot of an error message. The message reads your selected role S Y S admin cannot get data. Choose a role that has the import share privilege to get this data or please contact your account administrator. Insufficient privilege to accept data exchange listing terms.

Note

In Figure 14-38, the SYSADMIN role is set at the browser level, underneath the username.

Change role and retry, after which we should see a dialog shown in Figure 14-39.

A screenshot of the imported database of financial statement share for which the data is ready to query. The options below are query data and done.

Figure 14-39

Database imported

Clicking Query Data opens a new browser screen showing imported databases with sample queries pre-populated and ready for our use.

Snowflake Marketplace Summary

Snowflake Marketplace represents a pivotal point in Snowflake development and delivery, facilitating citizen scientists to rapidly acquire desired data sets into a single account and providing an opportunity to monetize data sets. Participation is critical for Snowflake’s success, and the ease of data set integration presents an almost frictionless opportunity for our organizations to derive immense value.

Automating integration with Snowflake Marketplace requires tooling outside of the user interface. Allowing programmatic interaction, along with improved consumption metrics, will encourage adoption. And Snowflake is signaling steps in this direction.

Summary

This chapter overviewed its objectives before diving into data sharing, explaining why by unpacking the advantages of adopting a new approach. We then developed a simple data share example using two separate Snowflake accounts, noting the use of the ACCOUNTADMIN role and caution over delegating entitlement to lower privileged roles. You began to see the power of sharing, where objects can be added and removed from a share with immediate visibility in the consumer account. Many accounts may consume a single share.

Using your newfound knowledge, we implemented a simple but readily extensible cost monitoring solution sharing daily Warehouse consumption costs from one account to another while introducing UDTFs and CRON scheduling for tasks. And for those who require replication before sharing, we walked through replicating a database between accounts.

Next, we focused on Snowflake Data Exchange, noting the use of Snowsight user interface for configuration, and walked through an example of how to create and manage a standard data listing noting that once published, we cannot change a listing type and unpublishing a listing does not remove existing consumer access.

Lastly, we investigated Snowflake Marketplace identifying how to access listings and publish our organizations’ listings. The process is largely similar to Snowflake Data Exchange, with additional governance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.77.63