Skip to content

Commit a0bdc25

Browse files
committed
fmt
1 parent 64feac6 commit a0bdc25

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

datafusion/core/src/datasource/file_format/json.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,16 @@ mod tests {
517517
.await?;
518518

519519
// Scan and read data
520-
let exec = scan_format(&ctx, &format, Some(file_schema), tmp_dir.path().to_str().unwrap(), "array.json", None, None).await?;
520+
let exec = scan_format(
521+
&ctx,
522+
&format,
523+
Some(file_schema),
524+
tmp_dir.path().to_str().unwrap(),
525+
"array.json",
526+
None,
527+
None,
528+
)
529+
.await?;
521530
let batches = collect(exec, task_ctx).await?;
522531

523532
assert_eq!(1, batches.len());
@@ -526,7 +535,10 @@ mod tests {
526535

527536
// Verify data
528537
let array_a = as_int64_array(batches[0].column(0))?;
529-
assert_eq!(vec![1, 2, 3], (0..3).map(|i| array_a.value(i)).collect::<Vec<_>>());
538+
assert_eq!(
539+
vec![1, 2, 3],
540+
(0..3).map(|i| array_a.value(i)).collect::<Vec<_>>()
541+
);
530542

531543
Ok(())
532544
}
@@ -540,18 +552,24 @@ mod tests {
540552

541553
let tmp_dir = tempfile::TempDir::new()?;
542554
let path = format!("{}/array.json", tmp_dir.path().to_string_lossy());
543-
std::fs::write(
544-
&path,
545-
r#"[{"a": 1, "b": "hello"}, {"a": 2, "b": "world"}]"#,
546-
)?;
555+
std::fs::write(&path, r#"[{"a": 1, "b": "hello"}, {"a": 2, "b": "world"}]"#)?;
547556

548557
let format = JsonFormat::default().with_format_array(true);
549558
let file_schema = format
550559
.infer_schema(&ctx, &store, &[local_unpartitioned_file(&path)])
551560
.await?;
552561

553562
// Project only column "a"
554-
let exec = scan_format(&ctx, &format, Some(file_schema), tmp_dir.path().to_str().unwrap(), "array.json", Some(vec![0]), None).await?;
563+
let exec = scan_format(
564+
&ctx,
565+
&format,
566+
Some(file_schema),
567+
tmp_dir.path().to_str().unwrap(),
568+
"array.json",
569+
Some(vec![0]),
570+
None,
571+
)
572+
.await?;
555573
let batches = collect(exec, task_ctx).await?;
556574

557575
assert_eq!(1, batches.len());

datafusion/datasource-json/src/file_format.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ fn infer_json_schema_from_json_array<R: Read>(
211211
})?;
212212

213213
// Parse as JSON array using serde_json
214-
let values: Vec<serde_json::Value> = serde_json::from_str(&content).map_err(|e| {
215-
ArrowError::JsonError(format!("Failed to parse JSON array: {e}"))
216-
})?;
214+
let values: Vec<serde_json::Value> = serde_json::from_str(&content)
215+
.map_err(|e| ArrowError::JsonError(format!("Failed to parse JSON array: {e}")))?;
217216

218217
// Take only max_records for schema inference
219218
let values_to_infer: Vec<_> = values.into_iter().take(max_records).collect();

0 commit comments

Comments
 (0)