You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "xudong963 (via GitHub)" <gi...@apache.org> on 2025/05/21 10:20:11 UTC
[PR] Fix parquet test using wrong schema [datafusion]
xudong963 opened a new pull request, #16133:
URL: https://github.com/apache/datafusion/pull/16133
## 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.
-->
When I review the PR: https://github.com/apache/datafusion/pull/16086, I found the test of parquet using the wrong schema to build predicates.
## 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.
-->
Using table schema to transfer logical expr to physical expr.
## 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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102026730
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -200,26 +210,43 @@ mod tests {
/// run the test, returning the `RoundTripResult`
async fn round_trip(&self, batches: Vec<RecordBatch>) -> RoundTripResult {
- let file_schema = match &self.schema {
+ self.round_trip_with_file_batches(batches, None).await
+ }
+
+ /// run the test, returning the `RoundTripResult`
+ /// If your table schema is different from file schema, you may need to specify the `file_batches` with the file schema
+ /// Or the file schema in the parquet source will be table schema, see `store_parquet` for detail
+ async fn round_trip_with_file_batches(
+ &self,
+ batches: Vec<RecordBatch>,
+ file_batches: Option<Vec<RecordBatch>>,
+ ) -> RoundTripResult {
+ let batches_schema =
+ Schema::try_merge(batches.iter().map(|b| b.schema().as_ref().clone()));
+ let file_schema = match &self.physical_file_schema {
Some(schema) => schema,
- None => &Arc::new(
- Schema::try_merge(
- batches.iter().map(|b| b.schema().as_ref().clone()),
- )
- .unwrap(),
- ),
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
};
let file_schema = Arc::clone(file_schema);
+ let table_schema = match &self.logical_file_schema {
+ Some(schema) => schema,
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
+ };
+
// If testing with page_index_predicate, write parquet
// files with multiple pages
let multi_page = self.page_index_predicate;
- let (meta, _files) = store_parquet(batches, multi_page).await.unwrap();
Review Comment:
The original code uses `batches` to write parquet files, and the physical file schema used in the parquet source will be table schema(logical file schema), so the tests in https://github.com/apache/datafusion/pull/16086 may be meaningless.
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102026730
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -200,26 +210,43 @@ mod tests {
/// run the test, returning the `RoundTripResult`
async fn round_trip(&self, batches: Vec<RecordBatch>) -> RoundTripResult {
- let file_schema = match &self.schema {
+ self.round_trip_with_file_batches(batches, None).await
+ }
+
+ /// run the test, returning the `RoundTripResult`
+ /// If your table schema is different from file schema, you may need to specify the `file_batches` with the file schema
+ /// Or the file schema in the parquet source will be table schema, see `store_parquet` for detail
+ async fn round_trip_with_file_batches(
+ &self,
+ batches: Vec<RecordBatch>,
+ file_batches: Option<Vec<RecordBatch>>,
+ ) -> RoundTripResult {
+ let batches_schema =
+ Schema::try_merge(batches.iter().map(|b| b.schema().as_ref().clone()));
+ let file_schema = match &self.physical_file_schema {
Some(schema) => schema,
- None => &Arc::new(
- Schema::try_merge(
- batches.iter().map(|b| b.schema().as_ref().clone()),
- )
- .unwrap(),
- ),
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
};
let file_schema = Arc::clone(file_schema);
+ let table_schema = match &self.logical_file_schema {
+ Some(schema) => schema,
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
+ };
+
// If testing with page_index_predicate, write parquet
// files with multiple pages
let multi_page = self.page_index_predicate;
- let (meta, _files) = store_parquet(batches, multi_page).await.unwrap();
Review Comment:
The original code uses `batches` to write parquet files, which will result in the physical file schema used in the parquet source being the table schema(logical file schema), so the tests in https://github.com/apache/datafusion/pull/16086 may be meaningless.
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102030382
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -887,11 +931,12 @@ mod tests {
assert_eq!(rt.batches.unwrap().len(), 0);
// Predicate should prune no row groups
- let filter = col("c1").eq(lit(ScalarValue::Utf8(Some("foo".to_string()))));
+ let filter = col("c1").eq(lit(ScalarValue::Utf8View(Some("foo".to_string()))));
Review Comment:
ditto
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#issuecomment-2902058974
Let me see if I can come up with something different
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#issuecomment-2897577975
> says this test shouldn't pass on main, yet the CI seems to be green.
Sorry for the confusion.
The PR #16086 is needed
You can see the comment: https://github.com/apache/datafusion/pull/16086#discussion_r2099949463, what I mean is that test in #16086 is a bit unreasonable, it's using file schema(utf8) to construct the logical filter expr. We should use table schema to construct logical filter expr. However, if using table schema to construct, the test in PR#16086 will fail because https://github.com/apache/datafusion/pull/16086/files#diff-c8eebe4fb9ee7662170c6ce507ad2be92c0229b3a91a2f4431a9bfc7185a0eb9L148 (uses file_schema to transfer logical expr to physical expr), my PR fixes there, using table schema to transfer logical expr to physical expr.
https://github.com/apache/datafusion/pull/16086#pullrequestreview-2857209714 The review is saying that I used the following test to verify in different branches, the test uses table schema to build filter, to guarantee I can run the test smoothly, I need the PR's fix or it'll fail as I said above. Without #16086, the main will fail as expected, so I use ❌.
```rust
let c1: ArrayRef =
Arc::new(StringArray::from(vec![Some("foo"), Some("bar")]));
let batch = create_batch(vec![("c1", c1.clone())]);
let schema = Arc::new(Schema::new(vec![Field::new("c1", DataType::Utf8View, false)]));
// Predicate should prune all row groups
let filter = col("c1").eq(lit(ScalarValue::Utf8(Some("aaa".to_string()))));
```
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#issuecomment-2902102034
> Let me see if I can come up with something different
I spent some time reviewing the tests and I think they are using the correct schema. I made a PR to try and clarify the comments
- https://github.com/apache/datafusion/pull/16155
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102030020
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -867,18 +904,25 @@ mod tests {
#[tokio::test]
async fn evolved_schema_column_type_filter_strings() {
// The table and filter have a common data type, but the file schema differs
- let c1: ArrayRef =
- Arc::new(StringViewArray::from(vec![Some("foo"), Some("bar")]));
- let batch = create_batch(vec![("c1", c1.clone())]);
+ let table_schema = Arc::new(Schema::new(vec![Field::new(
+ "c1",
+ DataType::Utf8View,
+ false,
+ )]));
- let schema = Arc::new(Schema::new(vec![Field::new("c1", DataType::Utf8, false)]));
+ let file_schema =
+ Arc::new(Schema::new(vec![Field::new("c1", DataType::Utf8, false)]));
+ let file_c1: ArrayRef =
+ Arc::new(StringArray::from(vec![Some("foo"), Some("bar")]));
+ let file_batch = create_batch(vec![("c1", file_c1.clone())]);
// Predicate should prune all row groups
- let filter = col("c1").eq(lit(ScalarValue::Utf8(Some("aaa".to_string()))));
+ let filter = col("c1").eq(lit(ScalarValue::Utf8View(Some("aaa".to_string()))));
Review Comment:
Use `Utf8View` to align with `table_schema`
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2103082309
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -909,30 +954,34 @@ mod tests {
#[tokio::test]
async fn evolved_schema_column_type_filter_ints() {
// The table and filter have a common data type, but the file schema differs
- let c1: ArrayRef = Arc::new(Int8Array::from(vec![Some(1), Some(2)]));
- let batch = create_batch(vec![("c1", c1.clone())]);
+ let table_schema =
+ Arc::new(Schema::new(vec![Field::new("c1", DataType::Int8, false)]));
- let schema =
+ let file_schema =
Arc::new(Schema::new(vec![Field::new("c1", DataType::UInt64, false)]));
+ let file_c1: ArrayRef = Arc::new(UInt64Array::from(vec![Some(1), Some(2)]));
+ let file_batch = create_batch(vec![("c1", file_c1.clone())]);
// Predicate should prune all row groups
- let filter = col("c1").eq(lit(ScalarValue::UInt64(Some(5))));
+ let filter = col("c1").eq(lit(ScalarValue::Int8(Some(5))));
Review Comment:
This change makes sense to me
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -200,26 +210,43 @@ mod tests {
/// run the test, returning the `RoundTripResult`
async fn round_trip(&self, batches: Vec<RecordBatch>) -> RoundTripResult {
- let file_schema = match &self.schema {
+ self.round_trip_with_file_batches(batches, None).await
+ }
+
+ /// run the test, returning the `RoundTripResult`
+ /// If your table schema is different from file schema, you may need to specify the `file_batches` with the file schema
+ /// Or the file schema in the parquet source will be table schema, see `store_parquet` for detail
+ async fn round_trip_with_file_batches(
+ &self,
+ batches: Vec<RecordBatch>,
+ file_batches: Option<Vec<RecordBatch>>,
+ ) -> RoundTripResult {
+ let batches_schema =
+ Schema::try_merge(batches.iter().map(|b| b.schema().as_ref().clone()));
+ let file_schema = match &self.physical_file_schema {
Some(schema) => schema,
- None => &Arc::new(
- Schema::try_merge(
- batches.iter().map(|b| b.schema().as_ref().clone()),
- )
- .unwrap(),
- ),
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
};
let file_schema = Arc::clone(file_schema);
+ let table_schema = match &self.logical_file_schema {
+ Some(schema) => schema,
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
+ };
+
// If testing with page_index_predicate, write parquet
// files with multiple pages
let multi_page = self.page_index_predicate;
- let (meta, _files) = store_parquet(batches, multi_page).await.unwrap();
Review Comment:
I am a little confused about this -- it makes more sense to me that the batches that are written to the file define the file schema.
When the file is read back, that schema may be different (because the table may have a different schema)
I think the key difference is testing when the table schema is different than the file schema
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102028642
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -200,26 +210,43 @@ mod tests {
/// run the test, returning the `RoundTripResult`
async fn round_trip(&self, batches: Vec<RecordBatch>) -> RoundTripResult {
- let file_schema = match &self.schema {
+ self.round_trip_with_file_batches(batches, None).await
+ }
+
+ /// run the test, returning the `RoundTripResult`
+ /// If your table schema is different from file schema, you may need to specify the `file_batches` with the file schema
+ /// Or the file schema in the parquet source will be table schema, see `store_parquet` for detail
+ async fn round_trip_with_file_batches(
+ &self,
+ batches: Vec<RecordBatch>,
+ file_batches: Option<Vec<RecordBatch>>,
+ ) -> RoundTripResult {
+ let batches_schema =
+ Schema::try_merge(batches.iter().map(|b| b.schema().as_ref().clone()));
+ let file_schema = match &self.physical_file_schema {
Some(schema) => schema,
- None => &Arc::new(
- Schema::try_merge(
- batches.iter().map(|b| b.schema().as_ref().clone()),
- )
- .unwrap(),
- ),
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
};
let file_schema = Arc::clone(file_schema);
+ let table_schema = match &self.logical_file_schema {
+ Some(schema) => schema,
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
+ };
+
// If testing with page_index_predicate, write parquet
// files with multiple pages
let multi_page = self.page_index_predicate;
- let (meta, _files) = store_parquet(batches, multi_page).await.unwrap();
+ let (meta, _files) =
+ store_parquet(file_batches.unwrap_or(batches), multi_page)
Review Comment:
Here, I introduced the `file_batches` to store parquet, which means the physical file schema used in the parquet source will be the real file schema
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#issuecomment-2900453122
I made more changes and fixes, please take another look @alamb , also cc @adriangb , I changed the tests in https://github.com/apache/datafusion/pull/16086
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2102031056
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -909,30 +954,34 @@ mod tests {
#[tokio::test]
async fn evolved_schema_column_type_filter_ints() {
// The table and filter have a common data type, but the file schema differs
- let c1: ArrayRef = Arc::new(Int8Array::from(vec![Some(1), Some(2)]));
- let batch = create_batch(vec![("c1", c1.clone())]);
+ let table_schema =
+ Arc::new(Schema::new(vec![Field::new("c1", DataType::Int8, false)]));
- let schema =
+ let file_schema =
Arc::new(Schema::new(vec![Field::new("c1", DataType::UInt64, false)]));
+ let file_c1: ArrayRef = Arc::new(UInt64Array::from(vec![Some(1), Some(2)]));
+ let file_batch = create_batch(vec![("c1", file_c1.clone())]);
// Predicate should prune all row groups
- let filter = col("c1").eq(lit(ScalarValue::UInt64(Some(5))));
+ let filter = col("c1").eq(lit(ScalarValue::Int8(Some(5))));
Review Comment:
Use `Int8` to align with table schema
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -909,30 +954,34 @@ mod tests {
#[tokio::test]
async fn evolved_schema_column_type_filter_ints() {
// The table and filter have a common data type, but the file schema differs
- let c1: ArrayRef = Arc::new(Int8Array::from(vec![Some(1), Some(2)]));
- let batch = create_batch(vec![("c1", c1.clone())]);
+ let table_schema =
+ Arc::new(Schema::new(vec![Field::new("c1", DataType::Int8, false)]));
- let schema =
+ let file_schema =
Arc::new(Schema::new(vec![Field::new("c1", DataType::UInt64, false)]));
+ let file_c1: ArrayRef = Arc::new(UInt64Array::from(vec![Some(1), Some(2)]));
+ let file_batch = create_batch(vec![("c1", file_c1.clone())]);
// Predicate should prune all row groups
- let filter = col("c1").eq(lit(ScalarValue::UInt64(Some(5))));
+ let filter = col("c1").eq(lit(ScalarValue::Int8(Some(5))));
let rt = RoundTrip::new()
.with_predicate(filter)
- .with_schema(schema.clone())
- .round_trip(vec![batch.clone()])
+ .with_physical_file_schema(file_schema.clone())
+ .with_logical_file_schema(table_schema.clone())
+ .round_trip_with_file_batches(vec![], Some(vec![file_batch.clone()]))
.await;
// There should be no predicate evaluation errors
let metrics = rt.parquet_exec.metrics().unwrap();
assert_eq!(get_value(&metrics, "predicate_evaluation_errors"), 0);
assert_eq!(rt.batches.unwrap().len(), 0);
// Predicate should prune no row groups
- let filter = col("c1").eq(lit(ScalarValue::UInt64(Some(1))));
+ let filter = col("c1").eq(lit(ScalarValue::Int8(Some(1))));
Review Comment:
ditto
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #16133:
URL: https://github.com/apache/datafusion/pull/16133#discussion_r2105700747
##########
datafusion/core/src/datasource/physical_plan/parquet.rs:
##########
@@ -200,26 +210,43 @@ mod tests {
/// run the test, returning the `RoundTripResult`
async fn round_trip(&self, batches: Vec<RecordBatch>) -> RoundTripResult {
- let file_schema = match &self.schema {
+ self.round_trip_with_file_batches(batches, None).await
+ }
+
+ /// run the test, returning the `RoundTripResult`
+ /// If your table schema is different from file schema, you may need to specify the `file_batches` with the file schema
+ /// Or the file schema in the parquet source will be table schema, see `store_parquet` for detail
+ async fn round_trip_with_file_batches(
+ &self,
+ batches: Vec<RecordBatch>,
+ file_batches: Option<Vec<RecordBatch>>,
+ ) -> RoundTripResult {
+ let batches_schema =
+ Schema::try_merge(batches.iter().map(|b| b.schema().as_ref().clone()));
+ let file_schema = match &self.physical_file_schema {
Some(schema) => schema,
- None => &Arc::new(
- Schema::try_merge(
- batches.iter().map(|b| b.schema().as_ref().clone()),
- )
- .unwrap(),
- ),
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
};
let file_schema = Arc::clone(file_schema);
+ let table_schema = match &self.logical_file_schema {
+ Some(schema) => schema,
+ None => &Arc::new(batches_schema.as_ref().unwrap().clone()),
+ };
+
// If testing with page_index_predicate, write parquet
// files with multiple pages
let multi_page = self.page_index_predicate;
- let (meta, _files) = store_parquet(batches, multi_page).await.unwrap();
Review Comment:
Yes, this is my aim in the PR
--
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] Fix parquet test using wrong schema [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 closed pull request #16133: Fix parquet test using wrong schema
URL: https://github.com/apache/datafusion/pull/16133
--
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