Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ zarrs_object_store = "0.5.0"
zarrs_storage = { version = "0.4.0", features = ["async"] }

[dev-dependencies]
chrono = "0.4.44"
geo = "0.31"
geoarrow-array = "0.7.0"
tempfile = "3"
tokio = { version = "1.48", features = ["macros", "rt-multi-thread"] }
wkb = "0.9"
Binary file removed data/icechunk/manifests/KC53SCXBBZQR3HR12Z7G
Binary file not shown.
Binary file removed data/icechunk/manifests/M0HCK3P6N722F5WSDJZG
Binary file not shown.
Binary file removed data/icechunk/manifests/S9CF7DYNZ4GHPJ1JNTSG
Binary file not shown.
1 change: 0 additions & 1 deletion data/icechunk/refs/branch.main/ref.json

This file was deleted.

Binary file removed data/icechunk/snapshots/1CECHNKREP0F1RSTCMT0
Binary file not shown.
Binary file removed data/icechunk/snapshots/ZKWW9E6BW6YFNNDKESR0
Binary file not shown.
Binary file removed data/icechunk/transactions/ZKWW9E6BW6YFNNDKESR0
Binary file not shown.
Binary file removed data/zarr_store.zarr/meta/bbox/c/0
Binary file not shown.
38 changes: 0 additions & 38 deletions data/zarr_store.zarr/meta/bbox/zarr.json

This file was deleted.

Binary file removed data/zarr_store.zarr/meta/collection/c/0
Binary file not shown.
38 changes: 0 additions & 38 deletions data/zarr_store.zarr/meta/collection/zarr.json

This file was deleted.

Binary file removed data/zarr_store.zarr/meta/date/c/0
Binary file not shown.
46 changes: 0 additions & 46 deletions data/zarr_store.zarr/meta/date/zarr.json

This file was deleted.

5 changes: 0 additions & 5 deletions data/zarr_store.zarr/meta/zarr.json

This file was deleted.

5 changes: 0 additions & 5 deletions data/zarr_store.zarr/zarr.json

This file was deleted.

21 changes: 21 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ dev-dependencies = [
"pytest",
"shapely",
]


[tool.ruff]
line-length = 88
target-version = "py311"

[tool.ruff.lint]
select = ["E", "F", "I"]
per-file-ignores = {}

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.pytest.ini_options]
# Directories to search for tests
testpaths = [
"tests",
]
3 changes: 1 addition & 2 deletions python/python/zarr_datafusion_search/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from ._rust import ZarrTable
from ._rust import ___version
from ._rust import ZarrTable, ___version

__version__: str = ___version()

Expand Down
51 changes: 51 additions & 0 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Pytest fixtures for zarr-datafusion tests."""
import pytest

from .fixtures import create_test_icechunk_data, create_test_zarr_data


@pytest.fixture
def zarr_store(tmp_path):
"""Create a temporary zarr store with test data.

Yields the path to the zarr store, which is automatically cleaned up after the test.
"""
store_path = tmp_path / "zarr_store.zarr"
create_test_zarr_data(store_path)
yield store_path


@pytest.fixture
def icechunk_store(tmp_path):
"""Create a temporary icechunk store with test data.

Yields the path to the icechunk store, which is automatically cleaned up
after the test.
"""
store_path = tmp_path / "icechunk"
create_test_icechunk_data(store_path)
yield store_path


@pytest.fixture(scope="session")
def session_zarr_store(tmp_path_factory):
"""Create a session-scoped zarr store with test data.

This fixture is created once per test session and shared across all tests.
Useful for read-only tests that don't modify the data.
"""
store_path = tmp_path_factory.mktemp("data") / "zarr_store.zarr"
create_test_zarr_data(store_path)
yield store_path


@pytest.fixture(scope="session")
def session_icechunk_store(tmp_path_factory):
"""Create a session-scoped icechunk store with test data.

This fixture is created once per test session and shared across all tests.
Useful for read-only tests that don't modify the data.
"""
store_path = tmp_path_factory.mktemp("data") / "icechunk"
create_test_icechunk_data(store_path)
yield store_path
89 changes: 89 additions & 0 deletions python/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from pathlib import Path

import icechunk
import numpy as np
import shapely
import zarr
from zarr.core.group import Group
from zarr.dtype import VariableLengthBytes, VariableLengthUTF8


def generate_test_data(root: Group) -> None:
"""Create test zarr data

Adds to a zarr store:
- a /meta group which contains
- date: datetime64[ms] array with dates [2023-01-01, 2023-01-02,
2023-01-03]
- collection: variable length UTF8 array with ["collection_a",
"collection_b", "collection_c"]
- bbox: variable length bytes (WKB) array with boxes at (-10,-10,10,10),
(-20,-20,20,20), (-30,-30,30,30)

Args:
root: The root Group in the target Zarr or Icechunk store.
"""
meta = root.create_group("meta")

# Create date array
date_data = np.array(
["2023-01-01", "2023-01-02", "2023-01-03"], dtype="datetime64[ms]"
)
meta.create_array("date", data=date_data)

# Create collection array
collection_data = ["collection_a", "collection_b", "collection_c"]
collection_array = meta.create_array(
"collection",
shape=(len(collection_data),),
dtype=VariableLengthUTF8(),
)
collection_array[:] = collection_data

# Create bbox array with WKB-encoded geometries
bbox_data = shapely.to_wkb(
[
shapely.box(-10.0, -10.0, 10.0, 10.0),
shapely.box(-20.0, -20.0, 20.0, 20.0),
shapely.box(-30.0, -30.0, 30.0, 30.0),
]
)

bbox_array = meta.create_array(
"bbox",
shape=(len(bbox_data),),
dtype=VariableLengthBytes(),
)
bbox_array[:] = bbox_data


def create_test_zarr_data(store_path: Path | str) -> None:
"""Create test store data at the specified path.

Args:
store_path: Path where the Zarr store will be created. Can be string
or Path object.

"""
store_path = Path(store_path) if isinstance(store_path, str) else store_path
root = zarr.open_group(store_path, mode="w", zarr_format=3)
generate_test_data(root=root)


def create_test_icechunk_data(store_path: Path | str) -> None:
"""Create test icechunk store at the specified path.

Args:
store_path: Path where the Icechunk repository will be created.
Can be string or Path object.

"""
store_path = Path(store_path) if isinstance(store_path, str) else store_path

storage = icechunk.local_filesystem_storage(str(store_path))
repo = icechunk.Repository.create(storage)
session = repo.writable_session("main")

root = zarr.open_group(session.store, mode="w", zarr_format=3)
generate_test_data(root=root)
session.commit("Initial test data")
Loading
Loading