From e636b3b0caa5f2de06a717da42c7fe719bb9812c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Feb 2023 11:33:38 +0800 Subject: [PATCH] Update arrow requirement from 32 to 33 (#123) * Update arrow requirement from 32 to 33 Updates the requirements on [arrow](https://github.com/apache/arrow-rs) to permit the latest version. - [Release notes](https://github.com/apache/arrow-rs/releases) - [Changelog](https://github.com/apache/arrow-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/apache/arrow-rs/compare/32.0.0...33.0.0) --- updated-dependencies: - dependency-name: arrow dependency-type: direct:production ... Signed-off-by: dependabot[bot] * fix clippy Change-Id: I2f9df13eecad63025d0bac3c01850bcfb26464c9 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: wangfenjin --- Cargo.toml | 2 +- libduckdb-sys/Cargo.toml | 2 +- libduckdb-sys/src/lib.rs | 22 +++++++++++----------- src/raw_statement.rs | 24 ++++++++++++------------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c584c44e..5c3b909b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ memchr = "2.3" uuid = { version = "1.0", optional = true } smallvec = "1.6.1" cast = { version = "0.3", features = ["std"] } -arrow = { version = "32", default-features = false, features = ["prettyprint", "ffi"] } +arrow = { version = "33", default-features = false, features = ["prettyprint", "ffi"] } rust_decimal = "1.14" strum = { version = "0.24", features = ["derive"] } r2d2 = { version = "0.8.9", optional = true } diff --git a/libduckdb-sys/Cargo.toml b/libduckdb-sys/Cargo.toml index 341e67f2..9a527b0d 100644 --- a/libduckdb-sys/Cargo.toml +++ b/libduckdb-sys/Cargo.toml @@ -28,4 +28,4 @@ cc = { version = "1.0", features = ["parallel"], optional = true } vcpkg = { version = "0.2", optional = true } [dev-dependencies] -arrow = { version = "32", default-features = false, features = ["ffi"] } \ No newline at end of file +arrow = { version = "33", default-features = false, features = ["ffi"] } \ No newline at end of file diff --git a/libduckdb-sys/src/lib.rs b/libduckdb-sys/src/lib.rs index 3e387833..72c4da5b 100644 --- a/libduckdb-sys/src/lib.rs +++ b/libduckdb-sys/src/lib.rs @@ -84,23 +84,23 @@ mod tests { assert_eq!(duckdb_arrow_row_count(result), 3); assert_eq!(duckdb_arrow_column_count(result), 2); - let mut arrays = &FFI_ArrowArray::empty(); - let mut schema = &FFI_ArrowSchema::empty(); - let schema = &mut schema; - if duckdb_query_arrow_schema(result, schema as *mut _ as *mut duckdb_arrow_schema) - != duckdb_state_DuckDBSuccess + let mut arrays = FFI_ArrowArray::empty(); + let mut schema = FFI_ArrowSchema::empty(); + if duckdb_query_arrow_schema( + result, + &mut std::ptr::addr_of_mut!(schema) as *mut _ as *mut duckdb_arrow_schema, + ) != duckdb_state_DuckDBSuccess { panic!("SELECT error") } - let arrays = &mut arrays; - if duckdb_query_arrow_array(result, arrays as *mut _ as *mut duckdb_arrow_array) - != duckdb_state_DuckDBSuccess + if duckdb_query_arrow_array( + result, + &mut std::ptr::addr_of_mut!(arrays) as *mut _ as *mut duckdb_arrow_array, + ) != duckdb_state_DuckDBSuccess { panic!("SELECT error") } - let arrow_array = - ArrowArray::try_from_raw(*arrays as *const FFI_ArrowArray, *schema as *const FFI_ArrowSchema) - .expect("ok"); + let arrow_array = ArrowArray::new(arrays, schema); let array_data = ArrayData::try_from(arrow_array).expect("ok"); let struct_array = StructArray::from(array_data); assert_eq!(struct_array.len(), 3); diff --git a/src/raw_statement.rs b/src/raw_statement.rs index 87c8a808..521ffac4 100644 --- a/src/raw_statement.rs +++ b/src/raw_statement.rs @@ -81,28 +81,28 @@ impl RawStatement { pub fn step(&self) -> Option { self.result?; unsafe { - let mut arrays = &FFI_ArrowArray::empty(); - let arrays = &mut arrays; - if ffi::duckdb_query_arrow_array(self.result_unwrap(), arrays as *mut _ as *mut ffi::duckdb_arrow_array) - != ffi::DuckDBSuccess + let mut arrays = FFI_ArrowArray::empty(); + if ffi::duckdb_query_arrow_array( + self.result_unwrap(), + &mut std::ptr::addr_of_mut!(arrays) as *mut _ as *mut ffi::duckdb_arrow_array, + ) != ffi::DuckDBSuccess { return None; } - if (**arrays).is_empty() { + if arrays.is_empty() { return None; } - let mut schema = &FFI_ArrowSchema::empty(); - let schema = &mut schema; - if ffi::duckdb_query_arrow_schema(self.result_unwrap(), schema as *mut _ as *mut ffi::duckdb_arrow_schema) - != ffi::DuckDBSuccess + let mut schema = FFI_ArrowSchema::empty(); + if ffi::duckdb_query_arrow_schema( + self.result_unwrap(), + &mut std::ptr::addr_of_mut!(schema) as *mut _ as *mut ffi::duckdb_arrow_schema, + ) != ffi::DuckDBSuccess { return None; } - let arrow_array = - ArrowArray::try_from_raw(*arrays as *const FFI_ArrowArray, *schema as *const FFI_ArrowSchema) - .expect("ok"); + let arrow_array = ArrowArray::new(arrays, schema); let array_data = ArrayData::try_from(arrow_array).expect("ok"); let struct_array = StructArray::from(array_data); Some(struct_array)