| 538 | |
| 539 | #[tokio::test] |
| 540 | async fn test_json_array_from_file() -> Result<()> { |
| 541 | // Test reading JSON array format from a file |
| 542 | let json_data = r#"[{"id": 1, "name": "alice"}, {"id": 2, "name": "bob"}]"#; |
| 543 | |
| 544 | let store = Arc::new(InMemory::new()); |
| 545 | let path = Path::from("test.json"); |
| 546 | store |
| 547 | .put(&path, PutPayload::from_static(json_data.as_bytes())) |
| 548 | .await?; |
| 549 | |
| 550 | let opener = JsonOpener::new( |
| 551 | 1024, |
| 552 | test_schema(), |
| 553 | FileCompressionType::UNCOMPRESSED, |
| 554 | store.clone(), |
| 555 | false, // JSON array format |
| 556 | ); |
| 557 | |
| 558 | let meta = store.head(&path).await?; |
| 559 | let file = PartitionedFile::new(path.to_string(), meta.size); |
| 560 | |
| 561 | let stream = opener.open(file)?.await?; |
| 562 | let batches: Vec<_> = stream.try_collect().await?; |
| 563 | |
| 564 | assert_eq!(batches.len(), 1); |
| 565 | assert_eq!(batches[0].num_rows(), 2); |
| 566 | |
| 567 | Ok(()) |
| 568 | } |
| 569 | |
| 570 | #[tokio::test] |
| 571 | async fn test_json_array_from_stream() -> Result<()> { |