Skip to content

Commit

Permalink
in query model use Exists(<set1>,<set2>).Count > 0 instead of mondria…
Browse files Browse the repository at this point in the history
…n-specific <set1> IN <set2>

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@516 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
pstoellberger committed Feb 27, 2012
1 parent 9f1c518 commit f0a1a2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions src/org/olap4j/query/Olap4jNodeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,23 @@ private static ParseTreeNode toHierarchyConsistentNode(
generateListSetCall(ancestorList);
CallNode inClause = new CallNode(
null,
"IN",
Syntax.Infix,
"Exists",
Syntax.Function,
ancestorNode,
ancestorSet);
inConditions.add(inClause);
CallNode count =
new CallNode(
null,
"Count",
Syntax.Property,
inClause);
CallNode greaterZero =
new CallNode(
null,
" > 0",
Syntax.Postfix,
count);
inConditions.add(greaterZero);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions testsrc/org/olap4j/OlapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1480,8 +1480,8 @@ public void testHierarchyConsistency() throws Exception {
String mdxString = query.getSelect().toString();
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{{[Product].[All Products]}, {[Product].[Food]}, Filter({{[Product].[Food].[Deli], [Product].[Food].[Dairy]}}, (Ancestor([Product].CurrentMember, [Product].[Product Family]) IN {[Product].[Food]})), Filter({{[Product].[Product Category].Members}}, ((Ancestor([Product].CurrentMember, [Product].[Product Family]) IN {[Product].[Food]}) AND (Ancestor([Product].CurrentMember, [Product].[Product Department]) IN {[Product].[Food].[Deli], [Product].[Food].[Dairy]})))} ON COLUMNS,\n"
+ "{{[Time].[1997]}, Filter({{[Time].[1997].[Q3].[7], [Time].[1997].[Q4].[11]}}, (Ancestor([Time].CurrentMember, [Time].[Year]) IN {[Time].[1997]}))} ON ROWS\n"
+ "{{[Product].[All Products]}, {[Product].[Food]}, Filter({{[Product].[Food].[Deli], [Product].[Food].[Dairy]}}, (Exists(Ancestor([Product].CurrentMember, [Product].[Product Family]), {[Product].[Food]}).Count > 0)), Filter({{[Product].[Product Category].Members}}, ((Exists(Ancestor([Product].CurrentMember, [Product].[Product Family]), {[Product].[Food]}).Count > 0) AND (Exists(Ancestor([Product].CurrentMember, [Product].[Product Department]), {[Product].[Food].[Deli], [Product].[Food].[Dairy]}).Count > 0)))} ON COLUMNS,\n"
+ "{{[Time].[1997]}, Filter({{[Time].[1997].[Q3].[7], [Time].[1997].[Q4].[11]}}, (Exists(Ancestor([Time].CurrentMember, [Time].[Year]), {[Time].[1997]}).Count > 0))} ON ROWS\n"
+ "FROM [Sales]",
mdxString);

Expand Down Expand Up @@ -1538,7 +1538,7 @@ public void testHierarchyConsistency() throws Exception {
TestContext.assertEqualsVerbose(
"SELECT\n"
+ "{[Product].[Food]} ON COLUMNS,\n"
+ "Hierarchize(Union(CrossJoin(Filter({[Time].[1997].[Q3].[7]}, (Ancestor([Time].CurrentMember, [Time].[Year]) IN {[Time].[1997]})), {[Measures].[Sales Count]}), Union(CrossJoin(Filter({[Time].[1997].[Q4].[11]}, (Ancestor([Time].CurrentMember, [Time].[Year]) IN {[Time].[1997]})), {[Measures].[Sales Count]}), CrossJoin({[Time].[1997]}, {[Measures].[Sales Count]})))) ON ROWS\n"
+ "Hierarchize(Union(CrossJoin(Filter({[Time].[1997].[Q3].[7]}, (Exists(Ancestor([Time].CurrentMember, [Time].[Year]), {[Time].[1997]}).Count > 0)), {[Measures].[Sales Count]}), Union(CrossJoin(Filter({[Time].[1997].[Q4].[11]}, (Exists(Ancestor([Time].CurrentMember, [Time].[Year]), {[Time].[1997]}).Count > 0)), {[Measures].[Sales Count]}), CrossJoin({[Time].[1997]}, {[Measures].[Sales Count]})))) ON ROWS\n"
+ "FROM [Sales]",
mdxString2);

Expand Down

0 comments on commit f0a1a2e

Please sign in to comment.