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)