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
- Drag the
SnowflakeTableRetrievercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set your Snowflake
user,account, andapi_key(password). Store the password as a secret calledSNOWFLAKE_API_KEY. For instructions, see Add Secrets. - Set the
database,db_schema, andwarehousefor your Snowflake connection.
- Set your Snowflake
- Go to the Advanced tab to configure
login_timeoutandreturn_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
| Parameter | Type | Description |
|---|---|---|
query | str | The SQL query to execute. |
return_markdown | Optional[bool] | Whether to return a Markdown-formatted string of the DataFrame. If not provided, uses the value set during initialization. |
Outputs
| Parameter | Type | Description |
|---|---|---|
dataframe | DataFrame | A Pandas DataFrame with the query results. |
table | str | 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. |
Related Information
Was this page helpful?