Before you beginReview the provider and consumer model
1. Agree on what Maple Market will publish
Maple Market must share one net sales row per allowed region and business day. Its India analytics partner needs date, region, order count and net sales. The partner does not need customer IDs, names, emails, individual orders or Europe data. The source includes EU 200 and IN 150. One currency is assumed in this fixture.
Use two different approved same-region accounts, one existing warehouse each, an approved provider operator and a consumer analyst identity. Use the actual account values from the identity query. Check that the object and role names in every setup command are unused. This capstone shows expected results. The provider session simulation is separate from a real consumer read.
| Actor | Allowed | Denied |
|---|---|---|
| Provider operator | Manage lab share and update private sales | Send private data to another account |
| India partner | Read the IN daily aggregate as its analyst | Read Europe, raw customer data or modify shared data |
| Europe evaluator | See EU in the provider simulation | Receive a live invitation in the main pilot without new approval |
| Unknown account | No approved access | Mount or query the share |
- Private provider dataExpose four approved fields to Secure regional view
- Secure regional viewGrant view, schema and database access to Provider share
- Provider shareImport and assign a local role to Consumer analyst
- Consumer analystProve that revocation takes effect to Offboard
- Private provider data
- Orders, customers and entitlement map.
- Secure regional view
- Filters before aggregating.
- Provider share
- Grants only the view and invites one account.
- Consumer analyst
- Mount, grant, read and verify.
- Offboard
- Remove account and prove reads fail.
2–4. Set up both accounts and identify sensitive fields
The two administrators perform setup in their own accounts before the lab operator loads data. Create the consumer role before mounting the share. The database and source tables belong to the provider operator. No permissions are delegated to any external account at this point.
Mark names, email and identifiers as sensitive in the lab inventory. An order date, region and net sum belong in the serving view. Individual sale and customer IDs stay in CORE. The setup query shows two India orders totaling 150 and one EU order totaling 200. Verify the source before building the access rule.
Record both account identities and compare regions
SELECT CURRENT_ORGANIZATION_NAME() AS ORG_NAME,
CURRENT_ACCOUNT_NAME() AS ACCOUNT_NAME,
CURRENT_ACCOUNT() AS ACCOUNT_LOCATOR,
CURRENT_REGION() AS REGION;Provider administrator creates the sharing role
-- Provider account. Use existing approved identities and warehouse.
USE ROLE ACCOUNTADMIN;
CREATE ROLE M19_SHARE_ADMIN;
GRANT CREATE DATABASE, CREATE SHARE, MANAGE SHARE TARGET
ON ACCOUNT TO ROLE M19_SHARE_ADMIN;
GRANT USAGE ON WAREHOUSE <provider_lab_warehouse> TO ROLE M19_SHARE_ADMIN;
GRANT ROLE M19_SHARE_ADMIN TO USER <provider_operator>;Consumer administrator assigns the local analyst and warehouse
-- Consumer account only.
USE ROLE ACCOUNTADMIN;
CREATE ROLE M19_PARTNER_ANALYST;
GRANT ROLE M19_PARTNER_ANALYST TO USER <consumer_analyst>;
GRANT USAGE ON WAREHOUSE <consumer_lab_warehouse> TO ROLE M19_PARTNER_ANALYST;Provider operator creates and verifies source data
-- Provider account. The role will own the objects it creates.
USE ROLE M19_SHARE_ADMIN;
USE WAREHOUSE <provider_lab_warehouse>;
CREATE DATABASE LS_M19_SHARE_LAB;
CREATE SCHEMA LS_M19_SHARE_LAB.CORE;
CREATE SCHEMA LS_M19_SHARE_LAB.PARTNER;
CREATE TABLE LS_M19_SHARE_LAB.CORE.CUSTOMERS
(CUSTOMER_ID NUMBER NOT NULL, CUSTOMER_NAME VARCHAR, EMAIL VARCHAR);
INSERT INTO LS_M19_SHARE_LAB.CORE.CUSTOMERS VALUES
(101,'Asha Rao','asha@example.invalid'),
(102,'Luc Martin','luc@example.invalid'),
(103,'Meera Shah','meera@example.invalid');
CREATE TABLE LS_M19_SHARE_LAB.CORE.SALES
(SALE_ID NUMBER NOT NULL, CUSTOMER_ID NUMBER NOT NULL, REGION VARCHAR NOT NULL,
SALE_DATE DATE NOT NULL, NET_AMOUNT NUMBER(10,2) NOT NULL);
INSERT INTO LS_M19_SHARE_LAB.CORE.SALES VALUES
(701,101,'IN','2026-01-06',100),
(702,102,'EU','2026-01-06',200),
(703,103,'IN','2026-01-06',50);
SELECT REGION, COUNT(*) AS ORDER_COUNT, SUM(NET_AMOUNT) AS NET_SALES
FROM LS_M19_SHARE_LAB.CORE.SALES GROUP BY REGION ORDER BY REGION;5–8. Build the secure view and invite the approved account
The provider operator fills in approved account locators and creates the view. A map row allows a region only after an account can reach the view. Use the provider simulation to test both India and Europe as the owner. For the main live exercise invite only the India account. Use the expected results below to check the provider preview and both simulated contexts.
Create the restricted share after approval. SHOW GRANTS TO SHARE proves the object list. SHOW GRANTS OF SHARE checks the target. Keep the entire CORE schema private. If the target identifier or region differs from the agreement, stop before adding it.
| Expected context | REGION | SALE_DATE | ORDER_COUNT | NET_SALES |
|---|---|---|---|---|
| Provider preview | EU | 2026-01-06 | 1 | 200.00 |
| Provider preview | IN | 2026-01-06 | 2 | 150.00 |
| India account only | IN | 2026-01-06 | 2 | 150.00 |
| Europe account only | EU | 2026-01-06 | 1 | 200.00 |
| Unknown entitlement | No rows |
Map the verified account locators to their regions
-- Provider account as M19_SHARE_ADMIN.
CREATE TABLE LS_M19_SHARE_LAB.CORE.PARTNER_ENTITLEMENT
(ACCOUNT_LOCATOR VARCHAR NOT NULL, REGION VARCHAR NOT NULL);
-- The current provider can preview both regions in an unsimulated session.
INSERT INTO LS_M19_SHARE_LAB.CORE.PARTNER_ENTITLEMENT
SELECT CURRENT_ACCOUNT(), COLUMN1 FROM VALUES ('IN'),('EU');
INSERT INTO LS_M19_SHARE_LAB.CORE.PARTNER_ENTITLEMENT VALUES
('<verified_india_consumer_locator>','IN'),
('<verified_europe_consumer_locator>','EU');Create the secure view in the provider account
-- Provider account as M19_SHARE_ADMIN.
CREATE SECURE VIEW LS_M19_SHARE_LAB.PARTNER.SALES_DAILY AS
SELECT S.REGION, S.SALE_DATE, COUNT(*) AS ORDER_COUNT,
SUM(S.NET_AMOUNT) AS NET_SALES
FROM LS_M19_SHARE_LAB.CORE.SALES S
WHERE EXISTS (
SELECT 1 FROM LS_M19_SHARE_LAB.CORE.PARTNER_ENTITLEMENT E
WHERE E.ACCOUNT_LOCATOR = CURRENT_ACCOUNT() AND E.REGION = S.REGION
)
GROUP BY S.REGION, S.SALE_DATE;Run the provider-side simulation in an isolated owner session
-- Provider account, in a dedicated worksheet as the view owner.
ALTER SESSION SET SIMULATED_DATA_SHARING_CONSUMER = '<verified_india_consumer_locator>';
SELECT * FROM LS_M19_SHARE_LAB.PARTNER.SALES_DAILY ORDER BY REGION, SALE_DATE;
ALTER SESSION UNSET SIMULATED_DATA_SHARING_CONSUMER;Create the share and audit its three object grants
-- Provider account as M19_SHARE_ADMIN.
CREATE SHARE MAPLE_M19_SALES_SHARE SECURE_OBJECTS_ONLY = TRUE;
GRANT USAGE ON DATABASE LS_M19_SHARE_LAB TO SHARE MAPLE_M19_SALES_SHARE;
GRANT USAGE ON SCHEMA LS_M19_SHARE_LAB.PARTNER TO SHARE MAPLE_M19_SALES_SHARE;
GRANT SELECT ON VIEW LS_M19_SHARE_LAB.PARTNER.SALES_DAILY TO SHARE MAPLE_M19_SALES_SHARE;
SHOW GRANTS TO SHARE MAPLE_M19_SALES_SHARE;Add the India account after matching the approved identity
-- Provider account as M19_SHARE_ADMIN.
ALTER SHARE MAPLE_M19_SALES_SHARE ADD ACCOUNTS = <consumer_org>.<consumer_account>;
SHOW GRANTS OF SHARE MAPLE_M19_SALES_SHARE;9–11. Import the share and prove the consumer’s data boundary
The consumer administrator checks the inbound share and mounts it under a local name. Grant IMPORTED PRIVILEGES for the directly attached objects. The analyst reads as the approved role, with secondary roles off. The normal query must show the India row first. Then run the denials one at a time to record the difference between a valid empty result and an authorization or column error.
| Action | Expected result | Evidence |
|---|---|---|
| Read PARTNER.SALES_DAILY | IN, 2026-01-06, 2, 150.00 | Valid role and entitled row |
| Read the same view for EU | Zero rows | The query can run, but the account lacks the EU entitlement |
| Request EMAIL on the view | Invalid column | The field was omitted |
| Read the CORE customer table | Unavailable or unauthorized | The source schema and object are outside the share |
Consumer administrator creates the imported database
-- Consumer account as ACCOUNTADMIN.
SHOW SHARES LIKE 'MAPLE_M19_SALES_SHARE';
CREATE DATABASE MAPLE_M19_IMPORTED FROM SHARE <verified_provider_locator>.MAPLE_M19_SALES_SHARE;
GRANT IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED TO ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Consumer analyst verifies the visible columns and India total
-- Consumer account in the assigned analyst's session.
USE ROLE M19_PARTNER_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE <consumer_lab_warehouse>;
SELECT CURRENT_ROLE(), CURRENT_ACCOUNT();
SELECT REGION, SALE_DATE, ORDER_COUNT, NET_SALES
FROM MAPLE_M19_IMPORTED.PARTNER.SALES_DAILY ORDER BY REGION, SALE_DATE;Consumer analyst verifies regional exclusion
-- Consumer analyst. Expect no rows for the India partner.
SELECT REGION, SALE_DATE, ORDER_COUNT, NET_SALES
FROM MAPLE_M19_IMPORTED.PARTNER.SALES_DAILY WHERE REGION = 'EU';Consumer analyst verifies email is not published
-- Consumer analyst. Run separately. Expect an invalid column error.
SELECT EMAIL FROM MAPLE_M19_IMPORTED.PARTNER.SALES_DAILY;Consumer analyst verifies raw source access fails
-- Consumer analyst. Run separately. Expect object unavailable or unauthorized.
SELECT EMAIL FROM MAPLE_M19_IMPORTED.CORE.CUSTOMERS;12–16. Correct a sale, diagnose a failure and end consumer access
Update sale 701 once and commit on the provider. With autocommit enabled it commits at the end of its statement. The India total rises by 25 and the order count remains two. Run the same analyst query after commit. Because the source objects and share have not been replaced, the partner reads 175 under the same imported database.
Next, create a controlled local failure by removing only the consumer analyst’s imported privilege. The analyst query should be denied, while the provider still lists the account and the inbound share remains. Restore only that privilege and read 175 again. This proves the local role was the cause. Finally remove the consumer account from the provider target list, then rerun the analyst read and confirm it is denied even after the local privilege has been restored.
| Checkpoint | Provider IN | Provider EU | India consumer IN |
|---|---|---|---|
| First query | 2 orders / 150.00 | 1 order / 200.00 | 2 orders / 150.00 |
| Provider corrects order 701 from 100 to 125 | 2 orders / 175.00 | 1 order / 200.00 | 2 orders / 175.00 after the commit |
| Local analyst privilege revoked | Unchanged | Unchanged | Query denied |
| Local privilege restored | Unchanged | Unchanged | 2 orders / 175.00 |
| Provider removes the consumer account | Unchanged | Unchanged | Share access revoked |
Provider operator corrects the one sale
-- Provider account as M19_SHARE_ADMIN. Keep the same view and share.
UPDATE LS_M19_SHARE_LAB.CORE.SALES SET NET_AMOUNT = 125
WHERE SALE_ID = 701 AND NET_AMOUNT = 100;
SELECT REGION, COUNT(*) AS ORDER_COUNT, SUM(NET_AMOUNT) AS NET_SALES
FROM LS_M19_SHARE_LAB.CORE.SALES GROUP BY REGION ORDER BY REGION;Consumer analyst repeats the same query
-- Consumer account in the assigned analyst's session.
USE ROLE M19_PARTNER_ANALYST;
USE SECONDARY ROLES NONE;
USE WAREHOUSE <consumer_lab_warehouse>;
SELECT CURRENT_ROLE(), CURRENT_ACCOUNT();
SELECT REGION, SALE_DATE, ORDER_COUNT, NET_SALES
FROM MAPLE_M19_IMPORTED.PARTNER.SALES_DAILY ORDER BY REGION, SALE_DATE;Consumer administrator creates the controlled failure
-- Consumer account, as the role that created MAPLE_M19_IMPORTED.
USE ROLE ACCOUNTADMIN;
REVOKE IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED FROM ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Consumer administrator restores the exact grant
-- Consumer account as ACCOUNTADMIN.
GRANT IMPORTED PRIVILEGES ON DATABASE MAPLE_M19_IMPORTED TO ROLE M19_PARTNER_ANALYST;
SHOW GRANTS TO ROLE M19_PARTNER_ANALYST;Provider operator offboards the known consumer
-- Provider account as M19_SHARE_ADMIN.
ALTER SHARE MAPLE_M19_SALES_SHARE REMOVE ACCOUNTS = <consumer_org>.<consumer_account>;
SHOW GRANTS OF SHARE MAPLE_M19_SALES_SHARE;17–18. Record operations evidence and clean up the approved lab
Keep the object-grant and target lists, the role context and account, and the query IDs for the allow and deny tests. The consumer owns local warehouse usage and should send only the agreed evidence to the provider. The provider owns source updates, invitation and customer support. The standard consumer pays for query compute. Review any different billing terms for reader or remote paths.
After the offboarding denial is recorded, the consumer admin can drop its lab import and lab role. On the provider confirm the exact share and database are disposable and check for alternate role-based shares, reader accounts or listings created in optional lessons. Retire those through their own cleanup before dropping the core lab. Drop only the named lab objects and leave existing accounts and warehouses alone.
Module 16 · Understand credits and recurring cost →
Module 18 · Protect query results with governance policies →
Provider operator confirms share inventory before cleanup
SHOW GRANTS OF SHARE MAPLE_M19_SALES_SHARE;
SHOW GRANTS TO SHARE MAPLE_M19_SALES_SHARE;Consumer analyst records a query ID after the read or denial
Run immediately after the statement to be captured, in the same session. Or copy the actual ID from Snowsight Query History if another statement ran after it.
SELECT LAST_QUERY_ID() AS EVIDENCE_QUERY_ID;Consumer administrator drops only the lab import and role
-- Consumer account. Run after the final denial is recorded.
USE ROLE ACCOUNTADMIN;
DROP DATABASE IF EXISTS MAPLE_M19_IMPORTED;
DROP ROLE M19_PARTNER_ANALYST;
SHOW DATABASES LIKE 'MAPLE_M19_IMPORTED';Provider operator removes the share and disposable database
-- Provider account. Run only after checking the exact lab share and database.
USE ROLE M19_SHARE_ADMIN;
DROP SHARE MAPLE_M19_SALES_SHARE;
DROP DATABASE LS_M19_SHARE_LAB;
SHOW SHARES LIKE 'MAPLE_M19_SALES_SHARE';
USE ROLE ACCOUNTADMIN;
DROP ROLE M19_SHARE_ADMIN;Interview practice
Explain the decision and the evidence you would use to test it.
What proves private data was protected?
The approved role can read the India aggregate. The Europe filter gives no rows, EMAIL was never exposed in the view, and the private customer table cannot be queried. I record all four results.
How did you distinguish an invitation problem from a local grant problem?
The inbound share remained visible to the importer and the provider still listed the account. Only the analyst lost its local grant, so I restored that grant and repeated the same read.
What evidence do you keep when ending a partner share?
I keep the approved target removal, the final consumer denial and the list of alternate delivery paths I checked. I also follow the agreement for any copy the partner made earlier.
Words used in this lesson
- Access contract
- Written allowed and denied actions for each participant.
- Readback
- Rerun the same query to verify the result after a change.
- Revocation
- Withdraw permission and verify the former reader is denied.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Enterprise Snowflake sharing capstone: publish, test and revoke a partner share
Maple Market share lifecycle
Check the data boundary, the two access gates and the final denial independently.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Maple Market share lifecycle
Check the data boundary, the two access gates and the final denial independently.
Private provider data → Secure regional view → Provider share → Consumer analyst → Offboard
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
The datasets are fictional. Results are expected or simulated. Run live steps only in approved test accounts with the documented roles, regions, and feature access.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
A new partner sees zero rows after installation. List checks that distinguish a correct denial from a setup mistake.
Compare your reasoning
Check the intended region, verified locator, entitlement map, current context and a known positive sample. Keep the raw data private while diagnosing the issue.
Connect this lesson to the learning path
Official sources and curriculum
Module 19 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab