Search in sources :

Example 96 with Result

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

the class BasicQueryTest method testFilteredCrossJoin.

/**
 * This resulted in {@link OutOfMemoryError} when the BatchingCellReader did not know the values for the tuples that
 * were used in filters.
 */
public void testFilteredCrossJoin() {
    TestContext.instance().flushSchemaCache();
    Result result = executeQuery("select {[Measures].[Store Sales]} on columns,\n" + "  NON EMPTY Crossjoin(\n" + "    Filter([Customers].[Name].Members,\n" + "      (([Measures].[Store Sales],\n" + "        [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],\n" + "        [Time].[1997].[Q1].[1]) > 5.0)),\n" + "    Filter([Product].[Product Name].Members,\n" + "      (([Measures].[Store Sales],\n" + "        [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],\n" + "        [Time].[1997].[Q1].[1]) > 5.0))\n" + " ) ON rows\n" + "from [Sales]\n" + "where (\n" + "  [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],\n" + "  [Time].[1997].[Q1].[1]\n" + ")\n");
    // ok if no OutOfMemoryError occurs
    Axis a = result.getAxes()[1];
    assertEquals(12, a.getPositions().size());
}
Also used : Axis(mondrian.olap.Axis) Result(mondrian.olap.Result)

Example 97 with Result

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

the class BasicQueryTest method testAllLevelName.

public void testAllLevelName() {
    TestContext testContext = TestContext.instance().createSubstitutingCube("Sales", "<Dimension name=\"Gender4\" foreignKey=\"customer_id\">\n" + "  <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"\n" + " allLevelName=\"GenderLevel\" primaryKey=\"customer_id\">\n" + "  <Table name=\"customer\"/>\n" + "    <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>\n" + "  </Hierarchy>\n" + "</Dimension>");
    String mdx = "select {[Gender4].[All Gender]} on columns from Sales";
    Result result = testContext.executeQuery(mdx);
    Axis axis0 = result.getAxes()[0];
    Position pos0 = axis0.getPositions().get(0);
    Member allGender = pos0.get(0);
    String caption = allGender.getLevel().getName();
    Assert.assertEquals(caption, "GenderLevel");
}
Also used : Position(mondrian.olap.Position) Member(mondrian.olap.Member) Axis(mondrian.olap.Axis) Result(mondrian.olap.Result)

Example 98 with Result

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

the class BasicQueryTest method testNonEmptyCrossJoin.

/**
 * Tests a query with a CrossJoin so large that we run out of memory unless we can push down evaluation to SQL.
 */
public void testNonEmptyCrossJoin() {
    if (!props.EnableNativeCrossJoin.get()) {
        // memory.
        return;
    }
    TestContext.instance().flushSchemaCache();
    Result result = executeQuery("select {[Measures].[Store Sales]} on columns,\n" + "  NON EMPTY Crossjoin(\n" + "    [Customers].[Name].Members,\n" + "    [Product].[Product Name].Members\n" + " ) ON rows\n" + "from [Sales]\n" + "where (\n" + "  [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],\n" + "  [Time].[1997].[Q1].[1]\n" + ")\n");
    // ok if no OutOfMemoryError occurs
    Axis a = result.getAxes()[1];
    assertEquals(67, a.getPositions().size());
}
Also used : Axis(mondrian.olap.Axis) Result(mondrian.olap.Result)

Example 99 with Result

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

the class BasicQueryTest method testMembersOfLargeDimensionTheHardWay.

public void testMembersOfLargeDimensionTheHardWay() {
    // Avoid this test if memory is scarce.
    if (Bug.avoidMemoryOverflow(TestContext.instance().getDialect())) {
        return;
    }
    final Connection connection = TestContext.instance().getConnection();
    String queryString = "select {[Measures].[Unit Sales]} on columns,\n" + "{[Customers].members} on rows\n" + "from Sales";
    Query query = connection.parseQuery(queryString);
    Result result = connection.execute(query);
    assertEquals(10407, result.getAxes()[1].getPositions().size());
}
Also used : Query(mondrian.olap.Query) RolapConnection(mondrian.rolap.RolapConnection) OlapConnection(org.olap4j.OlapConnection) Connection(mondrian.olap.Connection) Result(mondrian.olap.Result)

Example 100 with Result

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

the class BasicQueryTest method testBug1630754.

/**
 * Tests for bug #1630754. In Mondrian 2.2.2 the SqlTupleReader.readTuples method would create a SQL having an
 * in-clause with more that 1000 entities under some circumstances. This exceeded the limit for Oracle resulting in an
 * ORA-01795 error.
 */
public void testBug1630754() {
    // In order to reproduce this bug a dimension with 2 levels with more
    // than 1000 member each was necessary. The customer_id column has more
    // than 1000 distinct members so it was used for this test.
    TestContext testContext = TestContext.instance().createSubstitutingCube("Sales", "  <Dimension name=\"Customer_2\" foreignKey=\"customer_id\">\n" + "    <Hierarchy hasAll=\"true\" " + "allMemberName=\"All Customers\" " + "primaryKey=\"customer_id\" " + " >\n" + "      <Table name=\"customer\"/>\n" + "      <Level name=\"Name1\" column=\"customer_id\" uniqueMembers=\"true\"/>" + "      <Level name=\"Name2\" column=\"customer_id\" uniqueMembers=\"true\"/>\n" + "    </Hierarchy>\n" + "  </Dimension>");
    Result result = testContext.executeQuery("WITH SET [#DataSet#] AS " + "   'NonEmptyCrossjoin({Descendants([Customer_2].[All Customers], 2)}, " + "   {[Product].[All Products]})' " + "SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} on columns, " + "Hierarchize({[#DataSet#]}) on rows FROM [Sales]");
    final int rowCount = result.getAxes()[1].getPositions().size();
    assertEquals(5581, rowCount);
}
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