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

Function test_json_array_from_stream

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

Source from the content-addressed store, hash-verified

569
570 #[tokio::test]
571 async fn test_json_array_from_stream() -> Result<()> {
572 // Test reading JSON array format from object store stream (simulates S3)
573 let json_data = r#"[{"id": 1, "name": "alice"}, {"id": 2, "name": "bob"}, {"id": 3, "name": "charlie"}]"#;
574
575 // Use InMemory store which returns Stream payload
576 let store = Arc::new(InMemory::new());
577 let path = Path::from("test_stream.json");
578 store
579 .put(&path, PutPayload::from_static(json_data.as_bytes()))
580 .await?;
581
582 let opener = JsonOpener::new(
583 2, // small batch size to test multiple batches
584 test_schema(),
585 FileCompressionType::UNCOMPRESSED,
586 store.clone(),
587 false, // JSON array format
588 );
589
590 let meta = store.head(&path).await?;
591 let file = PartitionedFile::new(path.to_string(), meta.size);
592
593 let stream = opener.open(file)?.await?;
594 let batches: Vec<_> = stream.try_collect().await?;
595
596 let total_rows: usize = batches.iter().map(|b| b.num_rows()).sum();
597 assert_eq!(total_rows, 3);
598
599 Ok(())
600 }
601
602 #[tokio::test]
603 async fn test_json_array_nested_objects() -> Result<()> {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
sumMethod · 0.80
test_schemaFunction · 0.70
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…