fix: projection dropping a cftime coord crashes batch reading#230
Open
ghostiee-11 wants to merge 1 commit into
Open
fix: projection dropping a cftime coord crashes batch reading#230ghostiee-11 wants to merge 1 commit into
ghostiee-11 wants to merge 1 commit into
Conversation
iter_record_batches preloaded every dim's coord values and called schema.field(name) for cftime coords, but a projection (e.g. GROUP BY on a non-time dim) drops columns from the batch schema, so the lookup raised KeyError. Skip dims absent from the projected schema; they are never read in the batch loop, which iterates only the schema's fields.
ghostiee-11
force-pushed
the
fix/cftime-projection-drops-dim
branch
from
July 23, 2026 19:31
61b1d74 to
03d0c75
Compare
Contributor
Author
|
@alxmrs, Can you please review this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A projection that drops a cftime dimension coordinate (for example
GROUP BYon a non-time dim, which removestimefrom the scan) crashed withKeyError: 'Column time does not exist in schema'during batch reading.iter_record_batchespreloaded every dimension's coord values and calledschema.field(name)for cftime coords, but the projected batch schema no longer contains the dropped dim. datetime64 coords skip that branch, so only cftime datasets broke.The dropped dim is never read in the batch loop (it iterates only the schema's fields), so this skips preloading any dim absent from the projected schema.
Verified across all calendars (Gregorian/NoLeap mapped to timestamp, 360-day/Julian mapped to int64) and every projected dimension. The regression test in
test_df.pyfails without the fix (KeyError) and passes with it.