You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "pranavJibhakate (via GitHub)" <gi...@apache.org> on 2025/03/19 22:58:01 UTC
[PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
pranavJibhakate opened a new pull request, #15325:
URL: https://github.com/apache/datafusion/pull/15325
…15158
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #15158 .
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #15325:
URL: https://github.com/apache/datafusion/pull/15325#issuecomment-2745294019
Thanks again @pranavJibhakate
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #15325:
URL: https://github.com/apache/datafusion/pull/15325
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
Posted by "XiangpengHao (via GitHub)" <gi...@apache.org>.
XiangpengHao commented on code in PR #15325:
URL: https://github.com/apache/datafusion/pull/15325#discussion_r2008190901
##########
datafusion/wasmtest/src/lib.rs:
##########
@@ -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();
Review Comment:
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](https://docs.rs/object_store/latest/object_store/memory/struct.InMemory.html), and put the Parquet data you generated into the object_store.
2. [Register the object_store](https://github.com/apache/datafusion/blob/3269f01b42021cfab181577d579b0544808b4fca/datafusion/core/src/execution/context/mod.rs#L494) 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #15325:
URL: https://github.com/apache/datafusion/pull/15325#discussion_r2008783615
##########
datafusion/wasmtest/src/lib.rs:
##########
@@ -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();
Review Comment:
I filed a ticket to track this work:
- https://github.com/apache/datafusion/issues/15357
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Added tests with are writing into parquet files in memory for issue #… [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #15325:
URL: https://github.com/apache/datafusion/pull/15325#discussion_r2008176848
##########
datafusion/wasmtest/src/lib.rs:
##########
@@ -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();
Review Comment:
Thanks @pranavJibhakate !
Would you be willing to add a test that the same data could be read back from the parquet file as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org