Skip to content

Commit

Permalink
fix parquet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Blizzara committed Dec 13, 2024
1 parent 53d96be commit 38cdbf2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions datafusion/core/src/datasource/file_format/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,10 +2251,12 @@ mod tests {
scan_format(state, &*format, &testdata, file_name, projection, limit).await
}

/// Test that 0-byte files don't break while reading
#[tokio::test]
async fn test_read_empty_parquet() -> Result<()> {
let testdata = crate::test_util::parquet_test_data();
let path = format!("{testdata}/empty.parquet");
let tmp_dir = tempfile::TempDir::new().unwrap();
let path = format!("{}/empty.parquet", tmp_dir.path().to_string_lossy());
File::create(&path).await?;

let ctx = SessionContext::new();

Expand All @@ -2272,16 +2274,21 @@ mod tests {
Ok(())
}

/// Test that 0-byte files don't break while reading
#[tokio::test]
async fn test_read_partitioned_empty_parquet() -> Result<()> {
let testdata = crate::test_util::parquet_test_data();
let path = format!("{testdata}/partitioned/");
let tmp_dir = tempfile::TempDir::new().unwrap();
let partition_dir = tmp_dir.path().join("col1=a");
std::fs::create_dir(&partition_dir).unwrap();
File::create(partition_dir.join("empty.parquet"))
.await
.unwrap();

let ctx = SessionContext::new();

let df = ctx
.read_parquet(
&path,
tmp_dir.path().to_str().unwrap(),
ParquetReadOptions::new()
.table_partition_cols(vec![("col1".to_string(), DataType::Utf8)]),
)
Expand Down
2 changes: 1 addition & 1 deletion parquet-testing

0 comments on commit 38cdbf2

Please sign in to comment.