Overview
This powerful workflow enables you to process external files automatically, extract data, and trigger intelligent workflows based on file content. The Snowflake stage file access workflow consists of six main steps:- Create a Snowflake view for stage files
- Import the view as an Elementum table
- Build a Data Mine to monitor for new or changed files
- Create an automation triggered by the Data Mine
- Process files using the presigned URLs in your automation
- Add additional actions to your automation
This workflow enables you to securely access and process files stored in Snowflake stages - without duplicating the data outside of Snowflake. By default, files are not persisted or stored outside of Snowflake; your data remains protected and centralized unless you explicitly configure otherwise.
Prerequisites
Before starting this workflow, ensure you have:- Snowflake access with permissions to create views and access stages
- Elementum CloudLink configured and connected to your Snowflake instance
- Files uploaded to a Snowflake stage (e.g.,
@files_to_process
) - Directory Table enabled on your Snowflake stage for file listing and metadata access
The stage you use must have a Directory Table enabled. Enable it with:
- Understanding of Elementum Tables, Data Mining, and Automation System
Step 1: Create Snowflake View from a Stage
The first step is creating a Snowflake view that provides access to your stage files with presigned URLs for secure access. Execute this SQL in your Snowflake environment:Understanding the View Components
Understanding the View Components
RELATIVE_PATH
: File path within the stageSIZE
: File size in bytesLAST_MODIFIED
: Timestamp of last file modificationMD5
: File hash for integrity checkingpresigned_url
: Secure, time-limited URL for file access (valid for 3600 seconds = 1 hour)
The
presigned_url
is automatically regenerated every time the Data Mine runs, ensuring that URLs are always fresh and valid. This means you never have to worry about URL expiration interrupting your automated file processing.Step 2: Import View as Elementum Table
Once your Snowflake view is created, import it into Elementum as a table.- Navigate to Tables → Explore Data → CloudLink
- Select your Snowflake connection and choose the view you created
- Click “Create Table” and fill out the details
Step 3: Build Data Mine for File Monitoring
Create a Data Mine to automatically detect when new files arrive or existing files change.- In your table, go to Data Mining → Create Data Mine → Logic-Based Rules Mining
- Identifying Columns: Select
RELATIVE_PATH
,LAST_MODIFIED
, andMD5
These columns work together to track individual files across Data Mine runs, detect when files are modified or replaced, and ensure accurate state management (ON/OFF transitions).
- Matching Criteria: Set filters for file types or conditions (optional)
- Name and Schedule: Give it a name and set check frequency
Step 4: Create Automation with Data Mine Trigger
Build an automation that processes files when the Data Mine detects them.Your automation will follow this logical flow: Data Mine Trigger → Process File → Take Additional Actions (e.g. AI Analysis)
- Navigate to Automations → Create Automation
- Add Data Mine Trigger and select your Data Mine
- Set trigger option to “Trigger when data meets requirement”
Step 5: Process Files Using API Request Action
Add an API Request action to your automation to access files stored in the Snowflake stage.API Request action details:
- Request URL:
$PRESIGNED_URL
- Method:
GET
- Authorization:
No Auth
- Response Type:
File
Variable Reference: The
$PRESIGNED_URL
variable comes from the Data Mine trigger, providing access to all fields from the matching stage file record.Step 6: Add Additional Actions
After accessing the file via the API Request action, any additional actions you add will now have access to the file content.Summary
This workflow provides a powerful way to automatically process files stored in Snowflake stages:- Snowflake View provides secure access to stage files
- Elementum Table makes stage files accessible in your workspace
- Data Mine automatically detects new or changed files
- Automation provides access to the file content
- Additional Actions enable AI analysis, data extraction, and workflow automation
Appendix: Quick Test Setup in Snowflake
Use the following SQL to create a stage in Snowflake for testing purposes. Replace theALL_CAPS
placeholders with your actual values.
For complete configuration options, see Snowflake’s CREATE STAGE documentation.
Create Stage and View
Create Stage and View
Grant CloudLink Permissions
Grant CloudLink Permissions
Ensure your Elementum CloudLink role has the necessary permissions to access the stage and view.
Upload Test File
Upload Test File
Upload a test file to verify the stage is working correctly:
You can also upload files through the Snowflake web interface by navigating to your stage and using the “Upload Files” option.