Skip to content

Raise when to_zarr(append_dim=...) would mislabel data - #11505

Open
ghostiee-11 wants to merge 3 commits into
pydata:mainfrom
ghostiee-11:fix-11101-zarr-append-coord-alignment
Open

Raise when to_zarr(append_dim=...) would mislabel data#11505
ghostiee-11 wants to merge 3 commits into
pydata:mainfrom
ghostiee-11:fix-11101-zarr-append-coord-alignment

Conversation

@ghostiee-11

@ghostiee-11 ghostiee-11 commented Aug 10, 2026

Copy link
Copy Markdown

Description

to_zarr(append_dim=...) writes the new block in the incoming order without aligning it to the store, so a mismatched coordinate silently mislabels data: mode="a" relabels what's already there, mode="a-" mislabels what's appended. Now raises before writing.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR. Tools: Claude

to_zarr writes the appended block in the order given by the dataset being
written and never aligns it to the store. When a coordinate that does not
have append_dim among its dimensions disagrees with the store, data is
silently mislabelled: mode="a" overwrites the coordinate and relabels the
data already written, while mode="a-" keeps the store's coordinate and
mislabels the block being appended.

Compare such coordinates against the store before writing anything and
raise if they differ. Values are compared as encoded, so a lossy or
value-changing encoding does not raise spuriously. Data variables are
unaffected and keep the documented mode="a"/mode="a-" behaviour.

Fixes pydata#11101
@github-actions github-actions Bot added topic-backends topic-zarr Related to zarr storage library io labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

io topic-backends topic-zarr Related to zarr storage library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Appending to Zarr store on disk changes dimension metadata

1 participant