alamb opened a new issue, #3426:
URL: https://github.com/apache/arrow-datafusion/issues/3426

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   For testing (and those new to DataFusion) it would be very convenient to run 
a query against a single `RecordBatch` as a table. This can be done with 
[MemTable](https://docs.rs/datafusion/11.0.0/datafusion/datasource/memory/struct.MemTable.html)
 but it adds that much more boiler plate / cognitive overhead to using 
DataFusion. 
   
   For example the MemTable allows defining multiple "streams" of record 
batches in multiple partitions (this is what the `Vec<Vec<_>>` is all about)
   
   However, most of the uses of MemTable in DataFusion (see 
[query](https://github.com/apache/arrow-datafusion/search?q=MemTable)) look 
like 
[this](https://github.com/apache/arrow-datafusion/blob/ca5339bfd27677c165263aa01f263c8fba886a45/datafusion/core/tests/dataframe.rs#L66):
   
   
   ```rust
       let table1 = MemTable::try_new(schema1, vec![vec![batch1]])?;
       ctx.register_table("aa", Arc::new(table1))?;
   ```
   
   
https://docs.rs/datafusion/11.0.0/datafusion/execution/context/struct.SessionContext.html#method.register_table
   
   
   **Describe the solution you'd like**
   
   What I would like is a function on `SessionContext` that does that work
   
   ```rust
   impl SessionContext {
   
   ...
     /// Registers the RecordBatch as the specified table name
     fn register_batch(table_name: &str, batch: RecordBatch) -> 
Result<Option<Arc<dyn TableProvider>>> {
        // make a memtable here, return it
        todo!()
     }
   }
   ```
   
   And then replace the uses of `MemTable` in the datafusion tests with this 
new function
   **Describe alternatives you've considered**
   A clear and concise description of any alternative solutions or features 
you've considered.
   
   **Additional context**
   
   I think this is a good first issue as the code already exists and the 
changes would be largely mechanical: updating the codebase / examples / 
documentation would be a good exercise for someone to get more experience with 
it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to