Skip to content

Commit af2156d

Browse files
committed
Use pyo3_arrow's schema_equals function for now
1 parent 7695898 commit af2156d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

arrow-pyarrow/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,25 @@ impl Table {
515515
record_batches: Vec<RecordBatch>,
516516
schema: SchemaRef,
517517
) -> Result<Self, ArrowError> {
518+
/// This function was copied from `pyo3_arrow/utils.rs` for now. I don't understand yet why
519+
/// this is required instead of a "normal" `schema == record_batch.schema()` check.
520+
///
521+
/// TODO: Either remove this check, replace it with something already existing in `arrow-rs`
522+
/// or move it to a central `utils` location.
523+
fn schema_equals(left: &SchemaRef, right: &SchemaRef) -> bool {
524+
left.fields
525+
.iter()
526+
.zip(right.fields.iter())
527+
.all(|(left_field, right_field)| {
528+
left_field.name() == right_field.name()
529+
&& left_field
530+
.data_type()
531+
.equals_datatype(right_field.data_type())
532+
})
533+
}
534+
518535
for record_batch in &record_batches {
519-
if schema != record_batch.schema() {
536+
if !schema_equals(&schema, &record_batch.schema()) {
520537
return Err(ArrowError::SchemaError(
521538
//"All record batches must have the same schema.".to_owned(),
522539
format!(

0 commit comments

Comments
 (0)