Skip to content

Commit

Permalink
test(datasets): implement save and reload for Ibis
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman committed Mar 4, 2024
1 parent 175f3e9 commit c76fd22
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kedro-datasets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ test = [
"geopandas>=0.6.0, <1.0",
"hdfs>=2.5.8, <3.0",
"holoviews>=1.13.0",
"ibis-framework",
"ibis-framework[duckdb,examples]",
"import-linter[toml]==1.2.6",
"ipython>=7.31.1, <8.0",
"Jinja2<3.1.0",
Expand Down
Empty file.
37 changes: 37 additions & 0 deletions kedro-datasets/tests/ibis/test_table_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import ibis
import pytest
from pandas.testing import assert_frame_equal

from kedro_datasets.ibis import TableDataset


@pytest.fixture(scope="session")
def filepath_csv(tmp_path_factory):
path = (tmp_path_factory.mktemp("data") / "penguins.csv").as_posix()
ibis.examples.penguins.fetch().to_csv(path)
return path


@pytest.fixture
def connection_config(tmp_path):
return {"backend": "duckdb", "database": (tmp_path / "penguins.ddb").as_posix()}


@pytest.fixture
def table_dataset(connection_config):
return TableDataset(table_name="penguins", connection=connection_config)


@pytest.fixture
def dummy_table(filepath_csv, connection_config):
return TableDataset(
filepath=filepath_csv, file_format="csv", connection=connection_config
).load()


class TestTableDataset:
def test_save_and_load(self, table_dataset, dummy_table):
"""Test saving and reloading the data set."""
table_dataset.save(dummy_table)
reloaded = table_dataset.load()
assert_frame_equal(dummy_table.execute(), reloaded.execute())

0 comments on commit c76fd22

Please sign in to comment.