Search in sources :

Example 16 with SqlQuery

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;
    }
}
Also used : Table(mondrian.rolap.RolapStar.Table) SqlQuery(mondrian.rolap.sql.SqlQuery) Column(mondrian.rolap.RolapStar.Column) AggStar(mondrian.rolap.aggmatcher.AggStar) Column(mondrian.rolap.RolapStar.Column)

Aggregations

SqlQuery (mondrian.rolap.sql.SqlQuery)16 MondrianDef (mondrian.olap.MondrianDef)3 Dialect (mondrian.spi.Dialect)3 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 RolapAggregator (mondrian.rolap.RolapAggregator)2 AggStar (mondrian.rolap.aggmatcher.AggStar)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 RolapStar (mondrian.rolap.RolapStar)1 Column (mondrian.rolap.RolapStar.Column)1 Table (mondrian.rolap.RolapStar.Table)1 JdbcSchema (mondrian.rolap.aggmatcher.JdbcSchema)1 TupleConstraint (mondrian.rolap.sql.TupleConstraint)1 UnmodifiableArrayList (org.olap4j.impl.UnmodifiableArrayList)1