Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions datafusion/wasmtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,29 @@ mod test {
let task_ctx = ctx.task_ctx();
let _ = collect(physical_plan, task_ctx).await.unwrap();
}

#[wasm_bindgen_test(unsupported = tokio::test)]
async fn test_parquet_write() {
let schema = Arc::new(Schema::new(vec![
Field::new("id", DataType::Int32, false),
Field::new("value", DataType::Utf8, false),
]));

let data: Vec<ArrayRef> = vec![
Arc::new(Int32Array::from(vec![1])),
Arc::new(StringArray::from(vec!["a"])),
];

let batch = RecordBatch::try_new(schema.clone(), data).unwrap();
let mut buffer = Vec::new();
let mut writer = datafusion::parquet::arrow::ArrowWriter::try_new(
&mut buffer,
schema.clone(),
None,
)
.unwrap();

writer.write(&batch).unwrap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pranavJibhakate !

Would you be willing to add a test that the same data could be read back from the parquet file as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; I think the current code tests the re-exported Parquet functionalities, not touching the DataFusion-related code. Ideally, we should test the end-to-end Parquet reading process.

The process roughly looks like this:

  1. Create a in-memory object_store, and put the Parquet data you generated into the object_store.
  2. Register the object_store along with the path to the DataFusion.
  3. Run a SQL query from the DataFusion side to see if the results can be read back.

A loosely related test can be found here: https://github.com/XiangpengHao/parquet-viewer/blob/main/src/tests.rs#L9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed a ticket to track this work:

writer.close().unwrap();
}
}