This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git


The following commit(s) were added to refs/heads/main by this push:
     new 903ffbdb feat(examples/sedonadb-rust): Add example Rust project (#320)
903ffbdb is described below

commit 903ffbdbae3b86c4df9bc9c1f153142ab0970983
Author: Dewey Dunnington <[email protected]>
AuthorDate: Mon Nov 24 10:10:12 2025 -0600

    feat(examples/sedonadb-rust): Add example Rust project (#320)
---
 .github/workflows/examples.yml     | 81 ++++++++++++++++++++++++++++++++++++++
 Cargo.toml                         |  4 +-
 examples/.gitignore                | 18 +++++++++
 examples/sedonadb-rust/Cargo.toml  | 36 +++++++++++++++++
 examples/sedonadb-rust/README.md   | 41 +++++++++++++++++++
 examples/sedonadb-rust/src/main.rs | 35 ++++++++++++++++
 6 files changed, 213 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml
new file mode 100644
index 00000000..699bf7d0
--- /dev/null
+++ b/.github/workflows/examples.yml
@@ -0,0 +1,81 @@
+# 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.
+name: examples
+
+on:
+  pull_request:
+    branches:
+      - main
+    paths:
+      - 'Cargo.toml'
+      - 'Cargo.lock'
+      - '.github/workflows/rust.yml'
+      - 'rust/**'
+      - 'c/**'
+      - 'examples/**'
+  push:
+    branches:
+      - main
+
+concurrency:
+  group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }}-rust
+  cancel-in-progress: true
+
+permissions:
+  contents: read
+
+defaults:
+  run:
+    shell: bash -l -eo pipefail {0}
+
+env:
+  # At GEOS updated to 3.14.0
+  VCPKG_REF: 5a01de756c28279ddfdd2b061d1c75710a6255fa
+
+jobs:
+  rust:
+    strategy:
+      fail-fast: false
+
+    runs-on: ubuntu-latest
+    env:
+      CARGO_INCREMENTAL: 0
+
+    steps:
+      - uses: actions/checkout@v4
+      - name: Use stable Rust
+        id: rust
+        run: |
+          rustup toolchain install stable --no-self-update
+          rustup default stable
+
+      - uses: Swatinem/rust-cache@v2
+        with:
+          # Update this key to force a new cache
+          prefix-key: "rust-${{ matrix.name }}-v4"
+
+      - name: Install dependencies
+        shell: bash
+        run: |
+          sudo apt-get update && sudo apt-get install -y libgeos-dev
+
+      - name: Build and run examples/sedonadb-rust
+        shell: bash
+        run: |
+          rm -rf Cargo.toml
+          cd examples/sedonadb-rust
+          cargo run
diff --git a/Cargo.toml b/Cargo.toml
index 4c760977..45400c98 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,8 +59,8 @@ rust-version = "1.86"
 [workspace.dependencies]
 approx = "0.5"
 abi_stable = "0.11.3"
-adbc_core = ">=0.20.0"
-adbc_ffi = ">=0.20.0"
+adbc_core = ">=0.21.0"
+adbc_ffi = ">=0.21.0"
 lru = "0.12"
 arrow = { version = "56.0.0", features = ["prettyprint", "ffi", "chrono-tz"] }
 arrow-array = { version = "56.0.0" }
diff --git a/examples/.gitignore b/examples/.gitignore
new file mode 100644
index 00000000..8abe0fcc
--- /dev/null
+++ b/examples/.gitignore
@@ -0,0 +1,18 @@
+# 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.
+
+Cargo.lock
diff --git a/examples/sedonadb-rust/Cargo.toml 
b/examples/sedonadb-rust/Cargo.toml
new file mode 100644
index 00000000..e2f3b221
--- /dev/null
+++ b/examples/sedonadb-rust/Cargo.toml
@@ -0,0 +1,36 @@
+# 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.
+
+[package]
+name = "sedonadb-rust-example"
+version = "0.0.1"
+authors = ["Apache Sedona <[email protected]>"]
+license = "Apache-2.0"
+homepage = "https://github.com/apache/sedona-db";
+repository = "https://github.com/apache/sedona-db";
+description = "Apache SedonaDB Rust API Example"
+readme = "README.md"
+edition = "2021"
+rust-version = "1.86"
+
+[workspace]
+
+[dependencies]
+datafusion = { version = "50.2.0"}
+# When sedona is released on crates.io, this can be a version and not a git 
repo
+sedona = { git = "https://github.com/apache/sedona-db.git";, package = "sedona"}
+tokio = { version = "1.44", features = ["rt-multi-thread"]}
diff --git a/examples/sedonadb-rust/README.md b/examples/sedonadb-rust/README.md
new file mode 100644
index 00000000..76d45b9c
--- /dev/null
+++ b/examples/sedonadb-rust/README.md
@@ -0,0 +1,41 @@
+<!---
+  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.
+-->
+
+# Using SedonaDB from Rust
+
+This example shows how to use the `sedona` crate alongside `datafusion` in a 
Rust
+Project to run a basic query.
+
+```shell
+git clone https://github.com/apache/sedona-db.git
+cd sedona-db/examples/sedona-rust
+cargo run
+```
+
+```
++-------------+----------------------------------------------+
+|     name    |                   geometry                   |
++-------------+----------------------------------------------+
+| Abidjan     | POINT(-4.020206835187587 5.3231260722445715) |
+| Abu Dhabi   | POINT(54.3665934 24.4666836)                 |
+| Abuja       | POINT(7.489505042885861 9.054620406360845)   |
+| Accra       | POINT(-0.2186616 5.5519805)                  |
+| Addis Ababa | POINT(38.6980586 9.0352562)                  |
++-------------+----------------------------------------------+
+```
diff --git a/examples/sedonadb-rust/src/main.rs 
b/examples/sedonadb-rust/src/main.rs
new file mode 100644
index 00000000..7eca0774
--- /dev/null
+++ b/examples/sedonadb-rust/src/main.rs
@@ -0,0 +1,35 @@
+// 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.
+// Because a number of methods only return Err() for not implemented,
+// the compiler doesn't know how to guess which impl RecordBatchReader
+// will be returned. When we implement the methods, we can remove this.
+
+use datafusion::{common::Result, prelude::*};
+use sedona::context::{SedonaContext, SedonaDataFrame};
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let ctx = SedonaContext::new_local_interactive().await?;
+    let url = 
"https://raw.githubusercontent.com/geoarrow/geoarrow-data/v0.2.0/natural-earth/files/natural-earth_cities_geo.parquet";;
+    let df = ctx.read_parquet(url, Default::default()).await?;
+    let output = df
+        .sort_by(vec![col("name")])?
+        .show_sedona(&ctx, Some(5), Default::default())
+        .await?;
+    println!("{output}");
+    Ok(())
+}

Reply via email to