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

Function test_json_array_large_file

datafusion/datasource-json/src/source.rs:738–776  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

736
737 #[tokio::test]
738 async fn test_json_array_large_file() -> Result<()> {
739 // Test with a larger JSON array to verify streaming works
740 let mut json_data = String::from("[");
741 for i in 0..1000 {
742 if i > 0 {
743 json_data.push(',');
744 }
745 json_data.push_str(&format!(r#"{{"id": {i}, "name": "user{i}"}}"#));
746 }
747 json_data.push(']');
748
749 let store = Arc::new(InMemory::new());
750 let path = Path::from("large.json");
751 store
752 .put(&path, PutPayload::from(Bytes::from(json_data)))
753 .await?;
754
755 let opener = JsonOpener::new(
756 100, // batch size of 100
757 test_schema(),
758 FileCompressionType::UNCOMPRESSED,
759 store.clone(),
760 false,
761 );
762
763 let meta = store.head(&path).await?;
764 let file = PartitionedFile::new(path.to_string(), meta.size);
765
766 let stream = opener.open(file)?.await?;
767 let batches: Vec<_> = stream.try_collect().await?;
768
769 let total_rows: usize = batches.iter().map(|b| b.num_rows()).sum();
770 assert_eq!(total_rows, 1000);
771
772 // Should have multiple batches due to batch_size=100
773 assert!(batches.len() >= 10);
774
775 Ok(())
776 }
777
778 #[tokio::test]
779 async fn test_json_array_stream_cancellation() -> Result<()> {

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
sumMethod · 0.80
test_schemaFunction · 0.70
pushMethod · 0.45
putMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45
openMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…