|
| 1 | +# Snowflake to Redis Data Integration Demo Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | +This demo showcases real-time data integration from Snowflake to Redis using RIOTX. The demo will demonstrate CDC (Change Data Capture) capabilities, showing how data changes in Snowflake are automatically synchronized to Redis. |
| 5 | + |
| 6 | +## Setup Verification (Before Demo) |
| 7 | + |
| 8 | +### 1. Environment Setup |
| 9 | +```bash |
| 10 | +# Copy environment template and configure your values |
| 11 | +cp .env.example .env |
| 12 | +# Edit .env with your actual Snowflake and Redis credentials |
| 13 | +``` |
| 14 | + |
| 15 | +### 2. Environment Check |
| 16 | +```bash |
| 17 | +# Verify tools are available |
| 18 | +which riotx |
| 19 | +which snowsql |
| 20 | +``` |
| 21 | + |
| 22 | +### 3. Snowflake Connection Test |
| 23 | +```bash |
| 24 | +# Load environment variables |
| 25 | +source .env |
| 26 | +snowsql -c $SNOWFLAKE_ACCOUNT -q "SELECT COUNT(*) FROM $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE;" |
| 27 | +``` |
| 28 | + |
| 29 | +### 4. Redis Connection Test |
| 30 | +```bash |
| 31 | +# Test Redis connection (should be accessible via Redis Insights GUI) |
| 32 | +redis-cli -h $REDIS_HOST -p $REDIS_PORT -a '$REDIS_PASS' ping |
| 33 | +``` |
| 34 | + |
| 35 | +## Demo Flow (3-Window Setup) |
| 36 | + |
| 37 | +### Window 1: Snowflake Terminal |
| 38 | +**Purpose**: Show source data and simulate changes |
| 39 | +**Command**: `snowsql -c $SNOWFLAKE_ACCOUNT` |
| 40 | + |
| 41 | +### Window 2: RIOTX Data Sync |
| 42 | +**Purpose**: Run the data synchronization process |
| 43 | +**Command**: See main command below |
| 44 | + |
| 45 | +### Window 3: Redis Insights GUI |
| 46 | +**Purpose**: Visualize data in Redis in real-time |
| 47 | +**URL**: Open Redis Insights and connect to Redis cluster |
| 48 | + |
| 49 | +## Main Demo Script |
| 50 | + |
| 51 | +### Phase 1: Initial Data Load (5 minutes) |
| 52 | + |
| 53 | +#### 1.1 Show Current Snowflake Data |
| 54 | +```sql |
| 55 | +-- In Snowflake terminal (Window 1) |
| 56 | +USE SCHEMA $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA; |
| 57 | +SELECT COUNT(*) FROM $SNOWFLAKE_TABLE; |
| 58 | +SELECT * FROM $SNOWFLAKE_TABLE LIMIT 10; |
| 59 | +``` |
| 60 | + |
| 61 | +#### 1.2 Start RIOTX Sync Process |
| 62 | +```bash |
| 63 | +# In RIOTX terminal (Window 2) |
| 64 | +riotx snowflake-import \ |
| 65 | + -h $REDIS_HOST \ |
| 66 | + -p $REDIS_PORT \ |
| 67 | + -a $REDIS_PASS \ |
| 68 | + $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE \ |
| 69 | + --cdc-schema $SNOWFLAKE_CDC_SCHEMA \ |
| 70 | + --role $SNOWFLAKE_ROLE \ |
| 71 | + --warehouse $SNOWFLAKE_WAREHOUSE \ |
| 72 | + --jdbc-url "jdbc:snowflake://$SNOWFLAKE_ACCOUNT.snowflakecomputing.com?private_key_file=$SNOWFLAKE_PRIVATE_KEY_FILE" \ |
| 73 | + --jdbc-user $SNOWFLAKE_USER \ |
| 74 | + hset 'orders:#{ORDER_ID}' |
| 75 | +``` |
| 76 | + |
| 77 | +#### 1.3 Verify Initial Data in Redis |
| 78 | +- **In Redis Insights**: Browse to see the `orders:*` keys |
| 79 | +- **Expected**: Hash keys for each ORDER_ID with all order details |
| 80 | + |
| 81 | +### Phase 2: CDC Demonstration (10 minutes) |
| 82 | + |
| 83 | +#### 2.1 Insert New Orders |
| 84 | +```sql |
| 85 | +-- In Snowflake terminal (Window 1) |
| 86 | +INSERT INTO $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE |
| 87 | +(ORDER_ID, TRUCK_ID, LOCATION_ID, ORDER_TS, ORDER_CURRENCY, ORDER_AMOUNT, ORDER_TOTAL) |
| 88 | +VALUES |
| 89 | +(9999001, 99, 99999, CURRENT_TIMESTAMP(), 'USD', 150.00, 150.00), |
| 90 | +(9999002, 99, 99999, CURRENT_TIMESTAMP(), 'USD', 75.50, 75.50); |
| 91 | + |
| 92 | +-- Verify insertion |
| 93 | +SELECT * FROM $SNOWFLAKE_TABLE WHERE ORDER_ID >= 9999001; |
| 94 | +``` |
| 95 | + |
| 96 | +#### 2.2 Monitor RIOTX Output |
| 97 | +- **In RIOTX terminal**: Watch for new records being processed |
| 98 | +- **Expected**: Log messages showing CDC events being captured and sent to Redis |
| 99 | + |
| 100 | +#### 2.3 Verify in Redis |
| 101 | +- **In Redis Insights**: |
| 102 | + - Refresh the key browser |
| 103 | + - Look for new keys: `orders:9999001` and `orders:9999002` |
| 104 | + - Click on keys to see the hash field values |
| 105 | + |
| 106 | +#### 2.4 Update Existing Orders |
| 107 | +```sql |
| 108 | +-- In Snowflake terminal (Window 1) |
| 109 | +UPDATE $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE |
| 110 | +SET ORDER_AMOUNT = 200.00, ORDER_TOTAL = 200.00 |
| 111 | +WHERE ORDER_ID = 9999001; |
| 112 | + |
| 113 | +-- Verify update |
| 114 | +SELECT * FROM $SNOWFLAKE_TABLE WHERE ORDER_ID = 9999001; |
| 115 | +``` |
| 116 | + |
| 117 | +#### 2.5 Verify Update in Redis |
| 118 | +- **In Redis Insights**: Check `orders:9999001` to see updated values |
| 119 | +- **Expected**: ORDER_AMOUNT and ORDER_TOTAL fields should reflect new values |
| 120 | + |
| 121 | +### Phase 3: Scale and Performance (5 minutes) |
| 122 | + |
| 123 | +#### 3.1 Bulk Insert - Load More Data from Main Table |
| 124 | +```sql |
| 125 | +-- In Snowflake terminal (Window 1) |
| 126 | +-- The main order_header table has 1,698,440 rows vs incremental table's 100 rows |
| 127 | +-- Let's add 1000 more records from the main table |
| 128 | +INSERT INTO $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE |
| 129 | +SELECT * FROM $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.order_header |
| 130 | +WHERE ORDER_ID NOT IN (SELECT ORDER_ID FROM $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE) |
| 131 | +LIMIT 1000; |
| 132 | + |
| 133 | +-- Verify the insert |
| 134 | +SELECT COUNT(*) FROM $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE; |
| 135 | +``` |
| 136 | + |
| 137 | +#### 3.2 Monitor Bulk Processing |
| 138 | +- **In RIOTX terminal**: Watch batch processing metrics |
| 139 | +- **In Redis Insights**: Watch key count increase in real-time |
| 140 | + |
| 141 | +## Key Demo Points to Highlight |
| 142 | + |
| 143 | +### 1. Real-Time CDC |
| 144 | +- Changes in Snowflake appear in Redis within seconds |
| 145 | +- No polling - event-driven architecture |
| 146 | +- Maintains data consistency |
| 147 | + |
| 148 | +### 2. Scalability |
| 149 | +- Batch processing for bulk operations |
| 150 | +- Efficient handling of large datasets |
| 151 | +- Minimal impact on source system |
| 152 | + |
| 153 | +### 3. Data Structure |
| 154 | +- Snowflake rows → Redis hashes |
| 155 | +- Flexible key naming patterns |
| 156 | +- Preserves all data types and relationships |
| 157 | + |
| 158 | +### 4. Enterprise Features |
| 159 | +- Secure connections (TLS, authentication) |
| 160 | +- Role-based access control |
| 161 | +- Monitoring and observability |
| 162 | + |
| 163 | +## Troubleshooting Commands |
| 164 | + |
| 165 | +### Check Snowflake Stream Status |
| 166 | +```sql |
| 167 | +-- In Snowflake terminal |
| 168 | +SHOW STREAMS IN SCHEMA $SNOWFLAKE_CDC_SCHEMA; |
| 169 | +``` |
| 170 | + |
| 171 | +### Redis Connection Test |
| 172 | +```bash |
| 173 | +redis-cli -h $REDIS_HOST -p $REDIS_PORT -a '$REDIS_PASS' info replication |
| 174 | +``` |
| 175 | + |
| 176 | +### RIOTX Debug Mode |
| 177 | +```bash |
| 178 | +# Add --debug flag to the main command for verbose logging |
| 179 | +riotx snowflake-import --debug [... other parameters ...] |
| 180 | +``` |
| 181 | + |
| 182 | +## Q&A Preparation |
| 183 | + |
| 184 | +### Common Questions: |
| 185 | +1. **"How does CDC work?"** - Snowflake Streams capture changes, RIOTX polls streams |
| 186 | +2. **"What's the latency?"** - Typically 1-5 seconds depending on configuration |
| 187 | +3. **"Can it handle schema changes?"** - Yes, but requires restart for new columns |
| 188 | +4. **"What about failover?"** - Redis Enterprise provides high availability |
| 189 | +5. **"Cost implications?"** - Snowflake compute costs, Redis memory usage |
| 190 | + |
| 191 | +### Demo Recovery: |
| 192 | +- If RIOTX fails: Restart the command (it will resume from last position) |
| 193 | +- If Redis connection fails: Check Redis Insights connection settings |
| 194 | +- If Snowflake fails: Verify network connectivity and credentials |
| 195 | + |
| 196 | +## Post-Demo Cleanup |
| 197 | + |
| 198 | +```sql |
| 199 | +-- Optional: Clean up demo data |
| 200 | +DELETE FROM $SNOWFLAKE_DATABASE.$SNOWFLAKE_SCHEMA.$SNOWFLAKE_TABLE WHERE ORDER_ID >= 9999001; |
| 201 | +``` |
| 202 | + |
| 203 | +```bash |
| 204 | +# Optional: Clean up Redis keys |
| 205 | +redis-cli -h $REDIS_HOST -p $REDIS_PORT -a '$REDIS_PASS' --scan --pattern "orders:9999*" | xargs redis-cli -h $REDIS_HOST -p $REDIS_PORT -a '$REDIS_PASS' del |
| 206 | +``` |
| 207 | + |
| 208 | +## Success Metrics |
| 209 | +- [ ] Data appears in Redis within 5 seconds of Snowflake changes |
| 210 | +- [ ] All 3 windows show synchronized activity |
| 211 | +- [ ] Bulk operations process smoothly |
| 212 | +- [ ] Q&A handled confidently |
| 213 | +- [ ] Audience understands the value proposition |
| 214 | + |
| 215 | +--- |
| 216 | + |
| 217 | +**Remember**: Take your time, breathe, and focus on the story: "Real-time data integration made simple with Snowflake and Redis." |
0 commit comments