# Snowflake Cleanup Commands for Phase 0 Test Artifacts

## Overview
This document contains the SQL commands to clean up all artifacts created during Phase 0 validation testing. These commands should be executed in Snowflake to remove test applications and associated resources.

⚠️ **IMPORTANT**: Review each command before execution. These operations are destructive and cannot be undone.

## Streamlit App Cleanup

### Test Applications Created During Validation
The following Streamlit apps were created during Phase 0 testing and should be removed:

```sql
-- Remove Test 1: Basic Streamlit App
DROP STREAMLIT IF EXISTS spark_test_1_basic;

-- Remove Test 3: External API App  
DROP STREAMLIT IF EXISTS spark_test_3_api;

-- Remove Test 4: Package Testing App
DROP STREAMLIT IF EXISTS spark_test_4_packages;

-- Remove Test 5: Modular Structure App
DROP STREAMLIT IF EXISTS spark_test_5_modular;
```

### Additional Test Variants (if created)
```sql
-- Remove any additional test variants that may have been created
DROP STREAMLIT IF EXISTS spark_test_1_basic_fixed;
DROP STREAMLIT IF EXISTS spark_test_5_minimal;
DROP STREAMLIT IF EXISTS spark_test_5_modular_simple;
DROP STREAMLIT IF EXISTS spark_test_5_single_file;
DROP STREAMLIT IF EXISTS spark_test_5_simple_import;
```

## Stage Cleanup

### Remove Files from @spark_streamlit_stage
```sql
-- List files in the stage to see what needs cleanup
LIST @spark_streamlit_stage;

-- Remove all Python files uploaded during testing
REMOVE @spark_streamlit_stage/test_1_basic.py;
REMOVE @spark_streamlit_stage/test_1_basic_fixed.py;
REMOVE @spark_streamlit_stage/test_2_database.py;
REMOVE @spark_streamlit_stage/test_3_api.py;
REMOVE @spark_streamlit_stage/test_4_packages.py;
REMOVE @spark_streamlit_stage/test_5_minimal.py;
REMOVE @spark_streamlit_stage/test_5_modular.py;
REMOVE @spark_streamlit_stage/test_5_modular_simple.py;
REMOVE @spark_streamlit_stage/test_5_single_file.py;
REMOVE @spark_streamlit_stage/test_5_simple_import.py;

-- Remove utility files
REMOVE @spark_streamlit_stage/math_utils.py;
REMOVE @spark_streamlit_stage/utils/;

-- Remove requirements files
REMOVE @spark_streamlit_stage/requirements.txt;
```

### Alternative: Clean All Files from Stage
```sql
-- Alternative approach: Remove all files from the stage
-- CAUTION: This will remove ALL files, not just test files
-- REMOVE @spark_streamlit_stage;
```

## Verification Commands

### Verify Streamlit Apps Removed
```sql
-- Check that all test apps have been removed
SHOW STREAMLIT LIKE 'spark_test_%';
```

### Verify Stage Cleanup
```sql
-- Verify stage is clean (or contains only non-test files)
LIST @spark_streamlit_stage;
```

## Infrastructure Resources (DO NOT REMOVE)

### Keep These Resources
The following infrastructure components should **NOT** be removed as they may be used for future development:

```sql
-- DO NOT REMOVE - Keep these for future use:
-- COMPUTE POOL spark_compute_pool
-- EXTERNAL ACCESS INTEGRATION spark_external_access
-- NETWORK RULE spark_pypi_rule  
-- NETWORK RULE spark_api_rule
-- STAGE @spark_streamlit_stage
-- WAREHOUSE spark_warehouse
```

## Execution Order

Execute cleanup commands in this order:
1. **First**: Remove Streamlit applications (they depend on stage files)
2. **Second**: Clean up stage files
3. **Finally**: Verify cleanup with verification commands

## Recovery Information

### If You Need to Restore Infrastructure
If infrastructure resources are accidentally removed, refer to the setup commands in:
- `/Users/mach071/Documents/collab/mymac80/spark/snowflake_setup.sql`
- Phase 0 test documentation in this directory

### Test File Backup
Test files are preserved in the local filesystem archive:
- Original files: `/Users/mach071/Documents/collab/mymac80/spark/hello_world_tests/archive/`
- Documentation: This directory's README.md and Phase0_Results.md

## Notes

- All test applications used the same compute pool and external access integration
- Stage files can be safely removed as they are backed up locally
- Infrastructure resources are shared and should be preserved for future development
- These cleanup commands are for Phase 0 test artifacts only