Search in sources :

Example 6 with MemberExpr

use of mondrian.mdx.MemberExpr in project mondrian by pentaho.

the class SqlConstraintUtilsTest method makeAggregateExprMember.

private Member makeAggregateExprMember(Evaluator mockEvaluator, List<Member> endMembers) {
    Member member = Mockito.mock(Member.class);
    Mockito.doReturn(true).when(member).isCalculated();
    Member aggregatedMember0 = Mockito.mock(Member.class);
    Exp aggregateArg0 = new MemberExpr(aggregatedMember0);
    FunDef dummy = Mockito.mock(FunDef.class);
    Mockito.doReturn(Syntax.Function).when(dummy).getSyntax();
    Mockito.doReturn("dummy").when(dummy).getName();
    FunDef funDef = new AggregateFunDef(dummy);
    Exp[] args = new Exp[] { aggregateArg0 };
    Type returnType = new DecimalType(1, 1);
    Exp memberExp = new ResolvedFunCall(funDef, args, returnType);
    Mockito.doReturn(memberExp).when(member).getExpression();
    SetEvaluator setEvaluator = Mockito.mock(SetEvaluator.class);
    Mockito.doReturn(setEvaluator).when(mockEvaluator).getSetEvaluator(aggregateArg0, true);
    Mockito.doReturn(new UnaryTupleList(endMembers)).when(setEvaluator).evaluateTupleIterable();
    Assert.assertEquals(true, member.isCalculated());
    Assert.assertEquals(true, SqlConstraintUtils.isSupportedCalculatedMember(member));
    return member;
}
Also used : SetEvaluator(mondrian.olap.Evaluator.SetEvaluator) FunDef(mondrian.olap.FunDef) ParenthesesFunDef(mondrian.olap.fun.ParenthesesFunDef) AggregateFunDef(mondrian.olap.fun.AggregateFunDef) NullFunDef(mondrian.olap.fun.CrossJoinTest.NullFunDef) NullType(mondrian.olap.type.NullType) DecimalType(mondrian.olap.type.DecimalType) TupleType(mondrian.olap.type.TupleType) Type(mondrian.olap.type.Type) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) MemberExpr(mondrian.mdx.MemberExpr) DecimalType(mondrian.olap.type.DecimalType) AggregateFunDef(mondrian.olap.fun.AggregateFunDef) ResolvedFunCall(mondrian.mdx.ResolvedFunCall) Exp(mondrian.olap.Exp) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Example 7 with MemberExpr

use of mondrian.mdx.MemberExpr in project mondrian by pentaho.

the class SqlConstraintUtilsTest method makeSupportedExpressionForCalculatedMember.

private Exp makeSupportedExpressionForCalculatedMember() {
    Exp memberExpr = new MemberExpr(Mockito.mock(Member.class));
    Assert.assertEquals(true, SqlConstraintUtils.isSupportedExpressionForCalculatedMember(memberExpr));
    return memberExpr;
}
Also used : MemberExpr(mondrian.mdx.MemberExpr) Exp(mondrian.olap.Exp) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Example 8 with MemberExpr

use of mondrian.mdx.MemberExpr in project mondrian by pentaho.

the class SqlContextConstraint method findMeasures.

/**
 * Extracts the stored measures referenced in an expression
 *
 * @param exp expression
 * @param baseCubes set of base cubes
 */
private static void findMeasures(Exp exp, Set<RolapCube> baseCubes, List<RolapCube> baseCubeList) {
    if (exp instanceof MemberExpr) {
        MemberExpr memberExpr = (MemberExpr) exp;
        Member member = memberExpr.getMember();
        if (member instanceof RolapStoredMeasure) {
            addMeasure((RolapStoredMeasure) member, baseCubes, baseCubeList);
        } else if (member instanceof RolapCalculatedMember) {
            findMeasures(member.getExpression(), baseCubes, baseCubeList);
        }
    } else if (exp instanceof ResolvedFunCall) {
        ResolvedFunCall funCall = (ResolvedFunCall) exp;
        Exp[] args = funCall.getArgs();
        for (Exp arg : args) {
            findMeasures(arg, baseCubes, baseCubeList);
        }
    }
}
Also used : MemberExpr(mondrian.mdx.MemberExpr) ResolvedFunCall(mondrian.mdx.ResolvedFunCall) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember)

Aggregations

MemberExpr (mondrian.mdx.MemberExpr)8 Member (mondrian.olap.Member)7 TestMember (mondrian.olap.fun.TestMember)7 Exp (mondrian.olap.Exp)5 ResolvedFunCall (mondrian.mdx.ResolvedFunCall)4 FunDef (mondrian.olap.FunDef)3 AggregateFunDef (mondrian.olap.fun.AggregateFunDef)3 NullFunDef (mondrian.olap.fun.CrossJoinTest.NullFunDef)3 ParenthesesFunDef (mondrian.olap.fun.ParenthesesFunDef)3 DecimalType (mondrian.olap.type.DecimalType)3 NullType (mondrian.olap.type.NullType)3 TupleType (mondrian.olap.type.TupleType)3 Type (mondrian.olap.type.Type)3 Connection (mondrian.olap.Connection)2 Query (mondrian.olap.Query)2 QueryAxis (mondrian.olap.QueryAxis)2 Execution (mondrian.server.Execution)2 TestContext (mondrian.test.TestContext)2 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)1 SetEvaluator (mondrian.olap.Evaluator.SetEvaluator)1