MCPcopy Create free account
hub / github.com/apache/datafusion / format_record_batches

Function format_record_batches

benchmarks/src/sql_benchmark.rs:1511–1539  ·  view source on GitHub ↗
(
    batches: &[RecordBatch],
)

Source from the content-addressed store, hash-verified

1509}
1510
1511fn format_record_batches(
1512 batches: &[RecordBatch],
1513) -> Result<Vec<Vec<String>>, DataFusionError> {
1514 let mut expected_result = vec![];
1515 let arrow_format_options = FormatOptions::default()
1516 .with_null("NULL")
1517 .with_display_error(true);
1518
1519 for batch in batches {
1520 let schema = batch.schema_ref();
1521
1522 let formatters = batch
1523 .columns()
1524 .iter()
1525 .zip(schema.fields().iter())
1526 .map(|(c, field)| make_array_formatter(c, &arrow_format_options, Some(field)))
1527 .collect::<Result<Vec<_>, ArrowError>>()?;
1528
1529 for row in 0..batch.num_rows() {
1530 let mut cells = vec![];
1531 for formatter in &formatters {
1532 cells.push(formatter.value(row).to_string());
1533 }
1534 expected_result.push(cells);
1535 }
1536 }
1537
1538 Ok(expected_result)
1539}
1540
1541fn make_array_formatter<'a>(
1542 array: &'a dyn Array,

Callers 4

assertMethod · 0.85
verifyMethod · 0.85
read_query_from_fileFunction · 0.85
formatted_last_resultsFunction · 0.85

Calls 8

make_array_formatterFunction · 0.85
columnsMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
fieldsMethod · 0.45
pushMethod · 0.45
to_stringMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…