Skip to content

Commit

Permalink
Fix bug MONDRIAN-1105, "AggLevel column attribute not used properly i…
Browse files Browse the repository at this point in the history
…n all cases". Fix and test case contributed by Dan Dosch.

Obsolete method CsvDBTestCase.getCubeTestContext(). Derived classes can use the standard getTestContext() method if we take a little care during setUp(). Allow derived classes to create their own test context.
  • Loading branch information
julianhyde committed Apr 12, 2012
1 parent b3f75bc commit bb8cea9
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/aggmatcher/AggStar.java
Expand Up @@ -1340,7 +1340,7 @@ private void loadLevel(final JdbcSchema.Table.Column.Usage usage) {
convertTable(
AggStar.this.star.getColumn(bitPosition)
.getTable(),
null);
usage.levelColumnName);
/*
* Make sure to return the last child table, since
* AggQuerySpec will take care of going up the
Expand Down
10 changes: 5 additions & 5 deletions testsrc/main/mondrian/rolap/RolapResultTest.java
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2011 Pentaho and others
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap;
Expand Down Expand Up @@ -98,7 +98,7 @@ public void testAll() throws Exception {
+ " ON ROWS "
+ "from FTAll";

getCubeTestContext().assertQueryReturns(mdx, RESULTS_ALL);
getTestContext().assertQueryReturns(mdx, RESULTS_ALL);
/*
Result result = getCubeTestContext().executeQuery(mdx);
String resultString = TestContext.toString(result);
Expand All @@ -122,7 +122,7 @@ public void testD1() throws Exception {
+ "from FT1";

//getCubeTestContext().assertQueryReturns(mdx, RESULTS);
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
String resultString = TestContext.toString(result);
//System.out.println(resultString);
/*
Expand Down Expand Up @@ -151,7 +151,7 @@ public void testD2() throws Exception {
+ " ON ROWS "
+ "from FT2";

getCubeTestContext().assertQueryReturns(mdx, RESULTS);
getTestContext().assertQueryReturns(mdx, RESULTS);
/*
Result result = getCubeTestContext().executeQuery(mdx);
String resultString = TestContext.toString(result);
Expand Down Expand Up @@ -184,7 +184,7 @@ public void _testNullDefaultMeasure() throws Exception {
+ "from FT2Extra";

//getCubeTestContext().assertQueryReturns(mdx, RESULTS);
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
String resultString = TestContext.toString(result);
assertTrue(resultString.equals(RESULTS));
}
Expand Down
18 changes: 9 additions & 9 deletions testsrc/main/mondrian/rolap/aggmatcher/BUG_1541077.java
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2009 Pentaho and others
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
Expand Down Expand Up @@ -43,12 +43,12 @@ public void testStoreCount() throws Exception {

String mdx =
"select {[Measures].[Store Count]} on columns from Cheques";
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

propSaver.set(props.UseAggregates, true);

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -66,12 +66,12 @@ public void testSalesCount() throws Exception {

String mdx =
"select {[Measures].[Sales Count]} on columns from Cheques";
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

propSaver.set(props.UseAggregates, true);

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -89,12 +89,12 @@ public void testTotalAmount() throws Exception {

String mdx =
"select {[Measures].[Total Amount]} on columns from Cheques";
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

propSaver.set(props.UseAggregates, false);

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -112,13 +112,13 @@ public void testBug1541077() throws Exception {

String mdx = "select {[Measures].[Avg Amount]} on columns from Cheques";

Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getFormattedValue();

// get value with aggregates
propSaver.set(props.UseAggregates, true);

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getFormattedValue();

assertTrue(v.equals(v1));
Expand Down
8 changes: 3 additions & 5 deletions testsrc/main/mondrian/rolap/aggmatcher/Checkin_7634.java
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2006-2009 Pentaho and others
// Copyright (C) 2006-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
Expand Down Expand Up @@ -39,8 +39,6 @@ public class Checkin_7634 extends CsvDBTestCase {

private static final String CHECKIN_7634 = "Checkin_7634.csv";

private int crossJoinSize;

public Checkin_7634() {
super();
}
Expand All @@ -64,15 +62,15 @@ public void testCrossJoin() throws Exception {
propSaver.set(
MondrianProperties.instance().CrossJoinOptimizerSize,
Integer.MAX_VALUE);
Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
String resultString1 = TestContext.toString(result1);

// Execute query using the new version of the CrossJoin
// nonEmptyList optimization
propSaver.set(
MondrianProperties.instance().CrossJoinOptimizerSize,
Integer.MAX_VALUE);
Result result2 = getCubeTestContext().executeQuery(mdx);
Result result2 = getTestContext().executeQuery(mdx);
String resultString2 = TestContext.toString(result2);

// This succeeds.
Expand Down
11 changes: 4 additions & 7 deletions testsrc/main/mondrian/rolap/aggmatcher/Checkin_7641.java
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2006-2009 Pentaho and others
// Copyright (C) 2006-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
Expand All @@ -27,12 +27,9 @@
*/
public class Checkin_7641 extends CsvDBTestCase {
private static final String DIRECTORY =
"testsrc/main/mondrian/rolap/aggmatcher";
"testsrc/main/mondrian/rolap/aggmatcher";
private static final String CHECKIN_7641 = "Checkin_7641.csv";

public static final String PROP_NAME = "mondrian.test.checkin.7641";

//private boolean useImplicitMembers;
public Checkin_7641() {
super();
}
Expand All @@ -59,9 +56,9 @@ public void testImplicitMember() throws Exception {
+ "[Geography].[All Regions].Children)) ON ROWS"
+ " from [ImplicitMember]";

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
String resultString1 = TestContext.toString(result1);
Result result2 = getCubeTestContext().executeQuery(mdx);
Result result2 = getTestContext().executeQuery(mdx);
String resultString2 = TestContext.toString(result2);

assertEquals(resultString1, resultString2);
Expand Down
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2011 Pentaho and others
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
Expand Down Expand Up @@ -45,26 +45,26 @@ public void testTotal() throws Exception {

String mdx =
"select {[Measures].[Total]} on columns from [Fact]";
Result result = getCubeTestContext().executeQuery(mdx);
Result result = getTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

String mdx2 =
"select {[Measures].[Total]} on columns from [Fact] where "
+ "{[Product].[Cat One].[Prod Cat One].[One]}";
Result aresult = getCubeTestContext().executeQuery(mdx2);
Result aresult = getTestContext().executeQuery(mdx2);
Object av = aresult.getCell(new int[]{0}).getValue();

// unless there is a way to flush the cache,
// I'm skeptical about these results
propSaver.set(props.UseAggregates, true);
propSaver.set(props.ReadAggregates, false);

Result result1 = getCubeTestContext().executeQuery(mdx);
Result result1 = getTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));

Result aresult2 = getCubeTestContext().executeQuery(mdx2);
Result aresult2 = getTestContext().executeQuery(mdx2);
Object av1 = aresult2.getCell(new int[]{0}).getValue();

assertTrue(av.equals(av1));
Expand All @@ -82,7 +82,7 @@ public void testTupleSelection() throws Exception {
+ "{[Store].[All Stores]}) on rows "
+ "from [Fact]";

getCubeTestContext().assertQueryReturns(
getTestContext().assertQueryReturns(
mdx,
"Axis #0:\n"
+ "{}\n"
Expand All @@ -101,7 +101,7 @@ public void testChildSelection() throws Exception {

String mdx = "select {[Measures].[Total]} on columns, "
+ "non empty [Product].[Cat One].Children on rows from [Fact]";
getCubeTestContext().assertQueryReturns(
getTestContext().assertQueryReturns(
mdx,
"Axis #0:\n"
+ "{}\n"
Expand Down
Expand Up @@ -4,7 +4,7 @@
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2011 Pentaho and others
// Copyright (C) 2005-2012 Pentaho and others
// All Rights Reserved.
*/
package mondrian.rolap.aggmatcher;
Expand Down Expand Up @@ -189,7 +189,7 @@ public void testSingleJoin() throws Exception {
final String mdx =
"select {[Measures].[Unit Sales]} on columns, {[dimension.tenant].[tenant].Members} on rows from [foo]";

final TestContext context = getCubeTestContext();
final TestContext context = getTestContext();

// We expect the correct cell value + 1 if the agg table is used.
context.assertQueryReturns(
Expand All @@ -213,7 +213,7 @@ public void testComplexJoin() throws Exception {
final String mdx =
"select {[Measures].[Unit Sales]} on columns, {[dimension.distributor].[line class].Members} on rows from [foo]";

final TestContext context = getCubeTestContext();
final TestContext context = getTestContext();

// We expect the correct cell value + 1 if the agg table is used.
context.assertQueryReturns(
Expand Down Expand Up @@ -249,7 +249,7 @@ public void testComplexJoinDefaultRecognizer() throws Exception {
return;
}

final TestContext context = getCubeTestContext();
final TestContext context = getTestContext();

// We expect the correct cell value + 2 if the agg table is used.
final String mdx =
Expand Down

0 comments on commit bb8cea9

Please sign in to comment.