[Mondrian] NamedSet, StrToSet, work arounds

Charlie Hubbard charlie at fuseanalytics.com
Tue Jul 18 16:33:39 EDT 2017


So I have a NameSet that is defined at the query scope, but I have
CalculatedMeasures that are defined in the schema that I'd like to refer to
that NamedSet.  The reason the NamedSet is defined outside of the schema is
because the user can alter it.  If I define both NamedSet and Calculated
Measures at query scope then my query works fine.

So I tried to use StrToSet to work around this doing something like:

StrToSet("[MyNamedSet]", [Date].[YearQuarterMonth])

But that doesn't work as I get an error:

Member [MyNamedSet] cannot be found.

After digging through the code in StrToSet() it assumes that the string
contains a member/tuple of the hierarchies provided in the 2nd+ arguments.
This would work fine in Microsoft SAAS as it treats the StrToSet as a
dynamic expression that results in a Set.  StrToSet in Mondrian is much
more limited.

So I decided I'd try and write a UDF that let's me provide the name of a
NamedSet and it returns the NamedSet to work around Mondrian trying to
resolve the NamedSet at schema load time.

Set asNamedSet("[MyNamedSet]")

However, Mondrian doesn't offer any way for a UDF, or FunDef for that
matter, to lookup NamedSets through the Evaulator.  After using some
reflection to break into Query.scopedNamedSets I could get the NamedSet by
name.  After that my query failed because some eager compliation logic.
For example doing this:

asNamedSet("[MyNamedSet]").Item(0).Hierarchy

Blows up because when the schema is loaded it tries to check the arity of
the SetType and the parameters it's passed.  If that was done closer to
query execution it'd be fine.

So my question is how can I do this in Mondrian?  I'd like to delay
expressions to be more late which I think is possible in most cases.  It
just seems like I'm blocked at every point.

I'm using Mondrian 4.3.

Charlie

-- 
Charlie Hubbard | Chief Technology Officer
Fuse Analytics  | 404.234.8094
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20170718/e9bd8e65/attachment.html 


More information about the Mondrian mailing list