use of mondrian.olap.fun.MondrianEvaluationException in project mondrian by pentaho.
the class InverseNormalUdf method execute.
public Object execute(Evaluator evaluator, Argument[] args) {
final Object argValue = args[0].evaluateScalar(evaluator);
LOGGER.debug("Inverse Normal argument was : " + argValue);
if (!(argValue instanceof Number)) {
// function will be called again when the cache is loaded.
return null;
}
final Double d = new Double(((Number) argValue).doubleValue());
LOGGER.debug("Inverse Normal argument as Double was : " + d);
if (d.isNaN()) {
return null;
}
// If probability is nonnumeric or
// probability < 0 or
// probability > 1,
// returns an error.
double dbl = d.doubleValue();
if (dbl < 0.0 || dbl > 1.0) {
LOGGER.debug("Invalid value for inverse normal distribution: " + dbl);
throw new MondrianEvaluationException("Invalid value for inverse normal distribution: " + dbl);
}
try {
Double result = new Double(nd.inverseCumulativeProbability(dbl));
LOGGER.debug("Inverse Normal result : " + result.doubleValue());
return result;
} catch (MathException e) {
LOGGER.debug("Exception calculating inverse normal distribution: " + dbl, e);
throw new MondrianEvaluationException("Exception calculating inverse normal distribution: " + dbl);
}
}
use of mondrian.olap.fun.MondrianEvaluationException in project mondrian by pentaho.
the class NumberSqlCompilerTest method checkRejectsString.
private void checkRejectsString(String value) {
Exp exp = Literal.createString(value);
try {
compiler.compile(exp);
} catch (MondrianEvaluationException e) {
return;
}
fail("Expected to get MondrianEvaluationException for " + value);
}
Aggregations