(
batches: &[RecordBatch],
)
| 1509 | } |
| 1510 | |
| 1511 | fn 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 | |
| 1541 | fn make_array_formatter<'a>( |
| 1542 | array: &'a dyn Array, |
no test coverage detected
searching dependent graphs…