Skip to content

Commit

Permalink
MONDRIAN: revert changes made in 9550 as the requirement is no longer…
Browse files Browse the repository at this point in the history
… there.

[git-p4: depot-paths = "//open/mondrian/": change = 9829]
  • Loading branch information
Rushan Chen committed Aug 30, 2007
1 parent 9437cb6 commit 836f0ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mondrian.properties
Expand Up @@ -329,7 +329,7 @@ mondrian.rolap.iterationLimit=0
###############################################################################
# If true, a division having a non-null numerator and a null denominator
# evaluates to Infinity. If false, the same division results in Null.
# mondrian.olap.NullOrZeroDenominatorProducesNull=false
# mondrian.olap.NullDenominatorProducesNull=false

################################################################################
# If true and if the database supports group by grouping sets query, then roll-up
Expand Down
6 changes: 3 additions & 3 deletions src/main/mondrian/olap/MondrianProperties.java
Expand Up @@ -991,11 +991,11 @@ public Property getPropertyDefinition(String path) {
* it evaluates to "Infinity", which conforms to MSAS behavior. However,
* the old semantics of evaluating this to NULL (non MSAS-conforming), is
* useful in some applications. This property controls whether the
* result should be NULL if the denominator is Null or value zero.
* result should be NULL if the denominator is Null.
*/
public transient final BooleanProperty NullOrZeroDenominatorProducesNull =
public transient final BooleanProperty NullDenominatorProducesNull =
new BooleanProperty(
this, "mondrian.olap.NullOrZeroDenominatorProducesNull", false);
this, "mondrian.olap.NullDenominatorProducesNull", false);

/**
* Property which defines
Expand Down
6 changes: 3 additions & 3 deletions src/main/mondrian/olap/fun/BuiltinFunTable.java
Expand Up @@ -1540,9 +1540,9 @@ public double evaluateDouble(Evaluator evaluator) {
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final DoubleCalc calc0 = compiler.compileDouble(call.getArg(0));
final DoubleCalc calc1 = compiler.compileDouble(call.getArg(1));
final boolean isNullOrZeroDenominatorProducesNull =
final boolean isNullDenominatorProducesNull =
MondrianProperties.instance().
NullOrZeroDenominatorProducesNull.get();
NullDenominatorProducesNull.get();

// If the mondrian property
// mondrian.olap.NullOrZeroDenominatorProducesNull
Expand All @@ -1552,7 +1552,7 @@ public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
// If this property is true, Null or zero in denominator returns
// Null. This is only used by certain applications and does not
// conform to MSAS behavior.
if (isNullOrZeroDenominatorProducesNull != true) {
if (isNullDenominatorProducesNull != true) {
return new AbstractDoubleCalc(call, new Calc[] {calc0, calc1}) {
public double evaluateDouble(Evaluator evaluator) {
final double v0 = calc0.evaluateDouble(evaluator);
Expand Down
12 changes: 6 additions & 6 deletions testsrc/main/mondrian/olap/fun/FunctionTest.java
Expand Up @@ -4400,26 +4400,26 @@ public void testDivide() {
assertExprReturns(NullNumericExpr + " / - 2", "");
assertExprReturns(NullNumericExpr + " / " + NullNumericExpr, "");

boolean origNullOrZeroDenominatorProducesNull =
MondrianProperties.instance().NullOrZeroDenominatorProducesNull.get();
boolean origNullDenominatorProducesNull =
MondrianProperties.instance().NullDenominatorProducesNull.get();
try {
// default behavior
MondrianProperties.instance().NullOrZeroDenominatorProducesNull.set(false);
MondrianProperties.instance().NullDenominatorProducesNull.set(false);

assertExprReturns("-2 / " + NullNumericExpr, "Infinity");
assertExprReturns("0 / 0", "NaN");
assertExprReturns("-3 / (2 - 2)", "-Infinity");

// when NullOrZeroDenominatorProducesNull is set to true
MondrianProperties.instance().NullOrZeroDenominatorProducesNull.set(true);
MondrianProperties.instance().NullDenominatorProducesNull.set(true);

assertExprReturns("-2 / " + NullNumericExpr, "");
assertExprReturns("0 / 0", "");
assertExprReturns("-3 / (2 - 2)", "");

} finally {
MondrianProperties.instance().NullOrZeroDenominatorProducesNull.
set(origNullOrZeroDenominatorProducesNull);
MondrianProperties.instance().NullDenominatorProducesNull.
set(origNullDenominatorProducesNull);
}
}

Expand Down

0 comments on commit 836f0ea

Please sign in to comment.