Source:
<code>public static boolean isValidContext( Evaluator context, boolean disallowVirtualCube, Level levels, boolean strict, FunDef fun) { if (context == null) { return false; } RolapCube cube = (RolapCube) context.getCube(); if (disallowVirtualCube) { if (cube.isVirtual()) { return false; } } if (cube.isVirtual()) { Query query = context.getQuery(); Set<RolapCube> baseCubes = new HashSet<RolapCube>(); List<RolapCube> baseCubeList = new ArrayList<RolapCube>(); if (!findVirtualCubeBaseCubes(query, baseCubes, baseCubeList)) { return false; } assert levels != null; query.setBaseCubes(baseCubeList); } if (SqlConstraintUtils.measuresConflictWithMembers( context.getQuery().getMeasuresMembers(), context.getMembers())) { return false; } if (!strict) { return true; } Member[] members = context.getMembers(); for (int i = 0; i < members.length; i++) { boolean isCalculated = members[i].isCalculated(); if (isCalculated && !SqlConstraintUtils .isSupportedCalculatedMember(members[i])) { return false; } } int maxConstraints = MondrianProperties.instance().MaxConstraints.get(); int supportedCalculatedMembersQuantity = SqlConstraintUtils .expandSupportedCalculatedMembers( members, context).length; <START> if (supportedCalculatedMembersQuantity > maxConstraints) { <END> String message = MondrianResource.instance() .MembersQuantityExceedsMaxConstraints .str(String.valueOf(supportedCalculatedMembersQuantity)); alertNonNative(context, fun, message); return false; } return true; }</code><technical_language>@YuryBY this count correct multiple calculated members in context. E.g. aggregate Customer another aggregate Store. IN list for attributes individually fall maxConstraints. include a test covers case, well</technical_language>

Target:
public static boolean isValidContext( Evaluator context, boolean disallowVirtualCube, Level levels, boolean strict, FunDef fun) { if (context == null) { return false; } RolapCube cube = (RolapCube) context.getCube(); if (disallowVirtualCube) { if (cube.isVirtual()) { return false; } } if (cube.isVirtual()) { Query query = context.getQuery(); Set<RolapCube> baseCubes = new HashSet<RolapCube>(); List<RolapCube> baseCubeList = new ArrayList<RolapCube>(); if (!findVirtualCubeBaseCubes(query, baseCubes, baseCubeList)) { return false; } assert levels != null; query.setBaseCubes(baseCubeList); } if (SqlConstraintUtils.measuresConflictWithMembers( context.getQuery().getMeasuresMembers(), context.getMembers())) { return false; } if (!strict) { return true; } int maxConstraints = MondrianProperties.instance().MaxConstraints.get(); Member[] members = context.getMembers(); int calculatedMembersQuantity = 0; for (int i = 0; i < members.length; i++) { if (!(members[i].isCalculated())) { continue; } if (!SqlConstraintUtils.isSupportedCalculatedMember(members[i])) { return false; } List<Member> listMembers = SqlConstraintUtils .expandExpressions(members[i], null, context); Set<Member> uniqueMembers = new HashSet<Member>(listMembers); calculatedMembersQuantity = uniqueMembers.size(); if (calculatedMembersQuantity > maxConstraints) { String message = MondrianResource.instance() .MembersQuantityExceedsMaxConstraints .str(String.valueOf(calculatedMembersQuantity)); alertNonNative(context, fun, message); return false; } } return true; }