Skip to content

Commit

Permalink
MONDRIAN: fix sf.net bug #2118478, periodstodate should not
Browse files Browse the repository at this point in the history
       require hierarchy of type time

[git-p4: depot-paths = "//open/mondrian/": change = 11586]
  • Loading branch information
jsichi committed Sep 20, 2008
1 parent f4a9868 commit 8b15334
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/main/mondrian/olap/fun/PeriodsToDateFunDef.java
Expand Up @@ -56,12 +56,10 @@ public Type getResultType(Validator validator, Exp[] args) {
return new SetType(
MemberType.forHierarchy(hierarchy));
}
final Type type = args[0].getType();
if (type.getDimension() == null ||
type.getDimension().getDimensionType() !=
mondrian.olap.DimensionType.TimeDimension) {
throw MondrianResource.instance().TimeArgNeeded.ex(getName());
}

// If we have at least one arg, it's a level which will
// tell us the type.

return super.getResultType(validator, args);
}

Expand Down
4 changes: 0 additions & 4 deletions testsrc/main/mondrian/olap/fun/FunctionTest.java
Expand Up @@ -6553,10 +6553,6 @@ public void testPeriodsToDate() {
getTestContext().assertSetExprDependsOn(
"PeriodsToDate([Time].[Year], [Time].[1997].[Q2].[5])", "{}");

assertAxisThrows(
"PeriodsToDate([Product].[Product Family])",
"Argument to function 'PeriodsToDate' must belong to Time hierarchy.");

// two args
assertAxisReturns(
"PeriodsToDate([Time].[Quarter], [Time].[1997].[Q2].[5])",
Expand Down
32 changes: 31 additions & 1 deletion testsrc/main/mondrian/test/clearview/MiscTest.ref.xml
Expand Up @@ -127,7 +127,7 @@ Row #24: 11
<TestCase name="testSlicerStackOverflowNotContain">
<Resource name="description">
<![CDATA[
Tests that we do not get a stackoverflow for non-native necj evluation with slicer members that references the necj. (We do not get stackoverflow because if a dimension is referenced in the necj, then same dimension in the slicer is ignored.)
Tests that we do not get a stackoverflow for non-native necj evaluation with slicer members that references the necj. (We do not get stackoverflow because if a dimension is referenced in the necj, then same dimension in the slicer is ignored.)
]]>
</Resource>
<Resource name="mdx">
Expand Down Expand Up @@ -209,6 +209,36 @@ Axis #2:
{[Gender].[All Gender].[M]}
Row #0: 38,023
Row #1: 40,576
]]>
</Resource>
</TestCase>
<TestCase name="testPeriodstodateOnNonTimeDimension">
<Resource name="description">
<![CDATA[
Test for sf.net bug 2118478.
]]>
</Resource>
<Resource name="mdx">
<![CDATA[
select
{[Measures].[Unit Sales]} on columns,
periodstodate(
[Product].[Product Category],
[Product].[Food].[Baked Goods].[Bread].[Muffins]) on rows
from [Sales]
]]>
</Resource>
<Resource name="result">
<![CDATA[
Axis #0:
{}
Axis #1:
{[Measures].[Unit Sales]}
Axis #2:
{[Product].[All Products].[Food].[Baked Goods].[Bread].[Bagels]}
{[Product].[All Products].[Food].[Baked Goods].[Bread].[Muffins]}
Row #0: 815
Row #1: 3,497
]]>
</Resource>
</TestCase>
Expand Down

0 comments on commit 8b15334

Please sign in to comment.