<!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.6001.17052" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=136233001-01022008><FONT face=Verdana 
color=#000080 size=2>The solution looks ok - go ahead and check 
in.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=136233001-01022008></SPAN><SPAN 
class=136233001-01022008><FONT face=Verdana color=#000080 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=136233001-01022008><FONT face=Verdana 
color=#000080 size=2>Julian</FONT></SPAN></DIV><BR>
<BLOCKQUOTE 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000080 2px solid; MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> Matt Campbell [mailto:mkambol@gmail.com] 
  <BR><B>Sent:</B> Thursday, January 31, 2008 9:06 AM<BR><B>To:</B> 
  jhyde@pentaho.org; Mondrian developer mailing list<BR><B>Subject:</B> Re: 
  [Mondrian] when iif has a tuple and a member as its arguments weget an 
  exception<BR></FONT><BR></DIV>
  <DIV></DIV>Julian,<BR>Harun is working on Ajit's team.&nbsp; Would it be okay 
  if they check in the change he suggested?&nbsp; They wanted to get some 
  confirmation that their solution was correct.<BR>-matt<BR><BR>
  <DIV class=gmail_quote>On Jan 31, 2008 11:38 AM, Julian Hyde &lt;<A 
  href="mailto:jhyde@pentaho.org">jhyde@pentaho.org</A>&gt; wrote:<BR>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Thanks. 
    Logged as bug 1883611<BR><A 
    href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1883611&amp;group_id=35302&amp;atid=414613" 
    target=_blank>http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1883611&amp;group_id=35<BR>302&amp;atid=414613</A> 
    for tracking. Will fix in 3.0.<BR><FONT color=#888888><BR>Julian<BR></FONT>
    <DIV>
    <DIV></DIV>
    <DIV class=Wj3C7c><BR>&gt; -----Original Message-----<BR>&gt; From: <A 
    href="mailto:mondrian-bounces@pentaho.org">mondrian-bounces@pentaho.org</A><BR>&gt; 
    [mailto:<A 
    href="mailto:mondrian-bounces@pentaho.org">mondrian-bounces@pentaho.org</A>] 
    On Behalf Of Harun Pathan<BR>&gt; Sent: Thursday, January 31, 2008 6:54 
    AM<BR>&gt; To: <A 
    href="mailto:mondrian@pentaho.org">mondrian@pentaho.org</A><BR>&gt; Subject: 
    [Mondrian] when iif has a tuple and a member as its<BR>&gt; arguments weget 
    an exception<BR>&gt;<BR>&gt; Hi,<BR>&gt;<BR>&gt; When we run this mdx we get 
    an error stacktrace for which is as below.<BR>&gt;<BR>&gt; WITH<BR>&gt; 
    MEMBER [Gender].agg<BR>&gt; AS 'IIF(1=1, ([Gender].[All 
    Gender],measures.[unit<BR>&gt; sales]),([Gender].[All Gender]) )', 
    SOLVE_ORDER = 4<BR>&gt; SELECT {[Measures].[unit sales]} ON 0,<BR>&gt; 
    {{[Gender].[Gender].MEMBERS},{([Gender].agg)}} on 1 FROM 
    sales<BR>&gt;<BR>&gt; Caused by: mondrian.olap.MondrianException: Mondrian 
    Error:Internal<BR>&gt; error: could not derive type<BR>&gt; &nbsp; &nbsp; 
    &nbsp; at<BR>&gt; 
    mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:777)<BR>&gt; 
    &nbsp; &nbsp; &nbsp; at 
    mondrian.olap.Util.newInternal(Util.java:1333)<BR>&gt; &nbsp; &nbsp; &nbsp; 
    at mondrian.olap.fun.FunDefBase.createCall(FunDefBase.java:245)<BR>&gt; 
    &nbsp; &nbsp; &nbsp; at<BR>&gt; 
    mondrian.mdx.UnresolvedFunCall.accept(UnresolvedFunCall.java:101)<BR>&gt; 
    &nbsp; &nbsp; &nbsp; at 
    mondrian.olap.Query$StackValidator.validate(Query.java:1229)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at mondrian.olap.Formula.accept(Formula.java:131)<BR>&gt; 
    &nbsp; &nbsp; &nbsp; at 
    mondrian.olap.Query$StackValidator.validate(Query.java:1304)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at mondrian.olap.Query.resolve(Query.java:571)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at mondrian.olap.Query.resolve(Query.java:433)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at mondrian.olap.Query.&lt;init&gt;(Query.java:217)<BR>&gt; 
    &nbsp; &nbsp; &nbsp; at 
    mondrian.olap.Query.&lt;init&gt;(Query.java:177)<BR>&gt; &nbsp; &nbsp; 
    &nbsp; at mondrian.olap.Parser.makeQuery(Parser.java:850)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at<BR>&gt; 
    mondrian.olap.CUP$Parser$actions.CUP$Parser$do_action(Parser.j<BR>&gt; 
    ava:1683)<BR>&gt; &nbsp; &nbsp; &nbsp; at 
    mondrian.olap.Parser.do_action(Parser.java:684)<BR>&gt; &nbsp; &nbsp; &nbsp; 
    at java_cup.runtime.lr_parser.parse(lr_parser.java:569)<BR>&gt; &nbsp; 
    &nbsp; &nbsp; at 
    mondrian.olap.Parser.parseInternal(Parser.java:754)<BR>&gt;<BR>&gt; What we 
    saw is that when the iif function is resolved it tries to get<BR>&gt; a 
    common result type between its arguments.There is no common<BR>&gt; 
    resulttype between a TupleType and a MemberType.<BR>&gt; Currently in the 
    TupleType the result type gets resolved to a<BR>&gt; ScalarType when the 
    other type is a ScalarType and to a TupleType when<BR>&gt; the other one is 
    a Tuple and in all other cases null.<BR>&gt; Currently in the MemberType the 
    result type gets resolved to null for<BR>&gt; the above example when the 
    incoming tuple has more than one argument<BR>&gt; in it.<BR>&gt; is it valid 
    if the return type is resolved to a ScalarType when the<BR>&gt; IIF gets a 
    TupleType and MemberType as its arguments.<BR>&gt;<BR>&gt; Code changes in 
    TupleType :<BR>&gt; //currently this check isnt there.<BR>&gt; if (type 
    instanceof MemberType) {<BR>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
    return getValueType().computeCommonType(type,<BR>&gt; 
    conversionCount);<BR>&gt; }<BR>&gt;<BR>&gt; Code changes in 
    MemberType:<BR>&gt;<BR>&gt; if (type instanceof TupleType) {<BR>&gt; &nbsp; 
    &nbsp; &nbsp; TupleType tupleType = (TupleType) type;<BR>&gt; &nbsp; &nbsp; 
    &nbsp; &nbsp;if (tupleType.elementTypes.length == 1) {<BR>&gt; &nbsp; &nbsp; 
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return new TupleType(new 
    Type[]<BR>&gt; {type}).computeCommonType(tupleType, 
    conversionCount);<BR>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else 
    {<BR>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
    return<BR>&gt; 
    computeCommonType(tupleType.getValueType(),conversionCount);// this 
    is<BR>&gt; the code change, earlier returned null<BR>&gt; &nbsp; &nbsp; 
    &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&gt; &nbsp;}<BR>&gt; 
    _______________________________________________<BR>&gt; Mondrian mailing 
    list<BR>&gt; <A 
    href="mailto:Mondrian@pentaho.org">Mondrian@pentaho.org</A><BR>&gt; <A 
    href="http://lists.pentaho.org/mailman/listinfo/mondrian" 
    target=_blank>http://lists.pentaho.org/mailman/listinfo/mondrian</A><BR>&gt;<BR><BR>_______________________________________________<BR>Mondrian 
    mailing list<BR><A 
    href="mailto:Mondrian@pentaho.org">Mondrian@pentaho.org</A><BR><A 
    href="http://lists.pentaho.org/mailman/listinfo/mondrian" 
    target=_blank>http://lists.pentaho.org/mailman/listinfo/mondrian</A><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>