MCPcopy Create free account
hub / github.com/apache/datafusion / read_batches

Method read_batches

datafusion/core/src/execution/context/mod.rs:1785–1806  ·  view source on GitHub ↗

Create a [`DataFrame`] for reading a [`Vec[`RecordBatch`]`]

(
        &self,
        batches: impl IntoIterator<Item = RecordBatch>,
    )

Source from the content-addressed store, hash-verified

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.

Callers 4

sort_batchesFunction · 0.80
unnest_non_nullable_listFunction · 0.80
test_read_batchesFunction · 0.80
test_read_batches_emptyFunction · 0.80

Calls 9

newFunction · 0.85
provider_as_sourceFunction · 0.85
peekMethod · 0.80
emptyFunction · 0.50
scanFunction · 0.50
into_iterMethod · 0.45
schemaMethod · 0.45
stateMethod · 0.45
buildMethod · 0.45

Tested by 4

sort_batchesFunction · 0.64
unnest_non_nullable_listFunction · 0.64
test_read_batchesFunction · 0.64
test_read_batches_emptyFunction · 0.64