Search in sources :

Example 1 with LimitRecordCursorFactory

use of io.questdb.griffin.engine.LimitRecordCursorFactory in project questdb by bluestreak01.

the class SqlCodeGenerator method generateLimit.

private RecordCursorFactory generateLimit(RecordCursorFactory factory, QueryModel model, SqlExecutionContext executionContext) throws SqlException {
    ExpressionNode limitLo = model.getLimitLo();
    ExpressionNode limitHi = model.getLimitHi();
    if (limitLo == null && limitHi == null) {
        return factory;
    }
    final Function loFunc;
    final Function hiFunc;
    if (limitLo == null) {
        loFunc = LongConstant.ZERO;
    } else {
        loFunc = functionParser.parseFunction(limitLo, EmptyRecordMetadata.INSTANCE, executionContext);
        final int type = loFunc.getType();
        if (limitTypes.excludes(type)) {
            throw SqlException.$(limitLo.position, "invalid type: ").put(ColumnType.nameOf(type));
        }
    }
    if (limitHi != null) {
        hiFunc = functionParser.parseFunction(limitHi, EmptyRecordMetadata.INSTANCE, executionContext);
        final int type = hiFunc.getType();
        if (limitTypes.excludes(type)) {
            throw SqlException.$(limitHi.position, "invalid type: ").put(ColumnType.nameOf(type));
        }
    } else {
        hiFunc = null;
    }
    return new LimitRecordCursorFactory(factory, loFunc, hiFunc);
}
Also used : SymbolFunction(io.questdb.griffin.engine.functions.SymbolFunction) GroupByFunction(io.questdb.griffin.engine.functions.GroupByFunction) AnalyticFunction(io.questdb.griffin.engine.analytic.AnalyticFunction) LimitRecordCursorFactory(io.questdb.griffin.engine.LimitRecordCursorFactory)

Aggregations

LimitRecordCursorFactory (io.questdb.griffin.engine.LimitRecordCursorFactory)1 AnalyticFunction (io.questdb.griffin.engine.analytic.AnalyticFunction)1 GroupByFunction (io.questdb.griffin.engine.functions.GroupByFunction)1 SymbolFunction (io.questdb.griffin.engine.functions.SymbolFunction)1