[Mondrian] Mondrian Query element is not working

Ika Krtveli ikakartveli at yahoo.com
Sun Jul 19 18:30:08 EDT 2009


Hello, 

I know there is another thread related to this one at http://forums.pentaho.org/showthread.php?t=61848, but i was unable to subscribe to that thread so sending out this one instead. 

Here is a simple example that demonstrates the issue:
Given
the following simple schema, were i am defining two identical
dimensions one using query element and other using standard table
element

<?xml version="1.0"?>
<Schema name="QueryVsTable">
  <Cube name="Sales" defaultMeasure="Unit Sales">
    <Table name="sales_fact_1997"/>

      <Dimension name="ProductQuery" foreignKey="product_id">
        <Hierarchy hasAll="true" primaryKey="product_id">
          <Query><SQL dialect="generic"> SELECT * FROM "product_class" </SQL></Query>
          <Level name="Product Family" column="product_family"/>
        </Hierarchy>
      </Dimension>

      <Dimension name="ProductTable" foreignKey="product_id">
        <Hierarchy hasAll="true" primaryKey="product_id">
          <Table name="product_class"/>
          <Level name="Product Family" column="product_family"/>
        </Hierarchy>
      </Dimension>

      <Measure name="Unit Sales" column="unit_sales" aggregator="sum"/> 
   
  </Cube>
</Schema>

and then running the snippet:

import java.sql.DriverManager;
import java.sql.SQLException;
import org.olap4j.OlapConnection;

public class TestQuery {
    public static void main(String[] args) throws SQLException{

        OlapConnection connection = DriverManager.getConnection(
                    "jdbc:mondrian:Jdbc=jdbc:postgresql:" +
                    "//localhost/foodmartdb?user=foodmart&password=foodmart;" +
                    "Catalog=FoodMart.xml; " +
                    "JdbcDrivers=org.postgresql.Driver")
                    .unwrap(OlapConnection.class);

        int levelsInTable = connection.getSchema()
                            .getCubes()      .get( "Sales"   )
                            .getDimensions() .get( "ProductTable" )
                            .getHierarchies().get(0)
                            .getLevels()     .size();

        int levelsInQuery = connection.getSchema()
                            .getCubes()      .get( "Sales"   )
                            .getDimensions() .get( "ProductQuery" )
                            .getHierarchies().get(0)
                            .getLevels()     .size();

        System.out.format("Levels in Table = %d, Levels in Query = %d\n", levelsInTable, levelsInQuery );
    }
}

I am getting the output: Levels in Table = 2, Levels in Query = 1.
So it seems that there is problem with hierarchy construction when
using a Query element. This is then causing the problem highlighted in http://forums.pentaho.org/showthread.php?t=61848 where Mondrian throws "[Dimension].[Level1].[Level2] not found in cube" error. I  tryed to debug it through, but quickly got lost in the code. Any help would be greatly appreciated. Currently I am using "mondrian-3.0.4.11371"

Thanks, 
ikusha



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090719/b8e18384/attachment.html 


More information about the Mondrian mailing list