Skip to content

Commit

Permalink
MONDRIAN: integrate changes #13774 and #13776 from 3.2 branch, Fix fo…
Browse files Browse the repository at this point in the history
…r MONDRIAN-777, degenerate shared dimensions not working with Views

[git-p4: depot-paths = "//open/mondrian/": change = 13777]
  • Loading branch information
Will Gorman committed Jul 28, 2010
1 parent 82bc169 commit 06e8ed6
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/mondrian/olap/Mondrian.xml
Expand Up @@ -1194,6 +1194,28 @@ Revision is $Id$
sql.cdata = code;
selects[selects.length - 1] = sql;
}

public boolean equals(Object o) {
if (o instanceof View) {
View that = (View) o;
if (!this.alias.equals(that.alias)) {
return false;
}
if (this.selects == null || that.selects == null || this.selects.length != that.selects.length) {
return false;
}
for (int i = 0; i < selects.length; i++) {
if (!Util.equals(this.selects[i].dialect, that.selects[i].dialect)
|| !Util.equals(this.selects[i].cdata, that.selects[i].cdata))
{
return false;
}
}
return true;
} else {
return false;
}
}
</Code>
</Element>

Expand Down
66 changes: 66 additions & 0 deletions testsrc/main/mondrian/test/SchemaTest.java
Expand Up @@ -1267,6 +1267,72 @@ public void testNonAliasedDimensionUsage() {
}
}

/**
* Tests a cube whose fact table is a &lt;View&gt; element as well as a
* degenerate dimension.
*/
public void testViewDegenerateDims() {
TestContext testContext = TestContext.create(
null,

// Warehouse cube where the default member in the Warehouse
// dimension is USA.
"<Cube name=\"Warehouse (based on view)\">\n"
+ " <View alias=\"FACT\">\n"
+ " <SQL dialect=\"generic\">\n"
+ " <![CDATA[select * from \"inventory_fact_1997\" as \"FOOBAR\"]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"oracle\">\n"
+ " <![CDATA[select * from \"inventory_fact_1997\" \"FOOBAR\"]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"mysql\">\n"
+ " <![CDATA[select * from `inventory_fact_1997` as `FOOBAR`]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"infobright\">\n"
+ " <![CDATA[select * from `inventory_fact_1997` as `FOOBAR`]]>\n"
+ " </SQL>\n"
+ " </View>\n"
+ " <DimensionUsage name=\"Time\" source=\"Time\" foreignKey=\"time_id\"/>\n"
+ " <DimensionUsage name=\"Product\" source=\"Product\" foreignKey=\"product_id\"/>\n"
+ " <DimensionUsage name=\"Store\" source=\"Store\" foreignKey=\"store_id\"/>\n"
+ " <Dimension name=\"Warehouse\">\n"
+ " <Hierarchy hasAll=\"true\"> \n"
+ " <View alias=\"FACT\">\n"
+ " <SQL dialect=\"generic\">\n"
+ " <![CDATA[select * from \"inventory_fact_1997\" as \"FOOBAR\"]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"oracle\">\n"
+ " <![CDATA[select * from \"inventory_fact_1997\" \"FOOBAR\"]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"mysql\">\n"
+ " <![CDATA[select * from `inventory_fact_1997` as `FOOBAR`]]>\n"
+ " </SQL>\n"
+ " <SQL dialect=\"infobright\">\n"
+ " <![CDATA[select * from `inventory_fact_1997` as `FOOBAR`]]>\n"
+ " </SQL>\n"
+ " </View>\n"
+ " <Level name=\"Warehouse ID\" column=\"warehouse_id\" uniqueMembers=\"true\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n"
+ " <Measure name=\"Warehouse Cost\" column=\"warehouse_cost\" aggregator=\"sum\"/>\n"
+ " <Measure name=\"Warehouse Sales\" column=\"warehouse_sales\" aggregator=\"sum\"/>\n"
+ "</Cube>", null, null, null, null);

testContext.assertQueryReturns(
"select\n"
+ " NON EMPTY {[Time].[1997], [Time].[1997].[Q3]} on columns,\n"
+ " NON EMPTY {[Store].[USA].Children} on rows\n"
+ "From [Warehouse (based on view)]\n"
+ "where [Warehouse].[2]",
"Axis #0:\n"
+ "{[Warehouse].[2]}\n"
+ "Axis #1:\n"
+ "{[Time].[1997]}\n"
+ "Axis #2:\n"
+ "{[Store].[USA].[WA]}\n"
+ "Row #0: 917.554\n");
}

/**
* Tests a cube whose fact table is a &lt;View&gt; element.
*/
Expand Down

0 comments on commit 06e8ed6

Please sign in to comment.