[Mondrian] that was fun...

Ati Rosselet ati.rosselet at gmail.com
Sun Dec 14 20:04:02 EST 2008


ok... so there is a bug in the rollupPolicy="partial" implementation...
that's over my head.

My next task... adding drillthrough columns for the fact table.. NOT present
in any dimensions. Typically information fields.. that really wouldn't
aggregate.
I implemented an extension to the Cube in mondrian.xml
<Attribute name="extDrillThroughCols" type="String" required="false">
            <Doc>
                Specify additional columns to be added from fact table at
drillthrough
                format "colname:alias,colname:alias"
            </Doc>
        </Attribute>
and then modified RolapCube.java , adding a field

   private String[] extraDrillThroughColumns;

and to the NON virtual constructor:

   if (xmlCube.extDrillThroughCols!=null)
            this.extraDrillThroughColumns =
xmlCube.extDrillThroughCols.split(",");


now all I needed to do was modify the DrillThroughQuerySpec, and it all
seems to work..
I can now specify my additional tables like:
<Cube name="FI" extDrillThroughCols="text2:Info,text3:Text3">   (format is
"column:alias", where column is a column in the fact table).

if anyone is interested.. the DrillThroughQuerySpec changes are as follows:
added field:
   private final ArrayList<String[]> extColumnDefs;
changed constructor:
        super(request.getMeasure().getStar(), countOnly);
        this.request = request;
        extColumnDefs=getCubeExtraColDefs();   // new for handling extra
drillthrough columns

added:
 private ArrayList<String[]> getCubeExtraColDefs() {
        ArrayList<String[]> retval = new ArrayList<String[]>();
        try {
            mondrian.rolap.RolapCube cube = (mondrian.rolap.RolapCube)
getStar().getSchema().lookupCube(request.getMeasure().getCubeName(), false);
            if (cube != null && !cube.isVirtual() &&
cube.getExtraDrillThroughColumns() != null) {

                for (String extColDef : cube.getExtraDrillThroughColumns())
{
                    String[] pair = extColDef.split(":");
                    retval.add(pair);
                }
                if (retval.size() != 0) {
                    // if extra columns are defined, save the factable name
to the list - probably prettier in a separate variable... TBD
                    retval.add(0, new String[]{"fact",
cube.getStar().getFactTable().getTableName()});
                }
            }
        } catch (Exception ex) {
            System.out.println("cube lookup failed??");
        }
        return retval;
    }


and modified generateSqlQuery() to handle defined extra columns

public String generateSqlQuery() {
        SqlQuery sqlQuery = newSqlQuery();
        nonDistinctGenerateSql(sqlQuery);
        if (extColumnDefs.size()!=0){
            String factTable= extColumnDefs.get(0)[1];
            for(int i=1;i<extColumnDefs.size();i++){
                String[] pair = extColumnDefs.get(i);
                sqlQuery.addSelect("\""+factTable+"\".\""+pair[0]+"\"",
pair[1]);
            }
        }
        return sqlQuery.toString();
    }


works great in JPivot too...

Cheers
Ati
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20081215/444a0d5b/attachment.html 


More information about the Mondrian mailing list