Skip to content

Consolidate statistics merging code #15645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Apr 8, 2025

Which issue does this PR close?

Rationale for this change

While reviewing #15503 from @xudong963 I noticed he had to move compute_summary_statistics anyways

What changes are included in this PR?

  1. Move the statistics calculation code into Statistics::merge_iter and Statistics::merge
  2. Move tests

Are these changes tested?

Yes (by existing tests)

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate common Related to common crate datasource Changes to the datasource crate labels Apr 8, 2025
})
}

/// Merge this Statistics value with another Statistics value.
Copy link
Contributor Author

@alamb alamb Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core logic for merging one Statistics instance with another

@alamb alamb marked this pull request as draft April 8, 2025 21:10
@@ -433,6 +480,79 @@ fn check_num_rows(value: Option<usize>, is_exact: bool) -> Precision<usize> {
}
}

pub fn add_row_stats(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods had to remain pub for now as they are also used in the listing table statistics summary code. I will look into that and see if it makes sense to do as a individual PR

@@ -798,4 +920,173 @@ mod tests {
distinct_count: Precision::Exact(100),
}
}

#[test]
fn test_merge_iter_basic() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are just tests moved from datasource

@@ -409,62 +409,6 @@ pub async fn get_statistics_with_limit(
Ok((result_files, statistics))
}

/// Generic function to compute statistics across multiple items that have statistics
fn compute_summary_statistics<T, I>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was moved into Statistics

@xudong963
Copy link
Member

Just noticed the PR.

FYI, I've reviewed it in the PR: xudong963#5

@alamb
Copy link
Contributor Author

alamb commented Apr 9, 2025

Thanks @xudong963 -- I will work on this in a follow on PR

@alamb alamb closed this Apr 9, 2025
@alamb alamb deleted the alamb/consolidate_statistics_combinattion branch April 9, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants