<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=421330213-18042007><FONT face=Arial size=2>Since the 
introduction of ITERABLE into mondrian, I have a user defined function that is 
broken under some </FONT></SPAN><SPAN class=421330213-18042007><FONT face=Arial 
size=2>circumstances.</FONT></SPAN></DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial size=2>I have a user 
defined function, implementing an Iif() statement that accepts Sets.&nbsp; The 
return type is SetType(null).</FONT></SPAN></DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial size=2>But when using this 
function in a crossjoin, it fails with a ResultStyleException, since UdfResolver 
and the underlying </FONT></SPAN><SPAN class=421330213-18042007><FONT face=Arial 
size=2>AbstractCalc.getResultStyle() always returns VALUE.</FONT></SPAN></DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial size=2>Besides this 
problem, there is another one with user defined functions, regardless of the 
return type returned by getReturnType(), </FONT></SPAN><SPAN 
class=421330213-18042007><FONT face=Arial size=2>mondrian 
(FunDefBase.guessResultType) always looks to the first argument of the udf to 
determine the result type.&nbsp; So it is not possible to defined 
</FONT></SPAN><SPAN class=421330213-18042007><FONT face=Arial size=2>a Iif() 
function with first argument the logical expression, and then the two set 
arguments, since mondrian will assume that the UDF will </FONT></SPAN><SPAN 
class=421330213-18042007><FONT face=Arial size=2>return a logical 
expression.</FONT></SPAN></DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial size=2>The is a snapshot of 
my UDF :</FONT></SPAN></DIV>
<DIV><SPAN class=421330213-18042007><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" size=2>public class 
VDWIIfSet implements UserDefinedFunction {<BR>&nbsp;&nbsp;&nbsp; // public 
constructor<BR>&nbsp;&nbsp;&nbsp; public VDWIIfSet() {<BR>&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; public String getName() 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
"VDWIIfSet";<BR>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public String getDescription() 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ahh, logical expression must 
not be the first since <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 
FunDefBase.guessResultType always looks at the first 
argument<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // to guest the result 
type<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
"VDWIIfSet(&lt;Set1&gt;, &lt;Set2&gt;,&lt;Logical 
Expression&gt;)";<BR>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public Syntax getSyntax() 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
Syntax.Function;<BR>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public Type getReturnType(Type[] parameterTypes) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new 
SetType(null);<BR>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public Type[] getParameterTypes() 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new Type[] {new 
SetType(null),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
new 
SetType(null),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
new BooleanType()};<BR>&nbsp;&nbsp;&nbsp; }</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public Object execute(Evaluator evaluator, Argument[] 
arguments) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object list1 = 
arguments[0].evaluate(evaluator);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Object list2 = 
arguments[1].evaluate(evaluator);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Boolean expression = 
(Boolean)arguments[2].evaluate(evaluator);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (expression) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
list1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
list2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; 
}</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=421330213-18042007><FONT face="Courier New" 
size=2>&nbsp;&nbsp;&nbsp; public String[] getReservedWords() 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 
null;<BR>&nbsp;&nbsp;&nbsp; }<BR>}</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV align=left><SPAN class=421330213-18042007><FONT face=Arial 
size=2>Bart</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>