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

Function test_ndjson_still_works

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

Source from the content-addressed store, hash-verified

704
705 #[tokio::test]
706 async fn test_ndjson_still_works() -> Result<()> {
707 // Ensure NDJSON format still works correctly
708 let json_data =
709 "{\"id\": 1, \"name\": \"alice\"}\n{\"id\": 2, \"name\": \"bob\"}\n";
710
711 let store = Arc::new(InMemory::new());
712 let path = Path::from("test.ndjson");
713 store
714 .put(&path, PutPayload::from_static(json_data.as_bytes()))
715 .await?;
716
717 let opener = JsonOpener::new(
718 1024,
719 test_schema(),
720 FileCompressionType::UNCOMPRESSED,
721 store.clone(),
722 true, // NDJSON format
723 );
724
725 let meta = store.head(&path).await?;
726 let file = PartitionedFile::new(path.to_string(), meta.size);
727
728 let stream = opener.open(file)?.await?;
729 let batches: Vec<_> = stream.try_collect().await?;
730
731 assert_eq!(batches.len(), 1);
732 assert_eq!(batches[0].num_rows(), 2);
733
734 Ok(())
735 }
736
737 #[tokio::test]
738 async fn test_json_array_large_file() -> Result<()> {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
test_schemaFunction · 0.70
putMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…