Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-jooq-dialect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
java: [ '17', '21' ]
java: [ '21' , '25']

steps:
- uses: actions/checkout@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-jooq-dialect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: 'maven'

Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: 'maven'
server-id: ossrh-s01
Expand Down
4 changes: 2 additions & 2 deletions jooq-dialect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ This project introduces a JOOQ dialect specifically tailored for the Yandex Data

To utilize this JOOQ YDB Dialect, ensure you have:

- Java 11 or above.
- JOOQ 3.15 or higher.
- Java 21 or above.
- JOOQ 3.21 or higher.
- [YDB JDBC Driver](https://github.com/ydb-platform/ydb-jdbc-driver)
- Access to a YDB Database instance.

Expand Down
8 changes: 4 additions & 4 deletions jooq-dialect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>

<jooq.version>3.19.0</jooq.version>
<jooq.version>3.21.0</jooq.version>

<ydb.sdk.version>2.3.8</ydb.sdk.version>
<ydb.jdbc.version>2.3.11</ydb.jdbc.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import org.jooq.Field;
import org.jooq.Name;

public abstract class AbstractYdbAggregateFunction<T> extends AbstractAggregateFunction<T> {
import java.util.function.Function;

import static org.jooq.impl.Tools.EMPTY_FIELD;

public abstract class AbstractYdbAggregateFunction<T> extends AbstractAggregateFunction<T, AbstractYdbAggregateFunction<T>> {
protected AbstractYdbAggregateFunction(String name, DataType<T> type, Field<?>... arguments) {
super(name, type, arguments);
}
Expand All @@ -20,4 +24,16 @@ protected AbstractYdbAggregateFunction(boolean distinct, String name, DataType<T
protected AbstractYdbAggregateFunction(boolean distinct, Name name, DataType<T> type, Field<?>... arguments) {
super(distinct, name, type, arguments);
}

@Override
AbstractYdbAggregateFunction<T> copyAggregateFunction(
Function<? super AbstractYdbAggregateFunction<T>, ? extends AbstractYdbAggregateFunction<T>> function) {
return function.apply(new Copy<>(distinct, getQualifiedName(), getDataType(), getArguments().toArray(EMPTY_FIELD)));
}

private static final class Copy<T> extends AbstractYdbAggregateFunction<T> {
private Copy(boolean distinct, Name name, DataType<T> type, Field<?>... arguments) {
super(distinct, name, type, arguments);
}
}
}
17 changes: 14 additions & 3 deletions jooq-dialect/src/main/java/org/jooq/impl/BatchReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import tech.ydb.jooq.ReplaceQuery;
import tech.ydb.jooq.YdbDSLContext;

import java.util.function.Function;

public class BatchReplace extends AbstractBatch {
private final YdbDSLContext ydbDSLContext;
private final TableRecord<?>[] records;
Expand All @@ -20,11 +22,20 @@ public BatchReplace(YdbDSLContext ydbDSLContext, TableRecord<?>[] records) {

@Override
public int[] execute() throws DataAccessException {
return execute0(BatchBindStep::execute, new int[0]);
}

@Override
public long[] executeLarge() throws DataAccessException {
return execute0(BatchBindStep::executeLarge, new long[0]);
}

private <T> T execute0(Function<BatchBindStep, T> executor, T empty) {
BatchBindStep batchBindStep = prepareBatch();
if (batchBindStep == null) {
return new int[0];
return empty;
}
int[] result = batchBindStep.execute();
T result = executor.apply(batchBindStep);
updateChangedFlag();
return result;
}
Expand All @@ -35,7 +46,7 @@ public int size() {
}

@Override
public void subscribe(Subscriber<? super Integer> subscriber) {
void subscribe0(Subscriber<? super R2DBC.RowCount> subscriber) {
throw new UnsupportedOperationException("BatchReplace operation is not supported in a reactive way");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static <T> DataType<T> newDataType(DataType sqlDataType, String typeName,
name(typeName),
typeName,
typeName,
typeName,
sqlDataType.precisionDefined() ? sqlDataType.precision() : null,
sqlDataType.scaleDefined() ? sqlDataType.scale() : null,
sqlDataType.lengthDefined() ? sqlDataType.length() : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class FieldMapsForUpsertReplace extends AbstractQueryPart {
private final Table<?> table;
private final Map<Field<?>, Field<?>> empty;
private final Map<Field<?>, List<Field<?>>> values;
private int rows;
int rows;
private int nextRow = -1;

public FieldMapsForUpsertReplace(Table<?> table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ private <T> void addValue(UpsertReplaceQueryImpl<R> delegate, Field<T> field, in
} else if (object instanceof FieldLike f) {
delegate.addValue(field, index, f.asField());
} else if (field != null) {
delegate.addValue(field, index, field.getDataType().convert(object));
delegate.addValue(field, index, AbstractDataType.convert0(field.getDataType(), object, Internal.converterContext()));
} else {
delegate.addValue(field, index, (T) object);
}
Expand Down Expand Up @@ -782,7 +782,7 @@ public SELF set(Map<?, ?> map) {
}

public SELF set(Record record) {
return set(Tools.mapOfChangedValues(record));
return set(Tools.mapOfTouchedValues(getDelegate(), record));
}

public SELF set(Record... records) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.jooq.Field;
import org.jooq.Keyword;
import org.jooq.Record;
import org.jooq.Scope;
import org.jooq.Select;
import org.jooq.Table;
import tech.ydb.jooq.ReplaceQuery;
Expand Down Expand Up @@ -150,6 +151,17 @@ public boolean isExecutable() {
return upsertReplaceMaps.isExecutable() || select != null;
}

@Override
int estimatedRowCount(Scope ctx) {
if (select != null) {
return Integer.MAX_VALUE;
} else if (InlineDerivedTable.inlineDerivedTable(ctx, table(ctx)) instanceof InlineDerivedTable) {
return Integer.MAX_VALUE;
} else {
return upsertReplaceMaps.rows;
}
}

private UpsertReplaceQueryImpl<R> copy(Consumer<? super UpsertReplaceQueryImpl<R>> finisher) {
return copy(finisher, table);
}
Expand Down
21 changes: 20 additions & 1 deletion jooq-dialect/src/main/java/org/jooq/impl/YdbTableImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jooq.Comment;
import org.jooq.Condition;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.Record;
Expand All @@ -21,6 +22,24 @@ protected YdbTableImpl(Name name, Schema schema, Table<R> aliased, Field<?>[] pa
}

public Table<R> viewPrimaryKey() {
return new HintedTable<>(this, DSL.keyword("use primary key"), new QueryPartList<>(PRIMARY_KEY));
return new YdbHintedTable<>(this);
}

private static final class YdbHintedTable<R extends Record> extends AbstractDelegatingTable<R> {
private YdbHintedTable(AbstractTable<R> delegate) {
super(delegate);
}

@Override
<O extends Record> AbstractDelegatingTable<O> construct(AbstractTable<O> newDelegate) {
return new YdbHintedTable<>(newDelegate);
}

@Override
public void accept(Context<?> ctx) {
ctx.visit(delegate)
.sql(' ').visit(Keywords.K_VIEW)
.sql(' ').visit(PRIMARY_KEY);
}
}
}
21 changes: 21 additions & 0 deletions jooq-dialect/src/main/java/tech/ydb/jooq/codegen/YdbDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import org.jooq.DSLContext;
import org.jooq.Record12;
import org.jooq.Record15;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
Expand Down Expand Up @@ -279,4 +280,24 @@ public ResultQuery<Record4<String, String, String, String>> sources(List<String>
public ResultQuery<Record5<String, String, String, String, String>> comments(List<String> schemas) {
return null;
}

@Override
public ResultQuery<Record15<String, String, String, String, String, Integer, String, Integer, Integer, Boolean, String, String, String, String, String>> attributes(List<String> schemas) {
return null;
}

@Override
public ResultQuery<Record5<String, String, String, String, String>> identities(List<String> schemas) {
return null;
}

@Override
public ResultQuery<Record6<String, String, String, String, String, String>> generators(List<String> schemas) {
return null;
}

@Override
public ResultQuery<Record5<String, String, String, String, String>> checks(List<String> schemas) {
return null;
}
}
Loading