๐ŸŽ‰ 75% of content is free forever โ€” Unlock Premium from $10/mo โ†’
CW
NEWSLIVESearch All Content
๐Ÿ’ผ Servicesโ„น๏ธ Aboutโœ‰๏ธ ContactView Pricing Plansfrom $10

Topic: Secure Data Sharing & Data Marketplace

Snowflake AdvancedData Sharingโญ Premium

Snowflake Advanced ยท Interview Prep

Secure Data Sharing & Marketplace

Difficulty: Medium-Hard ยท Commonly asked at Uber, Microsoft, Google

Interview Question

"How would you design a data sharing architecture where multiple business units can share curated datasets without copying data? What are the security and governance implications?"

โ„น๏ธ

Companies Asking This: Uber (Senior Data Engineer), Microsoft (Principal Data Architect), Google (Cloud Data Engineer), Meta (Data Platform Engineer)


Secure Data Sharing Fundamentals

Snowflake enables direct, secure data sharing between accounts without copying or transferring data. The provider retains control over the data.

A share is an access object, not a file transfer: the provider grants database, schema, and object privileges into a share, adds consumer account IDs to it, and the consumer's account materializes an imported database whose queries execute against provider-owned storage. Nothing is copied, so provisioning takes seconds whether the shared table is 10 GB or 100 TB, and freshness is immediate โ€” every commit the provider makes answers on the consumer's next query, with no refresh window to explain to anyone. The boundaries matter just as much: consumers see only the granted objects, cannot write, and cannot enumerate the rest of the provider's account, while the provider can revoke access at any time and the imported database simply stops answering. A share can span accounts, regions, and even clouds, but a consumer querying far from the provider's storage pays that network round trip on every execution โ€” which is why multi-region rollouts usually pair the share with a replica placed near the reader rather than querying across the ocean nightly.

Billing deserves its own sentence because it surprises finance teams. Shared objects sit on the provider's storage bill at normal rates, queries burn credits in the consumer's own warehouses, and if the share exposes materialized views or dynamic tables, the refresh compute lands on the provider instead. Rehearse the full lifecycle once, end to end โ€” create the share, grant, import, query, revoke โ€” because each step is owned by a different team, and the failures in practice appear at the seams between those teams rather than inside anyone's account logs.

Sharing Architecture

Provider AccountDatabase: SHARED_DATASALES(Shared)CUSTOMERS(Shared)PRODUCTS(Shared)Secure Data ShareDirect access, no data movementConsumer 1Business Unit AConsumer 2Analytics TeamConsumer 3Data Science

Creating Shares

-- 1. Create a share
CREATE SHARE sales_share
    COMMENT = 'Sales data shared with analytics team';

-- 2. Grant usage on database to share
GRANT USAGE ON DATABASE analytics_db TO SHARE sales_share;

-- 3. Grant usage on schema
GRANT USAGE ON SCHEMA analytics_db.sales TO SHARE sales_share;

-- 4. Grant SELECT on tables
GRANT SELECT ON TABLE analytics_db.sales.orders TO SHARE sales_share;
GRANT SELECT ON TABLE analytics_db.sales.customers TO SHARE sales_share;

-- 5. Create a secure view for sharing (mask sensitive data)
CREATE OR REPLACE SECURE VIEW shared_sales_view AS
SELECT 
    order_id,
    order_date,
    customer_id,
    product_category,
    amount,
    region,
    -- Mask sensitive columns
    NULL AS customer_email,
    NULL AS payment_method
FROM analytics_db.sales.orders;

-- 6. Grant SELECT on secure view
GRANT SELECT ON VIEW analytics_db.sales.shared_sales_view TO SHARE sales_share;

-- 7. Add consumer accounts to the share
ALTER SHARE sales_share ADD ACCOUNT = consumer_account_1;
ALTER SHARE sales_share ADD ACCOUNT = consumer_account_2;

-- 8. Check share status
SELECT 
    share_name,
    share_type,
    owner_name,
    created_on,
    source_database
FROM information_schema.shares
WHERE share_name = 'SALES_SHARE';

Consumer Side

On the consumer side the share lands as an ordinary-looking database with three properties that are different. It is read-only โ€” DDL and DML against imported objects fail outright, which deletes an entire category of support tickets before they exist. Its access arrives through IMPORTED PRIVILEGES on the database, so the provider's grant decisions still determine what the object exposes while the consumer's own roles decide which users may query it. And compute billing stays local: everything scanned runs on the consumer's warehouses, the arrangement that makes sharing commercially sane โ€” the provider pays storage, the consumer pays for their own appetite. Revocation is symmetric and abrupt: once the provider removes the account from the share, the imported database answers with an access error, so treat revocation as a scripted, audited governance event rather than something a person types during an incident.

-- 1. Create database from share
CREATE DATABASE sales_analytics_db FROM SHARE provider_account.sales_share;

-- 2. Grant access to roles
GRANT IMPORTED PRIVILEGES ON DATABASE sales_analytics_db TO ROLE analyst;

-- 3. Query shared data
SELECT * FROM sales_analytics_db.sales.shared_sales_view;

-- 4. Monitor shared data usage
SELECT 
    table_name,
    query_count,
    last_query_time
FROM information_schema.database_usage
WHERE database_name = 'SALES_ANALYTICS_DB';

Real-World Scenario: Uber

Question: "How do you share real-time trip data with partner companies while ensuring they only see their own trips and can't access competitor data?"

Two failure modes frame the answer. If filtering lives on the consumer side, a misconfigured role eventually reads someone else's rows โ€” an incident, not a bug. If you create one share per partner, governance scales linearly with the partner count and nobody can say what is shared anymore. The pattern below pushes both problems to the provider, where one share and one policy serve every partner.

Solution: Row-Level Sharing with Security

Two design choices make this shareable rather than merely shared. Masking happens inside the provider's secure view, so the consumer never receives raw driver and rider identifiers โ€” nulling them at the provider is stronger than trusting a consumer-side filter, because the data never enters their control in the first place. Row restriction belongs in a row access policy applied on the provider side and evaluated at query time, so one share can serve many partners without multiplying into one share per partner and one governance workflow per account. The trade-off to state: policies and secure views add planning overhead and must be tested per role, because a view that filters correctly under one context and silently returns nothing under another surfaces as a broken dashboard long before anyone suspects the policy.

-- 1. Create a share with row-level security
CREATE SHARE partner_trips_share
    COMMENT = 'Trip data shared with partners';

-- 2. Create a secure view with row-level filtering
CREATE OR REPLACE SECURE VIEW partner_trips_view AS
SELECT 
    trip_id,
    pickup_location,
    dropoff_location,
    trip_date,
    trip_distance,
    fare_amount,
    partner_id,
    -- Mask driver information
    NULL AS driver_id,
    NULL AS driver_name,
    -- Mask rider information
    NULL AS rider_id,
    CONCAT(LEFT(rider_name, 1), '***') AS rider_name_masked
FROM trips
WHERE partner_id = CURRENT_SESSION():partner_id;  -- Dynamic filtering

-- 3. Create a mapping table for partner access
CREATE TABLE partner_access_map (
    partner_id VARCHAR(100),
    partner_name VARCHAR(200),
    allowed_tables ARRAY,
    max_rows_per_query NUMBER
);

-- 4. Create row access policy for partners
CREATE OR REPLACE ROW ACCESS POLICY partner_access_policy 
AS (partner_id VARCHAR) RETURNS BOOLEAN ->
    CASE
        WHEN CURRENT_ROLE() IN ('DATA_ADMIN', 'PARTNER_MANAGER') THEN TRUE
        WHEN EXISTS (
            SELECT 1 FROM partner_access_map 
            WHERE partner_id = partner_id
        ) THEN TRUE
        ELSE FALSE
    END;

-- 5. Apply policy and share
ALTER TABLE trips ADD ROW ACCESS POLICY partner_access_policy ON (partner_id);
GRANT SELECT ON TABLE trips TO SHARE partner_trips_share;

-- 6. Add partner accounts
ALTER SHARE partner_trips_share ADD ACCOUNT = partner_uber_account;

Data Marketplace

Listings package shares into products. A private listing is the share flow above with a catalog wrapper, onboarding a named consumer with no review cycle; a public listing turns the data into a storefront where consumers discover and subscribe themselves, and you stop doing account plumbing entirely. Providers can publish free listings or metered ones, and the real differences are operational rather than technical: the listing's metadata, refresh schedule, and version notes become part of your release routine; usage views show which consumers actually query what you published; and disabling the listing is the single kill switch that ends every subscription at once. Start private, where revocation is one account at a time, and go public only when answering support questions from strangers is somebody's actual job.

-- 1. Browse marketplace listings
SHOW MARKETPLACE LISTINGS;

-- 2. Create a listing (provider side)
CREATE OR REPLACE LISTING my_data_listing
    TITLE = 'Company Sales Data'
    DESCRIPTION = 'Aggregated sales data by region and product category'
    COMMENT = 'Updated daily'
    ENABLED = TRUE
    DATA_SHARING_SCOPE = 'PRIVATE'
    CONSUMER_ENTITIES = ('consumer_account_1', 'consumer_account_2');

-- 3. Set up listing refresh schedule
ALTER LISTING my_data_listing 
    SET REFRESH_SCHEDULE = 'USING CRON 0 6 * * * UTC';

-- 4. Monitor listing usage
SELECT 
    listing_name,
    consumer_account,
    query_count,
    last_query_time,
    data_freshness
FROM information_schema.marketplace_listing_usage
WHERE listing_name = 'MY_DATA_LISTING';

Best Practices

The economics are worth stating in an interview: a share replaces a nightly export with a grant, trading a pipeline and a duplicated storage copy for an object that costs nothing extra to create and never goes stale. Audit it accordingly โ€” walk the share list on a schedule, confirm every consumer still maps to a real business relationship, and revoke the ones that do not, because access nobody uses is still access you are accountable for when the security review comes.

PracticeRecommendation
Data minimizationShare only necessary columns/rows
Secure viewsAlways use SECURE VIEWs for sharing
GovernanceTrack all shares with resource monitors
FreshnessSet appropriate refresh schedules
MonitoringTrack consumer query patterns
CleanupRemove unused shares regularly

โš ๏ธ

Security Considerations:

  1. No data copying โ€” Consumers query provider data directly
  2. Provider control โ€” Provider can revoke access at any time
  3. No writes โ€” Consumers cannot modify shared data
  4. Billing โ€” Provider pays for compute; consumer pays for their queries

Key Takeaways

  • A share is a privilege object, not a copy: the consumer's imported database queries provider-owned storage live, provisions in seconds at any size, and is revoked by removing the account.
  • Consumers are read-only and never see ungranted objects โ€” put masking and row access policies in provider-side secure views so raw identifiers never leave your account.
  • Costs split cleanly: the provider pays storage and any refresh compute on shared objects, while each consumer pays for the warehouse their own queries consume.
  • Govern the lifecycle like any other access path โ€” audit the share list on a schedule, script revocation, and prefer a private listing until someone owns consumer support.
๐Ÿ”’

Premium Content

Topic: Secure Data Sharing & Data Marketplace

You've previewed the first section. Unlock this full lesson and 900+ advanced tutorials with a Premium plan.

๐ŸŽฏEnd-to-end Projects
๐Ÿ’ผInterview Prep
๐Ÿ“œCertificates
๐ŸคCommunity Access

Already a member? Log in

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-17

โ€”
โ˜†โ˜†โ˜†โ˜†โ˜†
0 ratings

Rate & Feedback

Advertisement