Search in sources :

Example 66 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testUnionQuery.

public void testUnionQuery() {
    Result result = executeQuery("select {[Measures].[Unit Sales], " + "[Measures].[Store Cost], " + "[Measures].[Store Sales]} on columns,\n" + " Hierarchize(\n" + "   Union(\n" + "     Crossjoin(\n" + "       Crossjoin([Gender].[All Gender].children,\n" + "                 [Marital Status].[All Marital Status].children),\n" + "       Crossjoin([Customers].[All Customers].children,\n" + "                 [Product].[All Products].children) ),\n" + "     Crossjoin({([Gender].[All Gender].[M], [Marital Status].[All Marital Status].[M])},\n" + "       Crossjoin(\n" + "         [Customers].[All Customers].[USA].children,\n" + "         [Product].[All Products].children) ) )) on rows\n" + "from Sales where ([Time].[1997])");
    final Axis rowsAxis = result.getAxes()[1];
    Assert.assertEquals(45, rowsAxis.getPositions().size());
}
Also used : Axis(mondrian.olap.Axis) Result(mondrian.olap.Result)

Example 67 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testBrokenContextBug.

public void testBrokenContextBug() {
    Result result = executeQuery("with\n" + "    member Measures.[Sales Per Customer] as 'Measures.[Sales Count] / Measures.[Customer Count]'\n" + "    member Measures.[Coal] as 'coalesceempty(([Measures].[Sales Per Customer], [Store].[All Stores]" + ".[Mexico].[DF]),\n" + "        Measures.[Sales Per Customer])'\n" + "select \n" + "    {Measures.[Coal]} on columns,\n" + "    {[Store].[All Stores].[USA].[WA]} on rows\n" + "from \n" + "    [Sales]\n" + "where\n" + "    ([Time].[1997].[Q2])");
    checkDataResults(new Double[][] { { new Double(8.963) } }, result, 0.001);
}
Also used : Result(mondrian.olap.Result)

Example 68 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testFirstInLevel.

public void testFirstInLevel() {
    Result result = executeQuery("select {[Gender].[F].PrevMember} ON COLUMNS from Sales");
    assertEquals(0, result.getAxes()[0].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Example 69 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testFilterCompound.

public void testFilterCompound() {
    Result result = executeQuery("select {[Measures].[Unit Sales]} on columns,\n" + "  Filter(\n" + "    CrossJoin(\n" + "      [Gender].Children,\n" + "      [Customers].[USA].Children),\n" + "    [Measures].[Unit Sales] > 9500) on rows\n" + "from Sales\n" + "where ([Time].[1997].[Q1])");
    List<Position> rows = result.getAxes()[1].getPositions();
    Assert.assertEquals(3, rows.size());
    Assert.assertEquals("F", rows.get(0).get(0).getName());
    Assert.assertEquals("WA", rows.get(0).get(1).getName());
    Assert.assertEquals("M", rows.get(1).get(0).getName());
    Assert.assertEquals("OR", rows.get(1).get(1).getName());
    Assert.assertEquals("M", rows.get(2).get(0).getName());
    Assert.assertEquals("WA", rows.get(2).get(1).getName());
}
Also used : Position(mondrian.olap.Position) Result(mondrian.olap.Result)

Example 70 with Result

use of mondrian.olap.Result in project mondrian by pentaho.

the class FunctionTest method testAll.

public void testAll() {
    Result result = executeQuery("select {[Gender].PrevMember} ON COLUMNS from Sales");
    // previous to [Gender].[All] is null, so no members are returned
    assertEquals(0, result.getAxes()[0].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Aggregations

Result (mondrian.olap.Result)113 Axis (mondrian.olap.Axis)24 Member (mondrian.olap.Member)10 Test (org.junit.Test)10 Cell (mondrian.olap.Cell)9 Connection (mondrian.olap.Connection)9 Query (mondrian.olap.Query)9 Position (mondrian.olap.Position)8 TestContext (mondrian.test.TestContext)7 ArrayList (java.util.ArrayList)5 MondrianProperties (mondrian.olap.MondrianProperties)5 OlapElement (mondrian.olap.OlapElement)5 RolapCell (mondrian.rolap.RolapCell)5 NonEmptyResult (mondrian.rolap.RolapConnection.NonEmptyResult)5 Execution (mondrian.server.Execution)5 Dialect (mondrian.spi.Dialect)5 OlapConnection (org.olap4j.OlapConnection)5 List (java.util.List)4 ResultBase (mondrian.olap.ResultBase)4 Evaluator (mondrian.olap.Evaluator)3