[Mondrian] Problem with user defined function returning a List

Pappyn Bart Bart.Pappyn at vandewiele.com
Wed Apr 18 09:14:13 EDT 2007

Since the introduction of ITERABLE into mondrian, I have a user defined
function that is broken under some circumstances.
I have a user defined function, implementing an Iif() statement that
accepts Sets.  The return type is SetType(null).
But when using this function in a crossjoin, it fails with a
ResultStyleException, since UdfResolver and the underlying
AbstractCalc.getResultStyle() always returns VALUE.
Besides this problem, there is another one with user defined functions,
regardless of the return type returned by getReturnType(), mondrian
(FunDefBase.guessResultType) always looks to the first argument of the
udf to determine the result type.  So it is not possible to defined a
Iif() function with first argument the logical expression, and then the
two set arguments, since mondrian will assume that the UDF will return a
logical expression.
The is a snapshot of my UDF :
public class VDWIIfSet implements UserDefinedFunction {
    // public constructor
    public VDWIIfSet() {
    public String getName() {
        return "VDWIIfSet";
    public String getDescription() {
        // ahh, logical expression must not be the first since 
        // FunDefBase.guessResultType always looks at the first argument
        // to guest the result type
        return "VDWIIfSet(<Set1>, <Set2>,<Logical Expression>)";
    public Syntax getSyntax() {
        return Syntax.Function;
    public Type getReturnType(Type[] parameterTypes) {
        return new SetType(null);
    public Type[] getParameterTypes() {
        return new Type[] {new SetType(null),
                           new SetType(null),
                           new BooleanType()};
    public Object execute(Evaluator evaluator, Argument[] arguments) {
        Object list1 = arguments[0].evaluate(evaluator);
        Object list2 = arguments[1].evaluate(evaluator);        
        Boolean expression = (Boolean)arguments[2].evaluate(evaluator);

        if (expression) {
            return list1;
        } else {
            return list2;
    public String[] getReservedWords() {
        return null;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20070418/5ca525d0/attachment.html 

More information about the Mondrian mailing list