use of mondrian.test.TestContext in project mondrian by pentaho.
the class AggregationOnDistinctCountMeasuresTest method testMultiLevelMembersMixedNullNonNullParent.
public void testMultiLevelMembersMixedNullNonNullParent() {
if (!isDefaultNullMemberRepresentation()) {
return;
}
String dimension = "<Dimension name=\"Warehouse2\">\n" + " <Hierarchy hasAll=\"true\" primaryKey=\"warehouse_id\">\n" + " <Table name=\"warehouse\"/>\n" + " <Level name=\"fax\" column=\"warehouse_fax\" uniqueMembers=\"true\"/>\n" + " <Level name=\"address1\" column=\"wa_address1\" uniqueMembers=\"false\"/>\n" + " <Level name=\"name\" column=\"warehouse_name\" uniqueMembers=\"false\"/>\n" + " </Hierarchy>\n" + "</Dimension>\n";
String cube = "<Cube name=\"Warehouse2\">\n" + " <Table name=\"inventory_fact_1997\"/>\n" + " <DimensionUsage name=\"Product\" source=\"Product\" foreignKey=\"product_id\"/>\n" + " <DimensionUsage name=\"Warehouse2\" source=\"Warehouse2\" foreignKey=\"warehouse_id\"/>\n" + " <Measure name=\"Cost Count\" column=\"warehouse_cost\" aggregator=\"distinct-count\"/>\n" + "</Cube>";
String query = "with\n" + "set [Filtered Warehouse Set] as " + "{[Warehouse2].[#null].[234 West Covina Pkwy].[Freeman And Co]," + " [Warehouse2].[971-555-6213].[3377 Coachman Place].[Jones International]} " + "member [Warehouse2].[TwoMembers] as 'AGGREGATE([Filtered Warehouse Set])' " + "select {[Measures].[Cost Count]} on columns, {[Warehouse2].[TwoMembers]} on rows " + "from [Warehouse2]";
String necjSqlMySql2 = "select count(distinct `inventory_fact_1997`.`warehouse_cost`) as `m0` from `warehouse` as `warehouse`, `inventory_fact_1997` as `inventory_fact_1997` where `inventory_fact_1997`.`warehouse_id` = `warehouse`.`warehouse_id` and ((`warehouse`.`warehouse_name` = 'Freeman And Co' and `warehouse`.`wa_address1` = '234 West Covina Pkwy' and `warehouse`.`warehouse_fax` is null) or (`warehouse`.`warehouse_name` = 'Jones International' and `warehouse`.`wa_address1` = '3377 Coachman Place' and `warehouse`.`warehouse_fax` = '971-555-6213'))";
TestContext testContext = TestContext.instance().create(dimension, cube, null, null, null, null);
String result = "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Cost Count]}\n" + "Axis #2:\n" + "{[Warehouse2].[TwoMembers]}\n" + "Row #0: 220\n";
testContext.assertQueryReturns(query, result);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class AggregationOnInvalidRoleWhenNotIgnoringTest method createContext.
private TestContext createContext() {
TestContext context = TestContext.instance().create(null, CUBE, null, null, null, ROLE).withRole("Test");
context.flushSchemaCache();
return context;
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class AggMeasureFactCountTest method verifySameAggAndNot.
private void verifySameAggAndNot(String query, String schema) {
TestContext testContext = getTestContext().withSchema(schema);
Result resultWithAgg = testContext.withFreshConnection().executeQuery(query);
disableAggregates();
Result result = testContext.executeQuery(query);
String resultStr = TestContext.toString(result);
String resultWithAggStr = TestContext.toString(resultWithAgg);
assertEquals("Results with and without agg table should be equal", resultStr, resultWithAggStr);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class AggregationOverAggTableTest method testAvgMeasureLowestGranularity.
public void testAvgMeasureLowestGranularity() throws Exception {
TestContext testContext = ExplicitRecognizerTest.setupMultiColDimCube("", "column=\"the_year\"", "column=\"quarter\"", "column=\"month_of_year\" ", "");
String query = "select {[Measures].[Avg Unit Sales]} on columns, " + "non empty CrossJoin({[TimeExtra].[1997].[Q1].Children},{[Gender].[M]}) on rows " + "from [ExtraCol]";
testContext.assertQueryReturns(query, "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Avg Unit Sales]}\n" + "Axis #2:\n" + "{[TimeExtra].[1997].[Q1].[1], [Gender].[M]}\n" + "{[TimeExtra].[1997].[Q1].[2], [Gender].[M]}\n" + "{[TimeExtra].[1997].[Q1].[3], [Gender].[M]}\n" + "Row #0: 3\n" + "Row #1: 3\n" + "Row #2: 3\n");
assertQuerySqlOrNot(testContext, query, mysqlPattern("select\n" + " `agg_c_avg_sales_fact_1997`.`the_year` as `c0`,\n" + " `agg_c_avg_sales_fact_1997`.`quarter` as `c1`,\n" + " `agg_c_avg_sales_fact_1997`.`month_of_year` as `c2`,\n" + " `agg_c_avg_sales_fact_1997`.`gender` as `c3`,\n" + " (`agg_c_avg_sales_fact_1997`.`unit_sales`) / (`agg_c_avg_sales_fact_1997`.`fact_count`) as `m0`\n" + "from\n" + " `agg_c_avg_sales_fact_1997` as `agg_c_avg_sales_fact_1997`\n" + "where\n" + " `agg_c_avg_sales_fact_1997`.`the_year` = 1997\n" + "and\n" + " `agg_c_avg_sales_fact_1997`.`quarter` = 'Q1'\n" + "and\n" + " `agg_c_avg_sales_fact_1997`.`month_of_year` in (1, 2, 3)\n" + "and\n" + " `agg_c_avg_sales_fact_1997`.`gender` = 'M'"), false, false, true);
}
use of mondrian.test.TestContext in project mondrian by pentaho.
the class NonCollapsedAggTest method testComplexJoinDefaultRecognizer.
public void testComplexJoinDefaultRecognizer() throws Exception {
if (!isApplicable()) {
return;
}
final TestContext context = getTestContext();
// We expect the correct cell value + 2 if the agg table is used.
final String mdx = "select {[Measures].[Unit Sales]} on columns, {[dimension.distributor].[line class].Members} on rows from [foo2]";
context.assertQueryReturns(mdx, "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Unit Sales]}\n" + "Axis #2:\n" + "{[dimension.distributor].[distributor one].[line class one]}\n" + "{[dimension.distributor].[distributor two].[line class two]}\n" + "Row #0: 32\n" + "Row #1: 122\n");
final String mdx2 = "select {[Measures].[Unit Sales]} on columns, {[dimension.network].[line class].Members} on rows from [foo2]";
// We expect the correct cell value + 2 if the agg table is used.
context.assertQueryReturns(mdx2, "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Measures].[Unit Sales]}\n" + "Axis #2:\n" + "{[dimension.network].[network one].[line class one]}\n" + "{[dimension.network].[network two].[line class two]}\n" + "Row #0: 32\n" + "Row #1: 122\n");
}
Aggregations