use of mondrian.rolap.sql.SqlQuery in project mondrian by pentaho.
the class SqlConstraintUtils method getLevelColumn.
/**
* Gets the column, using AggStar if available, and ensures the table is in
* the query.
*/
private static RolapStar.Column getLevelColumn(RolapLevel level, RolapCube baseCube, AggStar aggStar, SqlQuery sqlQuery) {
final RolapStar.Column column = ((RolapCubeLevel) level).getBaseStarKeyColumn(baseCube);
if (aggStar != null) {
int bitPos = column.getBitPosition();
final AggStar.Table.Column aggColumn = aggStar.lookupColumn(bitPos);
AggStar.Table table = aggColumn.getTable();
table.addToFrom(sqlQuery, false, true);
// create a delegate to use the aggregated column's expression
return new Column(aggColumn.getDatatype()) {
public String generateExprString(SqlQuery query) {
// used by predicates for sql generation
return aggColumn.generateExprString(query);
}
public int getBitPosition() {
// this is the same as the one in RolapStar.Column
return aggColumn.getBitPosition();
}
public Table getTable() {
return column.getTable();
}
public RolapStar getStar() {
return column.getStar();
}
};
} else {
column.getTable().addToFrom(sqlQuery, false, true);
return column;
}
}
Aggregations