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

Method read_data

datafusion-examples/examples/data_io/remote_catalog.rs:158–178  ·  view source on GitHub ↗

Fetches data for a table from a remote data source

(&self, name: &str)

Source from the content-addressed store, hash-verified

156
157 /// Fetches data for a table from a remote data source
158 pub async fn read_data(&self, name: &str) -> Result<SendableRecordBatchStream> {
159 if name != "remote_table" {
160 return plan_err!("Remote table not found: {}", name);
161 }
162
163 // In a real remote catalog this call would likely perform network IO to
164 // open and begin reading from a remote datasource, prefetching
165 // information, etc.
166 //
167 // In this example we are just demonstrating how the API works so simply
168 // return back some static data as a stream.
169 let batch = record_batch!(
170 ("id", Int32, [1, 2, 3]),
171 ("name", Utf8, ["alpha", "beta", "gamma"])
172 )
173 .unwrap();
174 let schema = batch.schema();
175
176 let stream = futures::stream::iter([Ok(batch)]);
177 Ok(Box::pin(RecordBatchStreamAdapter::new(schema, stream)))
178 }
179}
180
181/// Implements an async version of the DataFusion SchemaProvider API for tables

Callers 1

scanMethod · 0.80

Calls 2

newFunction · 0.85
schemaMethod · 0.45

Tested by

no test coverage detected