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

Function exec_with_limit

datafusion/datasource/src/memory.rs:860–883  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

858
859 #[tokio::test]
860 async fn exec_with_limit() -> Result<()> {
861 let task_ctx = Arc::new(TaskContext::default());
862 let batch = make_partition(7);
863 let schema = batch.schema();
864 let batches = vec![batch.clone(), batch];
865
866 let exec = MemorySourceConfig::try_new_from_batches(schema, batches).unwrap();
867 assert_eq!(exec.fetch(), None);
868
869 let exec = exec.with_fetch(Some(4)).unwrap();
870 assert_eq!(exec.fetch(), Some(4));
871
872 let mut it = exec.execute(0, task_ctx)?;
873 let mut results = vec![];
874 while let Some(batch) = it.next().await {
875 results.push(batch?);
876 }
877
878 let expected = [
879 "+---+", "| i |", "+---+", "| 0 |", "| 1 |", "| 2 |", "| 3 |", "+---+",
880 ];
881 assert_batches_eq!(expected, &results);
882 Ok(())
883 }
884
885 /// Test that `try_swapping_with_projection` preserves the `fetch` limit.
886 /// Regression test for <https://github.com/apache/datafusion/issues/21176>

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
make_partitionFunction · 0.70
schemaMethod · 0.45
with_fetchMethod · 0.45
executeMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…