[#2728] Add support for Amazon Redshift

This commit is contained in:
lukaseder 2015-05-06 19:10:47 +02:00
parent 3a20599ecc
commit adbd2f4d38
16 changed files with 159 additions and 79 deletions

View File

@ -56,6 +56,7 @@ import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...

View File

@ -44,6 +44,7 @@ package org.jooq;
// ...
// ...
// ...
// ...
/**
* This type is used for the window function DSL API.
@ -68,14 +69,14 @@ public interface WindowIgnoreNullsStep<T> extends WindowOverStep<T> {
x xxx xx xxxxxxxxxxxx xxxxxxxxxxxx xxxxxx xx xxx xxxxxx xxxxxxxxx xxxx
x xxxxx xxx xx xxxxxxxxx xx xxx xxxxxxxxx
xx
xxxxxxxxxx xxxx xxxxxxxxx xxxxxxx xxxxxx xx
xxxxxxxxxx xxxx xxxxxxxxx xxxxxxx xxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx
xxx
x xxx x xxxxxxxxxxxxx xxxxxxxxxxxx xxxxxx xx xxx xxxxxx xxxxxxxxx xxxx
x xxxxx xxx xx xxxxxxxxx xx xxx xxxxxxxxx
xx
xxxxxxxxxx xxxx xxxxxxxxx xxxxxxx xxxxxx xx
xxxxxxxxxx xxxx xxxxxxxxx xxxxxxx xxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx
xx [/pro] */
}

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
import java.util.Collection;

View File

@ -51,6 +51,7 @@ import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* This type is used for the window function DSL API.
@ -78,10 +79,8 @@ public interface WindowOverStep<T> {
* <p>
* An example: <code><pre>
* MAX(id) OVER (PARTITION BY 1)
* </code></pre>
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
* </code>
* </pre>
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, POSTGRES })
WindowPartitionByStep<T> over();
@ -92,12 +91,12 @@ public interface WindowOverStep<T> {
* <p>
* An example: <code><pre>
* MAX(id) OVER my_window
* </code></pre>
* </code>
* </pre>
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase. If the <code>WINDOW</code> clause is not supported
* (see {@link SelectWindowStep#window(WindowDefinition...)}, then
* referenced windows will be inlined.
* If the <code>WINDOW</code> clause is not supported (see
* {@link SelectWindowStep#window(WindowDefinition...)}, then referenced
* windows will be inlined.
*/
@Support({ CUBRID, POSTGRES })
WindowFinalStep<T> over(Name name);
@ -108,12 +107,12 @@ public interface WindowOverStep<T> {
* <p>
* An example: <code><pre>
* MAX(id) OVER my_window
* </code></pre>
* </code>
* </pre>
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase. If the <code>WINDOW</code> clause is not supported
* (see {@link SelectWindowStep#window(WindowDefinition...)}, then
* referenced windows will be inlined.
* If the <code>WINDOW</code> clause is not supported (see
* {@link SelectWindowStep#window(WindowDefinition...)}, then referenced
* windows will be inlined.
*/
@Support({ CUBRID, POSTGRES })
WindowFinalStep<T> over(String name);
@ -123,10 +122,8 @@ public interface WindowOverStep<T> {
* <p>
* An example: <code><pre>
* MAX(id) OVER (PARTITION BY 1)
* </code></pre>
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
* </code>
* </pre>
*/
@Support({ CUBRID, POSTGRES })
WindowFinalStep<T> over(WindowSpecification specification);
@ -137,12 +134,12 @@ public interface WindowOverStep<T> {
* <p>
* An example: <code><pre>
* MAX(id) OVER my_window
* </code></pre>
* </code>
* </pre>
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase. If the <code>WINDOW</code> clause is not supported
* (see {@link SelectWindowStep#window(WindowDefinition...)}, then
* referenced windows will be inlined.
* If the <code>WINDOW</code> clause is not supported (see
* {@link SelectWindowStep#window(WindowDefinition...)}, then referenced
* windows will be inlined.
*/
@Support({ CUBRID, POSTGRES })
WindowFinalStep<T> over(WindowDefinition definition);

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* This type is used for the window function DSL API.

View File

@ -46,6 +46,7 @@ package org.jooq;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* This type is used for the window function DSL API.

View File

@ -46,6 +46,7 @@ package org.jooq;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* This type is used for the window function DSL API.

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
import java.util.Collection;

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
import java.util.Collection;

View File

@ -46,6 +46,7 @@ package org.jooq;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* An intermediate step in the construction of a {@link WindowSpecification}.

View File

@ -46,6 +46,7 @@ package org.jooq;
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
/**
* An intermediate step in the construction of a {@link WindowSpecification}.

View File

@ -74,6 +74,7 @@ class Cosh extends AbstractFunction<BigDecimal> {
xxxx xxxxxxx
xxxx xxxx
xxxx xxxxxxx
xxxx xxxxxxxxx
xxxx xxxxxxxxxx
xxxx xxxxxxx
xx [/pro] */

View File

@ -11375,9 +11375,6 @@ public class DSL {
/**
* The <code>row_number() over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
* <p>
* Newer versions of {@link SQLDialect#DERBY} and {@link SQLDialect#H2} also
* support the <code>ROW_NUMBER() OVER()</code> window function without any
* window clause. See the respective docs for details.
@ -11391,9 +11388,6 @@ public class DSL {
/**
* The <code>rank() over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static WindowOverStep<Integer> rank() {
@ -11411,9 +11405,6 @@ public class DSL {
/**
* The <code>dense_rank() over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static WindowOverStep<Integer> denseRank() {
@ -11431,9 +11422,6 @@ public class DSL {
/**
* The <code>precent_rank() over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static WindowOverStep<BigDecimal> percentRank() {
@ -11451,9 +11439,6 @@ public class DSL {
/**
* The <code>cume_dist() over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static WindowOverStep<BigDecimal> cumeDist() {
@ -11471,9 +11456,6 @@ public class DSL {
/**
* The <code>ntile([number]) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static WindowOverStep<Integer> ntile(int number) {
@ -11522,9 +11504,6 @@ public class DSL {
/**
* The <code>first_value(field) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> firstValue(Field<T> field) {
@ -11533,9 +11512,6 @@ public class DSL {
/**
* The <code>last_value(field) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lastValue(Field<T> field) {
@ -11544,33 +11520,24 @@ public class DSL {
/**
* The <code>lead(field) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field) {
return new Function<T>("lead", nullSafeDataType(field), nullSafe(field));
return new LeadLag<T>("lead", nullSafe(field));
}
/**
* The <code>lead(field, offset) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset) {
return new Function<T>("lead", nullSafeDataType(field), nullSafe(field), inline(offset));
return new LeadLag<T>("lead", nullSafe(field), offset);
}
/**
* The
* <code>lead(field, offset, defaultValue) over ([analytic clause])</code>
* function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset, T defaultValue) {
@ -11581,44 +11548,32 @@ public class DSL {
* The
* <code>lead(field, offset, defaultValue) over ([analytic clause])</code>
* function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset, Field<T> defaultValue) {
return new Function<T>("lead", nullSafeDataType(field), nullSafe(field), inline(offset), nullSafe(defaultValue));
return new LeadLag<T>("lead", nullSafe(field), offset, nullSafe(defaultValue));
}
/**
* The <code>lag(field) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field) {
return new Function<T>("lag", nullSafeDataType(field), nullSafe(field));
return new LeadLag<T>("lag", nullSafe(field));
}
/**
* The <code>lag(field, offset) over ([analytic clause])</code> function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset) {
return new Function<T>("lag", nullSafeDataType(field), nullSafe(field), inline(offset));
return new LeadLag<T>("lag", nullSafe(field), offset);
}
/**
* The
* <code>lag(field, offset, defaultValue) over ([analytic clause])</code>
* function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset, T defaultValue) {
@ -11629,13 +11584,10 @@ public class DSL {
* The
* <code>lag(field, offset, defaultValue) over ([analytic clause])</code>
* function.
* <p>
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, POSTGRES })
public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset, Field<T> defaultValue) {
return new Function<T>("lag", nullSafeDataType(field), nullSafe(field), inline(offset), nullSafe(defaultValue));
return new LeadLag<T>("lag", nullSafe(field), offset, nullSafe(defaultValue));
}
// -------------------------------------------------------------------------

View File

@ -0,0 +1,118 @@
/**
* Copyright (c) 2009-2015, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* 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.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
package org.jooq.impl;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.keyword;
import org.jooq.Context;
import org.jooq.Field;
/**
* @author Lukas Eder
*/
class LeadLag<T> extends Function<T> {
/**
* Generated UID
*/
private static final long serialVersionUID = 7292087943334025737L;
private final String function;
private final Field<T> field;
private final int offset;
private final Field<T> defaultValue;
LeadLag(String function, Field<T> field) {
super(function, field.getDataType(), field);
this.function = function;
this.field = field;
this.offset = 0;
this.defaultValue = null;
}
LeadLag(String function, Field<T> field, int offset) {
super(function, field.getDataType(), field, inline(offset));
this.function = function;
this.field = field;
this.offset = offset;
this.defaultValue = null;
}
LeadLag(String function, Field<T> field, int offset, Field<T> defaultValue) {
super(function, field.getDataType(), field, inline(offset), defaultValue);
this.function = function;
this.field = field;
this.offset = offset;
this.defaultValue = defaultValue;
}
@Override
public final void accept(Context<?> ctx) {
if (defaultValue == null) {
super.accept(ctx);
}
else {
switch (ctx.family()) {
/* [pro] xx
xxxx xxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx xx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxx
xxxxxx
xx [/pro] */
default:
super.accept(ctx);
break;
}
}
}
}

View File

@ -74,6 +74,7 @@ class Sinh extends AbstractFunction<BigDecimal> {
xxxx xxxxxxx
xxxx xxxx
xxxx xxxxxxx
xxxx xxxxxxxxx
xxxx xxxxxxxxxx
xxxx xxxxxxx
xx [/pro] */

View File

@ -74,6 +74,7 @@ class Tanh extends AbstractFunction<BigDecimal> {
xxxx xxxxxxx
xxxx xxxx
xxxx xxxxxxx
xxxx xxxxxxxxx
xxxx xxxxxxxxxx
xxxx xxxxxxx
xx [/pro] */