Java Code Examples for org.apache.kylin.metadata.model.FunctionDesc#isMax()

The following examples show how to use org.apache.kylin.metadata.model.FunctionDesc#isMax() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryGenerator.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static String createMeasureStatement(List<MeasureDesc> measureList) {
    StringBuilder sql = new StringBuilder();

    for (MeasureDesc measureDesc : measureList) {
        FunctionDesc functionDesc = measureDesc.getFunction();
        if (functionDesc.isSum() || functionDesc.isMax() || functionDesc.isMin()) {
            sql.append("," + functionDesc.getExpression() + "(" + functionDesc.getParameter().getValue() + ")\n");
            break;
        } else if (functionDesc.isCountDistinct()) {
            sql.append(",COUNT" + "(DISTINCT " + functionDesc.getParameter().getValue() + ")\n");
            break;
        }
    }

    return sql.toString();
}
 
Example 2
Source File: FunctionRule.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private void validateReturnType(ValidateContext context, CubeDesc cube, FunctionDesc funcDesc) {

        String func = funcDesc.getExpression();
        DataType rtype = funcDesc.getReturnDataType();

        if (funcDesc.isCount()) {
            if (rtype.isIntegerFamily() == false) {
                context.addResult(ResultLevel.ERROR, "Return type for function " + func + " must be one of " + DataType.INTEGER_FAMILY);
            }
        } else if (funcDesc.isCountDistinct()) {
            if (rtype.isHLLC() == false && funcDesc.isHolisticCountDistinct() == false) {
                context.addResult(ResultLevel.ERROR, "Return type for function " + func + " must be hllc(10), hllc(12) etc.");
            }
        } else if (funcDesc.isMax() || funcDesc.isMin() || funcDesc.isSum()) {
            if (rtype.isNumberFamily() == false) {
                context.addResult(ResultLevel.ERROR, "Return type for function " + func + " must be one of " + DataType.NUMBER_FAMILY);
            }
        } else {
            if (StringUtils.equalsIgnoreCase(KylinConfig.getInstanceFromEnv().getProperty(KEY_IGNORE_UNKNOWN_FUNC, "false"), "false")) {
                context.addResult(ResultLevel.ERROR, "Unrecognized function: [" + func + "]");
            }
        }

    }