Skip to content

Commit c9fc5b9

Browse files
lidavidmamoebadaipom
authored
docs: acknowledge Rust's existence (#3083)
Co-authored-by: Bryce Mecum <petridish@gmail.com> Co-authored-by: Daijiro Fukuda <fukuda@clear-code.com>
1 parent d212b82 commit c9fc5b9

5 files changed

Lines changed: 146 additions & 1 deletion

File tree

docs/source/driver/installation.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,13 @@ Ruby
167167

168168
Install the appropriate driver package for C/C++. You can use it from
169169
Ruby.
170+
171+
Rust
172+
====
173+
174+
Add a dependency on ``adbc_core`` and any driver packages
175+
(e.g. ``adbc_datafusion``):
176+
177+
.. code-block:: shell
178+
179+
cargo add adbc_core adbc_datafusion

docs/source/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ make it more convenient to build analytical applications.
9696

9797
R
9898

99+
.. button-ref:: rust/quickstart
100+
:ref-type: doc
101+
:color: secondary
102+
:expand:
103+
104+
Rust
105+
99106
.. grid-item-card::
100107
:columns: 12 4 4 4
101108

@@ -190,7 +197,7 @@ Why ADBC?
190197

191198
.. grid-item-card:: Cross-language
192199

193-
Work in C/C++, C#, Go, Java, Python, R, Ruby, and more.
200+
Work in C/C++, C#, Go, Java, Python, R, Ruby, Rust, and more.
194201

195202
.. grid-item-card:: Full-featured
196203

@@ -222,6 +229,7 @@ Why ADBC?
222229
Java <java/index>
223230
Python <python/index>
224231
R <r/index>
232+
Rust <rust/index>
225233

226234
.. toctree::
227235
:maxdepth: 1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one
2+
.. or more contributor license agreements. See the NOTICE file
3+
.. distributed with this work for additional information
4+
.. regarding copyright ownership. The ASF licenses this file
5+
.. to you under the Apache License, Version 2.0 (the
6+
.. "License"); you may not use this file except in compliance
7+
.. with the License. You may obtain a copy of the License at
8+
..
9+
.. http://www.apache.org/licenses/LICENSE-2.0
10+
..
11+
.. Unless required by applicable law or agreed to in writing,
12+
.. software distributed under the License is distributed on an
13+
.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
.. KIND, either express or implied. See the License for the
15+
.. specific language governing permissions and limitations
16+
.. under the License.
17+
18+
==============
19+
Driver Manager
20+
==============
21+
22+
The driver manager is a library that implements the ADBC API by delegating to
23+
dynamically-loaded drivers. This allows applications to load drivers at
24+
runtime, and use drivers that aren't necessarily written in Rust. It is
25+
currently part of the adbc_core package, though we plan to split it into its
26+
own package for users who don't want or need FFI.

docs/source/rust/index.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one
2+
.. or more contributor license agreements. See the NOTICE file
3+
.. distributed with this work for additional information
4+
.. regarding copyright ownership. The ASF licenses this file
5+
.. to you under the Apache License, Version 2.0 (the
6+
.. "License"); you may not use this file except in compliance
7+
.. with the License. You may obtain a copy of the License at
8+
..
9+
.. http://www.apache.org/licenses/LICENSE-2.0
10+
..
11+
.. Unless required by applicable law or agreed to in writing,
12+
.. software distributed under the License is distributed on an
13+
.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
.. KIND, either express or implied. See the License for the
15+
.. specific language governing permissions and limitations
16+
.. under the License.
17+
18+
====
19+
Rust
20+
====
21+
22+
The ADBC Rust library is a standalone implementation of the ADBC APIs (like
23+
C/C++, C#, and Go). The primary crate is `adbc_core
24+
<https://crates.io/crates/adbc_core>`_.
25+
26+
.. toctree::
27+
:maxdepth: 2
28+
29+
quickstart
30+
driver_manager
31+
Rust API Reference <https://docs.rs/adbc_core/latest/adbc_core/>

docs/source/rust/quickstart.rst

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.. Licensed to the Apache Software Foundation (ASF) under one
2+
.. or more contributor license agreements. See the NOTICE file
3+
.. distributed with this work for additional information
4+
.. regarding copyright ownership. The ASF licenses this file
5+
.. to you under the Apache License, Version 2.0 (the
6+
.. "License"); you may not use this file except in compliance
7+
.. with the License. You may obtain a copy of the License at
8+
..
9+
.. http://www.apache.org/licenses/LICENSE-2.0
10+
..
11+
.. Unless required by applicable law or agreed to in writing,
12+
.. software distributed under the License is distributed on an
13+
.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
.. KIND, either express or implied. See the License for the
15+
.. specific language governing permissions and limitations
16+
.. under the License.
17+
18+
==========
19+
Quickstart
20+
==========
21+
22+
Here we'll briefly tour using ADBC with the `DataFusion`_ driver.
23+
24+
.. _DataFusion: https://datafusion.apache.org/
25+
26+
Installation
27+
============
28+
29+
Add a dependency on ``adbc_core`` and ``adbc_datafusion``:
30+
31+
.. code-block:: shell
32+
33+
cargo add adbc_core adbc_datafusion
34+
35+
Loading DataFusion
36+
==================
37+
38+
Create a driver instance, then a database handle, and then finally a
39+
connection. (This is a bit redundant for something like DataFusion, but the
40+
intent is that the database handle can hold shared state that multiple
41+
connections can share.)
42+
43+
.. code-block:: rust
44+
45+
// These traits must be in scope
46+
use adbc_core::{Connection, Database, Driver, Statement};
47+
48+
let mut driver = adbc_datafusion::DataFusionDriver {};
49+
let db = driver.new_database().expect("Failed to create database handle");
50+
let mut conn = db.new_connection().expect("Failed to create connection");
51+
52+
Running Queries
53+
===============
54+
55+
To run queries, we can create a statement and set a query:
56+
57+
.. code-block:: rust
58+
59+
let mut stmt = conn.new_statement().expect("Failed to create statement");
60+
stmt.set_sql_query("SELECT 1").expect("Failed to set SQL query");
61+
62+
We can then execute the query to get an Arrow ``RecordBatchReader``:
63+
64+
.. code-block:: rust
65+
66+
let reader = stmt.execute().expect("Failed to execute statement");
67+
for batch in reader {
68+
let batch = batch.expect("Failed to read batch");
69+
println!("{:?}", batch);
70+
}

0 commit comments

Comments
 (0)