Search in sources :

Example 1 with WindowIgnoreNullsStep

use of org.jooq.WindowIgnoreNullsStep in project jOOQ by jOOQ.

the class DefaultParseContext method parseFieldLeadLagIf.

private final Field<?> parseFieldLeadLagIf() {
    boolean lead = parseFunctionNameIf("LEAD");
    boolean lag = !lead && parseFunctionNameIf("LAG");
    if (lead || lag) {
        parse('(');
        Field<Void> f1 = (Field) parseField();
        Integer f2 = null;
        Field<Void> f3 = null;
        if (parseIf(',')) {
            f2 = asInt(parseUnsignedIntegerLiteral());
            if (parseIf(','))
                f3 = (Field) parseField();
        }
        WindowIgnoreNullsStep s1 = lead ? f2 == null ? lead(f1) : f3 == null ? lead(f1, f2) : lead(f1, f2, f3) : f2 == null ? lag(f1) : f3 == null ? lag(f1, f2) : lag(f1, f2, f3);
        WindowOverStep<?> s2 = parseWindowRespectIgnoreNulls(s1, s1);
        parse(')');
        return parseWindowFunction(null, s1, s2);
    }
    return null;
}
Also used : BigInteger(java.math.BigInteger) GroupField(org.jooq.GroupField) TableField(org.jooq.TableField) Field(org.jooq.Field) SortField(org.jooq.SortField) SelectField(org.jooq.SelectField) WindowIgnoreNullsStep(org.jooq.WindowIgnoreNullsStep)

Example 2 with WindowIgnoreNullsStep

use of org.jooq.WindowIgnoreNullsStep in project jOOQ by jOOQ.

the class DefaultParseContext method parseFieldNthValueIf.

private final Field<?> parseFieldNthValueIf() {
    if (parseFunctionNameIf("NTH_VALUE")) {
        parse('(');
        Field<?> f1 = parseField();
        parse(',');
        Field<?> f2 = parseField();
        WindowFromFirstLastStep<?> s1 = nthValue(f1, (Field) f2);
        WindowIgnoreNullsStep s2 = parseWindowFromFirstLast(s1, s1);
        WindowOverStep<?> s3 = parseWindowRespectIgnoreNulls(s2, s2);
        parse(')');
        return parseWindowFunction(s1, s2, s3);
    }
    return null;
}
Also used : WindowIgnoreNullsStep(org.jooq.WindowIgnoreNullsStep)

Aggregations

WindowIgnoreNullsStep (org.jooq.WindowIgnoreNullsStep)2 BigInteger (java.math.BigInteger)1 Field (org.jooq.Field)1 GroupField (org.jooq.GroupField)1 SelectField (org.jooq.SelectField)1 SortField (org.jooq.SortField)1 TableField (org.jooq.TableField)1