Skip to content

Commit

Permalink
Handle dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Nov 8, 2023
1 parent 9f39f98 commit ecb7d57
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
2 changes: 2 additions & 0 deletions py-polars/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ filterwarnings = [
# Ignore warnings issued by dependency internals
"ignore:.*is_sparse is deprecated.*:FutureWarning",
"ignore:FigureCanvasAgg is non-interactive:UserWarning",
"ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated.*:DeprecationWarning",
"ignore:datetime.datetime.utcnow\\(\\) is deprecated.*:DeprecationWarning",
]
xfail_strict = true

Expand Down
7 changes: 6 additions & 1 deletion py-polars/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ tzdata; platform_system == 'Windows'
# Database
SQLAlchemy
adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows'
connectorx
# TODO: Remove version constraint for connectorx when Python 3.12 is supported:
# https://github.com/sfu-db/connector-x/issues/527
connectorx; python_version <= '3.11'
# Cloud
cloudpickle
fsspec
s3fs[boto3]
# TODO: Unpin and remove aiohttp here when 3.9.0 is released:
# https://github.com/aio-libs/aiohttp/issues/7739
aiohttp==3.9.0b1
# Spreadsheet
ezodf
lxml
Expand Down
14 changes: 14 additions & 0 deletions py-polars/tests/unit/io/test_database_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ def adbc_sqlite_connect(*args: Any, **kwargs: Any) -> Any:
def create_temp_sqlite_db(test_db: str) -> None:
Path(test_db).unlink(missing_ok=True)

def convert_date(val):
"""Convert ISO 8601 date to datetime.date object."""
return date.fromisoformat(val.decode())

sqlite3.register_converter("date", convert_date)

# NOTE: at the time of writing adcb/connectorx have weak SQLite support (poor or
# no bool/date/datetime dtypes, for example) and there is a bug in connectorx that
# causes float rounding < py 3.11, hence we are only testing/storing simple values
Expand Down Expand Up @@ -183,6 +189,10 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any: # noqa: D102
schema_overrides={"id": pl.UInt8},
),
id="uri: connectorx",
marks=pytest.mark.skipif(
sys.version_info > (3, 11),
reason="connectorx cannot be installed on Python 3.12 yet.",
),
),
pytest.param(
*DatabaseReadTestParams(
Expand Down Expand Up @@ -584,6 +594,10 @@ def test_read_database_exceptions(
read_database(**params)


@pytest.mark.skipif(
sys.version_info > (3, 11),
reason="connectorx cannot be installed on Python 3.12 yet.",
)
@pytest.mark.parametrize(
"uri",
[
Expand Down
32 changes: 23 additions & 9 deletions py-polars/tests/unit/io/test_database_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ def adbc_sqlite_driver_version(*args: Any, **kwargs: Any) -> str:
return "n/a"


@pytest.mark.write_disk()
@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"])
@pytest.mark.skipif(
sys.version_info > (3, 11),
reason="connectorx cannot be installed on Python 3.12 yet.",
)
@pytest.mark.skipif(
sys.version_info < (3, 9) or sys.platform == "win32",
reason="adbc_driver_sqlite not available below Python 3.9 / on Windows",
)
@pytest.mark.write_disk()
@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"])
def test_write_database_create(engine: DbWriteEngine, tmp_path: Path) -> None:
df = pl.DataFrame(
{
Expand All @@ -51,12 +55,16 @@ def test_write_database_create(engine: DbWriteEngine, tmp_path: Path) -> None:
assert_frame_equal(result, df)


@pytest.mark.write_disk()
@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"])
@pytest.mark.skipif(
sys.version_info > (3, 11),
reason="connectorx cannot be installed on Python 3.12 yet.",
)
@pytest.mark.skipif(
sys.version_info < (3, 9) or sys.platform == "win32",
reason="adbc_driver_sqlite not available below Python 3.9 / on Windows",
)
@pytest.mark.write_disk()
@pytest.mark.parametrize("engine", ["adbc", "sqlalchemy"])
def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None:
df = pl.DataFrame(
{
Expand Down Expand Up @@ -96,6 +104,10 @@ def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None:
assert_frame_equal(result, pl.concat([df, df]))


@pytest.mark.skipif(
sys.version_info < (3, 9) or sys.platform == "win32",
reason="adbc_driver_sqlite not available below Python 3.9 / on Windows",
)
@pytest.mark.write_disk()
@pytest.mark.parametrize(
"engine",
Expand All @@ -106,13 +118,15 @@ def test_write_database_append(engine: DbWriteEngine, tmp_path: Path) -> None:
reason="ADBC SQLite driver has a bug with quoted/qualified table names",
),
),
"sqlalchemy",
pytest.param(
"sqlalchemy",
marks=pytest.mark.skipif(
sys.version_info > (3, 11),
reason="connectorx cannot be installed on Python 3.12 yet.",
),
),
],
)
@pytest.mark.skipif(
sys.version_info < (3, 9) or sys.platform == "win32",
reason="adbc_driver_sqlite not available below Python 3.9 / on Windows",
)
def test_write_database_create_quoted_tablename(
engine: DbWriteEngine, tmp_path: Path
) -> None:
Expand Down

0 comments on commit ecb7d57

Please sign in to comment.