Skip to content

Commit

Permalink
return error (#4752)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 authored Aug 30, 2023
1 parent 32e973d commit 735f48d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions arrow-pyarrow-integration-testing/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ def iter_batches():
with pytest.raises(ValueError, match="test error"):
rust.reader_return_errors(reader)

# Due to a long-standing oversight, PyArrow allows binary values in schema
# metadata that are not valid UTF-8. This is not allowed in Rust, but we
# make sure we error and not panic here.
schema = schema.with_metadata({"key": b"\xff"})
reader = pa.RecordBatchReader.from_batches(schema, iter_batches())
with pytest.raises(ValueError, match="invalid utf-8"):
rust.round_trip_record_batch_reader(reader)

def test_reject_other_classes():
# Arbitrary type that is not a PyArrow type
not_pyarrow = ["hello"]
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/ffi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn get_stream_schema(stream_ptr: *mut FFI_ArrowArrayStream) -> Result<SchemaRef>
let ret_code = unsafe { (*stream_ptr).get_schema.unwrap()(stream_ptr, &mut schema) };

if ret_code == 0 {
let schema = Schema::try_from(&schema).unwrap();
let schema = Schema::try_from(&schema)?;
Ok(Arc::new(schema))
} else {
Err(ArrowError::CDataInterface(format!(
Expand Down

0 comments on commit 735f48d

Please sign in to comment.