Skip to content

Commit 18fe59d

Browse files
authored
fix: correct search interval vs item datetime interval (#1071)
resolves #1070 ### Description Description of the changes, including any "sidecar" changes that came along (e.g. small bugfixes you found along the way). ### Related issues - List any issues that this pull request closes or is related to - Delete this section if it is not applicable ### Checklist Delete any checklist items that do not apply (e.g. if your change is minor, it may not require documentation updates). - [ ] Unit tests - [ ] Documentation, including doctests - [ ] Pull request title follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) - [ ] Pre-commit hooks pass (`prek run --all-files`)
1 parent 829ecfb commit 18fe59d

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

52.5 KB
Binary file not shown.

crates/duckdb/src/client.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ impl Client {
363363
if let Some(start) = interval.0 {
364364
wheres.push(format!(
365365
"?::TIMESTAMPTZ <= {}",
366-
if has_start_datetime {
367-
"start_datetime"
366+
if has_end_datetime {
367+
"coalesce(end_datetime, datetime)"
368368
} else {
369369
"datetime"
370370
}
@@ -374,8 +374,8 @@ impl Client {
374374
if let Some(end) = interval.1 {
375375
wheres.push(format!(
376376
"?::TIMESTAMPTZ >= {}", // Inclusive, https://github.com/radiantearth/stac-spec/pull/1280
377-
if has_end_datetime {
378-
"end_datetime"
377+
if has_start_datetime {
378+
"coalesce(start_datetime, datetime)"
379379
} else {
380380
"datetime"
381381
}
@@ -855,6 +855,17 @@ mod tests {
855855
assert_eq!(item_collection.items.len(), 1);
856856
}
857857

858+
#[rstest]
859+
fn search_datetime_start_end_datetime(client: Client) {
860+
let item_collection = client
861+
.search(
862+
"data/sentinel-1-global-mosaics.parquet",
863+
Search::default().datetime("2026-04-15T00:00:00Z"),
864+
)
865+
.unwrap();
866+
assert_eq!(item_collection.items.len(), 1);
867+
}
868+
858869
#[rstest]
859870
fn search_limit(client: Client) {
860871
let item_collection = client

0 commit comments

Comments
 (0)