From bfd66c5b8185298fda99f12558e96667643fbc60 Mon Sep 17 00:00:00 2001 From: anon Date: Wed, 14 Oct 2026 16:50:13 +0200 Subject: [PATCH] feat(schema): add study abstract/metadata collection columns --- src/sddb/_catalog_schema.py | 7 +++++++ tests/_fixtures.py | 5 +++-- tests/test_catalog_schema.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/sddb/_catalog_schema.py b/src/sddb/_catalog_schema.py index 4cc00e4..a4e535c 100644 --- a/src/sddb/_catalog_schema.py +++ b/src/sddb/_catalog_schema.py @@ -99,6 +99,13 @@ "n_members_total": "Int64", "size_bytes": "Int64", "members": "list[string]", + "abstract": "string", + "abstract_license": "string", + "abstract_source": "string", + "study_title": "string", + "study_authors": "string", + "study_year": "string", + "study_journal": "string", } COLLECTION_REQUIRED: tuple[str, ...] = ("slug", "name", "members") diff --git a/tests/_fixtures.py b/tests/_fixtures.py index e620379..5c1ae88 100644 --- a/tests/_fixtures.py +++ b/tests/_fixtures.py @@ -89,9 +89,10 @@ def make_fixture_collections() -> pd.DataFrame: """Build a valid synthetic collections table (one row per collection).""" rows = [ ("c-smith", "Smith2023", "Smith 2023 atlas", "publication", "EpCAM atlas", - "10.1/smith", "DOI", "Xenium", "human", "lung", 2, 2, 180_000, ["uid0001", "uid0002"]), + "10.1/smith", "DOI", "Xenium", "human", "lung", 2, 2, 180_000, ["uid0001", "uid0002"], + *[None] * 7), # abstract/study_* columns are optional: null here ("c-lee", "Lee2022", "Lee 2022 brain", "replicates", None, None, None, - "Visium", "mouse", "brain", 1, 1, 4_000, ["uid0003"]), + "Visium", "mouse", "brain", 1, 1, 4_000, ["uid0003"], *[None] * 7), ] df = pd.DataFrame(rows, columns=list(COLLECTION_COLUMNS)) return cast_scalars(df, COLLECTION_COLUMNS) diff --git a/tests/test_catalog_schema.py b/tests/test_catalog_schema.py index e1d9807..10624ed 100644 --- a/tests/test_catalog_schema.py +++ b/tests/test_catalog_schema.py @@ -150,3 +150,17 @@ def test_new_producer_columns_validate_populated_and_null(tmp_path): p = tmp_path / "c.parquet" df.to_parquet(p) cs.validate(pd.read_parquet(p)) # round-trips + + +def test_collection_columns_include_study_fields(): + import sddb._catalog_schema as cs + + expected = { + "abstract", "abstract_license", "abstract_source", + "study_title", "study_authors", "study_year", "study_journal", + } + assert expected <= set(cs.COLLECTION_COLUMNS) + # all are nullable string columns + assert all(cs.COLLECTION_COLUMNS[c] == "string" for c in expected) + # not newly required + assert expected.isdisjoint(set(cs.COLLECTION_REQUIRED))