<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Sans";
        panose-1:2 11 6 2 3 5 4 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='color:#1F497D'>Julian,<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Thanks for your response.&nbsp; I
think you have identified the behavior change associated with 9827.&nbsp; Before
this change, the CalcImpl constructor did not instantiate the UDF class, so an
attempt was not made to invoke the default constructor as now occurs when
Util.createUdf is called.&nbsp; <o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>The UDFs use a constructor with
a &nbsp;string argument per&nbsp; the&nbsp; UDF doc in &#8220;How to Design a
Mondrian Schema&#8221;:<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:9.5pt;font-family:"Arial","sans-serif";
color:black'>If a user-defined function has a public constructor with one
string argument, Mondrian will pass in the function's name. Why? This allows
you to define two or more user-defined functions using the same class.<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>This capability is then
demonstrated in the example for the PlusOrMinusOneUdf class.<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'>Chuck<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
mondrian-bounces@pentaho.org [mailto:mondrian-bounces@pentaho.org] <b>On Behalf
Of </b>Julian Hyde<br>
<b>Sent:</b> Wednesday, May 20, 2009 3:58 AM<br>
<b>To:</b> 'Mondrian developer mailing list'<br>
<b>Cc:</b> 'Rushan Chen'<br>
<b>Subject:</b> RE: [Mondrian] UDFs and Util.java changelist 9827<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>Chuck,</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>Are you claiming that behavior changed in 9827? It seems to me that
a block of code was moved from GlobalFunTable to Util.createUdf() essentially
unchanged.</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>I do see that UdfResolver.CalcImpl's constructor gets the class of
a UDF and passes it to Util.createUdf to create another instance of the same
UDF. That seems a bit wasteful - or maybe the author wanted to clone the UDF so
that each instance can use instance variables as workspace - but it's not
wrong.</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>Rushan, can you comment on your change at line 159 of UdfResolver?</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>UserDefinedFunction's javadoc is explicit about the default
constructor: &quot;The class must have a public, zero-arguments constructor, be
on&nbsp;Mondrian's runtime class-path, and be referenced from the schema
file&quot;.</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>Can you explain why you think we need to support UDF constructors
that take a 'String name' parameter?</span><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>&nbsp;<o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Lucida Sans","sans-serif";
color:navy'>Julian</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<blockquote style='border:none;border-left:solid navy 1.5pt;padding:0in 0in 0in 4.0pt;
margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p>&nbsp;</o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'>

<hr size=2 width="100%" align=center>

</span></div>

<p class=MsoNormal style='margin-bottom:12.0pt'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> mondrian-bounces@pentaho.org
[mailto:mondrian-bounces@pentaho.org] <b>On Behalf Of </b>Reidmiller, Chuck<br>
<b>Sent:</b> Monday, May 18, 2009 7:20 AM<br>
<b>To:</b> Mondrian@pentaho.org<br>
<b>Subject:</b> [Mondrian] UDFs and Util.java changelist 9827</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

<p class=MsoNormal>We have a few UDFs that were developed against Mondrian
2.3.2.&nbsp; I recently attempted to use the schema with these UDFs against
Mondrian 3.0 and ran into this error for the GetExtractDate UDF:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><i>Caused by: mondrian.olap.MondrianException: Mondrian
Error:Failed to load user-defined function '': class
'mondrian.udf.GetExtractDate' does not implement the required interface
'mondrian.spi.UserDefinedFunction'<o:p></o:p></i></p>

<p class=MsoNormal><i><o:p>&nbsp;</o:p></i></p>

<p class=MsoNormal>The public constructor for GetExtractDate takes a string argument
in order to get the function name:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'>&nbsp;&nbsp;&nbsp; public
GetExtractDate(String name){<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>but the createUdf method of Util &nbsp;is set up to call a
default constructor that has no argument.&nbsp; The createUdf method appears to
have been added on 2007/08/29 with changelist 9827.&nbsp; I have gotten past
the problem by overloading createUDF via: <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'>&nbsp;&nbsp;&nbsp; public static
UserDefinedFunction createUdf(Class&lt;?&gt; udfClass,<o:p></o:p></p>

<p class=MsoNormal>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
String name) {<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>which includes code borrowed from defineFunction of RolapSchema
to call the UDF with a string argument when applicable.&nbsp; In addition, I
changed the CalcImpl constructor in UdfResolver to invoke the overloaded
createUdf with the function name:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-indent:.5in'>this.udf =
Util.createUdf(udf.getClass(), udf.getName());<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Any comments from folks who know the code better than me?<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Thanks, Chuck<o:p></o:p></p>

<p class=MsoNormal style='text-indent:.5in'><o:p>&nbsp;</o:p></p>

</blockquote>

</div>

</body>

</html>