diff --git a/doc/whats-new.rst b/doc/whats-new.rst index ffc1dad6169..7543518c801 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -61,6 +61,8 @@ Bug fixes By `Tom White `_ and `Kai Mühlbauer `_. - Ensure dtype of reindex result matches dtype of the original DataArray (:issue:`7299`, :pull:`7917`) By `Anderson Banihirwe `_. +- Fix bug where a zero-length zarr ``chunk_store`` was ignored as if it was ``None`` (:pull:`7923`) + By `Juniper Tyree `_. Documentation ~~~~~~~~~~~~~ diff --git a/xarray/backends/zarr.py b/xarray/backends/zarr.py index 5c3d5781e35..5ff1cf5866e 100644 --- a/xarray/backends/zarr.py +++ b/xarray/backends/zarr.py @@ -417,7 +417,7 @@ def open_group( if consolidated is None: consolidated = False - if chunk_store: + if chunk_store is not None: open_kwargs["chunk_store"] = chunk_store if consolidated is None: consolidated = False diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index e0a2262a339..0450e769e7b 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -1849,6 +1849,8 @@ def test_with_chunkstore(self) -> None: with self.create_zarr_target() as store_target, self.create_zarr_target() as chunk_store: save_kwargs = {"chunk_store": chunk_store} self.save(expected, store_target, **save_kwargs) + # the chunk store must have been populated with some entries + assert len(chunk_store) > 0 open_kwargs = {"backend_kwargs": {"chunk_store": chunk_store}} with self.open(store_target, **open_kwargs) as ds: assert_equal(ds, expected)