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

Method result

datafusion/datasource/src/file_stream/mod.rs:293–339  ·  view source on GitHub ↗

Collect the results of the `FileStream`

(self)

Source from the content-addressed store, hash-verified

291
292 /// Collect the results of the `FileStream`
293 pub async fn result(self) -> Result<Vec<RecordBatch>> {
294 let file_schema = self
295 .opener
296 .records
297 .first()
298 .map(|batch| batch.schema())
299 .unwrap_or_else(|| Arc::new(Schema::empty()));
300
301 // let ctx = SessionContext::new();
302 let mock_files: Vec<(String, u64)> = (0..self.num_files)
303 .map(|idx| (format!("mock_file{idx}"), 10_u64))
304 .collect();
305
306 // let mock_files_ref: Vec<(&str, u64)> = mock_files
307 // .iter()
308 // .map(|(name, size)| (name.as_str(), *size))
309 // .collect();
310
311 let file_group = mock_files
312 .into_iter()
313 .map(|(name, size)| PartitionedFile::new(name, size))
314 .collect();
315
316 let on_error = self.on_error;
317
318 let table_schema = TableSchema::new(file_schema, vec![]);
319 let config = FileScanConfigBuilder::new(
320 ObjectStoreUrl::parse("test:///").unwrap(),
321 Arc::new(MockSource::new(table_schema)),
322 )
323 .with_file_group(file_group)
324 .with_limit(self.limit)
325 .build();
326 let metrics_set = ExecutionPlanMetricsSet::new();
327 let file_stream = FileStreamBuilder::new(&config)
328 .with_partition(0)
329 .with_file_opener(Arc::new(self.opener))
330 .with_metrics(&metrics_set)
331 .with_on_error(on_error)
332 .build()?;
333
334 file_stream
335 .collect::<Vec<_>>()
336 .await
337 .into_iter()
338 .collect::<Result<Vec<_>>>()
339 }
340 }
341
342 /// helper that creates a stream of 2 files with the same pair of batches in each ([0,1,2] and [0,1])

Callers 6

create_and_collectFunction · 0.80
on_error_openingFunction · 0.80
on_error_scanning_failFunction · 0.80
on_error_opening_failFunction · 0.80
on_error_scanningFunction · 0.80
on_error_mixedFunction · 0.80

Calls 14

newFunction · 0.85
collectMethod · 0.80
with_file_groupMethod · 0.80
emptyFunction · 0.50
mapMethod · 0.45
firstMethod · 0.45
schemaMethod · 0.45
into_iterMethod · 0.45
buildMethod · 0.45
with_limitMethod · 0.45
with_on_errorMethod · 0.45
with_metricsMethod · 0.45

Tested by

no test coverage detected