Skip to content

Commit 2e6f428

Browse files
Merge remote-tracking branch 'upstream/master' into develop
# Conflicts: # jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java
2 parents a03fdd4 + 3d74021 commit 2e6f428

File tree

75 files changed

+3513
-919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3513
-919
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
prepare:
1414
name: Prepare Maven cache
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616

1717
env:
1818
MAVEN_ARGS: --batch-mode -Dstyle.color=always
@@ -33,7 +33,7 @@ jobs:
3333

3434
build:
3535
name: Build JDBC Driver
36-
runs-on: ubuntu-latest
36+
runs-on: ubuntu-24.04
3737
needs: prepare
3838

3939
strategy:
@@ -103,7 +103,7 @@ jobs:
103103
coverage:
104104
if: github.repository == 'ydb-platform/ydb-jdbc-driver'
105105
name: Coverage JDBC Driver
106-
runs-on: ubuntu-latest
106+
runs-on: ubuntu-24.04
107107
needs: build
108108

109109
env:

.github/workflows/ci.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
prepare:
1313
name: Prepare Maven cache
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515

1616
env:
1717
MAVEN_ARGS: --batch-mode -Dstyle.color=always
@@ -47,7 +47,7 @@ jobs:
4747

4848
build:
4949
name: YDB JDBC Driver CI on JDK
50-
runs-on: ubuntu-latest
50+
runs-on: ubuntu-24.04
5151
needs: prepare
5252

5353
strategy:
@@ -75,8 +75,10 @@ jobs:
7575
- name: Extract YDB JDBC Driver version
7676
working-directory: ./jdbc
7777
run: |
78-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
79-
echo "JDBC_VERSION=$VERSION" >> "$GITHUB_ENV"
78+
JDBC_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
79+
SDK_VERSION=$(mvn help:evaluate -Dexpression=ydb.sdk.version -q -DforceStdout)
80+
echo "JDBC_VERSION=$JDBC_VERSION" >> "$GITHUB_ENV"
81+
echo "SDK_VERSION=$SDK_VERSION" >> "$GITHUB_ENV"
8082
8183
- name: Build YDB JDBC Driver
8284
working-directory: ./jdbc
@@ -90,4 +92,4 @@ jobs:
9092

9193
- name: Test examples with Maven
9294
working-directory: ./examples
93-
run: mvn $MAVEN_ARGS -Dydb.jdbc.version=$JDBC_VERSION test
95+
run: mvn $MAVEN_ARGS -Dydb.sdk.version=$SDK_VERSION -Dydb.jdbc.version=$JDBC_VERSION test

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
validate:
1010
name: Validate YDB JDBC Driver
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-24.04
1212

1313
steps:
1414
- name: Checkout
@@ -52,7 +52,7 @@ jobs:
5252

5353
publish:
5454
name: Publish YDB JDBC Driver
55-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-24.04
5656
needs: validate
5757

5858
env:

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
## 2.3.10 ##
2+
3+
* Added .metadata folder to system tables
4+
* Added support of GRANT/REVOKE keywords
5+
6+
## 2.3.9 ##
7+
8+
* Added option 'forceJdbcParameters' to detect ? in whole query text
9+
* Added option 'tokenProvider' to use custom auth provider
10+
* Upgrade to Java SDK 2.3.13
11+
12+
## 2.3.8 ##
13+
14+
* Added option 'grpcCompression'
15+
* Added bulk upsert validation
16+
* All grpc calls isolated from parent context
17+
18+
## 2.3.7 ##
19+
20+
* Added slf4j-to-jul to shaded jar
21+
* Upgrade to use Java SDK v2.3.8
22+
23+
## 2.3.6 ##
24+
25+
* Added jdbc_table which can be converted to AS_TABLE($list)
26+
27+
## 2.3.5 ##
28+
29+
* Disabled stream reader sets for SCAN queries
30+
31+
## 2.3.4 ##
32+
33+
* Upgraded to YDB Java SDK 2.3.6
34+
* Fixed closing of ResultSet on prepareStatement and createStatement
35+
* Added support of convertion IN (?, ?, ?) to IN $list
36+
* Added option cachedTransportsCount to shard JDBC connections
37+
38+
## 2.3.3 ##
39+
40+
* Upgraded to YDB Java SDK 2.3.5
41+
* Added support of setString for all YDB types
42+
* Fixed disablePrepareDataQuery option
43+
* Added support of UUID and custom decimal types
44+
145
## 2.3.2 ##
246

347
* Fixed typo in YdbTracer

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ Specify the YDB JDBC driver in the dependencies:
2626
<dependency>
2727
<groupId>tech.ydb.jdbc</groupId>
2828
<artifactId>ydb-jdbc-driver</artifactId>
29-
<version>2.3.2</version>
29+
<version>2.3.10</version>
3030
</dependency>
3131

3232
<!-- Shaded version with included dependencies -->
3333
<dependency>
3434
<groupId>tech.ydb.jdbc</groupId>
3535
<artifactId>ydb-jdbc-driver-shaded</artifactId>
36-
<version>2.3.2</version>
36+
<version>2.3.10</version>
3737
</dependency>
3838
</dependencies>
3939
```

jdbc-shaded/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.3.3-SNAPSHOT</version>
9+
<version>2.3.11-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver-shaded</artifactId>
@@ -19,6 +19,11 @@
1919
<groupId>tech.ydb.jdbc</groupId>
2020
<artifactId>ydb-jdbc-driver</artifactId>
2121
</dependency>
22+
23+
<dependency>
24+
<groupId>org.slf4j</groupId>
25+
<artifactId>slf4j-jdk14</artifactId>
26+
</dependency>
2227
</dependencies>
2328

2429
<build>
@@ -117,6 +122,12 @@
117122
<exclude>META-INF/*.RSA</exclude>
118123
</excludes>
119124
</filter>
125+
<filter>
126+
<artifact>org.slf4j:slf4j-api</artifact>
127+
<excludes>
128+
<exclude>org/slf4j/impl/**</exclude>
129+
</excludes>
130+
</filter>
120131
</filters>
121132

122133
<relocations>

jdbc/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>tech.ydb.jdbc</groupId>
88
<artifactId>ydb-jdbc-driver-parent</artifactId>
9-
<version>2.3.3-SNAPSHOT</version>
9+
<version>2.3.11-SNAPSHOT</version>
1010
</parent>
1111

1212
<artifactId>ydb-jdbc-driver</artifactId>
@@ -77,6 +77,7 @@
7777
<environmentVariables>
7878
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
7979
<YDB_DOCKER_IMAGE>ydbplatform/local-ydb:trunk</YDB_DOCKER_IMAGE>
80+
<YDB_DOCKER_FEATURE_FLAGS>enable_parameterized_decimal</YDB_DOCKER_FEATURE_FLAGS>
8081
</environmentVariables>
8182
<systemPropertyVariables>
8283
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>

jdbc/src/main/java/tech/ydb/jdbc/YdbConst.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ public final class YdbConst {
66
public static final int UNKNOWN_SQL_TYPE = Integer.MIN_VALUE;
77

88
public static final int SQL_KIND_PRIMITIVE = 10000;
9-
public static final int SQL_KIND_DECIMAL = 1 << 15; // 32768
10-
11-
// YDB does not support types with custom precision yet
12-
public static final int SQL_DECIMAL_DEFAULT_PRECISION = 22;
13-
public static final int SQL_DECIMAL_DEFAULT_SCALE = 9;
9+
public static final int SQL_KIND_DECIMAL = 1 << 14; // 16384
1410

1511
// Built-in limits
1612
public static final int MAX_PRIMARY_KEY_SIZE = 1024 * 1024; // 1 MiB per index

jdbc/src/main/java/tech/ydb/jdbc/YdbDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public YdbConnection connect(String url, Properties info) throws SQLException {
4747
}
4848

4949
YdbConfig config = YdbConfig.from(url, info);
50-
LOGGER.log(Level.FINE, "About to connect to [{0}] using properties {1}", new Object[] {
50+
LOGGER.log(Level.FINE, "Connect to [{0}] using properties {1}", new Object[] {
5151
config.getSafeUrl(),
5252
config.getSafeProps()
5353
});
@@ -80,7 +80,7 @@ public YdbContext getCachedContext(YdbConfig config) throws SQLException {
8080
// Was fixed in Java 9+
8181
YdbContext context = cache.get(config);
8282
if (context != null) {
83-
LOGGER.log(Level.FINE, "Reusing YDB connection to {0}", config.getSafeUrl());
83+
LOGGER.log(Level.FINEST, "Reusing YDB connection to {0}", config.getSafeUrl());
8484
return context;
8585
}
8686

jdbc/src/main/java/tech/ydb/jdbc/common/FixedResultSetFactory.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,22 @@ public Duration getInterval() {
317317
return value.getInterval();
318318
}
319319

320+
public LocalDate getDate32() {
321+
throw new UnsupportedOperationException("Not supported yet.");
322+
}
323+
324+
public LocalDateTime getDatetime64() {
325+
throw new UnsupportedOperationException("Not supported yet.");
326+
}
327+
328+
public Instant getTimestamp64() {
329+
throw new UnsupportedOperationException("Not supported yet.");
330+
}
331+
332+
public Duration getInterval64() {
333+
throw new UnsupportedOperationException("Not supported yet.");
334+
}
335+
320336
@Override
321337
public ZonedDateTime getTzDate() {
322338
return value.getTzDate();

jdbc/src/main/java/tech/ydb/jdbc/common/MappingGetters.java

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ static Getters buildGetters(Type type) {
6464
castToBooleanNotSupported(clazz),
6565
castToByteNotSupported(clazz),
6666
castToShortNotSupported(clazz),
67-
value -> value.getDecimal().toBigInteger().intValue(),
68-
value -> value.getDecimal().toBigInteger().longValue(),
69-
value -> value.getDecimal().toBigDecimal().floatValue(),
70-
value -> value.getDecimal().toBigDecimal().doubleValue(),
67+
value -> safeDecimalInt(value.getDecimal()),
68+
value -> safeDecimalLong(value.getDecimal()),
69+
value -> safeDecimal(value.getDecimal()).floatValue(),
70+
value -> safeDecimal(value.getDecimal()).doubleValue(),
7171
castToBytesNotSupported(clazz),
72-
value -> value.getDecimal().toBigDecimal(),
72+
value -> safeDecimal(value.getDecimal()),
7373
castToClassNotSupported(clazz),
7474
castToInstantNotSupported(clazz),
7575
castToNStringNotSupported(clazz),
7676
castToUrlNotSupported(clazz),
77-
value -> value.getDecimal().toBigDecimal(),
77+
value -> safeDecimal(value.getDecimal()),
7878
castToReaderNotSupported(clazz)
7979
);
8080
case VOID:
@@ -235,6 +235,35 @@ private static ValueToBoolean valueToBoolean(PrimitiveType id) {
235235
}
236236
}
237237

238+
private static BigDecimal safeDecimal(DecimalValue value) throws SQLException {
239+
if (value.isInf() || value.isNegativeInf() || value.isNan()) {
240+
throw cannotConvert(value.getType(), BigDecimal.class, value.toString());
241+
}
242+
return value.toBigDecimal();
243+
}
244+
245+
private static int safeDecimalInt(DecimalValue value) throws SQLException {
246+
if (value.isInf() || value.isNegativeInf() || value.isNan()) {
247+
throw cannotConvert(value.getType(), int.class, value.toString());
248+
}
249+
try {
250+
return value.toBigDecimal().intValueExact();
251+
} catch (ArithmeticException ex) {
252+
throw cannotConvert(value.getType(), int.class, value.toString());
253+
}
254+
}
255+
256+
private static long safeDecimalLong(DecimalValue value) throws SQLException {
257+
if (value.isInf() || value.isNegativeInf() || value.isNan()) {
258+
throw cannotConvert(value.getType(), long.class, value.toString());
259+
}
260+
try {
261+
return value.toBigDecimal().longValueExact();
262+
} catch (ArithmeticException ex) {
263+
throw cannotConvert(value.getType(), long.class, value.toString());
264+
}
265+
}
266+
238267
private static byte checkByteValue(PrimitiveType id, int value) throws SQLException {
239268
int ch = value >= 0 ? value : ~value;
240269
if ((ch & 0x7F) != ch) {
@@ -574,8 +603,9 @@ private static SqlType buildPrimitiveType(int sqlType, PrimitiveType id) {
574603
case Text:
575604
case Json:
576605
case JsonDocument:
577-
case Uuid:
578606
return new SqlType(sqlType, String.class);
607+
case Uuid:
608+
return new SqlType(sqlType, UUID.class);
579609
case Bytes:
580610
case Yson:
581611
return new SqlType(sqlType, byte[].class);
@@ -857,7 +887,7 @@ private static ValueToClass valueToClass(PrimitiveType id) {
857887
}
858888
}
859889

860-
private static SQLException cannotConvert(PrimitiveType type, Class<?> javaType, Object value) {
890+
private static SQLException cannotConvert(Type type, Class<?> javaType, Object value) {
861891
return new SQLException(String.format(YdbConst.UNABLE_TO_CONVERT, type, value, javaType));
862892
}
863893

0 commit comments

Comments
 (0)