[Mondrian] Mondrian Query element is not working

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


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:
the following simple schema, were i am defining two identical
dimensions one using query element and other using standard table

<?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"/>

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

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

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; " +

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

        int levelsInQuery = connection.getSchema()
                            .getCubes()      .get( "Sales"   )
                            .getDimensions() .get( "ProductQuery" )
                            .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-"


-------------- 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