Skip to content

Commit 735f48d

Browse files
authored
return error (#4752)
1 parent 32e973d commit 735f48d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

arrow-pyarrow-integration-testing/tests/test_sql.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ def iter_batches():
421421
with pytest.raises(ValueError, match="test error"):
422422
rust.reader_return_errors(reader)
423423

424+
# Due to a long-standing oversight, PyArrow allows binary values in schema
425+
# metadata that are not valid UTF-8. This is not allowed in Rust, but we
426+
# make sure we error and not panic here.
427+
schema = schema.with_metadata({"key": b"\xff"})
428+
reader = pa.RecordBatchReader.from_batches(schema, iter_batches())
429+
with pytest.raises(ValueError, match="invalid utf-8"):
430+
rust.round_trip_record_batch_reader(reader)
431+
424432
def test_reject_other_classes():
425433
# Arbitrary type that is not a PyArrow type
426434
not_pyarrow = ["hello"]

arrow/src/ffi_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn get_stream_schema(stream_ptr: *mut FFI_ArrowArrayStream) -> Result<SchemaRef>
281281
let ret_code = unsafe { (*stream_ptr).get_schema.unwrap()(stream_ptr, &mut schema) };
282282

283283
if ret_code == 0 {
284-
let schema = Schema::try_from(&schema).unwrap();
284+
let schema = Schema::try_from(&schema)?;
285285
Ok(Arc::new(schema))
286286
} else {
287287
Err(ArrowError::CDataInterface(format!(

0 commit comments

Comments
 (0)