Search in sources :

Example 11 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testSubtraction.

public void testSubtraction() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("-");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "([Measures].[Store Cost] - [Measures].[Unit Sales])");
        q.resolve(q.createValidator(cftab, true));
    } catch (Throwable e) {
        fail(e.getMessage());
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 12 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testMixingMemberLimitation.

/**
 * Mondrian is not strict about referencing a dimension member in calculated
 * measures.
 *
 * <p>The following expression passes parsing and validation.
 * Its computation is strange: the result is as if the measure is defined as
 *  ([Measures].[Store Cost] + [Measures].[Store Cost])
 */
public void testMixingMemberLimitation() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "([Measures].[Store Cost] + [Store].[USA])");
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here
        fail("Expected error did not occur.");
    } catch (Throwable e) {
        checkErrorMsg(e, "Expected error did not occur.");
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 13 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method getCustomizedFunctionTable.

CustomizedFunctionTable getCustomizedFunctionTable(Set<String> funNameSet) {
    Set<FunDef> specialFunctions = new HashSet<FunDef>();
    specialFunctions.add(new ParenthesesFunDef(Category.Numeric));
    CustomizedFunctionTable cftab = new CustomizedFunctionTable(funNameSet, specialFunctions);
    cftab.init();
    return cftab;
}
Also used : ParenthesesFunDef(mondrian.olap.fun.ParenthesesFunDef) ParenthesesFunDef(mondrian.olap.fun.ParenthesesFunDef) CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Example 14 with CustomizedFunctionTable

use of mondrian.olap.fun.CustomizedFunctionTable in project mondrian by pentaho.

the class CustomizedParserTest method testTupleFail.

public void testTupleFail() {
    Set<String> functionNameSet = new HashSet<String>();
    functionNameSet.add("+");
    functionNameSet.add("-");
    functionNameSet.add("*");
    functionNameSet.add("/");
    CustomizedFunctionTable cftab = getCustomizedFunctionTable(functionNameSet);
    try {
        Query q = getParsedQueryForExpr(cftab, "([Store].[USA], [Gender].[F])");
        q.resolve(q.createValidator(cftab, true));
        // Shouldn't reach here
        fail("Expected error did not occur.");
    } catch (Throwable e) {
        checkErrorMsg(e, "Mondrian Error:No function matches signature '(<Member>, <Member>)'");
    }
}
Also used : CustomizedFunctionTable(mondrian.olap.fun.CustomizedFunctionTable) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)14 CustomizedFunctionTable (mondrian.olap.fun.CustomizedFunctionTable)14 ParenthesesFunDef (mondrian.olap.fun.ParenthesesFunDef)1