[prev in list] [next in list] [prev in thread] [next in thread]
List: mondrian
Subject: [Mondrian] that was fun...
From: "Ati Rosselet" <ati.rosselet () gmail ! com>
Date: 2008-12-15 1:04:02
Message-ID: ce6402fc0812141704t7f64f2b5wef7a5367e3ac54db () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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
[Attachment #5 (text/html)]
ok... so there is a bug in the rollupPolicy="partial" implementation... \
that's over my head. <br><br>My next task... adding drillthrough columns for the \
fact table.. NOT present in any dimensions. Typically information fields.. that \
really wouldn't aggregate.<br> I implemented an extension to the Cube in \
mondrian.xml <br><Attribute name="extDrillThroughCols" \
type="String" \
required="false"><br> \
<Doc><br> \
Specify additional columns to be added from fact table at drillthrough<br> \
\
format "colname:alias,colname:alias"<br> \
</Doc><br> </Attribute><br>and \
then modified RolapCube.java , adding a field <br><br> private String[] \
extraDrillThroughColumns;<br> <br>and to the NON virtual \
constructor:<br><br> if \
(xmlCube.extDrillThroughCols!=null)<br> \
this.extraDrillThroughColumns = \
xmlCube.extDrillThroughCols.split(",");<br><br><br>now all I needed to do \
was modify the DrillThroughQuerySpec, and it all seems to work..<br> I can now \
specify my additional tables like:<br><Cube name="FI" \
extDrillThroughCols="text2:Info,text3:Text3"> (format is \
"column:alias", where column is a column in the fact table).<br> <br>if \
anyone is interested.. the DrillThroughQuerySpec changes are as follows:<br>added \
field:<br> private final ArrayList<String[]> \
extColumnDefs;<br>changed constructor:<br> \
super(request.getMeasure().getStar(), countOnly);<br> \
this.request = \
request;<br> \
extColumnDefs=getCubeExtraColDefs(); // new for handling extra \
drillthrough columns<br><br>added:<br> private ArrayList<String[]> \
getCubeExtraColDefs() {<br> \
ArrayList<String[]> retval = new ArrayList<String[]>();<br> \
try \
{<br> \
mondrian.rolap.RolapCube cube = (mondrian.rolap.RolapCube) \
getStar().getSchema().lookupCube(request.getMeasure().getCubeName(), \
false);<br> if \
(cube != null && !cube.isVirtual() && \
cube.getExtraDrillThroughColumns() != null) {<br> \
<br> \
for (String extColDef : cube.getExtraDrillThroughColumns()) \
{<br> \
String[] pair = extColDef.split(":");<br> \
retval.add(pair);<br> \
}<br> \
if (retval.size() != 0) {<br> \
\
// if extra columns are defined, save the factable name to the list - probably \
prettier in a separate variable... TBD \
<br> \
retval.add(0, new String[]{"fact", \
cube.getStar().getFactTable().getTableName()});<br> \
\
}<br> \
}<br> } catch (Exception ex) \
{<br> \
System.out.println("cube lookup \
failed??");<br> \
}<br> return retval;<br> \
}<br><br><br>and modified generateSqlQuery() to handle defined extra columns<br> \
<br>public String generateSqlQuery() {<br> \
SqlQuery sqlQuery = newSqlQuery();<br> \
nonDistinctGenerateSql(sqlQuery);<br> if \
(extColumnDefs.size()!=0){<br> \
String factTable= extColumnDefs.get(0)[1];<br> \
for(int \
i=1;i<extColumnDefs.size();i++){<br> \
String[] pair = extColumnDefs.get(i);<br> \
sqlQuery.addSelect("\""+factTable+"\".\""+pair[0]+"\"", \
pair[1]);<br> \
}<br> \
} \
<br> return \
sqlQuery.toString();<br> }<br><br><br>works great in JPivot \
too...<br><br>Cheers<br>Ati<br>
_______________________________________________
Mondrian mailing list
Mondrian@pentaho.org
http://lists.pentaho.org/mailman/listinfo/mondrian
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic