Search in sources :

Example 71 with Result

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

the class FunctionTest method testPropertiesFilter.

public void testPropertiesFilter() {
    Result result = executeQuery("SELECT { [Store Sales] } ON COLUMNS,\n" + " TOPCOUNT(Filter( [Store].[Store Name].Members,\n" + "                   [Store].CurrentMember.Properties(\"Store Type\") = \"Supermarket\"),\n" + "           10, [Store Sales]) ON ROWS\n" + "FROM [Sales]");
    Assert.assertEquals(8, result.getAxes()[1].getPositions().size());
}
Also used : Result(mondrian.olap.Result)

Example 72 with Result

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

the class FunctionTest method testCurrentMemberFromAxis.

public void testCurrentMemberFromAxis() {
    Result result = executeQuery("with member [Measures].[Foo] as" + " '[Gender].CurrentMember.Name" + " || [Marital Status].CurrentMember.Name'\n" + "select {[Measures].[Foo]} on columns,\n" + " CrossJoin({[Gender].children}," + "           {[Marital Status].children}) on rows\n" + "from Sales");
    Assert.assertEquals("FM", result.getCell(new int[] { 0, 0 }).getValue());
}
Also used : Result(mondrian.olap.Result)

Example 73 with Result

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

the class FunctionTest method testCoalesceEmpty.

public void testCoalesceEmpty() {
    // [DF] is all null and [WA] has numbers for 1997 but not for 1998.
    Result result = executeQuery("with\n" + "    member Measures.[Coal1] as 'coalesceempty(([Time].[1997], Measures.[Store Sales]), ([Time].[1998], " + "Measures.[Store Sales]))'\n" + "    member Measures.[Coal2] as 'coalesceempty(([Time].[1997], Measures.[Unit Sales]), ([Time].[1998], " + "Measures.[Unit Sales]))'\n" + "select \n" + "    {Measures.[Coal1], Measures.[Coal2]} on columns,\n" + "    {[Store].[All Stores].[Mexico].[DF], [Store].[All Stores].[USA].[WA]} on rows\n" + "from \n" + "    [Sales]");
    checkDataResults(new Double[][] { new Double[] { null, null }, new Double[] { new Double(263793.22), new Double(124366) } }, result, 0.001);
    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.[Sales Per Customer], Measures.[Coal]} on columns,\n" + "    {[Store].[All Stores].[Mexico].[DF], [Store].[All Stores].[USA].[WA]} on rows\n" + "from \n" + "    [Sales]\n" + "where\n" + "    ([Time].[1997].[Q2])");
    checkDataResults(new Double[][] { new Double[] { null, null }, new Double[] { new Double(8.963), new Double(8.963) } }, result, 0.001);
    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], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        ([Measures].[Sales Per Customer], [Store].[All Stores].[Mexico].[DF]),\n" + "        Measures.[Sales Per Customer])'\n" + "select \n" + "    {Measures.[Sales Per Customer], Measures.[Coal]} on columns,\n" + "    {[Store].[All Stores].[Mexico].[DF], [Store].[All Stores].[USA].[WA]} on rows\n" + "from \n" + "    [Sales]\n" + "where\n" + "    ([Time].[1997].[Q2])");
    checkDataResults(new Double[][] { new Double[] { null, null }, new Double[] { new Double(8.963), new Double(8.963) } }, result, 0.001);
}
Also used : Result(mondrian.olap.Result)

Example 74 with Result

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

the class FunctionTest method testBasic.

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

Example 75 with Result

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

the class FunctionTest method testBasic2.

public void testBasic2() {
    Result result = executeQuery("select {[Gender].[F].NextMember} ON COLUMNS from Sales");
    assertEquals("M", result.getAxes()[0].getPositions().get(0).get(0).getName());
}
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