[Mondrian] Parent-child hierarchies and StrToMember

Nikolay Samofatov nikolay.samofatov at red-soft.biz
Sun Feb 17 06:32:05 EST 2008


Hi, Dear Mondrian developers!

We have encountered an issue with parent-child hierarchies.

The problem is that if you take UniqueName for a member in a 
parent-child hierarchy and than pass it to a StrToMember it cannot find 
a member.

The UniqueName is generated in the form:
<HierarchyName>.<AllMemeberName>.<ParentName>.<ChildName>......

Such name does not resolve in recent mondrian (tested perforce version 
as of yesterday).

This logic doesn't work for a while already. I think this is a 
regression from Mondrian 2.2 release, but I didn't test to find exact 
build where it got broken.

To reference members in parent-child hierarchy now one has to use:
<HierarchyName>.<LevelName>.<MemberName>

If so, shouldn't UniqueName return names in this form for members of a 
parent-child hierarchy?

As an example, see cube:

  <Cube name="Фильтры и представления">
    <Table name="KBK_REGION_FACT"/>
   
    <Dimension name="Территория" foreignKey="REGION">
      <Hierarchy hasAll="true" parentColumn="PARENT_ID" 
allMemberName="Все территории" primaryKey="ID">
        <Table name="TERRITORY"/>
        <Level name="Территория" column="ID" nameColumn="CAPTION" 
parentColumn="PARENT_ID" uniqueMembers="true">
          <Property name="HasChildren" type="Numeric" 
column="HAS_CHILDREN"/>
          <Closure parentColumn="PARENT_ID" childColumn="TERRITORY_ID">
            <Table name="TERRITORY_CLOSURE"/>         
          </Closure>
        </Level>
      </Hierarchy>
    </Dimension>   
   
    <Dimension name="КБК" foreignKey="KBK">
      <Hierarchy hasAll="true" allMemberName="Все коды" primaryKey="KBK">
        <Table name="KBK_VIEW"/>
        <Level name="КБК1" column="KBK1" uniqueMembers="true"/>
        <Level name="КБК2" column="KBK2" uniqueMembers="true"/>
        <Level name="КБК" column="KBK" uniqueMembers="true"/>
      </Hierarchy>
    </Dimension>
   
    <Measure name="PARAM" column="AMOUNT" aggregator="sum" 
formatString="#,###.00"/>

  </Cube>

The query:

with member [Measures].[Test] as 
'StrToMember([Территория].CurrentMember.UniqueName)'
select NON EMPTY {[Measures].[Test]}
ON COLUMNS,
  crossjoin({[Территория].[Территория].[Венгрия]}, {[КБК].AllMembers}) 
ON ROWS
from [Фильтры и представления]

Dies with:

Caused by: mondrian.olap.MondrianException: Mondrian Error:MDX object 
'Венгрия' not found in member '[Территория].[Все территории]'
    at 
mondrian.resource.MondrianResource$_Def1.ex(MondrianResource.java:802)
    at mondrian.olap.Util.lookupCompound(Util.java:585)
    at 
mondrian.rolap.RolapSchemaReader.lookupCompound(RolapSchemaReader.java:345)
    at 
mondrian.olap.DelegatingSchemaReader.lookupCompound(DelegatingSchemaReader.java:100)
    at mondrian.olap.Query$QuerySchemaReader.lookupCompound(Query.java:1539)
    at mondrian.olap.Query$QuerySchemaReader.lookupCompound(Query.java:1506)
    at 
mondrian.olap.fun.BuiltinFunTable$23.strToMember(BuiltinFunTable.java:649)
    at 
mondrian.olap.fun.BuiltinFunTable$23$1.evaluateMember(BuiltinFunTable.java:639)
    at mondrian.calc.impl.MemberValueCalc.evaluate(MemberValueCalc.java:47)
    at 
mondrian.rolap.RolapEvaluator.evaluateCurrent(RolapEvaluator.java:529)



Nikolay Samofatov



More information about the Mondrian mailing list