[Mondrian] CurrentDateMember udf

Rushan Chen rchen at lucidera.com
Tue Aug 28 20:48:33 EDT 2007


The caching I was thinking of adding does use the dependency interface 
to declare that CurrentDateMember/CurrentDateString UDFs are not 
dependent on any dimension value.

I will add the timestamp to RolapResult because it will make any 
computation requiring the current time consistent. However, itself alone 
will not help with the time consuming part of the UDF, i.e. issuing a 
SQL to look up whether the member value corresponding the (cached) 
timestamp string exists. Expression caching will still be a good 
addition here.

Rushan

Julian Hyde wrote:
> People writing MDX should not make any assumptions about how many times a
> UDF is executed. Mondrian has to assume that a function depends on the
> entire dimensional context (that is, the current member of each dimension),
> so to be safe, it will typically execute it every time it is needed.
>
> If you really want to ensure that a UDF is executed only once, you can use a
> parameter. Something like this:
>
> WITH MEMBER [Time].[Today] AS 
>  ' Parameter("now", CurrentDateMember([Time], '[YYYY].[MM].[DD]')) '
> SELECT {[Time].[Today]} ON 0
>  ...
>
> Using parameters for this purpose is a bit of a back. I guess we could add a
> function 'Cache(<Expression>)' to asks mondrian to cache expression results:
>
> WITH MEMBER [Time].[Today] AS 
>  ' Cache(CurrentDateMember([Time], '[YYYY].[MM].[DD]')) '
> SELECT {[Time].[Today]} ON 0
>  ...
>
> And/or, the UDF SPI could allow a UDF to declare which dimensions it depends
> on. That sounds a bit complicated, though.
>
> Re. CurrentDateMember specifically, it's a good idea to make it use the time
> that the query started executing. You could add a field to RolapResult for
> that, initialized when a RolapResult is created.
>
> Unless & until we make UDFs declare their dependencies, it is not safe for
> the system to automatically cache their results, so it would also be a good
> idea to have CurrentDateMember cache the results for a particular timestamp
> string. 
>
> Julian
>
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian
>   





More information about the Mondrian mailing list