[#7647] Support window function EXCLUDE clause
This commit is contained in:
parent
d62518fa25
commit
31e8dae615
96
jOOQ/src/main/java/org/jooq/WindowExcludeStep.java
Normal file
96
jOOQ/src/main/java/org/jooq/WindowExcludeStep.java
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL_8_0;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.POSTGRES_11;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* This type is used for the window function DSL API.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* field.firstValue()
|
||||
* .ignoreNulls()
|
||||
* .over()
|
||||
* .partitionBy(AUTHOR_ID)
|
||||
* .orderBy(PUBLISHED_IN.asc())
|
||||
* .rowsBetweenUnboundedPreceding()
|
||||
* .andUnboundedFollowing()
|
||||
* </pre></code>
|
||||
*
|
||||
* @param <T> The function return type
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface WindowExcludeStep<T> extends WindowFinalStep<T> {
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE CURRENT ROW</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> excludeCurrentRow();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE GROUP</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> excludeGroup();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE TIES</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> excludeTies();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE NO OTHERS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> excludeNoOthers();
|
||||
}
|
||||
@ -73,33 +73,33 @@ public interface WindowRowsAndStep<T> {
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> andUnboundedPreceding();
|
||||
WindowExcludeStep<T> andUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND [number] PRECEDING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> andPreceding(int number);
|
||||
WindowExcludeStep<T> andPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>... AND CURRENT ROW</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> andCurrentRow();
|
||||
WindowExcludeStep<T> andCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> andUnboundedFollowing();
|
||||
WindowExcludeStep<T> andUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND [number] FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> andFollowing(int number);
|
||||
WindowExcludeStep<T> andFollowing(int number);
|
||||
}
|
||||
|
||||
@ -75,34 +75,34 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rowsUnboundedPreceding();
|
||||
WindowExcludeStep<T> rowsUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS [number] PRECEDING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rowsPreceding(int number);
|
||||
WindowExcludeStep<T> rowsPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS CURRENT ROW</code> frame clause to the window function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rowsCurrentRow();
|
||||
WindowExcludeStep<T> rowsCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rowsUnboundedFollowing();
|
||||
WindowExcludeStep<T> rowsUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS [number] FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rowsFollowing(int number);
|
||||
WindowExcludeStep<T> rowsFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
@ -144,34 +144,34 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rangeUnboundedPreceding();
|
||||
WindowExcludeStep<T> rangeUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE [number] PRECEDING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rangePreceding(int number);
|
||||
WindowExcludeStep<T> rangePreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE CURRENT ROW</code> frame clause to the window function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rangeCurrentRow();
|
||||
WindowExcludeStep<T> rangeCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rangeUnboundedFollowing();
|
||||
WindowExcludeStep<T> rangeUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE [number] FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowFinalStep<T> rangeFollowing(int number);
|
||||
WindowExcludeStep<T> rangeFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
@ -213,34 +213,34 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
|
||||
* function.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> groupsUnboundedPreceding();
|
||||
WindowExcludeStep<T> groupsUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS [number] PRECEDING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> groupsPreceding(int number);
|
||||
WindowExcludeStep<T> groupsPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS CURRENT ROW</code> frame clause to the window function.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> groupsCurrentRow();
|
||||
WindowExcludeStep<T> groupsCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> groupsUnboundedFollowing();
|
||||
WindowExcludeStep<T> groupsUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS [number] FOLLOWING</code> frame clause to the window
|
||||
* function.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowFinalStep<T> groupsFollowing(int number);
|
||||
WindowExcludeStep<T> groupsFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
|
||||
111
jOOQ/src/main/java/org/jooq/WindowSpecificationExcludeStep.java
Normal file
111
jOOQ/src/main/java/org/jooq/WindowSpecificationExcludeStep.java
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL_8_0;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.POSTGRES_11;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* An intermediate step in the construction of a {@link WindowSpecification}.
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* WindowSpecification spec =
|
||||
* DSL.partitionBy(BOOK.AUTHOR_ID)
|
||||
* .orderBy(BOOK.ID)
|
||||
* .rowsBetweenUnboundedPreceding()
|
||||
* .andCurrentRow();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface WindowSpecificationExcludeStep extends WindowSpecificationFinalStep {
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE CURRENT ROW</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep excludeCurrentRow();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE GROUP</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep excludeGroup();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE TIES</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep excludeTies();
|
||||
|
||||
/**
|
||||
* Add an <code>EXCLUDE NO OTHERS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep excludeNoOthers();
|
||||
}
|
||||
@ -89,34 +89,34 @@ public interface WindowSpecificationRowsAndStep {
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep andUnboundedPreceding();
|
||||
WindowSpecificationExcludeStep andUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND [number] PRECEDING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep andPreceding(int number);
|
||||
WindowSpecificationExcludeStep andPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>... AND CURRENT ROW</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep andCurrentRow();
|
||||
WindowSpecificationExcludeStep andCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep andUnboundedFollowing();
|
||||
WindowSpecificationExcludeStep andUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>... AND [number] FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep andFollowing(int number);
|
||||
WindowSpecificationExcludeStep andFollowing(int number);
|
||||
|
||||
}
|
||||
|
||||
@ -90,35 +90,35 @@ public interface WindowSpecificationRowsStep extends WindowSpecificationFinalSte
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rowsUnboundedPreceding();
|
||||
WindowSpecificationExcludeStep rowsUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS [number] PRECEDING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rowsPreceding(int number);
|
||||
WindowSpecificationExcludeStep rowsPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS CURRENT ROW</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rowsCurrentRow();
|
||||
WindowSpecificationExcludeStep rowsCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rowsUnboundedFollowing();
|
||||
WindowSpecificationExcludeStep rowsUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS [number] FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rowsFollowing(int number);
|
||||
WindowSpecificationExcludeStep rowsFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>ROWS BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
@ -160,35 +160,35 @@ public interface WindowSpecificationRowsStep extends WindowSpecificationFinalSte
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rangeUnboundedPreceding();
|
||||
WindowSpecificationExcludeStep rangeUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE [number] PRECEDING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rangePreceding(int number);
|
||||
WindowSpecificationExcludeStep rangePreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE CURRENT ROW</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rangeCurrentRow();
|
||||
WindowSpecificationExcludeStep rangeCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rangeUnboundedFollowing();
|
||||
WindowSpecificationExcludeStep rangeUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE [number] FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
WindowSpecificationFinalStep rangeFollowing(int number);
|
||||
WindowSpecificationExcludeStep rangeFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>RANGE BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
@ -230,35 +230,35 @@ public interface WindowSpecificationRowsStep extends WindowSpecificationFinalSte
|
||||
* specification.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep groupsUnboundedPreceding();
|
||||
WindowSpecificationExcludeStep groupsUnboundedPreceding();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS [number] PRECEDING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep groupsPreceding(int number);
|
||||
WindowSpecificationExcludeStep groupsPreceding(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS CURRENT ROW</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep groupsCurrentRow();
|
||||
WindowSpecificationExcludeStep groupsCurrentRow();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS UNBOUNDED FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep groupsUnboundedFollowing();
|
||||
WindowSpecificationExcludeStep groupsUnboundedFollowing();
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS [number] FOLLOWING</code> frame clause to the window
|
||||
* specification.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
WindowSpecificationFinalStep groupsFollowing(int number);
|
||||
WindowSpecificationExcludeStep groupsFollowing(int number);
|
||||
|
||||
/**
|
||||
* Add a <code>GROUPS BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
|
||||
|
||||
@ -318,7 +318,7 @@ import org.jooq.WindowFromFirstLastStep;
|
||||
import org.jooq.WindowIgnoreNullsStep;
|
||||
import org.jooq.WindowOverStep;
|
||||
import org.jooq.WindowSpecification;
|
||||
import org.jooq.WindowSpecificationFinalStep;
|
||||
import org.jooq.WindowSpecificationExcludeStep;
|
||||
import org.jooq.WindowSpecificationOrderByStep;
|
||||
import org.jooq.WindowSpecificationRowsAndStep;
|
||||
import org.jooq.WindowSpecificationRowsStep;
|
||||
@ -17560,7 +17560,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>ROWS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rowsUnboundedPreceding() {
|
||||
public static WindowSpecificationExcludeStep rowsUnboundedPreceding() {
|
||||
return new WindowSpecificationImpl().rowsUnboundedPreceding();
|
||||
}
|
||||
|
||||
@ -17568,7 +17568,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>ROWS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rowsPreceding(int number) {
|
||||
public static WindowSpecificationExcludeStep rowsPreceding(int number) {
|
||||
return new WindowSpecificationImpl().rowsPreceding(number);
|
||||
}
|
||||
|
||||
@ -17576,7 +17576,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>ROWS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rowsCurrentRow() {
|
||||
public static WindowSpecificationExcludeStep rowsCurrentRow() {
|
||||
return new WindowSpecificationImpl().rowsCurrentRow();
|
||||
}
|
||||
|
||||
@ -17584,7 +17584,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>ROWS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rowsUnboundedFollowing() {
|
||||
public static WindowSpecificationExcludeStep rowsUnboundedFollowing() {
|
||||
return new WindowSpecificationImpl().rowsUnboundedFollowing();
|
||||
}
|
||||
|
||||
@ -17592,7 +17592,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>ROWS</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rowsFollowing(int number) {
|
||||
public static WindowSpecificationExcludeStep rowsFollowing(int number) {
|
||||
return new WindowSpecificationImpl().rowsFollowing(number);
|
||||
}
|
||||
|
||||
@ -17640,7 +17640,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>RANGE</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rangeUnboundedPreceding() {
|
||||
public static WindowSpecificationExcludeStep rangeUnboundedPreceding() {
|
||||
return new WindowSpecificationImpl().rangeUnboundedPreceding();
|
||||
}
|
||||
|
||||
@ -17648,7 +17648,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>RANGE</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rangePreceding(int number) {
|
||||
public static WindowSpecificationExcludeStep rangePreceding(int number) {
|
||||
return new WindowSpecificationImpl().rangePreceding(number);
|
||||
}
|
||||
|
||||
@ -17656,7 +17656,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>RANGE</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rangeCurrentRow() {
|
||||
public static WindowSpecificationExcludeStep rangeCurrentRow() {
|
||||
return new WindowSpecificationImpl().rangeCurrentRow();
|
||||
}
|
||||
|
||||
@ -17664,7 +17664,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>RANGE</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rangeUnboundedFollowing() {
|
||||
public static WindowSpecificationExcludeStep rangeUnboundedFollowing() {
|
||||
return new WindowSpecificationImpl().rangeUnboundedFollowing();
|
||||
}
|
||||
|
||||
@ -17672,7 +17672,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>RANGE</code> clause.
|
||||
*/
|
||||
@Support({ MARIADB, MYSQL_8_0, POSTGRES })
|
||||
public static WindowSpecificationFinalStep rangeFollowing(int number) {
|
||||
public static WindowSpecificationExcludeStep rangeFollowing(int number) {
|
||||
return new WindowSpecificationImpl().rangeFollowing(number);
|
||||
}
|
||||
|
||||
@ -17720,7 +17720,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>GROUPS</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
public static WindowSpecificationFinalStep groupsUnboundedPreceding() {
|
||||
public static WindowSpecificationExcludeStep groupsUnboundedPreceding() {
|
||||
return new WindowSpecificationImpl().groupsUnboundedPreceding();
|
||||
}
|
||||
|
||||
@ -17728,7 +17728,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>GROUPS</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
public static WindowSpecificationFinalStep groupsPreceding(int number) {
|
||||
public static WindowSpecificationExcludeStep groupsPreceding(int number) {
|
||||
return new WindowSpecificationImpl().groupsPreceding(number);
|
||||
}
|
||||
|
||||
@ -17736,7 +17736,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>GROUPS</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
public static WindowSpecificationFinalStep groupsCurrentRow() {
|
||||
public static WindowSpecificationExcludeStep groupsCurrentRow() {
|
||||
return new WindowSpecificationImpl().groupsCurrentRow();
|
||||
}
|
||||
|
||||
@ -17744,7 +17744,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>GROUPS</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
public static WindowSpecificationFinalStep groupsUnboundedFollowing() {
|
||||
public static WindowSpecificationExcludeStep groupsUnboundedFollowing() {
|
||||
return new WindowSpecificationImpl().groupsUnboundedFollowing();
|
||||
}
|
||||
|
||||
@ -17752,7 +17752,7 @@ public class DSL {
|
||||
* Create a {@link WindowSpecification} with a <code>GROUPS</code> clause.
|
||||
*/
|
||||
@Support({ POSTGRES_11 })
|
||||
public static WindowSpecificationFinalStep groupsFollowing(int number) {
|
||||
public static WindowSpecificationExcludeStep groupsFollowing(int number) {
|
||||
return new WindowSpecificationImpl().groupsFollowing(number);
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +98,7 @@ import org.jooq.SQL;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.WindowBeforeOverStep;
|
||||
import org.jooq.WindowDefinition;
|
||||
import org.jooq.WindowExcludeStep;
|
||||
import org.jooq.WindowFinalStep;
|
||||
import org.jooq.WindowFromFirstLastStep;
|
||||
import org.jooq.WindowIgnoreNullsStep;
|
||||
@ -125,7 +126,8 @@ class Function<T> extends AbstractField<T> implements
|
||||
WindowFromFirstLastStep<T>,
|
||||
WindowPartitionByStep<T>,
|
||||
WindowRowsStep<T>,
|
||||
WindowRowsAndStep<T>
|
||||
WindowRowsAndStep<T>,
|
||||
WindowExcludeStep<T>
|
||||
{
|
||||
|
||||
|
||||
@ -703,31 +705,31 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rowsUnboundedPreceding() {
|
||||
public final WindowExcludeStep<T> rowsUnboundedPreceding() {
|
||||
windowSpecification.rowsUnboundedPreceding();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rowsPreceding(int number) {
|
||||
public final WindowExcludeStep<T> rowsPreceding(int number) {
|
||||
windowSpecification.rowsPreceding(number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rowsCurrentRow() {
|
||||
public final WindowExcludeStep<T> rowsCurrentRow() {
|
||||
windowSpecification.rowsCurrentRow();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rowsUnboundedFollowing() {
|
||||
public final WindowExcludeStep<T> rowsUnboundedFollowing() {
|
||||
windowSpecification.rowsUnboundedFollowing();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rowsFollowing(int number) {
|
||||
public final WindowExcludeStep<T> rowsFollowing(int number) {
|
||||
windowSpecification.rowsFollowing(number);
|
||||
return this;
|
||||
}
|
||||
@ -763,31 +765,31 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rangeUnboundedPreceding() {
|
||||
public final WindowExcludeStep<T> rangeUnboundedPreceding() {
|
||||
windowSpecification.rangeUnboundedPreceding();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rangePreceding(int number) {
|
||||
public final WindowExcludeStep<T> rangePreceding(int number) {
|
||||
windowSpecification.rangePreceding(number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rangeCurrentRow() {
|
||||
public final WindowExcludeStep<T> rangeCurrentRow() {
|
||||
windowSpecification.rangeCurrentRow();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rangeUnboundedFollowing() {
|
||||
public final WindowExcludeStep<T> rangeUnboundedFollowing() {
|
||||
windowSpecification.rangeUnboundedFollowing();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> rangeFollowing(int number) {
|
||||
public final WindowExcludeStep<T> rangeFollowing(int number) {
|
||||
windowSpecification.rangeFollowing(number);
|
||||
return this;
|
||||
}
|
||||
@ -823,31 +825,31 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> groupsUnboundedPreceding() {
|
||||
public final WindowExcludeStep<T> groupsUnboundedPreceding() {
|
||||
windowSpecification.groupsUnboundedPreceding();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> groupsPreceding(int number) {
|
||||
public final WindowExcludeStep<T> groupsPreceding(int number) {
|
||||
windowSpecification.groupsPreceding(number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> groupsCurrentRow() {
|
||||
public final WindowExcludeStep<T> groupsCurrentRow() {
|
||||
windowSpecification.groupsCurrentRow();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> groupsUnboundedFollowing() {
|
||||
public final WindowExcludeStep<T> groupsUnboundedFollowing() {
|
||||
windowSpecification.groupsUnboundedFollowing();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> groupsFollowing(int number) {
|
||||
public final WindowExcludeStep<T> groupsFollowing(int number) {
|
||||
windowSpecification.groupsFollowing(number);
|
||||
return this;
|
||||
}
|
||||
@ -883,32 +885,56 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> andUnboundedPreceding() {
|
||||
public final WindowExcludeStep<T> andUnboundedPreceding() {
|
||||
windowSpecification.andUnboundedPreceding();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> andPreceding(int number) {
|
||||
public final WindowExcludeStep<T> andPreceding(int number) {
|
||||
windowSpecification.andPreceding(number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> andCurrentRow() {
|
||||
public final WindowExcludeStep<T> andCurrentRow() {
|
||||
windowSpecification.andCurrentRow();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> andUnboundedFollowing() {
|
||||
public final WindowExcludeStep<T> andUnboundedFollowing() {
|
||||
windowSpecification.andUnboundedFollowing();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> andFollowing(int number) {
|
||||
public final WindowExcludeStep<T> andFollowing(int number) {
|
||||
windowSpecification.andFollowing(number);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> excludeCurrentRow() {
|
||||
windowSpecification.excludeCurrentRow();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> excludeGroup() {
|
||||
windowSpecification.excludeGroup();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> excludeTies() {
|
||||
windowSpecification.excludeTies();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowFinalStep<T> excludeNoOthers() {
|
||||
windowSpecification.excludeNoOthers();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +123,7 @@ final class Keywords {
|
||||
static final Keyword K_ENUM = keyword("enum");
|
||||
static final Keyword K_ESCAPE = keyword("escape");
|
||||
static final Keyword K_EXCEPTION = keyword("exception");
|
||||
static final Keyword K_EXCLUDE = keyword("exclude");
|
||||
static final Keyword K_EXEC = keyword("exec");
|
||||
static final Keyword K_EXECUTE_BLOCK = keyword("execute block");
|
||||
static final Keyword K_EXECUTE_IMMEDIATE = keyword("execute immediate");
|
||||
|
||||
@ -399,6 +399,7 @@ import org.jooq.WindowFromFirstLastStep;
|
||||
import org.jooq.WindowIgnoreNullsStep;
|
||||
import org.jooq.WindowOverStep;
|
||||
import org.jooq.WindowSpecification;
|
||||
import org.jooq.WindowSpecificationExcludeStep;
|
||||
import org.jooq.WindowSpecificationOrderByStep;
|
||||
import org.jooq.WindowSpecificationRowsAndStep;
|
||||
import org.jooq.WindowSpecificationRowsStep;
|
||||
@ -1265,6 +1266,7 @@ final class ParserImpl implements Parser {
|
||||
final WindowSpecificationOrderByStep s1;
|
||||
final WindowSpecificationRowsStep s2;
|
||||
final WindowSpecificationRowsAndStep s3;
|
||||
final WindowSpecificationExcludeStep s4;
|
||||
|
||||
s1 = parseKeywordIf(ctx, "PARTITION BY")
|
||||
? partitionBy(parseFields(ctx))
|
||||
@ -1364,18 +1366,18 @@ final class ParserImpl implements Parser {
|
||||
|
||||
if (parseKeywordIf(ctx, "UNBOUNDED"))
|
||||
if (parseKeywordIf(ctx, "PRECEDING"))
|
||||
return s3.andUnboundedPreceding();
|
||||
s4 = s3.andUnboundedPreceding();
|
||||
else if (parseKeywordIf(ctx, "FOLLOWING"))
|
||||
return s3.andUnboundedFollowing();
|
||||
s4 = s3.andUnboundedFollowing();
|
||||
else
|
||||
throw ctx.expected("FOLLOWING", "PRECEDING");
|
||||
else if (parseKeywordIf(ctx, "CURRENT ROW"))
|
||||
return s3.andCurrentRow();
|
||||
s4 = s3.andCurrentRow();
|
||||
else if ((n = parseUnsignedInteger(ctx)) != null)
|
||||
if (parseKeywordIf(ctx, "PRECEDING"))
|
||||
return s3.andPreceding(n.intValue());
|
||||
s4 = s3.andPreceding(n.intValue());
|
||||
else if (parseKeywordIf(ctx, "FOLLOWING"))
|
||||
return s3.andFollowing(n.intValue());
|
||||
s4 = s3.andFollowing(n.intValue());
|
||||
else
|
||||
throw ctx.expected("FOLLOWING", "PRECEDING");
|
||||
else
|
||||
@ -1383,7 +1385,7 @@ final class ParserImpl implements Parser {
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "UNBOUNDED"))
|
||||
if (parseKeywordIf(ctx, "PRECEDING"))
|
||||
return s2 == null
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
? rowsUnboundedPreceding()
|
||||
: range
|
||||
@ -1395,7 +1397,7 @@ final class ParserImpl implements Parser {
|
||||
? s2.rangeUnboundedPreceding()
|
||||
: s2.groupsUnboundedPreceding();
|
||||
else if (parseKeywordIf(ctx, "FOLLOWING"))
|
||||
return s2 == null
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
? rowsUnboundedFollowing()
|
||||
: range
|
||||
@ -1409,7 +1411,7 @@ final class ParserImpl implements Parser {
|
||||
else
|
||||
throw ctx.expected("FOLLOWING", "PRECEDING");
|
||||
else if (parseKeywordIf(ctx, "CURRENT ROW"))
|
||||
return s2 == null
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
? rowsCurrentRow()
|
||||
: range
|
||||
@ -1422,7 +1424,7 @@ final class ParserImpl implements Parser {
|
||||
: s2.groupsCurrentRow();
|
||||
else if ((n = parseUnsignedInteger(ctx)) != null)
|
||||
if (parseKeywordIf(ctx, "PRECEDING"))
|
||||
return s2 == null
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
? rowsPreceding(n.intValue())
|
||||
: range
|
||||
@ -1434,7 +1436,7 @@ final class ParserImpl implements Parser {
|
||||
? s2.rangePreceding(n.intValue())
|
||||
: s2.groupsPreceding(n.intValue());
|
||||
else if (parseKeywordIf(ctx, "FOLLOWING"))
|
||||
return s2 == null
|
||||
s4 = s2 == null
|
||||
? rows
|
||||
? rowsFollowing(n.intValue())
|
||||
: range
|
||||
@ -1449,6 +1451,20 @@ final class ParserImpl implements Parser {
|
||||
throw ctx.expected("FOLLOWING", "PRECEDING");
|
||||
else
|
||||
throw ctx.expected("BETWEEN", "CURRENT ROW", "UNBOUNDED", "integer literal");
|
||||
|
||||
if (parseIf(ctx, "EXCLUDE"))
|
||||
if (parseIf(ctx, "CURRENT ROW"))
|
||||
return s4.excludeCurrentRow();
|
||||
else if (parseIf(ctx, "TIES"))
|
||||
return s4.excludeTies();
|
||||
else if (parseIf(ctx, "GROUP"))
|
||||
return s4.excludeGroup();
|
||||
else if (parseIf(ctx, "NO OTHERS"))
|
||||
return s4.excludeNoOthers();
|
||||
else
|
||||
throw ctx.expected("CURRENT ROW", "TIES", "GROUP", "NO OTHERS");
|
||||
else
|
||||
return s4;
|
||||
}
|
||||
else
|
||||
return s2;
|
||||
|
||||
@ -46,12 +46,17 @@ import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.Keywords.K_AND;
|
||||
import static org.jooq.impl.Keywords.K_BETWEEN;
|
||||
import static org.jooq.impl.Keywords.K_CURRENT_ROW;
|
||||
import static org.jooq.impl.Keywords.K_EXCLUDE;
|
||||
import static org.jooq.impl.Keywords.K_FOLLOWING;
|
||||
import static org.jooq.impl.Keywords.K_ORDER_BY;
|
||||
import static org.jooq.impl.Keywords.K_PARTITION_BY;
|
||||
import static org.jooq.impl.Keywords.K_PRECEDING;
|
||||
import static org.jooq.impl.Keywords.K_UNBOUNDED_FOLLOWING;
|
||||
import static org.jooq.impl.Keywords.K_UNBOUNDED_PRECEDING;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.Exclude.CURRENT_ROW;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.Exclude.GROUP;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.Exclude.NO_OTHERS;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.Exclude.TIES;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.FrameUnits.GROUPS;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.FrameUnits.RANGE;
|
||||
import static org.jooq.impl.WindowSpecificationImpl.FrameUnits.ROWS;
|
||||
@ -66,6 +71,7 @@ import org.jooq.Field;
|
||||
import org.jooq.Keyword;
|
||||
import org.jooq.OrderField;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.WindowSpecificationExcludeStep;
|
||||
import org.jooq.WindowSpecificationFinalStep;
|
||||
import org.jooq.WindowSpecificationOrderByStep;
|
||||
import org.jooq.WindowSpecificationPartitionByStep;
|
||||
@ -78,7 +84,8 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
|
||||
// Cascading interface implementations for window specification behaviour
|
||||
WindowSpecificationPartitionByStep,
|
||||
WindowSpecificationRowsAndStep
|
||||
WindowSpecificationRowsAndStep,
|
||||
WindowSpecificationExcludeStep
|
||||
{
|
||||
|
||||
|
||||
@ -93,6 +100,7 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
private Integer frameStart;
|
||||
private Integer frameEnd;
|
||||
private FrameUnits frameUnits;
|
||||
private Exclude exclude;
|
||||
private boolean partitionByOne;
|
||||
|
||||
WindowSpecificationImpl() {
|
||||
@ -144,6 +152,9 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
}
|
||||
|
||||
glue = " ";
|
||||
|
||||
if (exclude != null)
|
||||
ctx.sql(glue).visit(K_EXCLUDE).sql(' ').visit(exclude.keyword);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +192,7 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
public final WindowSpecificationOrderByStep partitionByOne() {
|
||||
partitionByOne = true;
|
||||
partitionBy.add(one());
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,35 +207,35 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rowsUnboundedPreceding() {
|
||||
public final WindowSpecificationExcludeStep rowsUnboundedPreceding() {
|
||||
frameUnits = ROWS;
|
||||
frameStart = Integer.MIN_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rowsPreceding(int number) {
|
||||
public final WindowSpecificationExcludeStep rowsPreceding(int number) {
|
||||
frameUnits = ROWS;
|
||||
frameStart = -number;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rowsCurrentRow() {
|
||||
public final WindowSpecificationExcludeStep rowsCurrentRow() {
|
||||
frameUnits = ROWS;
|
||||
frameStart = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rowsUnboundedFollowing() {
|
||||
public final WindowSpecificationExcludeStep rowsUnboundedFollowing() {
|
||||
frameUnits = ROWS;
|
||||
frameStart = Integer.MAX_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rowsFollowing(int number) {
|
||||
public final WindowSpecificationExcludeStep rowsFollowing(int number) {
|
||||
frameUnits = ROWS;
|
||||
frameStart = number;
|
||||
return this;
|
||||
@ -261,35 +272,35 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rangeUnboundedPreceding() {
|
||||
public final WindowSpecificationExcludeStep rangeUnboundedPreceding() {
|
||||
frameUnits = RANGE;
|
||||
frameStart = Integer.MIN_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rangePreceding(int number) {
|
||||
public final WindowSpecificationExcludeStep rangePreceding(int number) {
|
||||
frameUnits = RANGE;
|
||||
frameStart = -number;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rangeCurrentRow() {
|
||||
public final WindowSpecificationExcludeStep rangeCurrentRow() {
|
||||
frameUnits = RANGE;
|
||||
frameStart = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rangeUnboundedFollowing() {
|
||||
public final WindowSpecificationExcludeStep rangeUnboundedFollowing() {
|
||||
frameUnits = RANGE;
|
||||
frameStart = Integer.MAX_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep rangeFollowing(int number) {
|
||||
public final WindowSpecificationExcludeStep rangeFollowing(int number) {
|
||||
frameUnits = RANGE;
|
||||
frameStart = number;
|
||||
return this;
|
||||
@ -326,35 +337,35 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep groupsUnboundedPreceding() {
|
||||
public final WindowSpecificationExcludeStep groupsUnboundedPreceding() {
|
||||
frameUnits = GROUPS;
|
||||
frameStart = Integer.MIN_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep groupsPreceding(int number) {
|
||||
public final WindowSpecificationExcludeStep groupsPreceding(int number) {
|
||||
frameUnits = GROUPS;
|
||||
frameStart = -number;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep groupsCurrentRow() {
|
||||
public final WindowSpecificationExcludeStep groupsCurrentRow() {
|
||||
frameUnits = GROUPS;
|
||||
frameStart = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep groupsUnboundedFollowing() {
|
||||
public final WindowSpecificationExcludeStep groupsUnboundedFollowing() {
|
||||
frameUnits = GROUPS;
|
||||
frameStart = Integer.MAX_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep groupsFollowing(int number) {
|
||||
public final WindowSpecificationExcludeStep groupsFollowing(int number) {
|
||||
frameUnits = GROUPS;
|
||||
frameStart = number;
|
||||
return this;
|
||||
@ -391,44 +402,81 @@ final class WindowSpecificationImpl extends AbstractQueryPart implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep andUnboundedPreceding() {
|
||||
public final WindowSpecificationExcludeStep andUnboundedPreceding() {
|
||||
frameEnd = Integer.MIN_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep andPreceding(int number) {
|
||||
public final WindowSpecificationExcludeStep andPreceding(int number) {
|
||||
frameEnd = -number;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep andCurrentRow() {
|
||||
public final WindowSpecificationExcludeStep andCurrentRow() {
|
||||
frameEnd = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep andUnboundedFollowing() {
|
||||
public final WindowSpecificationExcludeStep andUnboundedFollowing() {
|
||||
frameEnd = Integer.MAX_VALUE;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final WindowSpecificationFinalStep andFollowing(int number) {
|
||||
public final WindowSpecificationExcludeStep andFollowing(int number) {
|
||||
frameEnd = number;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowSpecificationFinalStep excludeCurrentRow() {
|
||||
exclude = CURRENT_ROW;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowSpecificationFinalStep excludeGroup() {
|
||||
exclude = GROUP;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowSpecificationFinalStep excludeTies() {
|
||||
exclude = TIES;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowSpecificationFinalStep excludeNoOthers() {
|
||||
exclude = NO_OTHERS;
|
||||
return this;
|
||||
}
|
||||
|
||||
enum FrameUnits {
|
||||
ROWS("rows"),
|
||||
RANGE("range"),
|
||||
GROUPS("groups");
|
||||
|
||||
private final Keyword keyword;
|
||||
final Keyword keyword;
|
||||
|
||||
private FrameUnits(String keyword) {
|
||||
this.keyword = DSL.keyword(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
enum Exclude {
|
||||
CURRENT_ROW("current row"),
|
||||
TIES("ties"),
|
||||
GROUP("group"),
|
||||
NO_OTHERS("no others");
|
||||
|
||||
final Keyword keyword;
|
||||
|
||||
private Exclude(String keyword) {
|
||||
this.keyword = DSL.keyword(keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user