[Mondrian] #2710740 - Parent/Child hierarchy with no closure causes ClassCastException.

rolf.lear at algorithmics.com rolf.lear at algorithmics.com
Tue Mar 24 21:01:42 EDT 2009


Hi all... This is just a duplicate of my tracker item submitted to
sourceforge #2710740
 
Attached is the test-case I put together to 'exorcise' this bug.
 
 
Mondrian throws a class-cast exception when attempting to process an MDX
referencing members on a Parent/child dimension where there is no
closure on the hierarchy.
 
I have confirmed this issue against the latest code in the 3.1 Perforce
repo as of this morning. Attached is a TestCase which I believe would be
most appropriate to put in mondrian.test.ParentChildHierarchyTest (which
is where I have been using it). The test case is 'simple'. It runs a
simple MDX query against the Parent/Child hierarchy in
FoodMart(Employees) using a Closure table. Then runs the identical MDX
against the identical cube except the second time there is no closure
defined. It attemtps to assert that the results of both MDX's are
identical.
 
The trace as thrown in JUnit is as follows, and I have taken the liberty
of 'annotating it' so that I can describe the relevant details of the
problem. My notes are indicated with *rlear note x* and after the trace
I give a break-down of the relevant system states for the various notes.
 
mondrian.olap.MondrianException: Mondrian Error:Internal error: Error
while executing query [select {[Measures].[Count]} ON COLUMNS,
  NON EMPTY {[Employees].AllMembers} ON ROWS
from [HR4C]
]
        at
mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:811)
        at mondrian.olap.Util.newInternal(Util.java:1472)
        at mondrian.olap.Util.newError(Util.java:1488)
        at
mondrian.rolap.RolapConnection.execute(RolapConnection.java:589)
        at mondrian.test.TestContext.executeQuery(TestContext.java:478)
        at
mondrian.test.TestContext.assertQueryReturns(TestContext.java:820)
        at
mondrian.test.ParentChildHierarchyTest.testClosureVsNoClosure(ParentChil
dHierarchyTest.java:238)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:164)
        at junit.framework.TestCase.runBare(TestCase.java:130)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:120)
        at junit.framework.TestSuite.runTest(TestSuite.java:230)
        at junit.framework.TestSuite.run(TestSuite.java:225)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUn
it3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.ja
va:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)
Caused by: java.lang.ClassCastException: mondrian.rolap.RolapMember
*rlear note 1*
        at
mondrian.rolap.RolapCubeHierarchy$CacheRolapCubeHierarchyMemberReader.re
adMemberChildren(RolapCubeHierarchy.java:475)
        at
mondrian.rolap.RolapCubeHierarchy$CacheRolapCubeHierarchyMemberReader.ge
tMemberChildren(RolapCubeHierarchy.java:585)
        at
mondrian.rolap.SmartMemberReader.getMemberChildren(SmartMemberReader.jav
a:175)
        at
mondrian.rolap.SmartMemberReader.getMemberChildren(SmartMemberReader.jav
a:165)
*rlear note 2*
        at
mondrian.rolap.SqlMemberSource$RolapParentChildMember.getPropertyValue(S
qlMemberSource.java:1158)
        at
mondrian.rolap.RolapCubeMember.getPropertyValue(RolapCubeMember.java:223
)
        at
mondrian.rolap.RolapMember.getPropertyValue(RolapMember.java:524)
        at
mondrian.olap.fun.BuiltinFunTable$22$1.aggregateChildren(BuiltinFunTable
.java:713)
        at
mondrian.olap.fun.BuiltinFunTable$22$1$1.evaluate(BuiltinFunTable.java:7
00)
        at
mondrian.rolap.RolapEvaluator.evaluateCurrent(RolapEvaluator.java:449)
        at
mondrian.rolap.RolapResult.executeStripe(RolapResult.java:890)
        at
mondrian.rolap.RolapResult.executeStripe(RolapResult.java:1027)
        at
mondrian.rolap.RolapResult.executeStripe(RolapResult.java:1027)
        at mondrian.rolap.RolapResult.executeBody(RolapResult.java:788)
        at mondrian.rolap.RolapResult.<init>(RolapResult.java:414)
        at
mondrian.rolap.RolapConnection.execute(RolapConnection.java:560)
        ... 21 more
 
 
*rlear note 1* the list parentRolapCubeMemberList is iterated over with
the expectation that it contains RolapCubeMember instances. In this
particular case though, it contains just a RolapMember (not
RolapCubeMember). This is what causes the exception.
 
*rlear note 2* the RolapParentChildMember that is referred to here is
actually a RolapParentChildMemberNoClosure, and the significance of the
trace at this point is that the 'dataMember' instance variable is a
plain RolapMember, not a RolapCubeMember. This is why the
ClassCastException happens later in the trace.
 
 
I tried to 'fix' this issue by modifying the
SqlMemberSource.makeMember() method to create the
RolapParentChildMemberNoClosure instance with a RolapCubeMember in the
constructor instead of a RolapCube, and this works for single-level
hierarchies, but, there is a form of recursion that happens in this code
section as the hierarchy is traversed finding the Child members, and I
can't find a way to ensure that the correct RolapCubeMember is used in
the lower levels. Further, I am not certain that this would be the best
'fix'.
 
Rolf

 


 
--------------------------------------------------------------------------
This email and any files transmitted with it are confidential and proprietary to Algorithmics Incorporated and its affiliates ("Algorithmics"). If received in error, use is prohibited. Please destroy, and notify sender. Sender does not waive confidentiality or privilege. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. Algorithmics does not accept liability for any errors or omissions. Any commitment intended to bind Algorithmics must be reduced to writing and signed by an authorized signatory.
--------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090324/c618092e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.testcase.java.snippet
Type: application/octet-stream
Size: 1843 bytes
Desc: bug.testcase.java.snippet
Url : http://lists.pentaho.org/pipermail/mondrian/attachments/20090324/c618092e/attachment.obj 


More information about the Mondrian mailing list