fn create_context() -> Result<ExecutionContext> {
    use arrow::datatypes::{Field, Schema};
    use datafusion::datasource::MemTable;
    // define a schema.
    let schema = Arc::new(Schema::new(vec![
        Field::new("a", DataType::Float32, false),
        Field::new("b", DataType::Float64, false),
    ]));

    // define data.
    let batch = RecordBatch::try_new(
        schema.clone(),
        vec![
            Arc::new(Float32Array::from(vec![2.1, 3.1, 4.1, 5.1])),
            Arc::new(Float64Array::from(vec![1.0, 2.0, 3.0, 4.0])),
        ],
    )?;

    // declare a new context. In spark API, this corresponds to a new spark SQLsession
    let mut ctx = ExecutionContext::new();

    // declare a table in memory. In spark API, this corresponds to createDataFrame(...).
    let provider = MemTable::try_new(schema, vec![vec![batch]])?;
    ctx.register_table("t", Box::new(provider));
    Ok(ctx)
}
// create local execution context with an in-memory table
create local execution context with an in-memory table
create local execution context with an in - memory table
fn create_context() -> Result<ExecutionContext> {
    use arrow::datatypes::{Field, Schema};
    use datafusion::datasource::MemTable;
    // define a schema.
    let schema = Arc::new(Schema::new(vec![
        Field::new("a", DataType::Float32, false),
        Field::new("b", DataType::Float64, false),
    ]));
    // define data.
    let batch = RecordBatch::try_new(
        schema.clone(),
        vec![
            Arc::new(Float32Array::from(vec![2.1, 3.1, 4.1, 5.1])),
            Arc::new(Float64Array::from(vec![1.0, 2.0, 3.0, 4.0])),
        ],
    )?;
    // declare a new context. In spark API, this corresponds to a new spark SQLsession
    let mut ctx = ExecutionContext::new();
    // declare a table in memory. In spark API, this corresponds to createDataFrame(...).
    let provider = MemTable::try_new(schema, vec![vec![batch]])?;
    ctx.register_table("t", Box::new(provider));
    Ok(ctx)
}
fn create_context ( ) -> Result < ExecutionContext > { use arrow :: datatypes :: { Field , Schema } ; use datafusion :: datasource :: MemTable ; // define a schema. let schema = Arc :: new ( Schema :: new ( vec ! [ Field new ( " " DataType Float32 false ) Field new ( " " DataType Float64 false ) ] ) ) ; // define data. let batch = RecordBatch :: try_new ( schema . clone ( ) , vec ! [ Arc new ( Float32Array from ( vec [ 2.1 3.1 4.1 5.1 ] ) ) Arc new ( Float64Array from ( vec [ 1.0 2.0 3.0 4.0 ] ) ) ] , ) ? ; // declare a new context. In spark API, this corresponds to a new spark SQLsession let mut ctx = ExecutionContext :: new ( ) ; // declare a table in memory. In spark API, this corresponds to createDataFrame(...). let provider = MemTable :: try_new ( schema , vec ! [ vec [ batch ] ] ) ? ; ctx . register_table ( " " , Box :: new ( provider ) ) ; Ok ( ctx ) }
create local execution context with an in-memory table
create local execution context with an in - memory table