﻿# Kedro PartitionedDataset: a cached partition list is not a materialized copy of every partition

Use Kedro partition loaders with explicit membership and read-time semantics, separating a cached mapping of partition IDs from the bytes loaded when each callable runs.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-kedro-partitioned-dataset-loader-membership-cache/
Language: en

## Inspect what the node actually receives

A node receives a partitioned dataset and counts the dictionary entries, then assumes all source files are already loaded in memory. The [partition concepts guide](https://docs.kedro.org/en/stable/catalog-data/partitioned_and_incremental_datasets/) describes a mapping from partition IDs to load functions. An entry represents a deferred read opportunity rather than the partition's materialized dataframe. Inspect the value type before estimating memory use, passing it to model preprocessing or treating the dictionary as a complete in-memory snapshot of the source collection.

## Separate discovered membership from content reads

The documented load cache preserves the partition dictionary across consumers until it is released. Newly added files do not automatically appear in that cached mapping. Meanwhile each loader refers to an underlying dataset read. A stable list of identifiers is not itself a byte-preserving snapshot of mutable files. If a source file changes between discovery and invocation, examine the storage and dataset semantics rather than assuming membership consistency also established immutable content for every future read.

## Select partitions before materializing them

The [PartitionedDataset API](https://docs.kedro.org/projects/kedro-datasets/en/kedro-datasets-9.6.0/api/kedro_datasets/partitions.PartitionedDataset/) defines deferred loading through the configured underlying dataset. A consuming node can deliberately choose the partitions it needs before invoking their loaders. Preserve which identifiers were selected and how that selection relates to the evaluation population. Counting all available keys while evaluating only a subset should not produce a claim that the model was assessed on the entire discovered dataset.

## Treat release as a change to discovery state

The [partition usage guide](https://docs.kedro.org/en/stable/catalog-data/how_to_use_partitioned_and_incremental_datasets/) explains partition workflows and cache handling. Releasing the dataset permits a later load to discover a changed population. That can be useful in a long interactive session, but it should be a visible boundary if consumers are expected to share one membership view. Avoid refreshing between related evaluation steps accidentally, then interpreting differing sample counts as model behavior rather than a change in the selected source population.

## Test additions and replacements separately

Use a small collection, retain the loader mapping, add another partition and replace an existing file in a controlled fixture. Inspect membership before and after release and inspect content when the chosen loader is invoked. Related guides cover [stream snapshot sampling](/journal/data-guide-reservoir-sampling-stream-snapshot/) and [dataset sample identities](/journal/data-guide-coco-instance-caption-identities/). The test distinguishes discovery, selection and materialization. A reproducible evaluation needs the intended contract for all of them, not only a stable count of dictionary entries.
