[jOOQ/jOOQ#14360] Add parser support for prefixed PARTITION BY .. OUTER

JOIN syntax

This includes:

- [jOOQ/jOOQ#14361] Add API support for fullJoin(..).partitionBy(..)
This commit is contained in:
Lukas Eder 2022-12-05 11:06:45 +01:00
parent 046900cf89
commit b2dd7d4c21
6 changed files with 344 additions and 32 deletions

View File

@ -1618,7 +1618,7 @@ extends
*/
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
TableOnStep<Record> fullJoin(TableLike<?> table);
TablePartitionByStep<Record> fullJoin(TableLike<?> table);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1633,7 +1633,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullJoin(SQL sql);
TablePartitionByStep<Record> fullJoin(SQL sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1648,7 +1648,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullJoin(String sql);
TablePartitionByStep<Record> fullJoin(String sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1663,7 +1663,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullJoin(String sql, Object... bindings);
TablePartitionByStep<Record> fullJoin(String sql, Object... bindings);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1678,7 +1678,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullJoin(String sql, QueryPart... parts);
TablePartitionByStep<Record> fullJoin(String sql, QueryPart... parts);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1687,7 +1687,7 @@ extends
*/
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
TableOnStep<Record> fullJoin(Name name);
TablePartitionByStep<Record> fullJoin(Name name);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1696,7 +1696,7 @@ extends
*/
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
TableOnStep<Record> fullOuterJoin(TableLike<?> table);
TablePartitionByStep<Record> fullOuterJoin(TableLike<?> table);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1714,7 +1714,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullOuterJoin(SQL sql);
TablePartitionByStep<Record> fullOuterJoin(SQL sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1732,7 +1732,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql);
TablePartitionByStep<Record> fullOuterJoin(String sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1751,7 +1751,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql, Object... bindings);
TablePartitionByStep<Record> fullOuterJoin(String sql, Object... bindings);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1770,7 +1770,7 @@ extends
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql, QueryPart... parts);
TablePartitionByStep<Record> fullOuterJoin(String sql, QueryPart... parts);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
@ -1781,7 +1781,7 @@ extends
*/
@NotNull
@Support({ FIREBIRD, HSQLDB, POSTGRES, SQLITE, YUGABYTEDB })
TableOnStep<Record> fullOuterJoin(Name name);
TablePartitionByStep<Record> fullOuterJoin(Name name);
/**
* <code>CROSS JOIN</code> a table to this table.

View File

@ -39,7 +39,7 @@ package org.jooq;
import org.jetbrains.annotations.*;
import static org.jooq.SQLDialect.DEFAULT;
// ...
import org.jooq.impl.DSL;
@ -484,6 +484,202 @@ public interface TableOuterJoinStep<R extends Record> {

View File

@ -1337,7 +1337,7 @@ implements
// ------------------------------------------------------------------------
@Override
public final TableOptionalOnStep<Record> join(TableLike<?> table, JoinType type) {
public final JoinTable<?> join(TableLike<?> table, JoinType type) {
switch (type) {
case CROSS_APPLY:
return new CrossApply(this, table);
@ -1569,62 +1569,62 @@ implements
}
@Override
public final TableOnStep<Record> fullOuterJoin(TableLike<?> table) {
return join(table, FULL_OUTER_JOIN);
public final TablePartitionByStep<Record> fullOuterJoin(TableLike<?> table) {
return (TablePartitionByStep<Record>) join(table, FULL_OUTER_JOIN);
}
@Override
public final TableOnStep<Record> fullOuterJoin(SQL sql) {
public final TablePartitionByStep<Record> fullOuterJoin(SQL sql) {
return fullOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql) {
public final TablePartitionByStep<Record> fullOuterJoin(String sql) {
return fullOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql, Object... bindings) {
public final TablePartitionByStep<Record> fullOuterJoin(String sql, Object... bindings) {
return fullOuterJoin(table(sql, bindings));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql, QueryPart... parts) {
public final TablePartitionByStep<Record> fullOuterJoin(String sql, QueryPart... parts) {
return fullOuterJoin(table(sql, parts));
}
@Override
public final TableOnStep<Record> fullOuterJoin(Name name) {
public final TablePartitionByStep<Record> fullOuterJoin(Name name) {
return fullOuterJoin(table(name));
}
@Override
public final TableOnStep<Record> fullJoin(TableLike<?> table) {
public final TablePartitionByStep<Record> fullJoin(TableLike<?> table) {
return fullOuterJoin(table);
}
@Override
public final TableOnStep<Record> fullJoin(SQL sql) {
public final TablePartitionByStep<Record> fullJoin(SQL sql) {
return fullOuterJoin(sql);
}
@Override
public final TableOnStep<Record> fullJoin(String sql) {
public final TablePartitionByStep<Record> fullJoin(String sql) {
return fullOuterJoin(sql);
}
@Override
public final TableOnStep<Record> fullJoin(String sql, Object... bindings) {
public final TablePartitionByStep<Record> fullJoin(String sql, Object... bindings) {
return fullOuterJoin(sql, bindings);
}
@Override
public final TableOnStep<Record> fullJoin(String sql, QueryPart... parts) {
public final TablePartitionByStep<Record> fullJoin(String sql, QueryPart... parts) {
return fullOuterJoin(sql, parts);
}
@Override
public final TableOnStep<Record> fullJoin(Name name) {
public final TablePartitionByStep<Record> fullJoin(Name name) {
return fullOuterJoin(name);
}

View File

@ -154,7 +154,7 @@ import org.jooq.impl.QOM.UnmodifiableList;
*/
abstract class JoinTable<J extends JoinTable<J>>
extends
AbstractTable<Record>
AbstractTable<Record>
implements
TableOuterJoinStep<Record>,
TableOptionalOnStep<Record>,

View File

@ -669,6 +669,7 @@ import org.jooq.TableField;
import org.jooq.TableLike;
import org.jooq.TableOnStep;
import org.jooq.TableOptionalOnStep;
import org.jooq.TableOuterJoinStep;
import org.jooq.TablePartitionByStep;
import org.jooq.Truncate;
import org.jooq.TruncateCascadeStep;
@ -7417,6 +7418,50 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
private final Table<?> parseJoinedTableIf(Table<?> left, BooleanSupplier forbiddenKeywords) {
int p = position();
if (!ignoreProEdition() && parseKeywordIf("PARTITION BY") && requireProEdition()) {
}
JoinType joinType = parseJoinTypeIf();
if (joinType == null)
@ -7433,9 +7478,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
case LEFT_OUTER_JOIN:
case FULL_OUTER_JOIN:
case RIGHT_OUTER_JOIN:
if (!ignoreProEdition() && parseKeywordIf("PARTITION BY")) {
requireProEdition();
if (!ignoreProEdition() && parseKeywordIf("PARTITION BY") && requireProEdition()) {

View File

@ -37,6 +37,7 @@
*/
package org.jooq.impl;
import static org.jooq.JoinType.FULL_OUTER_JOIN;
import static org.jooq.JoinType.LEFT_OUTER_JOIN;
import static org.jooq.JoinType.RIGHT_OUTER_JOIN;
import static org.jooq.impl.DSL.table;
@ -52,8 +53,8 @@ import org.jooq.Record;
import org.jooq.SQL;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableOnStep;
import org.jooq.TableOuterJoinStep;
import org.jooq.TablePartitionByStep;
/**
* @author Lukas Eder
@ -218,6 +219,78 @@ final class PartitionJoinTable implements TableOuterJoinStep<Record> {