Create a [`DataFrame`] for reading a [`Vec[`RecordBatch`]`]
(
&self,
batches: impl IntoIterator<Item = RecordBatch>,
)
| 1783 | } |
| 1784 | /// Create a [`DataFrame`] for reading a [`Vec[`RecordBatch`]`] |
| 1785 | pub fn read_batches( |
| 1786 | &self, |
| 1787 | batches: impl IntoIterator<Item = RecordBatch>, |
| 1788 | ) -> Result<DataFrame> { |
| 1789 | // check schema uniqueness |
| 1790 | let mut batches = batches.into_iter().peekable(); |
| 1791 | let schema = if let Some(batch) = batches.peek() { |
| 1792 | batch.schema() |
| 1793 | } else { |
| 1794 | Arc::new(Schema::empty()) |
| 1795 | }; |
| 1796 | let provider = MemTable::try_new(schema, vec![batches.collect()])?; |
| 1797 | Ok(DataFrame::new( |
| 1798 | self.state(), |
| 1799 | LogicalPlanBuilder::scan( |
| 1800 | UNNAMED_TABLE, |
| 1801 | provider_as_source(Arc::new(provider)), |
| 1802 | None, |
| 1803 | )? |
| 1804 | .build()?, |
| 1805 | )) |
| 1806 | } |
| 1807 | /// Registers a [`ListingTable`] that can assemble multiple files |
| 1808 | /// from locations in an [`ObjectStore`] instance into a single |
| 1809 | /// table. |