You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "james-willis (via GitHub)" <gi...@apache.org> on 2026/05/29 06:47:41 UTC
[PR] feat(sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
james-willis opened a new pull request, #888:
URL: https://github.com/apache/sedona-db/pull/888
## Summary
Adds cloud storage backends to `sedona-raster-zarr`. `ZarrChunkReader` now accepts `file://`, bare paths, `s3://`, `gs://` / `gcs://`, `az://` / `abfs://` / `abfss://`, and `http://` / `https://`. The local filesystem path is unchanged (direct `FilesystemStore`); every cloud scheme routes through `object_store` + `zarrs_object_store::AsyncObjectStore`, bridged into zarrs's sync API by an `AsyncToSyncStorageAdapter` running on a dedicated multi-thread tokio runtime that's intentionally separate from any host DataFusion executor.
```python
import sedonadb
import sedonadb_zarr
con = sedonadb.connect()
con.read_format(
sedonadb_zarr.ZarrFormatSpec(),
"s3://its-live-data/datacubes/v2/N40W120/ITS_LIVE_vel_EPSG32610_G0120_X250000_Y5450000.zarr",
).show()
```
## What's in this PR
**`parse_zarr_uri(uri, runtime_env)` resolver in `source_uri.rs`.** Single entry point for every supported scheme. Cloud schemes consult `runtime_env.object_store_registry.get_store(scheme://host)` first so a `SedonaContext` that already registered a credentialed store wins; if nothing is registered, fall back to per-scheme `*Builder::from_env().with_url(uri).build()`. `PrefixStore` pins the bucket-relative group path for s3 / gs / az; `http(s)://` uses the full URL as the store root with no extra prefix. `file://` and bare paths skip the bridge entirely and stay on the sync `FilesystemStore`.
**Dedicated tokio runtime in `runtime.rs`.** `OnceLock`-initialised multi-thread runtime, default 4 worker threads, overridable via `SEDONA_ZARR_RUNTIME_THREADS`. It exists to satisfy `Handle::block_on`'s "must not be the runtime you're inside" rule when a future caller wraps the loader in `spawn_blocking` from a DataFusion executor; today's call sites (test code, the `PyZarrChunkReader` FFI) drive it directly.
**Fault-tolerant child enumeration.** Replaces `Group::child_arrays()` (which opens every child up front and errors hard on any per-array metadata failure) with two purpose-built paths driven by the caller's `arrays` filter:
- `arrays: Some([...])` — open each named array directly via `Array::open`. No directory listing, so this path stays viable against backends that can't list (plain HTTPS without WebDAV, S3-via-HttpStore).
- `arrays: None` — list direct children via `storage.list_dir` and `Array::open` each. Per-array open failures are logged at `warn!` and skipped, so a single malformed sibling (e.g. an xarray-style fixed-length-Unicode coord variable with a null `fill_value` that zarrs 0.23 can't open) no longer poisons the rest of the group.
**Real-bucket smoke coverage.** New `#[ignore]`-gated tests in `tests/cloud.rs` against the public anonymous ITS_LIVE v2 ice-velocity datacubes (NASA MEaSUREs, `s3://its-live-data/...`, `us-west-2`). Both smokes target the same bucket via the same key — one through `AmazonS3Builder`, one through `HttpStore` — and assert that at least one raster row streams through end-to-end.
```bash
AWS_SKIP_SIGNATURE=true AWS_REGION=us-west-2 \
cargo test -p sedona-raster-zarr --test cloud -- --ignored --nocapture
```
`PyZarrChunkReader` builds its own `Arc::new(RuntimeEnvBuilder::new().build()?)` at construction time since the Python FFI path has no `SessionContext` to inherit from. Cloud-backed stores fall back to env-var credential discovery in that case; callers that need a pre-registered store should go through the `SedonaContext` path once the table function lands.
## Version pinning
`zarrs_object_store` is pinned to `0.5` in the workspace. `0.6` (the latest) depends on `object_store 0.13`, which is semver-incompatible with the `object_store 0.12.x` the rest of the workspace uses through DataFusion 52. Bumping the whole workspace to `object_store 0.13` is a separate exercise; the 0.5 pin keeps the dependency graph coherent today.
## Known limitation worth flagging
The loader's default spatial-dim policy still requires the last two dimension names to be exactly `["y", "x"]` unless the group declares an explicit `spatial:dims` attribute. That excludes most CF-style cloud Zarrs (`lat`/`lon`, `latitude`/`longitude`) — verified against MUR-SST and the carbonplan USGS DEM, both of which reach the loader cleanly but trip the policy. Tracked as a follow-up; expanding the default canonical pairs is a small, mechanical change.
## Out of scope (separate follow-ups)
- **Expanding the default spatial-dim pairs** to also accept `(lat, lon)` and `(latitude, longitude)`. Tracked.
- **DataFusion table function (`sd_read_zarr`) wiring** of `Arc<RuntimeEnv>` through `SedonaContext` to a future `ZarrReadFunction::new(Arc<RuntimeEnv>)`. Today the runtime_env flows through `try_new` directly.
- **Per-call JSON credential overrides** on a future UDTF JSON-options surface (`aws.region`, `aws.access_key_id`, ...).
- **Dropping `zarrs_filesystem`** for the local path in favour of `object_store::local::LocalFileSystem` behind the same async bridge. The direct sync `FilesystemStore` is strictly faster for `file://` and bare paths today.
- **GCS public-bucket smoke**. No public anonymous GCS Zarr identified that passes the current dim-name policy. The scheme is wired and reachable; testing waits on either a working public target or the dim-name expansion above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on code in PR #888:
URL: https://github.com/apache/sedona-db/pull/888#discussion_r3350754300
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -70,6 +90,88 @@ impl PyZarrChunkReader {
}
}
+/// Build an `Arc<dyn ObjectStore>` for `uri` using env-var credential
+/// discovery, per scheme. This is the temporary bridge that lets the
+/// Python FFI work without going through `con.read_format`; it
+/// reaches into `AWS_*` / `GOOGLE_*` / `AZURE_*` environment
+/// variables via the `object_store` per-backend `Builder::from_env`
+/// helpers.
+///
+/// **Slated for removal.** When the host wheel surfaces
+/// `args.src.store` to `open_reader` via the `FFI_ObjectStore`
+/// capsule machinery (in progress — see
+/// <https://github.com/apache/sedona-db/pull/890>), this function (and
+/// the `object_store` `aws`/`gcp`/`azure`/`http` features that back it)
+/// gets deleted — the store will arrive credentialed from the host's
+/// `ObjectStoreRegistry` and `PyZarrChunkReader::new` will extract it
+/// from the capsule instead. For `file://` and bare paths the
+/// returned store is a no-op placeholder; the loader uses
+/// `FilesystemStore` directly for the local case.
+fn default_object_store_for_uri(uri: &str) -> Result<Arc<dyn ObjectStore>, PyErr> {
+ // file:// and bare paths use a LocalFileSystem rooted at `/`;
+ // open_storage_from_uri prefixes it at the group's path. This
+ // matches the store the host's ObjectStoreRegistry yields for
+ // file://, so the loader treats local and cloud uniformly.
+ if uri.starts_with("file://") || !uri.contains("://") {
+ return Ok(Arc::new(object_store::local::LocalFileSystem::new()));
+ }
+ let url = Url::parse(uri)
+ .map_err(|e| PyValueError::new_err(format!("group URI {uri:?} is not a valid URL: {e}")))?;
+ match url.scheme().to_ascii_lowercase().as_str() {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
Posted by "james-willis (via GitHub)" <gi...@apache.org>.
james-willis commented on code in PR #888:
URL: https://github.com/apache/sedona-db/pull/888#discussion_r3342879802
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -39,7 +42,24 @@ impl PyZarrChunkReader {
#[new]
#[pyo3(signature = (uri, arrays=None, batch_size=8192))]
fn new(uri: &str, arrays: Option<Vec<String>>, batch_size: usize) -> PyResult<Self> {
- let reader = ZarrChunkReader::try_new(uri, arrays.as_deref(), batch_size)
+ let store =
+ default_object_store_for_uri(uri).map_err(|e| PyValueError::new_err(e.to_string()))?;
+ let storage =
+ open_storage_from_uri(uri, store).map_err(|e| PyValueError::new_err(e.to_string()))?;
+ // The crate's async-native loader exposes `try_new` as an
+ // `async fn`; the Python FFI is a sync constructor by
+ // contract, so we bridge with an ad-hoc current-thread tokio
+ // runtime here. `next()` on the returned reader is pure CPU
+ // and stays synchronous.
Review Comment:
done
##########
rust/sedona-raster-zarr/tests/cloud.rs:
##########
@@ -0,0 +1,127 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Cloud-backed smoke tests for `ZarrChunkReader`.
+//!
+//! These tests reach the network and are `#[ignore]` by default. Both
+//! target the public, anonymous ITS_LIVE v2 ice-velocity datacubes
+//! (NASA MEaSUREs), hosted at `s3://its-live-data/` in `us-west-2`. The
+//! dataset is a Zarr v2 group whose data arrays declare
+//! `dimension_names = ['mid_date', 'y', 'x']` — passing the loader's
+//! default spatial-dim policy — and whose coordinate variables include
+//! a few short fixed-length Unicode (`<U…`) arrays with null
+//! fill_values that current zarrs (0.23) can't open. The loader's
+//! list-then-open-each path tolerates those per-array failures, so a
+//! valid raster row still streams out.
+//!
+//! Run with:
+//!
+//! ```bash
+//! AWS_SKIP_SIGNATURE=true AWS_REGION=us-west-2 \
+//! cargo test -p sedona-raster-zarr --test cloud -- --ignored --nocapture
+//! ```
+
+use std::sync::Arc;
+
+use object_store::aws::AmazonS3Builder;
+use object_store::http::HttpBuilder;
+use object_store::ObjectStore;
+use sedona_raster::array::RasterStructArray;
+use sedona_raster_zarr::{open_storage_from_uri, ZarrChunkReader};
+
+/// ITS_LIVE bucket layout: `s3://<BUCKET>/<KEY>` ↔
+/// `https://<BUCKET>.s3.us-west-2.amazonaws.com/<KEY>`.
Review Comment:
done
##########
rust/sedona-raster-zarr/Cargo.toml:
##########
@@ -33,17 +33,26 @@ result_large_err = "allow"
[dependencies]
arrow-array = { workspace = true }
arrow-schema = { workspace = true }
+async-trait = { workspace = true }
+datafusion = { workspace = true, default_features = false }
Review Comment:
deleted - wasn't needed at all
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -70,6 +90,88 @@ impl PyZarrChunkReader {
}
}
+/// Build an `Arc<dyn ObjectStore>` for `uri` using env-var credential
+/// discovery, per scheme. This is the temporary bridge that lets the
+/// Python FFI work without going through `con.read_format`; it
+/// reaches into `AWS_*` / `GOOGLE_*` / `AZURE_*` environment
+/// variables via the `object_store` per-backend `Builder::from_env`
+/// helpers.
+///
+/// **Slated for removal.** When the host wheel surfaces
+/// `args.src.store` to `open_reader` via the `FFI_ObjectStore`
+/// capsule machinery (in progress — see
+/// <https://github.com/apache/sedona-db/pull/890>), this function (and
+/// the `object_store` `aws`/`gcp`/`azure`/`http` features that back it)
+/// gets deleted — the store will arrive credentialed from the host's
+/// `ObjectStoreRegistry` and `PyZarrChunkReader::new` will extract it
+/// from the capsule instead. For `file://` and bare paths the
+/// returned store is a no-op placeholder; the loader uses
+/// `FilesystemStore` directly for the local case.
+fn default_object_store_for_uri(uri: &str) -> Result<Arc<dyn ObjectStore>, PyErr> {
+ // file:// and bare paths use a LocalFileSystem rooted at `/`;
+ // open_storage_from_uri prefixes it at the group's path. This
+ // matches the store the host's ObjectStoreRegistry yields for
+ // file://, so the loader treats local and cloud uniformly.
+ if uri.starts_with("file://") || !uri.contains("://") {
+ return Ok(Arc::new(object_store::local::LocalFileSystem::new()));
+ }
+ let url = Url::parse(uri)
+ .map_err(|e| PyValueError::new_err(format!("group URI {uri:?} is not a valid URL: {e}")))?;
+ match url.scheme().to_ascii_lowercase().as_str() {
Review Comment:
This is the temporary code until we pipe the store through. I'm not sure how much testing we want to add just for that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #888:
URL: https://github.com/apache/sedona-db/pull/888#discussion_r3343057496
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -70,6 +90,88 @@ impl PyZarrChunkReader {
}
}
+/// Build an `Arc<dyn ObjectStore>` for `uri` using env-var credential
+/// discovery, per scheme. This is the temporary bridge that lets the
+/// Python FFI work without going through `con.read_format`; it
+/// reaches into `AWS_*` / `GOOGLE_*` / `AZURE_*` environment
+/// variables via the `object_store` per-backend `Builder::from_env`
+/// helpers.
+///
+/// **Slated for removal.** When the host wheel surfaces
+/// `args.src.store` to `open_reader` via the `FFI_ObjectStore`
+/// capsule machinery (in progress — see
+/// <https://github.com/apache/sedona-db/pull/890>), this function (and
+/// the `object_store` `aws`/`gcp`/`azure`/`http` features that back it)
+/// gets deleted — the store will arrive credentialed from the host's
+/// `ObjectStoreRegistry` and `PyZarrChunkReader::new` will extract it
+/// from the capsule instead. For `file://` and bare paths the
+/// returned store is a no-op placeholder; the loader uses
+/// `FilesystemStore` directly for the local case.
+fn default_object_store_for_uri(uri: &str) -> Result<Arc<dyn ObjectStore>, PyErr> {
+ // file:// and bare paths use a LocalFileSystem rooted at `/`;
+ // open_storage_from_uri prefixes it at the group's path. This
+ // matches the store the host's ObjectStoreRegistry yields for
+ // file://, so the loader treats local and cloud uniformly.
+ if uri.starts_with("file://") || !uri.contains("://") {
+ return Ok(Arc::new(object_store::local::LocalFileSystem::new()));
+ }
+ let url = Url::parse(uri)
+ .map_err(|e| PyValueError::new_err(format!("group URI {uri:?} is not a valid URL: {e}")))?;
+ match url.scheme().to_ascii_lowercase().as_str() {
Review Comment:
I think you can just remove the untested code here (filesystem and S3 should suffice to actually use this until we pipe through the store)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #888:
URL: https://github.com/apache/sedona-db/pull/888
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(sedona-raster-zarr): cloud storage backends (s3, gcs, azure, http) via object_store [sedona-db]
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #888:
URL: https://github.com/apache/sedona-db/pull/888#discussion_r3338279592
##########
rust/sedona-raster-zarr/tests/cloud.rs:
##########
@@ -0,0 +1,127 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Cloud-backed smoke tests for `ZarrChunkReader`.
+//!
+//! These tests reach the network and are `#[ignore]` by default. Both
+//! target the public, anonymous ITS_LIVE v2 ice-velocity datacubes
+//! (NASA MEaSUREs), hosted at `s3://its-live-data/` in `us-west-2`. The
+//! dataset is a Zarr v2 group whose data arrays declare
+//! `dimension_names = ['mid_date', 'y', 'x']` — passing the loader's
+//! default spatial-dim policy — and whose coordinate variables include
+//! a few short fixed-length Unicode (`<U…`) arrays with null
+//! fill_values that current zarrs (0.23) can't open. The loader's
+//! list-then-open-each path tolerates those per-array failures, so a
+//! valid raster row still streams out.
+//!
+//! Run with:
+//!
+//! ```bash
+//! AWS_SKIP_SIGNATURE=true AWS_REGION=us-west-2 \
+//! cargo test -p sedona-raster-zarr --test cloud -- --ignored --nocapture
+//! ```
+
+use std::sync::Arc;
+
+use object_store::aws::AmazonS3Builder;
+use object_store::http::HttpBuilder;
+use object_store::ObjectStore;
+use sedona_raster::array::RasterStructArray;
+use sedona_raster_zarr::{open_storage_from_uri, ZarrChunkReader};
+
+/// ITS_LIVE bucket layout: `s3://<BUCKET>/<KEY>` ↔
+/// `https://<BUCKET>.s3.us-west-2.amazonaws.com/<KEY>`.
Review Comment:
Can you add a URL for a site describing what this is / the data?
Or if you are only going to test one object store, maybe just use a filesystem store?
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -39,7 +42,24 @@ impl PyZarrChunkReader {
#[new]
#[pyo3(signature = (uri, arrays=None, batch_size=8192))]
fn new(uri: &str, arrays: Option<Vec<String>>, batch_size: usize) -> PyResult<Self> {
- let reader = ZarrChunkReader::try_new(uri, arrays.as_deref(), batch_size)
+ let store =
+ default_object_store_for_uri(uri).map_err(|e| PyValueError::new_err(e.to_string()))?;
+ let storage =
+ open_storage_from_uri(uri, store).map_err(|e| PyValueError::new_err(e.to_string()))?;
+ // The crate's async-native loader exposes `try_new` as an
+ // `async fn`; the Python FFI is a sync constructor by
+ // contract, so we bridge with an ad-hoc current-thread tokio
+ // runtime here. `next()` on the returned reader is pure CPU
+ // and stays synchronous.
Review Comment:
This is probably fine, although you could also make a shared (global/static) runtime for your whole Python package if this becomes an issue.
##########
rust/sedona-raster-zarr/Cargo.toml:
##########
@@ -33,17 +33,26 @@ result_large_err = "allow"
[dependencies]
arrow-array = { workspace = true }
arrow-schema = { workspace = true }
+async-trait = { workspace = true }
+datafusion = { workspace = true, default_features = false }
Review Comment:
If you can avoid this one by using a subcrate, the compile will probably be faster / wheel will probably be smaller
##########
python/sedonadb-zarr/src/lib.rs:
##########
@@ -70,6 +90,88 @@ impl PyZarrChunkReader {
}
}
+/// Build an `Arc<dyn ObjectStore>` for `uri` using env-var credential
+/// discovery, per scheme. This is the temporary bridge that lets the
+/// Python FFI work without going through `con.read_format`; it
+/// reaches into `AWS_*` / `GOOGLE_*` / `AZURE_*` environment
+/// variables via the `object_store` per-backend `Builder::from_env`
+/// helpers.
+///
+/// **Slated for removal.** When the host wheel surfaces
+/// `args.src.store` to `open_reader` via the `FFI_ObjectStore`
+/// capsule machinery (in progress — see
+/// <https://github.com/apache/sedona-db/pull/890>), this function (and
+/// the `object_store` `aws`/`gcp`/`azure`/`http` features that back it)
+/// gets deleted — the store will arrive credentialed from the host's
+/// `ObjectStoreRegistry` and `PyZarrChunkReader::new` will extract it
+/// from the capsule instead. For `file://` and bare paths the
+/// returned store is a no-op placeholder; the loader uses
+/// `FilesystemStore` directly for the local case.
+fn default_object_store_for_uri(uri: &str) -> Result<Arc<dyn ObjectStore>, PyErr> {
+ // file:// and bare paths use a LocalFileSystem rooted at `/`;
+ // open_storage_from_uri prefixes it at the group's path. This
+ // matches the store the host's ObjectStoreRegistry yields for
+ // file://, so the loader treats local and cloud uniformly.
+ if uri.starts_with("file://") || !uri.contains("://") {
+ return Ok(Arc::new(object_store::local::LocalFileSystem::new()));
+ }
+ let url = Url::parse(uri)
+ .map_err(|e| PyValueError::new_err(format!("group URI {uri:?} is not a valid URL: {e}")))?;
+ match url.scheme().to_ascii_lowercase().as_str() {
Review Comment:
There are some tests in the sedona crate (I think) that smoke test these openers that you can steal. Alternatively, include fewer options since we'll remove some (not sure HTTP applies, unless there's some directory listing stuff I don't know about, and gcs/azure could probably be dropped for now).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org