Skip to content

fix: read items in the last second of each time step - #97

Merged
hrodmn merged 1 commit into
developmentseed:mainfrom
earlybard:fix/whole-period-datetime-filters
Nov 18, 2026
Merged

hrodmn merged 1 commit into
developmentseed:mainfrom
earlybard:fix/whole-period-datetime-filters

Conversation

@earlybard

Copy link
Copy Markdown
Contributor

Daily steps pass rustac a bare YYYY-MM-DD as the datetime filter, and rustac ends a bare date at 23:59:59. Weekly, monthly, yearly and PnD steps end the same way, and PTnH steps end on the second before the next bucket. So an item timestamped in the last second of its step, e.g. 23:59:59.5, matches no step's filter and is never read, with no error.

This makes every bucketed filter a closed range ending a microsecond before the next bucket, e.g. 2023-01-15T00:00:00Z/2023-01-15T23:59:59.999999Z. DuckDB stores timestamps to the microsecond, so steps still don't overlap. Exact grouping (time_period=None) is unchanged.

To reproduce, write one item at 2023-12-31T23:59:59.5Z and search with each grouper's filter:

step = grouper_from_period("P1D").time_step("2023-12-31")
rustac.DuckdbClient().search("items.parquet", datetime=step.datetime_filter)
# before: []   after: [the item]

The new test does this for P1D, P1W, P1M, P1Y, PnD and PT1H. The tests that pinned the old filter strings now pin the new ones.

The flexible temporal grouping spec chose second precision for PTnH and accepted that fractional-second items could be missed. Sentinel-2 and Landsat times do have fractional seconds, though, and the daily case wasn't covered there, so this moves every period to microseconds. I've left the spec as written, as a record of the original decision.

We found this while checking an in-memory index of lazycogs' item searches against DuckDB, for Geoscience Australia's ARD.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the fix label Oct 28, 2026
Daily steps passed rustac a bare date, which it ends at 23:59:59, and hourly
steps ended on the second before the next. An item at 23:59:59.5 was in no
time step, so it was never read. Every bucketed filter is now a closed range
ending a microsecond before the next bucket, DuckDB's timestamp precision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hrodmn
hrodmn force-pushed the fix/whole-period-datetime-filters branch from 1dd6326 to cfe3f7f Compare November 18, 2026 02:25

@hrodmn hrodmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another helpful fix - thanks @earlybard !

@hrodmn
hrodmn merged commit 468831d into developmentseed:main Nov 18, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants