Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

SnowflakeTableRetriever

Connect to a Snowflake database and execute SQL queries using ADBC and Polars. It returns the results as a Pandas DataFrame and optionally as a Markdown-formatted string.

For more information, see Polars documentation and ADBC documentation.

Key Features

  • Executes SQL queries against a Snowflake database using ADBC and Polars.
  • Returns query results as a Pandas DataFrame and as a Markdown-formatted table.
  • Configurable login timeout.
  • Supports passing the SQL query at runtime for dynamic data retrieval.

Configuration

  1. Drag the SnowflakeTableRetriever component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    • Set your Snowflake user, account, and api_key (password). Store the password as a secret called SNOWFLAKE_API_KEY. For instructions, see Add Secrets.
    • Set the database, db_schema, and warehouse for your Snowflake connection.
  4. Go to the Advanced tab to configure login_timeout and return_markdown.

Connections

SnowflakeTableRetriever receives SQL queries at runtime. It outputs the query results as a dataframe (Pandas DataFrame) and optionally as a table (Markdown string). Connect it to components that process or format the query results.

Source Code

To check this component's source code, open snowflake_table_retriever.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  SnowflakeTableRetriever:
type:
snowflake.src.haystack_integrations.components.retrievers.snowflake.snowflake_table_retriever.SnowflakeTableRetriever
init_parameters: {}
components:
SnowflakeTableRetriever:
type: snowflake.src.haystack_integrations.components.retrievers.snowflake.snowflake_table_retriever.SnowflakeTableRetriever
init_parameters:

Parameters

Inputs

ParameterTypeDescription
querystrThe SQL query to execute.
return_markdownOptional[bool]Whether to return a Markdown-formatted string of the DataFrame. If not provided, uses the value set during initialization.

Outputs

ParameterTypeDescription
dataframeDataFrameA Pandas DataFrame with the query results.
tablestrA Markdown-formatted string representation of the DataFrame.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
userstrUser's login.
accountstrSnowflake account identifier.
api_keySecretSecret.from_env_var('SNOWFLAKE_API_KEY')Snowflake account password.
databaseOptional[str]NoneName of the database to use.
db_schemaOptional[str]NoneName of the schema to use.
warehouseOptional[str]NoneName of the warehouse to use.
login_timeoutOptional[int]60Timeout in seconds for login.
return_markdownboolTrueWhether to return a Markdown-formatted string of the DataFrame.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
querystrThe SQL query to execute.
return_markdownOptional[bool]NoneWhether to return a Markdown-formatted string of the DataFrame. If not provided, uses the value set during initialization.