Skip to content

Commit fd8793a

Browse files
authored
buid: add pins for Snowflake + small refactoring (#1860)
1 parent 08dd4d8 commit fd8793a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

.github/workflows/snowflake.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ jobs:
6060
- name: Run tests
6161
run: hatch run cov-retry
6262

63+
- name: Run unit tests with lowest direct dependencies
64+
run: |
65+
hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt
66+
hatch run uv pip install -r requirements_lowest_direct.txt
67+
hatch run test -m "not integration"
68+
6369
- name: Nightly - run unit tests with Haystack main branch
6470
if: github.event_name == 'schedule'
6571
run: |
72+
hatch env prune
6673
hatch run uv pip install git+https://github.com/deepset-ai/haystack.git@main
6774
hatch run cov-retry -m "not integration"
6875

integrations/snowflake/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: Implementation :: CPython",
2525
"Programming Language :: Python :: Implementation :: PyPy",
2626
]
27-
dependencies = ["haystack-ai", "adbc_driver_snowflake>=1.4.0", "polars>=1.23.0", "pyarrow>=19.0.1", "pandas"]
27+
dependencies = ["haystack-ai", "adbc_driver_snowflake>=1.4.0", "polars[pandas,pyarrow]>=1.23.0"]
2828

2929
[project.urls]
3030
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/snowflake#readme"

integrations/snowflake/src/haystack_integrations/components/retrievers/snowflake/snowflake_table_retriever.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
# SPDX-License-Identifier: Apache-2.0
44
from typing import Any, Dict, Optional
55

6-
import pandas as pd
6+
import polars as pl
77
from haystack import component, default_from_dict, default_to_dict, logging
8-
from haystack.lazy_imports import LazyImport
98
from haystack.utils import Secret, deserialize_secrets_inplace
10-
11-
with LazyImport("Run 'pip install polars>=1.23.0'") as polars_import:
12-
import polars as pl
9+
from pandas import DataFrame
1310

1411
logger = logging.getLogger(__name__)
1512

@@ -151,15 +148,14 @@ def _snowflake_uri_constructor(self) -> str:
151148
return uri
152149

153150
@staticmethod
154-
def _polars_to_md(data: "pl.DataFrame") -> str:
151+
def _polars_to_md(data: pl.DataFrame) -> str:
155152
"""
156153
Converts a Polars DataFrame to a Markdown-formatted string.
157154
Uses Polars' built-in table formatting for efficient conversion.
158155
159156
:param data: The Polars DataFrame to convert.
160157
:returns: A Markdown-formatted string if `data` is not empty; otherwise, an empty string.
161158
"""
162-
polars_import.check() # Ensure polars is imported
163159
if data.is_empty():
164160
return "" # No markdown for empty DataFrame.
165161

@@ -184,9 +180,9 @@ def _empty_response() -> Dict[str, Any]:
184180
- `dataframe`: An empty Pandas DataFrame.
185181
- `table`: An empty Markdown string.
186182
"""
187-
return {"dataframe": pd.DataFrame(), "table": ""}
183+
return {"dataframe": DataFrame(), "table": ""}
188184

189-
@component.output_types(dataframe=pd.DataFrame, table=str)
185+
@component.output_types(dataframe=DataFrame, table=str)
190186
def run(self, query: str, return_markdown: Optional[bool] = None) -> Dict[str, Any]:
191187
"""
192188
Executes a SQL query against a Snowflake database using ADBC and Polars.

0 commit comments

Comments
 (0)