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

Function test_work_table_exec

datafusion/physical-plan/src/work_table.rs:304–350  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302
303 #[tokio::test]
304 async fn test_work_table_exec() {
305 let schema = Arc::new(Schema::new(vec![
306 Field::new("a", DataType::Int64, false),
307 Field::new("b", DataType::Int32, false),
308 Field::new("c", DataType::Int16, false),
309 ]));
310 let work_table_exec =
311 WorkTableExec::new("wt".into(), Arc::clone(&schema), Some(vec![2, 1]))
312 .unwrap();
313
314 // We inject the work table
315 let work_table = Arc::new(WorkTable::new("wt".into()));
316 let work_table_exec = work_table_exec
317 .with_new_state(Arc::clone(&work_table) as _)
318 .unwrap();
319
320 // We update the work table
321 let pool = Arc::new(UnboundedMemoryPool::default()) as _;
322 let reservation = MemoryConsumer::new("test_work_table").register(&pool);
323 let batch = RecordBatch::try_new(
324 Arc::clone(&schema),
325 vec![
326 Arc::new(Int64Array::from(vec![1, 2, 3, 4, 5])),
327 Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5])),
328 Arc::new(Int16Array::from(vec![1, 2, 3, 4, 5])),
329 ],
330 )
331 .unwrap();
332 work_table.update(ReservedBatches::new(vec![batch], reservation));
333
334 // We get back the batch from the work table
335 let returned_batch = work_table_exec
336 .execute(0, Arc::new(TaskContext::default()))
337 .unwrap()
338 .next()
339 .await
340 .unwrap()
341 .unwrap();
342 assert_eq!(
343 returned_batch,
344 RecordBatch::try_from_iter(vec![
345 ("c", Arc::new(Int16Array::from(vec![1, 2, 3, 4, 5])) as _),
346 ("b", Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5])) as _),
347 ])
348 .unwrap()
349 );
350 }
351}

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
intoMethod · 0.45
with_new_stateMethod · 0.45
registerMethod · 0.45
updateMethod · 0.45
nextMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…