<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I don’t have any concrete suggestions but I feel your pain.<div class=""><br class=""></div><div class="">Mondrian tries very hard to figure out the dimensionality of each expression at prepare time. It exploits that type information to generate more efficient code. But situations where the type cannot be known at prepare time are not well supported.</div><div class=""><br class=""></div><div class="">I don’t recall why named sets in the schema are treated differently (from a type-checking perspective) from named sets in a query. If there is no inherent reason for this maybe you can improve how Mondrian derives the dimensionality of a schema named set when it is used in a query.</div><div class=""><br class=""></div><div class="">Julian</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 18, 2017, at 1:33 PM, Charlie Hubbard &lt;<a href="mailto:charlie@fuseanalytics.com" class="">charlie@fuseanalytics.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">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.&nbsp; The reason the NamedSet is defined outside of the schema is because the user can alter it.&nbsp; If I define both NamedSet and Calculated Measures at query scope then my query works fine.</div><div class=""><br class=""></div><div class="">So I tried to use StrToSet to work around this doing something like:</div><div class=""><br class=""></div><div class="">StrToSet("[MyNamedSet]", [Date].[YearQuarterMonth])&nbsp;</div><div class=""><br class=""></div><div class="">But that doesn't work as I get an error:</div><div class=""><br class=""></div><div class="">Member [MyNamedSet] cannot be found.</div><div class=""><br class=""></div><div class="">After digging through the code in StrToSet() it assumes that the string contains a member/tuple of the hierarchies provided in the 2nd+ arguments.&nbsp; This would work fine in Microsoft SAAS as it treats the StrToSet as a dynamic expression that results in a Set.&nbsp; StrToSet in Mondrian is much more limited.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Set asNamedSet("[MyNamedSet]")</div><div class=""><br class=""></div><div class="">However, Mondrian doesn't offer any way for a UDF, or FunDef for that matter, to lookup NamedSets through the Evaulator.&nbsp; After using some reflection to break into Query.scopedNamedSets I could get the NamedSet by name.&nbsp; After that my query failed because some eager compliation logic.&nbsp; For example doing this:</div><div class=""><br class=""></div><div class="">asNamedSet("[MyNamedSet]").Item(0).Hierarchy</div><div class=""><br class=""></div><div class="">Blows up because when the schema is loaded it tries to check the arity of the SetType and the parameters it's passed.&nbsp; If that was done closer to query execution it'd be fine.</div><div class=""><br class=""></div><div class="">So my question is how can I do this in Mondrian?&nbsp; I'd like to delay expressions to be more late which I think is possible in most cases.&nbsp; It just seems like I'm blocked at every point.</div><div class=""><br class=""></div><div class="">I'm using Mondrian 4.3.</div><div class=""><br class=""></div><div class="">Charlie</div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">Charlie Hubbard | Chief Technology Officer<div class=""><div class=""><span style="font-weight:bold;background-color:rgb(255,255,255)" class=""><font color="#0b5394" class="">F</font><font color="#f6b26b" class="">u</font><font color="#0b5394" class="">se</font></span><font color="#0b5394" style="font-weight:bold" class="">&nbsp;Analytics</font><font color="#0b5394" class=""> &nbsp;</font><font class="">| </font><font class="">404.234.8094</font></div></div></div></div>
</div>
_______________________________________________<br class="">Mondrian mailing list<br class=""><a href="mailto:Mondrian@pentaho.org" class="">Mondrian@pentaho.org</a><br class="">http://lists.pentaho.org/mailman/listinfo/mondrian<br class=""></div></blockquote></div><br class=""></div></body></html>