Skip to content

Add tests for LinRegR2 and LinRegVariance with NULL arguments#151

Merged
rsim merged 3 commits intomasterfrom
bugfix/lineregr2_lineregvariance_null_value_arguments
Feb 20, 2026
Merged

Add tests for LinRegR2 and LinRegVariance with NULL arguments#151
rsim merged 3 commits intomasterfrom
bugfix/lineregr2_lineregvariance_null_value_arguments

Conversation

@jjustaments
Copy link
Collaborator

Mondrian patch:

diff --git a/mondrian/src/main/java/mondrian/olap/fun/LinReg.java b/mondrian/src/main/java/mondrian/olap/fun/LinReg.java
index bcf121d8a..63c2c017b 100644
--- a/mondrian/src/main/java/mondrian/olap/fun/LinReg.java
+++ b/mondrian/src/main/java/mondrian/olap/fun/LinReg.java
@@ -610,9 +610,11 @@ public abstract class LinReg extends FunDefBase {
             case Slope:
                 return value.getSlope();
             case Variance:
-                return accuracy(value).getVariance();
+                double variance = accuracy(value).getVariance();
+                return variance == Double.MAX_VALUE ? Double.NaN : variance;
             case R2:
-                return accuracy(value).getRSquared();
+                double rSquared = accuracy(value).getRSquared();
+                return rSquared == Double.MAX_VALUE ? Double.NaN : rSquared;
             default:
             case Point:
                 throw Util.newInternal("unexpected value " + regType);

Test that both functions return NaN when the value expression argument
is NULL and cannot be calculated.
@rsim rsim merged commit 65864d3 into master Feb 20, 2026
6 checks passed
@rsim rsim deleted the bugfix/lineregr2_lineregvariance_null_value_arguments branch February 20, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants