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

Function read_small_batches

datafusion/core/src/datasource/file_format/csv.rs:195–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193
194 #[tokio::test]
195 async fn read_small_batches() -> Result<()> {
196 let config = SessionConfig::new().with_batch_size(2);
197 let session_ctx = SessionContext::new_with_config(config);
198 let state = session_ctx.state();
199 let task_ctx = state.task_ctx();
200 // skip column 9 that overflows the automatically discovered column type of i64 (u64 would work)
201 let projection = Some(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12]);
202 let exec =
203 get_exec(&state, "aggregate_test_100.csv", projection, None, true).await?;
204 let stream = exec.execute(0, task_ctx)?;
205
206 let tt_batches: i32 = stream
207 .map(|batch| {
208 let batch = batch.unwrap();
209 assert_eq!(12, batch.num_columns());
210 assert_eq!(2, batch.num_rows());
211 })
212 .fold(0, |acc, _| async move { acc + 1i32 })
213 .await;
214
215 assert_eq!(tt_batches, 50 /* 100/2 */);
216
217 // test metadata
218 assert_eq!(exec.partition_statistics(None)?.num_rows, Precision::Absent);
219 assert_eq!(
220 exec.partition_statistics(None)?.total_byte_size,
221 Precision::Absent
222 );
223
224 Ok(())
225 }
226
227 #[tokio::test]
228 async fn read_limit() -> Result<()> {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
get_execFunction · 0.70
with_batch_sizeMethod · 0.45
stateMethod · 0.45
task_ctxMethod · 0.45
executeMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…