fix null_count on compute_record_batch_statistics to report null counts across partitions#10468
Merged
alamb merged 4 commits intoapache:mainfrom May 17, 2024
Merged
Conversation
samuelcolvin
commented
May 12, 2024
| for (stat_index, col_index) in projection.iter().enumerate() { | ||
| column_statistics[stat_index].null_count = | ||
| Precision::Exact(batch.column(*col_index).null_count()); | ||
| null_counts[stat_index] += batch.column(*col_index).null_count(); |
Contributor
Author
There was a problem hiding this comment.
There would be fewer bounds checks i think if we used zip here, rather than .enumerate() and lookup each column
null_count on compute_record_batch_statisticsnull_count on compute_record_batch_statistics to report null counts across partitions
alamb
approved these changes
May 13, 2024
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank you for the contribution @samuelcolvin
Looks like a very good improvement to me
| ], | ||
| }; | ||
|
|
||
| assert_eq!(actual, expected); |
Contributor
There was a problem hiding this comment.
I verified test coverage by running this test without the code in this PR and the test fails like this
assertion `left == right` failed
left: Statistics { num_rows: Exact(6), total_byte_size: Exact(368), column_statistics: [ColumnStatistics { null_count: Exact(1), max_value: Absent, min_value: Absent, distinct_count: Absent }] }
right: Statistics { num_rows: Exact(6), total_byte_size: Exact(368), column_statistics: [ColumnStatistics { null_count: Exact(3), max_value: Absent, min_value: Absent, distinct_count: Absent }] }
Contributor
|
I took the liberty of merging up from main and runnning |
Contributor
|
Thanks again @samuelcolvin -- sorry for the delay in merging |
findepi
pushed a commit
to findepi/datafusion
that referenced
this pull request
Jul 16, 2024
…counts across partitions (apache#10468) * fix null_count on compute_record_batch_statistics * fmt --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Maybe I'm missing something or being dumb, but while reading
datafusion::physical_plan::common::compute_record_batch_statisticsI noticed that thenull_counttook the value from the last partition, not the sum of all partition.What changes are included in this PR?
compute_record_batch_statisticsAre these changes tested?
yes
Are there any user-facing changes?
I don't think so, perhaps some queries are now correct that were previously incorrect.