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

Commit

Permalink
Fixed error in union ffi. (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao authored Nov 23, 2021
1 parent 659433e commit 439dacf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
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

0 comments on commit 439dacf

Please sign in to comment.