[Mondrian] UDFs and Util.java changelist 9827

Julian Hyde jhyde at pentaho.com
Wed May 20 03:58:18 EDT 2009


Chuck,
 
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.
 
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.
 
Rushan, can you comment on your change at line 159 of UdfResolver?
 
UserDefinedFunction's javadoc is explicit about the default constructor:
"The class must have a public, zero-arguments constructor, be on Mondrian's
runtime class-path, and be referenced from the schema file".
 
Can you explain why you think we need to support UDF constructors that take
a 'String name' parameter?
 
Julian


  _____  

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On
Behalf Of Reidmiller, Chuck
Sent: Monday, May 18, 2009 7:20 AM
To: Mondrian at pentaho.org
Subject: [Mondrian] UDFs and Util.java changelist 9827



We have a few UDFs that were developed against Mondrian 2.3.2.  I recently
attempted to use the schema with these UDFs against Mondrian 3.0 and ran
into this error for the GetExtractDate UDF:

 

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'



The public constructor for GetExtractDate takes a string argument in order
to get the function name:

 

    public GetExtractDate(String name){

 

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

 

    public static UserDefinedFunction createUdf(Class<?> udfClass,

                                        String name) {

 

which includes code borrowed from defineFunction of RolapSchema to call the
UDF with a string argument when applicable.  In addition, I changed the
CalcImpl constructor in UdfResolver to invoke the overloaded createUdf with
the function name:

 

this.udf = Util.createUdf(udf.getClass(), udf.getName());

 

Any comments from folks who know the code better than me?

 

Thanks, Chuck

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090520/d8f2b746/attachment.html 


More information about the Mondrian mailing list