SnowflakeTableRetriever
Connects to a Snowflake database and executes SQL queries, returning results as a Pandas DataFrame and optional Markdown table.
Key Features
- Executes SQL queries against Snowflake using ADBC and Polars for fast data transfer.
- Returns results as a Pandas DataFrame (converted from Polars).
- Optional Markdown-formatted string output for easy display in pipelines.
- Configurable database, schema, warehouse, and role for flexible query targeting.
- Configurable login timeout for handling slow network connections.
Configuration
You need Snowflake credentials to use this component. Store the Snowflake password as a secret called SNOWFLAKE_API_KEY in your workspace. For more information, see Add Secrets.
- Drag the
SnowflakeTableRetrievercomponent onto the canvas from the Component Library. - Click the component to open the configuration panel.
- On the General tab:
- Enter your Snowflake username.
- Enter your Snowflake account identifier.
- Go to the Advanced tab to configure the API key, database, schema, warehouse, login timeout, and other options.
Connections
SnowflakeTableRetriever accepts a SQL query string as input. It outputs a Pandas DataFrame (dataframe) and a Markdown table string (table).
Connect a PromptBuilder or Input component to its query input. Connect its table output to a generator or answer builder for presenting query results.
Usage Example
components:
SnowflakeTableRetriever:
type: snowflake.src.haystack_integrations.components.retrievers.snowflake.snowflake_table_retriever.SnowflakeTableRetriever
init_parameters:
Parameters
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | The SQL query to execute. | |
| return_markdown | Optional[bool] | None | Whether to return a Markdown-formatted string of the DataFrame. If not provided, uses the value set during initialization. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| dataframe | DataFrame | A dictionary containing: - "dataframe": A Pandas DataFrame with the query results. - "table": A Markdown-formatted string representation of the DataFrame. | |
| table | str | A dictionary containing: - "dataframe": A Pandas DataFrame with the query results. - "table": A Markdown-formatted string representation of the DataFrame. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| user | str | User's login. | |
| account | str | Snowflake account identifier. | |
| api_key | Secret | Secret.from_env_var('SNOWFLAKE_API_KEY') | Snowflake account password. |
| database | Optional[str] | None | Name of the database to use. |
| db_schema | Optional[str] | None | Name of the schema to use. |
| warehouse | Optional[str] | None | Name of the warehouse to use. |
| login_timeout | Optional[int] | 60 | Timeout in seconds for login. |
| return_markdown | bool | True | Whether 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | The SQL query to execute. | |
| return_markdown | Optional[bool] | None | Whether to return a Markdown-formatted string of the DataFrame. If not provided, uses the value set during initialization. |
Was this page helpful?