fn scan_batch(
    batch: RecordBatch,
    schema: SchemaRef,
    projection: Option<&Vec<usize>>,
) -> DataFusionResult<Arc<dyn ExecutionPlan>> {
    // apply projection, if any
    let (schema, batch) = match projection {
        None => (schema, batch),
        Some(projection) => {
            let projected_columns: DataFusionResult<Vec<Field>> = projection
                .iter()
                .map(|i| {
                    if *i < schema.fields().len() {
                        Ok(schema.field(*i).clone())
                    } else {
                        Err(DataFusionError::Internal(format!(
                            "Projection index out of range in ChunksProvider: {}",
                            i
                        )))
                    }
                })
                .collect();

            let projected_schema = Arc::new(Schema::new(projected_columns?));

            let columns = projection
                .iter()
                .map(|i| Arc::clone(batch.column(*i)))
                .collect::<Vec<_>>();

            let projected_batch = RecordBatch::try_new(Arc::clone(&projected_schema), columns)?;
            (projected_schema, projected_batch)
        }
    };

    Ok(Arc::new(MemoryExec::try_new(&[vec![batch]], schema, None)?))
}
/// Creates a DataFusion ExecutionPlan node that scans a single batch
/// of records.
Creates a DataFusion ExecutionPlan node that scans a single batch
of records.
Creates a DataFusion ExecutionPlan node that scans a single batch of records .
fn scan_batch(
    batch: RecordBatch,
    schema: SchemaRef,
    projection: Option<&Vec<usize>>,
) -> DataFusionResult<Arc<dyn ExecutionPlan>> {
    // apply projection, if any
    let (schema, batch) = match projection {
        None => (schema, batch),
        Some(projection) => {
            let projected_columns: DataFusionResult<Vec<Field>> = projection
                .iter()
                .map(|i| {
                    if *i < schema.fields().len() {
                        Ok(schema.field(*i).clone())
                    } else {
                        Err(DataFusionError::Internal(format!(
                            "Projection index out of range in ChunksProvider: {}",
                            i
                        )))
                    }
                })
                .collect();
            let projected_schema = Arc::new(Schema::new(projected_columns?));
            let columns = projection
                .iter()
                .map(|i| Arc::clone(batch.column(*i)))
                .collect::<Vec<_>>();
            let projected_batch = RecordBatch::try_new(Arc::clone(&projected_schema), columns)?;
            (projected_schema, projected_batch)
        }
    };
    Ok(Arc::new(MemoryExec::try_new(&[vec![batch]], schema, None)?))
}
fn scan_batch ( batch : RecordBatch , schema : SchemaRef , projection : Option < & Vec < usize > > , ) -> DataFusionResult < Arc < dyn ExecutionPlan > > { // apply projection, if any let ( schema , batch ) = match projection { None => ( schema , batch ) , Some ( projection ) => { let projected_columns : DataFusionResult < Vec < Field > > = projection . iter ( ) . map ( | i | { if * i < schema . fields ( ) . len ( ) { Ok ( schema . field ( * i ) . clone ( ) ) } else { Err ( DataFusionError :: Internal ( format ! ( " " i ) ) ) } } ) . collect ( ) ; let projected_schema = Arc :: new ( Schema :: new ( projected_columns ? ) ) ; let columns = projection . iter ( ) . map ( | i | Arc :: clone ( batch . column ( * i ) ) ) . collect :: < Vec < _ > > ( ) ; let projected_batch = RecordBatch :: try_new ( Arc :: clone ( & projected_schema ) , columns ) ? ; ( projected_schema , projected_batch ) } } ; Ok ( Arc :: new ( MemoryExec :: try_new ( & [ vec ! [ batch ] ] , schema , None ) ? ) ) }
Creates a DataFusion ExecutionPlan node that scans a single batch
of records.
Creates a DataFusion ExecutionPlan node that scans a single batch of records .
batch
RecordBatch
schema
SchemaRef
projection
Option<&Vec<usize>>
batch
RecordBatch
schema
SchemaRef
projection
Option<&Vec<usize>>