Repository navigation
Compute corr, the covariances and regr_* in the steps of PostgreSQL - #3002
Merged
Merged
Conversation
This was referenced Oct 10, 2026
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.
Part of #2492.
PostgreSQL computes
corr,covar_pop,covar_sampand theregr_*family (exceptregr_count) from the state offloat8_regr_accum. The state holds the count, the two sums, the sums of squared differences from the means in the steps of Youngs and Cramer, and the common value of each side while every row has the same one. Because of the common value, a sum of squares stays at an exact zero for a constant column, socorr(0.09, g)andregr_slope(g, 0.09)are null. rudb used the pin's state for all sessions and gave NaN there, andcorr(g, g)gave1.0000000000000002where PostgreSQL gives1.The new module
rudb-kernels/src/pgregression.rsportsfloat8_regr_accum,float8_regr_combineand the final functions, with the same overflow errors and the same fallbacks through the square roots and throughfrexpandldexpwhen a product does not fit. In a session with the Postgres aggregate types, the binder gives these calls the names of PostgreSQL's final functions (float8_corrand the others), in the same way that it already does for the variance family. The pin keeps the state ofrudb-kernels/src/statistics.rs, so DuckDB behavior does not change.The tests are four unit tests in the module (constant columns, a split state, overflow,
frexp) and the server testa_pair_statistic_of_a_constant_column_is_null_as_postgres, which checks oracle answers for a group and for a window. On the harness the statements score goes from 1866 to 1869 of 2588, and nothing regresses.