You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "NGA-TRAN (via GitHub)" <gi...@apache.org> on 2024/05/20 21:38:42 UTC
[PR] test: add more tests for statistics reading [datafusion]
NGA-TRAN opened a new pull request, #10592:
URL: https://github.com/apache/datafusion/pull/10592
## 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.
-->
More tests for https://github.com/apache/datafusion/issues/10453
## 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] test: add more tests for statistics reading [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#issuecomment-2123171863
> What I still cannot understand is this a regression test for the bug we missed earlier?
My strong suspicion is that the bugs @NGA-TRAN is finding would manifest themselves as potentially incorrect results when reading parquet files predicates on these types of columns.
It may also simply manifest as not being able to prune row groups based on such predicates
I haven't worked to make a reproducer as it would likely require creating parquet files with multiple row groups with carefully chosen data patterns
--
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] test: add more tests for statistics reading [datafusion]
Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on code in PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#discussion_r1608870254
##########
datafusion/core/tests/parquet/arrow_statistics.rs:
##########
@@ -624,20 +624,281 @@ async fn test_dates_64_diff_rg_sizes() {
.run("date64");
}
+// BUG:
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint() {
+ let row_per_group = 4;
+
+ // This creates a parquet files of 4 columns named "u8", "u16", "u32", "u64"
+ // "u8" --> UInt8Array
+ // "u16" --> UInt16Array
+ // "u32" --> UInt32Array
+ // "u64" --> UInt64Array
+
+ // The file is created by 4 record batches (each has a null row), each has 5 rows but then will be split into 5 row groups with size 4
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+
+ // u8
+ // BUG: expect UInt8Array but returns Int32Array
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt8Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt8Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u8");
+
+ // u16
+ // BUG: expect UInt16Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt16Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt16Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u16");
+
+ // u32
+ // BUG: expect UInt32Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u32");
+
+ // u64
+ // BUG: expect UInt64rray but returns Int64Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int64Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt64Array
+ expected_max: Arc::new(Int64Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt64Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u64");
+}
+
+#[tokio::test]
+async fn test_int32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "i"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::Int32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])),
+ expected_max: Arc::new(Int32Array::from(vec![300000])),
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("i");
+}
+
+// BUG: not convert UInt32Array to Int32Array
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "u"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::UInt32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![300000])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("u");
+}
+
+#[tokio::test]
+async fn test_float64() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "f"
+ // file has 4 record batches, each has 5 rows. They will be saved into 4 row groups
+ let reader = parquet_file_many_columns(Scenario::Float64, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Float64Array::from(vec![-5.0, -4.0, -0.0, 5.0])),
+ expected_max: Arc::new(Float64Array::from(vec![-1.0, 0.0, 4.0, 9.0])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5, 5]),
+ }
+ .run("f");
+}
+
+#[tokio::test]
+async fn test_decimal() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "decimal_col" with decimal data type and precicion 9, scale 2
+ // file has 3 record batches, each has 5 rows. They will be saved into 3 row groups
+ let reader = parquet_file_many_columns(Scenario::Decimal, row_per_group).await;
Review Comment:
@alamb : can you be more specific? In the test below, I had to make sure they have the same precision & scale. What else do we have to test here?
--
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] test: add more tests for statistics reading [datafusion]
Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#issuecomment-2122987903
@alamb : This PR is ready for review
--
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] test: add more tests for statistics reading [datafusion]
Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#issuecomment-2123026061
@comphead
> What I still cannot understand is this a regression test for the bug we missed earlier?
I am working on new arrow statistics API https://github.com/apache/datafusion/issues/10453 and @alamb suggested me to add more coverage tests as well as moving tests for private functions in datafusion/core/src/datasource/physical_plan/parquet/statistics.rs to this file. Sorry that I am not aware of available/related bug tickets
--
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] test: add more tests for statistics reading [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#issuecomment-2123281857
Since this PR is just tests, merging it in
--
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] test: add more tests for statistics reading [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#discussion_r1608840230
##########
datafusion/core/tests/parquet/arrow_statistics.rs:
##########
@@ -624,20 +624,281 @@ async fn test_dates_64_diff_rg_sizes() {
.run("date64");
}
+// BUG:
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint() {
+ let row_per_group = 4;
+
+ // This creates a parquet files of 4 columns named "u8", "u16", "u32", "u64"
+ // "u8" --> UInt8Array
+ // "u16" --> UInt16Array
+ // "u32" --> UInt32Array
+ // "u64" --> UInt64Array
+
+ // The file is created by 4 record batches (each has a null row), each has 5 rows but then will be split into 5 row groups with size 4
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+
+ // u8
+ // BUG: expect UInt8Array but returns Int32Array
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt8Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt8Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u8");
+
+ // u16
+ // BUG: expect UInt16Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt16Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt16Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u16");
+
+ // u32
+ // BUG: expect UInt32Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u32");
+
+ // u64
+ // BUG: expect UInt64rray but returns Int64Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int64Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt64Array
+ expected_max: Arc::new(Int64Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt64Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u64");
+}
+
+#[tokio::test]
+async fn test_int32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "i"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::Int32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])),
+ expected_max: Arc::new(Int32Array::from(vec![300000])),
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("i");
+}
+
+// BUG: not convert UInt32Array to Int32Array
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "u"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::UInt32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![300000])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("u");
+}
+
+#[tokio::test]
+async fn test_float64() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "f"
+ // file has 4 record batches, each has 5 rows. They will be saved into 4 row groups
+ let reader = parquet_file_many_columns(Scenario::Float64, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Float64Array::from(vec![-5.0, -4.0, -0.0, 5.0])),
+ expected_max: Arc::new(Float64Array::from(vec![-1.0, 0.0, 4.0, 9.0])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5, 5]),
+ }
+ .run("f");
+}
+
+#[tokio::test]
+async fn test_decimal() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "decimal_col" with decimal data type and precicion 9, scale 2
+ // file has 3 record batches, each has 5 rows. They will be saved into 3 row groups
+ let reader = parquet_file_many_columns(Scenario::Decimal, row_per_group).await;
Review Comment:
Another important thing to test with decimals is different precision / scales -- maybe we can do this as a different PR
##########
datafusion/core/tests/parquet/arrow_statistics.rs:
##########
@@ -624,20 +624,281 @@ async fn test_dates_64_diff_rg_sizes() {
.run("date64");
}
+// BUG:
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint() {
+ let row_per_group = 4;
+
+ // This creates a parquet files of 4 columns named "u8", "u16", "u32", "u64"
+ // "u8" --> UInt8Array
+ // "u16" --> UInt16Array
+ // "u32" --> UInt32Array
+ // "u64" --> UInt64Array
+
+ // The file is created by 4 record batches (each has a null row), each has 5 rows but then will be split into 5 row groups with size 4
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+
+ // u8
+ // BUG: expect UInt8Array but returns Int32Array
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt8Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt8Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u8");
+
+ // u16
+ // BUG: expect UInt16Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt16Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt16Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u16");
+
+ // u32
+ // BUG: expect UInt32Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u32");
+
+ // u64
+ // BUG: expect UInt64rray but returns Int64Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int64Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt64Array
+ expected_max: Arc::new(Int64Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt64Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u64");
+}
+
+#[tokio::test]
+async fn test_int32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "i"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::Int32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])),
+ expected_max: Arc::new(Int32Array::from(vec![300000])),
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("i");
+}
+
+// BUG: not convert UInt32Array to Int32Array
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "u"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::UInt32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![300000])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("u");
+}
+
+#[tokio::test]
+async fn test_float64() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "f"
+ // file has 4 record batches, each has 5 rows. They will be saved into 4 row groups
+ let reader = parquet_file_many_columns(Scenario::Float64, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Float64Array::from(vec![-5.0, -4.0, -0.0, 5.0])),
+ expected_max: Arc::new(Float64Array::from(vec![-1.0, 0.0, 4.0, 9.0])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5, 5]),
+ }
+ .run("f");
+}
+
+#[tokio::test]
+async fn test_decimal() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "decimal_col" with decimal data type and precicion 9, scale 2
+ // file has 3 record batches, each has 5 rows. They will be saved into 3 row groups
+ let reader = parquet_file_many_columns(Scenario::Decimal, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(
+ Decimal128Array::from(vec![100, -500, 2000])
+ .with_precision_and_scale(9, 2)
+ .unwrap(),
+ ),
+ expected_max: Arc::new(
+ Decimal128Array::from(vec![600, 600, 6000])
+ .with_precision_and_scale(9, 2)
+ .unwrap(),
+ ),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5]),
+ }
+ .run("decimal_col");
+}
+
+// BUG: not convert BinaryArray to StringArray
+// https://github.com/apache/datafusion/issues/10605
+#[tokio::test]
+async fn test_byte() {
+ let row_per_group = 5;
+
+ // This creates a parquet file of 4 columns
+ // "name"
+ // "service_string"
+ // "service_binary"
+ // "service_fixedsize"
+
+ // file has 3 record batches, each has 5 rows. They will be saved into 3 row groups
+ let reader = parquet_file_many_columns(Scenario::ByteArray, row_per_group).await;
+
+ // column "name"
+ Test {
+ reader,
+ expected_min: Arc::new(StringArray::from(vec![
+ "all frontends",
+ "mixed",
+ "all backends",
+ ])),
+ expected_max: Arc::new(StringArray::from(vec![
+ "all frontends",
+ "mixed",
+ "all backends",
+ ])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5]),
+ }
+ .run("name");
+
+ // column "service_string"
+ let reader = parquet_file_many_columns(Scenario::ByteArray, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(StringArray::from(vec![
+ "frontend five",
+ "backend one",
+ "backend eight",
+ ])),
+ expected_max: Arc::new(StringArray::from(vec![
+ "frontend two",
+ "frontend six",
+ "backend six",
+ ])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5]),
+ }
+ .run("service_string");
+
+ // column "service_binary"
+ let reader = parquet_file_many_columns(Scenario::ByteArray, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(StringArray::from(vec![
+ "frontend five",
+ "backend one",
+ "backend eight",
+ ])), // Shuld be BinaryArray
Review Comment:
👍
--
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] test: add more tests for statistics reading [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10592:
URL: https://github.com/apache/datafusion/pull/10592#discussion_r1610641830
##########
datafusion/core/tests/parquet/arrow_statistics.rs:
##########
@@ -624,20 +624,281 @@ async fn test_dates_64_diff_rg_sizes() {
.run("date64");
}
+// BUG:
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint() {
+ let row_per_group = 4;
+
+ // This creates a parquet files of 4 columns named "u8", "u16", "u32", "u64"
+ // "u8" --> UInt8Array
+ // "u16" --> UInt16Array
+ // "u32" --> UInt32Array
+ // "u64" --> UInt64Array
+
+ // The file is created by 4 record batches (each has a null row), each has 5 rows but then will be split into 5 row groups with size 4
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+
+ // u8
+ // BUG: expect UInt8Array but returns Int32Array
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt8Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt8Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u8");
+
+ // u16
+ // BUG: expect UInt16Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt16Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt16Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u16");
+
+ // u32
+ // BUG: expect UInt32Array but returns Int32Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u32");
+
+ // u64
+ // BUG: expect UInt64rray but returns Int64Array
+ let reader = parquet_file_many_columns(Scenario::UInt, row_per_group).await;
+ Test {
+ reader,
+ expected_min: Arc::new(Int64Array::from(vec![0, 1, 4, 7, 251])), // shoudld be UInt64Array
+ expected_max: Arc::new(Int64Array::from(vec![3, 4, 6, 250, 254])), // shoudld be UInt64Array
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![4, 4, 4, 4, 4]),
+ }
+ .run("u64");
+}
+
+#[tokio::test]
+async fn test_int32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "i"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::Int32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])),
+ expected_max: Arc::new(Int32Array::from(vec![300000])),
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("i");
+}
+
+// BUG: not convert UInt32Array to Int32Array
+// https://github.com/apache/datafusion/issues/10604
+#[tokio::test]
+async fn test_uint32_range() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "u"
+ // file has 2 record batches, each has 2 rows. They will be saved into one row group
+ let reader = parquet_file_many_columns(Scenario::UInt32Range, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Int32Array::from(vec![0])), // shoudld be UInt32Array
+ expected_max: Arc::new(Int32Array::from(vec![300000])), // shoudld be UInt32Array
+ expected_null_counts: UInt64Array::from(vec![0]),
+ expected_row_counts: UInt64Array::from(vec![4]),
+ }
+ .run("u");
+}
+
+#[tokio::test]
+async fn test_float64() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "f"
+ // file has 4 record batches, each has 5 rows. They will be saved into 4 row groups
+ let reader = parquet_file_many_columns(Scenario::Float64, row_per_group).await;
+
+ Test {
+ reader,
+ expected_min: Arc::new(Float64Array::from(vec![-5.0, -4.0, -0.0, 5.0])),
+ expected_max: Arc::new(Float64Array::from(vec![-1.0, 0.0, 4.0, 9.0])),
+ expected_null_counts: UInt64Array::from(vec![0, 0, 0, 0]),
+ expected_row_counts: UInt64Array::from(vec![5, 5, 5, 5]),
+ }
+ .run("f");
+}
+
+#[tokio::test]
+async fn test_decimal() {
+ let row_per_group = 5;
+ // This creates a parquet file of 1 column "decimal_col" with decimal data type and precicion 9, scale 2
+ // file has 3 record batches, each has 5 rows. They will be saved into 3 row groups
+ let reader = parquet_file_many_columns(Scenario::Decimal, row_per_group).await;
Review Comment:
I was thinking smaller precisions -- I can't remember but I vaguely remember that spark stores different scale decimals with different underlying datatypes or something
--
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] test: add more tests for statistics reading [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10592:
URL: https://github.com/apache/datafusion/pull/10592
--
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