fn create_table(results: &[RecordBatch]) -> Result<Table> {
    let mut table = Table::new();
    table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);

    if results.is_empty() {
        return Ok(table);
    }

    let schema = results[0].schema();

    let mut header = Vec::new();
    for field in schema.fields() {
        header.push(Cell::new(&field.name()));
    }
    table.set_titles(Row::new(header));

    for batch in results {
        let displayes = batch
            .columns()
            .iter()
            .map(|array| get_display(array.as_ref()))
            .collect::<Result<Vec<_>>>()?;

        for row in 0..batch.num_rows() {
            let mut cells = Vec::new();
            (0..batch.num_columns()).for_each(|col| {
                let string = displayes[col](row);
                cells.push(Cell::new(&string));
            });
            table.add_row(Row::new(cells));
        }
    }

    Ok(table)
}
/// Convert a series of record batches into a table
Convert a series of record batches into a table
Convert a series of record batches into a table
fn create_table(results: &[RecordBatch]) -> Result<Table> {
    let mut table = Table::new();
    table.set_format(*format::consts::FORMAT_NO_LINESEP_WITH_TITLE);
    if results.is_empty() {
        return Ok(table);
    }
    let schema = results[0].schema();
    let mut header = Vec::new();
    for field in schema.fields() {
        header.push(Cell::new(&field.name()));
    }
    table.set_titles(Row::new(header));
    for batch in results {
        let displayes = batch
            .columns()
            .iter()
            .map(|array| get_display(array.as_ref()))
            .collect::<Result<Vec<_>>>()?;
        for row in 0..batch.num_rows() {
            let mut cells = Vec::new();
            (0..batch.num_columns()).for_each(|col| {
                let string = displayes[col](row);
                cells.push(Cell::new(&string));
            });
            table.add_row(Row::new(cells));
        }
    }
    Ok(table)
}
fn create_table ( results : & [ RecordBatch ] ) -> Result < Table > { let mut table = Table :: new ( ) ; table . set_format ( * format :: consts :: FORMAT_NO_LINESEP_WITH_TITLE ) ; if results . is_empty ( ) { return Ok ( table ) ; } let schema = results [ 0 ] . schema ( ) ; let mut header = Vec :: new ( ) ; for field in schema . fields ( ) { header . push ( Cell :: new ( & field . name ( ) ) ) ; } table . set_titles ( Row :: new ( header ) ) ; for batch in results { let displayes = batch . columns ( ) . iter ( ) . map ( | array | get_display ( array . as_ref ( ) ) ) . collect :: < Result < Vec < _ > > > ( ) ? ; for row in 0 .. batch . num_rows ( ) { let mut cells = Vec :: new ( ) ; ( 0 .. batch . num_columns ( ) ) . for_each ( | col | { let string = displayes [ col ] ( row ) ; cells . push ( Cell :: new ( & string ) ) ; } ) ; table . add_row ( Row :: new ( cells ) ) ; } } Ok ( table ) }
Convert a series of record batches into a table
Convert a series of record batches into a table
results
&[RecordBatch]