From 67d6c9069c43d96956987643e4f0125eee8758c5 Mon Sep 17 00:00:00 2001 From: Tobias Brandt Date: Wed, 26 Oct 2022 04:39:24 +0200 Subject: [PATCH] =?UTF-8?q?Re-exports=20arrow=20dependency=20to=20minimise?= =?UTF-8?q?=20version=20maintenance=20for=20crate=E2=80=A6=20(#93)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Re-exports arrow dependency to minimise version maintenance for crate users * use duckdb::arrow; add more comments Change-Id: I8d68c1f9da480439a0271d22ff91d442ca3e5ee7 * use duckdb::arrow Change-Id: I2e2b4e9e9033a5d4cd29fbb9f6aa3e7798eee18d Co-authored-by: wangfenjin --- README.md | 13 +++++++++++-- examples/basic.rs | 4 ++-- examples/parquet.rs | 5 ++--- src/arrow_batch.rs | 2 +- src/lib.rs | 7 +++++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ee2b455d..57f8c329 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,17 @@ forked from rusqlite as duckdb also tries to expose a sqlite3 compatible API. ```rust use duckdb::{params, Connection, Result}; -use arrow::record_batch::RecordBatch; -use arrow::util::pretty::print_batches; + +// In your project, we need to keep the arrow version same as the version used in duckdb. +// Refer to https://github.com/wangfenjin/duckdb-rs/issues/92 +// You can either: +use duckdb::arrow::record_batch::RecordBatch; +// Or in your Cargo.toml, use * as the version; features can be toggled according to your needs +// arrow = { version = "*", default-features = false, features = ["prettyprint"] } +// Then you can: +// use arrow::record_batch::RecordBatch; + +use duckdb::arrow::util::pretty::print_batches; #[derive(Debug)] struct Person { diff --git a/examples/basic.rs b/examples/basic.rs index ee08e681..967e2b09 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -2,8 +2,8 @@ extern crate duckdb; -use arrow::record_batch::RecordBatch; -use arrow::util::pretty::print_batches; +use duckdb::arrow::record_batch::RecordBatch; +use duckdb::arrow::util::pretty::print_batches; use duckdb::{params, Connection, Result}; #[derive(Debug)] diff --git a/examples/parquet.rs b/examples/parquet.rs index 6ff4aea9..e2e7a334 100644 --- a/examples/parquet.rs +++ b/examples/parquet.rs @@ -1,9 +1,8 @@ extern crate duckdb; +use duckdb::arrow::record_batch::RecordBatch; +use duckdb::arrow::util::pretty::print_batches; use duckdb::{Connection, Result}; -use arrow::record_batch::RecordBatch; -use arrow::util::pretty::print_batches; - fn main() -> Result<()> { let db = Connection::open_in_memory()?; db.execute_batch("INSTALL parquet; LOAD parquet;")?; diff --git a/src/arrow_batch.rs b/src/arrow_batch.rs index a1751330..29bd6844 100644 --- a/src/arrow_batch.rs +++ b/src/arrow_batch.rs @@ -1,5 +1,5 @@ +use super::arrow::{datatypes::SchemaRef, record_batch::RecordBatch}; use super::Statement; -use arrow::{datatypes::SchemaRef, record_batch::RecordBatch}; /// An handle for the resulting RecordBatch of a query. #[must_use = "Arrow is lazy and will do nothing unless consumed"] diff --git a/src/lib.rs b/src/lib.rs index e28657e4..89f882ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,8 +3,8 @@ //! //! ```rust //! use duckdb::{params, Connection, Result}; -//! use arrow::record_batch::RecordBatch; -//! use arrow::util::pretty::print_batches; +//! use duckdb::arrow::record_batch::RecordBatch; +//! use duckdb::arrow::util::pretty::print_batches; //! //! #[derive(Debug)] //! struct Person { @@ -87,6 +87,9 @@ pub use crate::statement::Statement; pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior}; pub use crate::types::ToSql; +// re-export dependencies from arrow-rs to minimise version maintenance for crate users +pub use arrow; + #[macro_use] mod error; mod appender;