Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
- uses: astral-sh/setup-uv@v3
- uses: Swatinem/rust-cache@v2
- name: Sync
run: uv sync
run: uv sync --no-install-project
- name: Build directly with maturin
run: uv run maturin dev --uv
- name: Lint
run: scripts/lint
- name: Test
Expand Down
92 changes: 36 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ default = ["duckdb-bundled"]
duckdb-bundled = ["duckdb/bundled"]

[dependencies]
duckdb = { version = "1.1.1" }
duckdb = { version = "=1.1.1" }
libduckdb-sys = { version = "=1.1.1" }
geojson = "0.24.1"
pyo3 = { version = "0.23.4", features = ["abi3-py310"] }
pyo3-async-runtimes = { version = "0.23.0", features = [
Expand Down
11 changes: 8 additions & 3 deletions src/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pyo3::{
types::{PyDict, PyList},
};
use stac_api::python::{StringOrDict, StringOrList};
use stac_duckdb::Client;
use stac_duckdb::{Client, Config};
use std::sync::Mutex;

#[pyclass(frozen)]
Expand All @@ -14,8 +14,13 @@ pub struct DuckdbClient(Mutex<Client>);
#[pymethods]
impl DuckdbClient {
#[new]
fn new() -> Result<DuckdbClient> {
let client = Client::new()?;
#[pyo3(signature = (use_s3_credential_chain=true, use_hive_partitioning=false))]
fn new(use_s3_credential_chain: bool, use_hive_partitioning: bool) -> Result<DuckdbClient> {
let config = Config {
use_s3_credential_chain,
use_hive_partitioning,
};
let client = Client::with_config(config)?;
Ok(DuckdbClient(Mutex::new(client)))
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod write;

use ::duckdb as _;
use error::Error;
use libduckdb_sys as _;
use pyo3::prelude::*;

type Result<T> = std::result::Result<T, Error>;
Expand Down
12 changes: 12 additions & 0 deletions stacrs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ from typing import Any, Optional, Tuple
class DuckdbClient:
"""A client for querying stac-geoparquet with DuckDB."""

def __init__(
self, use_s3_credential_chain: bool = True, use_hive_partitioning: bool = False
) -> None:
"""Creates a new duckdb client.

Args:
use_s3_credential_chain: If true, configures DuckDB to correctly
handle s3:// urls.
use_hive_partitioning: If true, enables queries on hive partitioned
geoparquet files.
"""

def search(
self,
href: str,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ def test_search_offset(client: DuckdbClient) -> None:
def test_get_collections(client: DuckdbClient) -> None:
collections = client.get_collections("data/100-sentinel-2-items.parquet")
assert len(collections) == 1


def test_init_with_config() -> None:
DuckdbClient(use_s3_credential_chain=True, use_hive_partitioning=True)