You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Ted-Jiang (via GitHub)" <gi...@apache.org> on 2024/04/08 02:54:02 UTC
[PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Ted-Jiang opened a new pull request, #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989
…atistics
## 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.
-->
Part #9961 .
## 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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1556967113
##########
datafusion/core/tests/parquet/row_group_pruning.rs:
##########
@@ -1264,3 +1264,37 @@ async fn prune_periods_in_column_names() {
.test_row_group_prune()
.await;
}
+
+#[tokio::test]
+async fn test_row_group_all_null_values() {
+ // Three row groups:
+ // 1. all Null values
+ // 2. values from 1 to 5
+ // 3. all Null values
+
+ // After pruning, only row group 2 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" <= 5")
+ .with_expected_errors(Some(0))
+ .with_matched_by_stats(Some(1))
+ .with_pruned_by_stats(Some(2))
+ .with_expected_rows(5)
+ .with_matched_by_bloom_filter(Some(0))
+ .with_pruned_by_bloom_filter(Some(0))
+ .test_row_group_prune()
+ .await;
+
+ // After pruning, only row group 1,3 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" is Null")
Review Comment:
@alamb thanks! Add test in https://github.com/apache/arrow-datafusion/pull/9989/commits/11567d9f68e0e2e0459cf784f6f51f8e0e568912, and support the isNotNull
|Do you plan to add support in page_filter.rs as well (maybe that is why the PR is marked "Part https://github.com/apache/arrow-datafusion/issues/9961 ")?
As the page level prune i prefer in next pr to keep this pr short and clean.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#issuecomment-2041812114
@alamb @waynexia PTAL
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1556967113
##########
datafusion/core/tests/parquet/row_group_pruning.rs:
##########
@@ -1264,3 +1264,37 @@ async fn prune_periods_in_column_names() {
.test_row_group_prune()
.await;
}
+
+#[tokio::test]
+async fn test_row_group_all_null_values() {
+ // Three row groups:
+ // 1. all Null values
+ // 2. values from 1 to 5
+ // 3. all Null values
+
+ // After pruning, only row group 2 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" <= 5")
+ .with_expected_errors(Some(0))
+ .with_matched_by_stats(Some(1))
+ .with_pruned_by_stats(Some(2))
+ .with_expected_rows(5)
+ .with_matched_by_bloom_filter(Some(0))
+ .with_pruned_by_bloom_filter(Some(0))
+ .test_row_group_prune()
+ .await;
+
+ // After pruning, only row group 1,3 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" is Null")
Review Comment:
@alamb thanks! Add test in https://github.com/apache/arrow-datafusion/pull/9989/commits/11567d9f68e0e2e0459cf784f6f51f8e0e568912, and support the isNotNull, as the page level prune i prefer in next pr to keep this pr short and clean.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1555358636
##########
datafusion/core/tests/parquet/row_group_pruning.rs:
##########
@@ -1264,3 +1264,37 @@ async fn prune_periods_in_column_names() {
.test_row_group_prune()
.await;
}
+
+#[tokio::test]
+async fn test_row_group_all_null_values() {
+ // Tree row groups:
Review Comment:
"Three" instead of "Tree" I guess 😆
```suggestion
// Three row groups:
```
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -342,8 +342,10 @@ impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
scalar.to_array().ok()
}
- fn row_counts(&self, _column: &Column) -> Option<ArrayRef> {
- None
+ fn row_counts(&self, column: &Column) -> Option<ArrayRef> {
+ let (c, _) = self.column(&column.name)?;
+ let scalar = ScalarValue::UInt64(Some(c.num_values() as u64));
Review Comment:
Another implementor returns an `Int64` array. I'm not sure if the type matters?
https://github.com/apache/arrow-datafusion/blob/215f30f74a12e91fd7dca0d30e37014c8c3493ed/datafusion/core/src/physical_optimizer/pruning.rs#L1699-L1709
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts , handle IS NOT NULL [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#issuecomment-2050985763
> Thanks @Ted-Jiang -- the support for `IS NOT NULL` is also quite neat.
sorry there is a bug here i will fix this it should
```
/// If set `with_not` to true: which means is not null
/// datafusion use false flag to prune unit (row group, page ..)
/// Given an expression reference to `expr`, if `expr` is a column expression,
/// returns a pruning expression in terms of IsNotNull that will evaluate to true
/// if the column may contain any nonnull values, and false if definitely does not contain
/// nonnull values null which any null values.
```
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1555564611
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -342,8 +342,10 @@ impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
scalar.to_array().ok()
}
- fn row_counts(&self, _column: &Column) -> Option<ArrayRef> {
- None
+ fn row_counts(&self, column: &Column) -> Option<ArrayRef> {
+ let (c, _) = self.column(&column.name)?;
+ let scalar = ScalarValue::UInt64(Some(c.num_values() as u64));
Review Comment:
Try to keep with https://github.com/apache/arrow-datafusion/blob/18c9f4d7e68b3eb470b2b2ef3f2297e018dd4298/datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs#L340-L342 avoid cast during `=` , i think Int64Array only use in test
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1556914263
##########
datafusion/core/tests/parquet/mod.rs:
##########
@@ -75,6 +76,7 @@ enum Scenario {
DecimalLargePrecisionBloomFilter,
ByteArray,
PeriodsInColumnNames,
+ AllNullValues,
Review Comment:
make sense
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#issuecomment-2043480225
Thanks @Ted-Jiang -- this looks awesome -- I look forward to reviewing it later today
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts , handle IS NOT NULL [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1555564611
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -342,8 +342,10 @@ impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
scalar.to_array().ok()
}
- fn row_counts(&self, _column: &Column) -> Option<ArrayRef> {
- None
+ fn row_counts(&self, column: &Column) -> Option<ArrayRef> {
+ let (c, _) = self.column(&column.name)?;
+ let scalar = ScalarValue::UInt64(Some(c.num_values() as u64));
Review Comment:
keep with https://github.com/apache/arrow-datafusion/blob/18c9f4d7e68b3eb470b2b2ef3f2297e018dd4298/datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs#L340-L342 avoid cast during `=`
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -342,8 +342,10 @@ impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
scalar.to_array().ok()
}
- fn row_counts(&self, _column: &Column) -> Option<ArrayRef> {
- None
+ fn row_counts(&self, column: &Column) -> Option<ArrayRef> {
+ let (c, _) = self.column(&column.name)?;
+ let scalar = ScalarValue::UInt64(Some(c.num_values() as u64));
Review Comment:
Try to keep with https://github.com/apache/arrow-datafusion/blob/18c9f4d7e68b3eb470b2b2ef3f2297e018dd4298/datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs#L340-L342 avoid cast during `=`
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1555172069
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -1026,15 +1028,17 @@ mod tests {
column_statistics: Vec<ParquetStatistics>,
) -> RowGroupMetaData {
let mut columns = vec![];
+ let number_row = 1000;
Review Comment:
Before all unit test set each col with default `0 row`, will trigger num_rows == num_nulls
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "Ted-Jiang (via GitHub)" <gi...@apache.org>.
Ted-Jiang commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1556967113
##########
datafusion/core/tests/parquet/row_group_pruning.rs:
##########
@@ -1264,3 +1264,37 @@ async fn prune_periods_in_column_names() {
.test_row_group_prune()
.await;
}
+
+#[tokio::test]
+async fn test_row_group_all_null_values() {
+ // Three row groups:
+ // 1. all Null values
+ // 2. values from 1 to 5
+ // 3. all Null values
+
+ // After pruning, only row group 2 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" <= 5")
+ .with_expected_errors(Some(0))
+ .with_matched_by_stats(Some(1))
+ .with_pruned_by_stats(Some(2))
+ .with_expected_rows(5)
+ .with_matched_by_bloom_filter(Some(0))
+ .with_pruned_by_bloom_filter(Some(0))
+ .test_row_group_prune()
+ .await;
+
+ // After pruning, only row group 1,3 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" is Null")
Review Comment:
@alamb thanks! Add test in https://github.com/apache/arrow-datafusion/pull/9989/commits/11567d9f68e0e2e0459cf784f6f51f8e0e568912, and support the isNotNull
>Do you plan to add support in page_filter.rs as well (maybe that is why the PR is marked "Part
https://github.com/apache/arrow-datafusion/issues/9961 ")?
As the page level prune i prefer in next pr to keep this pr short and clean.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Prune columns are all null in ParquetExec by row_counts in pruning st… [arrow-datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9989:
URL: https://github.com/apache/arrow-datafusion/pull/9989#discussion_r1556412838
##########
datafusion/core/tests/parquet/mod.rs:
##########
@@ -75,6 +76,7 @@ enum Scenario {
DecimalLargePrecisionBloomFilter,
ByteArray,
PeriodsInColumnNames,
+ AllNullValues,
Review Comment:
I found this name confusing as the scenario contains things other than Nulls.
Maybe `NullValues` or `WithNullValues` would be more specific 🤔
##########
datafusion/core/tests/parquet/row_group_pruning.rs:
##########
@@ -1264,3 +1264,37 @@ async fn prune_periods_in_column_names() {
.test_row_group_prune()
.await;
}
+
+#[tokio::test]
+async fn test_row_group_all_null_values() {
+ // Three row groups:
+ // 1. all Null values
+ // 2. values from 1 to 5
+ // 3. all Null values
+
+ // After pruning, only row group 2 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" <= 5")
+ .with_expected_errors(Some(0))
+ .with_matched_by_stats(Some(1))
+ .with_pruned_by_stats(Some(2))
+ .with_expected_rows(5)
+ .with_matched_by_bloom_filter(Some(0))
+ .with_pruned_by_bloom_filter(Some(0))
+ .test_row_group_prune()
+ .await;
+
+ // After pruning, only row group 1,3 should be selected
+ RowGroupPruningTest::new()
+ .with_scenario(Scenario::AllNullValues)
+ .with_query("SELECT * FROM t WHERE \"i8\" is Null")
Review Comment:
Could you also add a tests:
1. `i16 IS NOT NULL` (to cover the opposite)
2. `i32 > 7` (prune via nulls and some via counts)
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -1026,15 +1028,17 @@ mod tests {
column_statistics: Vec<ParquetStatistics>,
) -> RowGroupMetaData {
let mut columns = vec![];
+ let number_row = 1000;
Review Comment:
I was wondering if this could cause problems in real files (for example, if the row counts were not included in the statistics that were written into the file).
However, I double checked the code and it seems like `ColumnChunkMetaData::num_values` is non nullable so I think we are good.
##########
datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs:
##########
@@ -342,8 +342,10 @@ impl<'a> PruningStatistics for RowGroupPruningStatistics<'a> {
scalar.to_array().ok()
}
- fn row_counts(&self, _column: &Column) -> Option<ArrayRef> {
- None
+ fn row_counts(&self, column: &Column) -> Option<ArrayRef> {
+ let (c, _) = self.column(&column.name)?;
+ let scalar = ScalarValue::UInt64(Some(c.num_values() as u64));
Review Comment:
`UInt64` also matches the documentation https://docs.rs/datafusion/latest/datafusion/physical_optimizer/pruning/trait.PruningStatistics.html#tymethod.row_counts 👍
I made a PR to fix the tests: https://github.com/apache/arrow-datafusion/pull/10004
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org