MCPcopy Create free account
hub / github.com/apache/paimon-rust / vortex_array_to_record_batch

Function vortex_array_to_record_batch

crates/paimon/src/arrow/format/vortex.rs:470–506  ·  view source on GitHub ↗

Convert a Vortex ArrayRef to an Arrow RecordBatch.

(
    vortex_array: ArrayRef,
    schema: &SchemaRef,
)

Source from the content-addressed store, hash-verified

468
469/// Convert a Vortex ArrayRef to an Arrow RecordBatch.
470fn vortex_array_to_record_batch(
471 vortex_array: ArrayRef,
472 schema: &SchemaRef,
473) -> crate::Result<RecordBatch> {
474 let arrow_array = vortex_array
475 .into_arrow(&ArrowDataType::Struct(schema.fields().clone()))
476 .map_err(|e| Error::DataInvalid {
477 message: format!("Failed to convert Vortex array to Arrow: {e}"),
478 source: None,
479 })?;
480
481 let struct_array = arrow_array
482 .as_any()
483 .downcast_ref::<arrow_array::StructArray>()
484 .ok_or_else(|| Error::DataInvalid {
485 message: "Vortex array did not convert to Arrow StructArray".to_string(),
486 source: None,
487 })?;
488
489 if struct_array.columns().len() != schema.fields().len() {
490 return Err(Error::DataInvalid {
491 message: format!(
492 "Vortex column count {} does not match target schema column count {}",
493 struct_array.columns().len(),
494 schema.fields().len()
495 ),
496 source: None,
497 });
498 }
499
500 RecordBatch::try_new(schema.clone(), struct_array.columns().to_vec()).map_err(|e| {
501 Error::DataInvalid {
502 message: format!("Failed to build RecordBatch from Vortex data: {e}"),
503 source: None,
504 }
505 })
506}
507
508// ---------------------------------------------------------------------------
509// VortexWrite adapter

Callers 1

read_batch_streamMethod · 0.85

Calls 4

to_vecMethod · 0.80
fieldsMethod · 0.45
as_anyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected