Jefffrey commented on code in PR #9197:
URL: https://github.com/apache/arrow-datafusion/pull/9197#discussion_r1487637459
##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -934,7 +935,30 @@ impl SessionContext {
.build()?,
))
}
-
+ /// Create a [`DataFrame`] for reading a [`Vec[`RecordBatch`]`]
+ pub fn read_batches(
+ &self,
+ batches: impl IntoIterator<Item = RecordBatch>,
+ ) -> Result<DataFrame> {
+ // check schema uniqueness
+ let mut batches = batches.into_iter().peekable();
+ let schema = if let Some(batch) = batches.peek() {
+ batch.schema().clone()
+ } else {
+ Arc::new(Schema::empty())
+ };
+ let provider =
+ MemTable::try_new(schema, batches.map(|batch|
vec![batch]).collect())?;
Review Comment:
Hmm, is there any difference to mapping each batch into its own vec (which
seemingly represents a different partition?) vs just collecting the batches
into a single vec and passing in a single vec?
e.g. something like
```suggestion
let provider =
MemTable::try_new(schema, vec![batches.collect()])?;
```
--
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]