Skip to content

Commit 84972c8

Browse files
committed
feat: Add Oracle table provider with rust-oracle driver
Implement Oracle support using rust-oracle (ODPI-C) and bb8 connection pooling. Includes comprehensive type mappings (NUMBER, DATE, TIMESTAMP, CLOB, BLOB, RAW), schema inference, and 12 integration tests. Tested against Oracle Database 23c Free. Note: This is my first contribution to the project. Feedback welcome! :)
1 parent 8b277b5 commit 84972c8

File tree

18 files changed

+2018
-10
lines changed

18 files changed

+2018
-10
lines changed

Cargo.lock

Lines changed: 99 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let ctx = SessionContext::with_state(state);
2222

2323
- PostgreSQL
2424
- MySQL
25+
- Oracle
2526
- SQLite
2627
- ClickHouse
2728
- DuckDB
@@ -165,6 +166,57 @@ EOF
165166
cargo run -p datafusion-table-providers --example mysql --features mysql
166167
```
167168

169+
### Oracle
170+
171+
In order to run the Oracle example, you need to have an Oracle database server running. You can use the following command to start an Oracle Free server in a Docker container the example can use:
172+
173+
```bash
174+
docker run --name oracle-free \
175+
-e ORACLE_PASSWORD=OraclePassword123 \
176+
-p 1521:1521 \
177+
-d gvenzl/oracle-free:latest
178+
179+
# Wait for the Oracle server to start and healthcheck to pass
180+
echo "Waiting for Oracle to start (this may take 1-2 minutes)..."
181+
until docker exec oracle-free /usr/local/bin/checkHealth.sh >/dev/null 2>&1; do
182+
sleep 5
183+
done
184+
echo "Oracle is ready!"
185+
186+
# Create a table in the Oracle server and insert some data
187+
docker exec -i oracle-free sqlplus system/OraclePassword123@FREEPDB1 <<EOF
188+
CREATE TABLE companies (
189+
id NUMBER PRIMARY KEY,
190+
name VARCHAR2(100)
191+
);
192+
193+
INSERT INTO companies (id, name) VALUES (1, 'Acme Corporation');
194+
INSERT INTO companies (id, name) VALUES (2, 'Widget Inc.');
195+
COMMIT;
196+
EXIT;
197+
EOF
198+
```
199+
200+
**Prerequisites:** The `rust-oracle` crate requires Oracle Instant Client libraries (ODPI-C). Install them:
201+
202+
- **Linux (Debian/Ubuntu):**
203+
```bash
204+
apt-get install libaio1 wget unzip
205+
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
206+
unzip instantclient-basiclite-linuxx64.zip -d /opt/oracle
207+
export LD_LIBRARY_PATH=/opt/oracle/instantclient_XX_X:$LD_LIBRARY_PATH
208+
```
209+
210+
- **macOS:**
211+
```bash
212+
brew install instantclient-basic
213+
```
214+
215+
```bash
216+
# Run from repo folder
217+
cargo run -p datafusion-table-providers --example oracle --features oracle
218+
```
219+
168220
### Flight SQL
169221

170222
```bash

core/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ rust_decimal = { version = "1.38.0", features = ["db-postgres"] }
103103
adbc_driver_manager = { workspace = true, optional = true }
104104
adbc_core = { workspace = true, optional = true }
105105
r2d2_adbc = { version = "0.2.0", optional = true }
106+
oracle = { version = "0.6", optional = true }
107+
bb8-oracle = { version = "0.3", optional = true }
106108

107109
[dev-dependencies]
108110
anyhow = "1.0"
@@ -167,6 +169,14 @@ adbc = [
167169
"dep:r2d2",
168170
]
169171
adbc-federation = ["adbc", "federation"]
172+
oracle = [
173+
"dep:oracle",
174+
"dep:bb8",
175+
"dep:bb8-oracle",
176+
"dep:async-stream",
177+
"dep:arrow-schema",
178+
]
179+
oracle-federation = ["oracle", "federation"]
170180

171181
# docs.rs-specific configuration
172182
[package.metadata.docs.rs]

core/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub mod flight;
1717
pub mod mysql;
1818
#[cfg(feature = "odbc")]
1919
pub mod odbc;
20+
#[cfg(feature = "oracle")]
21+
pub mod oracle;
2022
#[cfg(feature = "postgres")]
2123
pub mod postgres;
2224
#[cfg(feature = "sqlite")]

0 commit comments

Comments
 (0)