Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Fixed error in union FFI #625

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/integration-ffi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
key: ${{ runner.os }}-amd64-target-maturin-cache
- uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: "3.7"
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel
- name: Run tests
Expand All @@ -38,6 +38,6 @@ jobs:
python -m venv venv
source venv/bin/activate

pip install maturin==0.10.2 toml==0.10.1 pyarrow==5.0.0
pip install maturin==0.10.2 toml==0.10.1 pyarrow==6.0.0
maturin develop
python -m unittest discover tests
3 changes: 1 addition & 2 deletions arrow-pyarrow-integration-testing/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def tearDown(self):
# No leak of C++ memory
self.assertEqual(self.old_allocated_cpp, pyarrow.total_allocated_bytes())

# see https://issues.apache.org/jira/browse/ARROW-14680
def _test_null(self):
def test_null(self):
"""
Python -> Rust -> Python
"""
Expand Down
7 changes: 3 additions & 4 deletions src/array/union/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ unsafe impl ToFfi for UnionArray {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
if let Some(offsets) = &self.offsets {
vec![
None,
Some(self.types.as_ptr().cast::<u8>()),
Some(offsets.as_ptr().cast::<u8>()),
]
} else {
vec![None, Some(self.types.as_ptr().cast::<u8>())]
vec![Some(self.types.as_ptr().cast::<u8>())]
}
}

Expand All @@ -37,11 +36,11 @@ impl<A: ffi::ArrowArrayRef> FromFfi<A> for UnionArray {
let data_type = field.data_type().clone();
let fields = Self::get_fields(field.data_type());

let mut types = unsafe { array.buffer::<i8>(1) }?;
let mut types = unsafe { array.buffer::<i8>(0) }?;
let offsets = if Self::is_sparse(&data_type) {
None
} else {
Some(unsafe { array.buffer::<i32>(2) }?)
Some(unsafe { array.buffer::<i32>(1) }?)
};

let length = array.array().len();
Expand Down