[#1917] Add support for CUBRID 9.0's new features - Added and documented

support for CUBRID window functions
This commit is contained in:
Lukas Eder 2012-11-02 13:05:33 +01:00
parent 4c224b77c6
commit eec85836c5
9 changed files with 37 additions and 28 deletions

View File

@ -360,7 +360,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
public void testWindowFunctions() throws Exception {
switch (getDialect()) {
case ASE:
case CUBRID:
case FIREBIRD:
case INGRES:
case MYSQL:
@ -490,6 +489,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
assertEquals(Integer.valueOf(1), result.getValue(3, column));
switch (getDialect()) {
case CUBRID:
case DB2:
case SQLSERVER:
log.info("SKIPPING", "PERCENT_RANK() and CUME_DIST() window function tests");
@ -605,7 +605,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
}
// NTILE()
if (asList(SYBASE, DB2).contains(getDialect())) {
if (asList(CUBRID, DB2, SYBASE).contains(getDialect())) {
log.info("SKIPPING", "NTILE tests");
}
else {
@ -627,7 +627,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
}
column = 0;
if (getDialect() == SQLDialect.SQLSERVER) {
if (asList(CUBRID, SQLSERVER).contains(getDialect())) {
log.info("SKIPPING", "ROWS UNBOUNDED PRECEDING and similar tests");
return;
}

View File

@ -35,6 +35,7 @@
*/
package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
@ -63,7 +64,7 @@ public interface AggregateFunction<T> extends Field<T>, WindowOverStep<T> {
* Sybase.
*/
@Override
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> over();
/**

View File

@ -2129,7 +2129,7 @@ public interface Field<T> extends GroupField {
* @see Factory#count(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<Integer> countOver();
/**
@ -2140,7 +2140,7 @@ public interface Field<T> extends GroupField {
* @see Factory#max(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> maxOver();
/**
@ -2151,7 +2151,7 @@ public interface Field<T> extends GroupField {
* @see Factory#min(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> minOver();
/**
@ -2162,7 +2162,7 @@ public interface Field<T> extends GroupField {
* @see Factory#sum(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> sumOver();
/**
@ -2173,7 +2173,7 @@ public interface Field<T> extends GroupField {
* @see Factory#avg(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> avgOver();
/**
@ -2294,7 +2294,7 @@ public interface Field<T> extends GroupField {
* @see Factory#stddevPop(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> stddevPopOver();
/**
@ -2305,7 +2305,7 @@ public interface Field<T> extends GroupField {
* @see Factory#stddevSamp(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> stddevSampOver();
/**
@ -2316,7 +2316,7 @@ public interface Field<T> extends GroupField {
* @see Factory#varPop(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> varPopOver();
/**
@ -2327,7 +2327,7 @@ public interface Field<T> extends GroupField {
* @see Factory#varSamp(Field)
* @see AggregateFunction#over()
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<BigDecimal> varSampOver();
/**

View File

@ -35,7 +35,11 @@
*/
package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
@ -67,7 +71,7 @@ public interface WindowBeforeOverStep<T> extends WindowOverStep<T>, Field<T> {
* Add an <code>OVER</code> clause
*/
@Override
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> over();
}

View File

@ -35,6 +35,7 @@
*/
package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
@ -64,18 +65,18 @@ public interface WindowOrderByStep<T> extends WindowFinalStep<T> {
/**
* Add an <code>ORDER BY</code> clause to the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowRowsStep<T> orderBy(Field<?>... fields);
/**
* Add an <code>ORDER BY</code> clause to the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowRowsStep<T> orderBy(SortField<?>... fields);
/**
* Add an <code>ORDER BY</code> clause to the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowRowsStep<T> orderBy(Collection<SortField<?>> fields);
}

View File

@ -35,6 +35,7 @@
*/
package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.H2;
@ -68,7 +69,7 @@ public interface WindowOverStep<T> {
/**
* Add an <code>OVER</code> clause
*/
@Support({ DB2, DERBY, H2, HSQLDB, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> over();
}

View File

@ -35,13 +35,13 @@
*/
package org.jooq;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SYBASE;
/**
* This type is used for the window function DSL API.
* <p>
@ -63,17 +63,17 @@ public interface WindowPartitionByStep<T> extends WindowOrderByStep<T> {
/**
* Add a <code>PARTITION BY</code> clause to the window functions.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowOrderByStep<T> partitionBy(Field<?>... fields);
/**
* Add a <code>PARTITION BY 1</code> clause to the window functions, where
* such a clause is required by the syntax of an RDBMS.
* <p>
* This clause is not supported in the Sybase dialect. If you use it, jOOQ
* will simply ignore it.
* This clause is not supported as such in the CUBRID and Sybase dialects.
* If you use it, jOOQ will simply ignore it.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowOrderByStep<T> partitionByOne();
}

View File

@ -5086,7 +5086,7 @@ public class Factory {
* {@link SQLDialect#HSQLDB} can simulate this function using
* <code>ROWNUM()</code>
*/
@Support({ DB2, DERBY, H2, HSQLDB, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, POSTGRES, ORACLE, SQLSERVER, SYBASE })
public static WindowOverStep<Integer> rowNumber() {
return new Function<Integer>(ROW_NUMBER, SQLDataType.INTEGER);
}
@ -5097,7 +5097,7 @@ public class Factory {
* Window functions are supported in DB2, Postgres, Oracle, SQL Server and
* Sybase.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
public static WindowOverStep<Integer> rank() {
return new Function<Integer>("rank", SQLDataType.INTEGER);
}
@ -5108,7 +5108,7 @@ public class Factory {
* Window functions are supported in DB2, Postgres, Oracle, SQL Server and
* Sybase.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
public static WindowOverStep<Integer> denseRank() {
return new Function<Integer>("dense_rank", SQLDataType.INTEGER);
}

View File

@ -307,8 +307,10 @@ class Function<T> extends AbstractField<T> implements
String glue = "";
context.keyword(" over (");
if (!partitionBy.isEmpty()) {
if (partitionByOne && context.getDialect() == SQLDialect.SYBASE) {
// Ignore partition clause. Sybase does not support this construct
// Ignore PARTITION BY 1 clause. These databases erroneously map the
// 1 literal onto the column index
if (partitionByOne && asList(CUBRID, SYBASE).contains(context.getDialect())) {
}
else {
context.sql(glue)