|
| 1 | +--- |
| 2 | +name: data-product-sharing |
| 3 | +description: "Share data products across Snowflake accounts using listings, shares, and the marketplace. Use for: data sharing, CREATE SHARE, CREATE LISTING, private listings, marketplace listings, cross-account sharing, secure data sharing, provider/consumer, application packages, data products, organization listings. Triggers: share data, data product, listing, marketplace, cross-account, share table, share view, provider studio, consumer, secure share, private share, auto-fulfillment." |
| 4 | +--- |
| 5 | + |
| 6 | +# Data Product Sharing |
| 7 | + |
| 8 | +Share tables, views, and other Snowflake objects with other accounts — privately or on the Snowflake Marketplace. No data copying, no ETL, real-time access. |
| 9 | + |
| 10 | +## When to Use |
| 11 | + |
| 12 | +- User wants to share data with another Snowflake account |
| 13 | +- User mentions listings, marketplace, data products, or secure sharing |
| 14 | +- User needs to set up provider/consumer data sharing |
| 15 | +- User wants to publish to Snowflake Marketplace |
| 16 | +- User needs cross-region or cross-cloud data sharing (auto-fulfillment) |
| 17 | + |
| 18 | +## Tools Used |
| 19 | + |
| 20 | +- `snowflake_sql_execute` — Create shares, grants, listings, verify access |
| 21 | +- `ask_user_question` — Confirm sharing model, target accounts, access type |
| 22 | +- `read` / `write` / `edit` — Configure SQL templates with user-specific values |
| 23 | + |
| 24 | +## Bundled Files |
| 25 | + |
| 26 | +``` |
| 27 | +data-product-sharing/ |
| 28 | +├── SKILL.md # This file (agent instructions) |
| 29 | +├── README.md # Human-facing docs |
| 30 | +└── templates/ |
| 31 | + ├── setup.sql # Source data and provider setup |
| 32 | + ├── create-share.sql # Secure share with grants |
| 33 | + ├── create-listing.sql # Private and marketplace listings |
| 34 | + └── consumer-access.sql # Consumer-side install and query |
| 35 | +``` |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Phase 0: Briefing |
| 40 | + |
| 41 | +Present this to the user before starting: |
| 42 | + |
| 43 | +> **Snowflake Data Sharing** lets you share live data with other Snowflake accounts — no copying, no ETL, no storage costs for consumers. |
| 44 | +> |
| 45 | +> Three sharing methods: |
| 46 | +> - **Direct Share** — Point-to-point sharing with specific accounts. Simplest. Consumer gets a read-only database. |
| 47 | +> - **Private Listing** — Like a direct share but with metadata, usage analytics, and support for paid access. Best for business partnerships. |
| 48 | +> - **Marketplace Listing** — Publish publicly on Snowflake Marketplace. Best for broad distribution. |
| 49 | +> |
| 50 | +> I'll help you: |
| 51 | +> 1. Prepare the data you want to share |
| 52 | +> 2. Create a share or listing |
| 53 | +> 3. Configure consumer access |
| 54 | +> 4. Verify end-to-end |
| 55 | +
|
| 56 | +--- |
| 57 | + |
| 58 | +## Workflow |
| 59 | + |
| 60 | +### Step 1: Gather Requirements |
| 61 | + |
| 62 | +Ask the user: |
| 63 | +- **What data?** Database, schema, specific tables/views to share |
| 64 | +- **Who?** Target accounts (org.account format) or public marketplace |
| 65 | +- **How?** Direct share, private listing, or marketplace listing |
| 66 | +- **Access type?** Free, limited trial, or paid |
| 67 | + |
| 68 | +**Decision guide:** |
| 69 | + |
| 70 | +| Need | Method | Why | |
| 71 | +|------|--------|-----| |
| 72 | +| Quick share with one account | Direct Share | Simplest, no listing overhead | |
| 73 | +| Share with metadata and analytics | Private Listing | Usage tracking, descriptions, sample queries | |
| 74 | +| Broad distribution | Marketplace Listing | Publicly discoverable | |
| 75 | +| Monetize data | Paid Listing | Stripe integration for payments | |
| 76 | +| Internal org sharing | Organization Listing | Internal marketplace for business units | |
| 77 | +| Share apps + data + agents | Application Package (TYPE=DATA) | Declarative sharing via manifest | |
| 78 | + |
| 79 | +**For application packages (TYPE=DATA)** with agents, semantic views, or notebooks — use the `declarative-sharing` bundled skill instead. This skill covers share-based and listing-based sharing. |
| 80 | + |
| 81 | +**Defaults if not specified:** |
| 82 | +- Method: `direct share` |
| 83 | +- Access type: `free` |
| 84 | + |
| 85 | +### Step 2: Prepare Source Data |
| 86 | + |
| 87 | +Load `templates/setup.sql` and customize: |
| 88 | +- Replace `{{DATABASE}}`, `{{SCHEMA}}` with source database/schema |
| 89 | +- Create or identify the tables/views to share |
| 90 | +- Ensure objects are in a database the sharing role owns |
| 91 | + |
| 92 | +**Key rule**: You share a database, then grant access to specific objects within it. You cannot share individual objects without a database context. |
| 93 | + |
| 94 | +**Best practice**: Create secure views over raw tables to control what consumers see: |
| 95 | +```sql |
| 96 | +CREATE OR REPLACE SECURE VIEW share_ready_view AS |
| 97 | +SELECT col1, col2, col3 -- only columns you want to expose |
| 98 | +FROM raw_table |
| 99 | +WHERE is_public = TRUE; -- row-level filtering |
| 100 | +``` |
| 101 | + |
| 102 | +**STOP**: Confirm which objects to share before proceeding. |
| 103 | + |
| 104 | +### Step 3: Create Share or Listing |
| 105 | + |
| 106 | +Based on Step 1 decision: |
| 107 | + |
| 108 | +**Option A: Direct Share** — Load `templates/create-share.sql` |
| 109 | +- Creates a share, grants usage on database/schema, grants SELECT on tables/views |
| 110 | +- Adds consumer accounts |
| 111 | + |
| 112 | +**Option B: Private Listing** — Load `templates/create-listing.sql` |
| 113 | +- Creates a share first (same as Option A) |
| 114 | +- Then wraps it in a listing with metadata |
| 115 | + |
| 116 | +**Option C: Marketplace Listing** — Guide user to Provider Studio in Snowsight |
| 117 | +- Requires a provider profile (one-time setup) |
| 118 | +- Must accept Snowflake Provider and Consumer Terms |
| 119 | +- Listing goes through approval process |
| 120 | + |
| 121 | +Execute the appropriate SQL. |
| 122 | + |
| 123 | +### Step 4: Consumer-Side Access |
| 124 | + |
| 125 | +Share `templates/consumer-access.sql` with the consumer (or run it if testing in a second account): |
| 126 | +- Creates a database from the share/listing |
| 127 | +- Grants usage to consumer roles |
| 128 | +- Verifies data is accessible |
| 129 | + |
| 130 | +### Step 5: Verify End-to-End |
| 131 | + |
| 132 | +**Provider side:** |
| 133 | +```sql |
| 134 | +SHOW SHARES; |
| 135 | +DESCRIBE SHARE {{SHARE_NAME}}; |
| 136 | +-- For listings: |
| 137 | +SHOW LISTINGS; |
| 138 | +``` |
| 139 | + |
| 140 | +**Consumer side:** |
| 141 | +```sql |
| 142 | +SHOW AVAILABLE LISTINGS; |
| 143 | +-- or |
| 144 | +SHOW SHARES; |
| 145 | +SELECT * FROM {{CONSUMER_DB}}.{{SCHEMA}}.{{TABLE}} LIMIT 10; |
| 146 | +``` |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## Sharing Reference |
| 151 | + |
| 152 | +### What Can Be Shared |
| 153 | + |
| 154 | +| Object | Shareable | Notes | |
| 155 | +|--------|-----------|-------| |
| 156 | +| Tables | Yes | SELECT grant | |
| 157 | +| Secure Views | Yes | Recommended over raw tables | |
| 158 | +| Secure UDFs | Yes | Including UDTFs | |
| 159 | +| Secure Materialized Views | Yes | Consumer sees materialized data | |
| 160 | +| Schemas | Yes | Via USAGE grant | |
| 161 | +| Databases | Yes | Required as container | |
| 162 | + |
| 163 | +### Access Control |
| 164 | + |
| 165 | +| Role | Privileges Needed | |
| 166 | +|------|-------------------| |
| 167 | +| Provider (share creator) | `CREATE SHARE` on account | |
| 168 | +| Provider (listing creator) | `CREATE DATA EXCHANGE LISTING` on account | |
| 169 | +| Consumer (access listing) | `CREATE DATABASE`, `IMPORT SHARE` | |
| 170 | + |
| 171 | +### Key SQL Commands |
| 172 | + |
| 173 | +```sql |
| 174 | +-- Shares |
| 175 | +CREATE SHARE ... -- Create empty share |
| 176 | +GRANT USAGE ON DATABASE ... TO SHARE ... -- Add database |
| 177 | +GRANT USAGE ON SCHEMA ... TO SHARE ... -- Add schema |
| 178 | +GRANT SELECT ON TABLE ... TO SHARE ... -- Add table |
| 179 | +ALTER SHARE ... ADD ACCOUNTS = ... -- Add consumers |
| 180 | +DESCRIBE SHARE ... -- View share contents |
| 181 | +REVOKE ... FROM SHARE ... -- Remove access |
| 182 | + |
| 183 | +-- Consumer side |
| 184 | +CREATE DATABASE ... FROM SHARE ... -- Mount shared data |
| 185 | +-- or |
| 186 | +CREATE DATABASE ... FROM LISTING ... -- Install from listing |
| 187 | + |
| 188 | +-- Listings (SQL) |
| 189 | +SHOW LISTINGS; |
| 190 | +DESCRIBE LISTING ...; |
| 191 | +``` |
| 192 | + |
| 193 | +### Auto-Fulfillment (Cross-Region) |
| 194 | + |
| 195 | +When sharing with accounts in different regions, Snowflake automatically replicates data: |
| 196 | +- Provider sets refresh frequency (default: 1 hour) |
| 197 | +- Consumer sees data with slight lag |
| 198 | +- Provider pays for replication compute and storage |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## Stopping Points |
| 203 | + |
| 204 | +- **Step 2**: Confirm which objects to share |
| 205 | +- **Step 3**: Review share/listing before adding consumer accounts |
| 206 | +- **Step 5**: Verify consumer can query the data |
| 207 | + |
| 208 | +## Common Patterns |
| 209 | + |
| 210 | +**Secure view with row-level filtering:** |
| 211 | +```sql |
| 212 | +CREATE OR REPLACE SECURE VIEW shared_orders AS |
| 213 | +SELECT order_id, product, amount, region |
| 214 | +FROM orders |
| 215 | +WHERE region = CURRENT_ACCOUNT(); -- per-consumer filtering |
| 216 | +``` |
| 217 | + |
| 218 | +**Reader accounts (for non-Snowflake consumers):** |
| 219 | +```sql |
| 220 | +CREATE MANAGED ACCOUNT consumer_reader |
| 221 | + ADMIN_NAME = 'admin' |
| 222 | + ADMIN_PASSWORD = 'ChangeMe123!' |
| 223 | + TYPE = READER; |
| 224 | + |
| 225 | +ALTER SHARE my_share ADD ACCOUNTS = consumer_reader; |
| 226 | +``` |
| 227 | + |
| 228 | +**Revoking access:** |
| 229 | +```sql |
| 230 | +ALTER SHARE my_share REMOVE ACCOUNTS = target_org.target_account; |
| 231 | +-- or |
| 232 | +DROP SHARE my_share; |
| 233 | +``` |
0 commit comments