A native Apache Doris driver with SQLx queries, exact Doris values, streamed results and optional Stream Load ingestion. Use upstream sqlx for generic queries, pools, FromRow and migrations; declare sqlx-doris as your sole Doris extension, without internal packages. Checked queries and migration tools are optional; specialist recovery is a separate choice.
0.2.0 is published on crates.io. Requires Rust 1.94+ and a C toolchain; the verified baseline is Doris 4.1.5 with SQLx 0.9.0. Only Doris is provided; no sqlx-mysql package or driver patch is required.
- Run your first query
- Enable only the capabilities you use
- Choose a guide
- Work on the source checkout
- License
Add the dependency below and configure external build paths. The target database and account must already exist. This runtime example needs no build-time DATABASE_URL.
[dependencies]
sqlx = { version = "=0.9.0", default-features = false, features = ["derive"] }
sqlx-doris = "0.2.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }Put this complete program in src/main.rs:
use sqlx_doris::DorisPool;
#[derive(Debug, sqlx::FromRow)]
struct Answer {
id: i64,
name: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = DorisPool::connect(&std::env::var("DORIS_URL")?).await?;
let row: Answer = sqlx::query_as("SELECT CAST(? AS BIGINT) AS id, CAST(? AS STRING) AS name")
.bind(42_i64)
.bind("Doris 中文🙂")
.fetch_one(&pool)
.await?;
assert_eq!(row.id, 42);
assert_eq!(row.name, "Doris 中文🙂");
println!("{row:?}");
pool.close().await;
Ok(())
}Set DORIS_URL to doris://user:password@fe:9030/database and run your application with cargo run. URL-encode reserved characters in credentials/database names.
| Need | sqlx-doris feature |
Upstream sqlx feature |
|---|---|---|
| Runtime queries, pools and Doris types | None | None; derive for FromRow |
| Batch ingestion | stream-load (includes operations) |
As required by your query code |
| Schema/MV/visibility helpers | operations |
As required by your query code |
| Checked Doris queries | macros |
derive or macros; direct dependency named sqlx |
| Embedded migrations | migrate |
macros, migrate |
| Runtime migration directory | migrate |
migrate |
| Basic CLI | cli (includes migrate) |
Managed by the CLI |
| Doris administration | cli-admin (includes cli) |
Managed by the CLI |
| Independent Kafka preflight | cli-admin-kafka (includes cli-admin) |
Managed by the CLI |
Default features are empty. Checked queries use sqlx_doris::query!; embedded migration files use upstream sqlx::migrate!. See Installation.
Start with the task map, trace control and execution paths, or explore the five-package architecture. A local interactive atlas accompanies the static diagrams and text.
- Installation: crates.io dependency, features, external paths and TLS.
- Everyday queries and types, batch ingestion and troubleshooting.
- Checked queries and offline builds, SQLx migrations and CLI.
- Specialist administration: recovery, managed Routine Load and Kafka continuation preflight.
- Performance, compatibility, testing, dependencies and release notes.
- Full documentation and terminology.
Repository tools require Python 3.12+. From the repository root, use a mounted external physical volume:
export SQLX_DORIS_EXTERNAL_VOLUME="<absolute-external-mount>"
./scripts/dev cargo fetch --locked
./scripts/dev ./scripts/checkThe wrapper keeps target/build, caches, downloads, temporary files and logs external and fails if the volume is unavailable. Docker/Lima disks and server data must also be external before local server startup; see Testing.
Apache-2.0. Dependencies retain their own licenses.