Skip to content

Commit

Permalink
Re-exports arrow dependency to minimise version maintenance for crate… (
Browse files Browse the repository at this point in the history
#93)

* 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 <[email protected]>
  • Loading branch information
Tobias Brandt and wangfenjin authored Oct 26, 2022
1 parent 227f915 commit 67d6c90
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 2 additions & 3 deletions examples/parquet.rs
Original file line number Diff line number Diff line change
@@ -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;")?;
Expand Down
2 changes: 1 addition & 1 deletion src/arrow_batch.rs
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 67d6c90

Please sign in to comment.