Overview

Tool Name

snowflake_tools

Purpose

The snowflake_tools suite gives you Snowflake-specific power that goes beyond standard SQL. Work with stages and files, run Python in Snowpark, and use Cortex search to retrieve AI-ranked results from indexed content.

Key Features & Functions

Stage Operations

List, upload, read, and delete files in Snowflake stages to support file-based pipelines.

Snowpark Python

Execute Python against Snowflake data for analytics, data science, and ML.

Cortex Search

Run AI-powered search over configured services to surface relevant content quickly.

Artifacts

Persist outputs and files as artifacts for easy sharing and traceability.
Unless your workflow specifies otherwise, use your WORKSPACE database, schema, and stage to simplify file paths and permissions.

Input Parameters for Each Function

_list_stage_contents

Parameters
NameDefinitionFormat
databaseTarget database name.String
schemaTarget schema name.String
stageStage name to inspect.String
patternFilename or glob-style pattern to filter results.String

_add_file_to_stage

Parameters
NameDefinitionFormat
databaseDatabase that owns the stage.String
schemaSchema that owns the stage.String
stageStage name.String
file_nameFull local path to the file to upload.String
target_pathOptional subfolder on the stage, exclude the filename.String

_delete_file_from_stage

Parameters
NameDefinitionFormat
databaseDatabase that owns the stage.String
schemaSchema that owns the stage.String
stageStage name.String
file_nameOriginal filename on the stage, with optional path.String

_read_file_from_stage

Parameters
NameDefinitionFormat
databaseDatabase that owns the stage.String
schemaSchema that owns the stage.String
stageStage name.String
file_nameFilename on the stage, with optional path.String
return_contentsReturn file contents instead of only the filename.Boolean
is_binaryTreat file as binary when returning contents.Boolean
max_bytesMaximum bytes to return when streaming content. Default 10000.Integer
save_artifactsSave the downloaded file as an artifact with a link for reuse and sharing.Boolean
For binary reads, set is_binary = true. If you also set save_artifacts = true, the file will be persisted and returned with an artifact link.
Parameters
NameDefinitionFormat
service_nameName of the configured Cortex search service.String
queryShort text query to search for.String
top_nNumber of top results to return. Default 15, max 25.Integer

_run_snowpark_python

Parameters
NameDefinitionFormat
codePython code to execute in Snowpark.String
purposeHuman-readable explanation used for validation and auditing.String
packagesComma-separated list of additional packages to install.String
note_idExecute previously saved code by note id instead of passing code.String
save_artifactsPersist outputs as artifacts for later access and sharing.Boolean

Use Cases

  1. Create data visualizations from Snowflake data with matplotlib or similar libraries.
  2. Perform advanced statistical analysis on enterprise datasets.
  3. Build and run machine learning models inside Snowflake.
  4. Process CSVs by uploading to stages and analyzing with Snowpark.
  5. Generate automated reports and dashboards with Python-based workflows.
  6. Search indexed documentation and knowledge bases using Cortex AI.
  7. Spin up temporary data workflows that leverage Snowflake compute.
  8. Develop custom transformation scripts for large-scale datasets.
  9. Combine SQL and Python for interactive analysis.
  10. Manage file-based pipelines for ETL and data quality validation.

Workflow/How It Works

  1. Land files with _add_file_to_stage or verify with _list_stage_contents.
  2. Transform and analyze using _run_snowpark_python with access to Snowflake data.
  3. Discover content via _cortex_search for AI-ranked retrieval when needed.
  4. Retrieve or share with _read_file_from_stage, optionally saving results as artifacts.

Integration Relevance

  • data_connector_tools for SQL-centric operations that complement Snowpark workloads.
  • file_manager_tools to register outputs and maintain lineage.
  • artifact_manager_tools to persist visualizations, CSVs, or notebooks.
  • project_manager_tools to track Snowflake tasks across missions and todos.
  • image_tools to inspect or analyze images generated by Snowpark code.
Snowpark jobs and frequent stage operations can incur compute and storage costs. Ensure roles, warehouses, and stage privileges are configured before running workloads.

Configuration Details

  • Use forward slashes in stage paths and avoid special characters.
  • Ensure your role has USAGE on the database and schema, plus required privileges on the stage.
  • In Snowpark, set a top-level result variable in your code to capture returned output.
  • Cortex services must be provisioned and indexed before you can query them.
  • Package names should exclude standard libraries and list only additional needs.

Limitations or Notes

  1. Stage and Snowpark operations require appropriate Snowflake permissions.
  2. Large files and long-running Python jobs may hit resource or timeout limits.
  3. First-time package installation in Snowpark can add latency.
  4. Cortex search availability depends on account features and service configuration.
  5. Complex Python tasks can require significant compute and time.
  6. Binary file handling may require is_binary = true and max_bytes tuning.
  7. Network connectivity to Snowflake is required for all operations.

Output

  • Stage Operations Listings, upload confirmations, deletions, and resolved file paths.
  • File Content Returned text or binary bytes with size and encoding info when requested.
  • Cortex Search Ranked results with relevance scores and snippets.
  • Snowpark Execution Captured result, console logs, and optional artifacts for downstream use.
  • Artifacts Artifact ids and links for reports, images, or data files created during execution.
  • Errors Clear messages for permission issues, invalid paths, missing services, or runtime failures.