Skip to content

Commit 8a9eb6e

Browse files
committed
Upgrade to SDK 2.3.5
1 parent ea0cc0c commit 8a9eb6e

File tree

2 files changed

+93
-18
lines changed

2 files changed

+93
-18
lines changed

jdbc/src/test/java/tech/ydb/jdbc/YdbDriverOlapTablesTest.java

Lines changed: 92 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.time.LocalDate;
1111

1212
import org.junit.jupiter.api.Assertions;
13-
import org.junit.jupiter.api.Disabled;
1413
import org.junit.jupiter.api.Test;
1514
import org.junit.jupiter.api.extension.RegisterExtension;
1615

@@ -22,7 +21,6 @@
2221
*
2322
* @author Aleksandr Gorshenin
2423
*/
25-
@Disabled
2624
public class YdbDriverOlapTablesTest {
2725
@RegisterExtension
2826
private static final YdbHelperExtension ydb = new YdbHelperExtension();
@@ -33,10 +31,6 @@ public class YdbDriverOlapTablesTest {
3331

3432
private final static String ERROR_DATA_MANIPULATION =
3533
"Data manipulation queries do not support column shard tables. (S_ERROR)";
36-
private final static String ERROR_TRANSACTIONS =
37-
"Transactions between column and row tables are disabled at current time. (S_ERROR)";
38-
private final static String ERROR_SCAN_QUERY =
39-
"Scan query should have a single result set. (S_ERROR)";
4034

4135
private final static String ERROR_BULK_UNSUPPORTED =
4236
"BULK mode is available only for prepared statement with one UPSERT";
@@ -76,15 +70,15 @@ public void defaultModeTest() throws SQLException {
7670
ps.setInt(1, ++idx);
7771
ps.setString(2, prefix + idx);
7872
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
79-
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
73+
ps.executeUpdate();
8074
}
8175

8276
// single insert
8377
try (PreparedStatement ps = connection.prepareStatement(INSERT_ROW)) {
8478
ps.setInt(1, ++idx);
8579
ps.setString(2, prefix + idx);
8680
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
87-
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
81+
ps.executeUpdate();
8882
}
8983

9084
// batch upsert
@@ -95,7 +89,7 @@ public void defaultModeTest() throws SQLException {
9589
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
9690
ps.addBatch();
9791
}
98-
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeBatch);
92+
ps.executeBatch();
9993
}
10094

10195
// batch insert
@@ -106,25 +100,34 @@ public void defaultModeTest() throws SQLException {
106100
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
107101
ps.addBatch();
108102
}
109-
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeBatch);
103+
ps.executeBatch();
110104
}
111105

112106
// read all
113-
try (Statement st = connection.createStatement()) {
114-
ExceptionAssert.ydbException(ERROR_TRANSACTIONS, () -> st.executeQuery(SELECT_ALL));
107+
try (PreparedStatement ps = connection.prepareStatement(SELECT_ALL)) {
108+
int readed = 0;
109+
try (ResultSet rs = ps.executeQuery()) {
110+
while (rs.next()) {
111+
readed++;
112+
Assertions.assertEquals(readed, rs.getInt("id"));
113+
Assertions.assertEquals(prefix + readed, rs.getString("value"));
114+
Assertions.assertEquals(Date.valueOf(ld.plusDays(readed)), rs.getDate("date"));
115+
}
116+
}
117+
Assertions.assertEquals(2002, readed);
115118
}
116119

117120
// single update
118121
try (PreparedStatement ps = connection.prepareStatement(UPDATE_ROW)) {
119122
ps.setString(1, "updated-value");
120123
ps.setInt(2, 1);
121-
ExceptionAssert.ydbException(ERROR_TRANSACTIONS, ps::execute);
124+
ps.executeUpdate();
122125
}
123126

124127
// single delete
125128
try (PreparedStatement ps = connection.prepareStatement(DELETE_ROW)) {
126129
ps.setInt(1, 2);
127-
ExceptionAssert.ydbException(ERROR_TRANSACTIONS, ps::execute);
130+
ps.executeUpdate();
128131
}
129132
}
130133
}
@@ -318,21 +321,20 @@ public void forceScanAndBulkTest() throws SQLException {
318321
try (PreparedStatement ps = conn.prepareStatement(UPDATE_ROW)) {
319322
ps.setString(1, "updated-value");
320323
ps.setInt(2, 1);
321-
ExceptionAssert.ydbException(ERROR_SCAN_QUERY, ps::execute);
324+
ps.executeUpdate();
322325
}
323326

324327
// single delete
325328
try (PreparedStatement ps = conn.prepareStatement(DELETE_ROW)) {
326329
ps.setInt(1, 2);
327-
ExceptionAssert.ydbException(ERROR_SCAN_QUERY, ps::execute);
330+
ps.executeUpdate();
328331
}
329332
}
330333
}
331334

332335
@Test
333336
public void streamResultsTest() throws SQLException {
334337
try (Connection conn = DriverManager.getConnection(jdbcURL
335-
.withArg("useQueryService", "true")
336338
.withArg("useStreamResultSets", "true")
337339
.build()
338340
)) {
@@ -456,4 +458,77 @@ public void streamResultsTest() throws SQLException {
456458
}
457459
}
458460
}
461+
462+
@Test
463+
public void tableServiceModeTest() throws SQLException {
464+
try (Connection connection = DriverManager.getConnection(jdbcURL.withArg("useQueryService", "false").build())) {
465+
try {
466+
connection.createStatement().execute(DROP_TABLE);
467+
} catch (SQLException e) {
468+
// ignore
469+
}
470+
471+
connection.createStatement().execute(CREATE_TABLE);
472+
473+
LocalDate ld = LocalDate.of(2017, 12, 3);
474+
String prefix = "text-value-";
475+
int idx = 0;
476+
477+
// single upsert
478+
try (PreparedStatement ps = connection.prepareStatement(UPSERT_ROW)) {
479+
ps.setInt(1, ++idx);
480+
ps.setString(2, prefix + idx);
481+
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
482+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
483+
}
484+
485+
// single insert
486+
try (PreparedStatement ps = connection.prepareStatement(INSERT_ROW)) {
487+
ps.setInt(1, ++idx);
488+
ps.setString(2, prefix + idx);
489+
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
490+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
491+
}
492+
493+
// batch upsert
494+
try (PreparedStatement ps = connection.prepareStatement(UPSERT_ROW)) {
495+
for (int j = 0; j < 1000; j++) {
496+
ps.setInt(1, ++idx);
497+
ps.setString(2, prefix + idx);
498+
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
499+
ps.addBatch();
500+
}
501+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeBatch);
502+
}
503+
504+
// batch insert
505+
try (PreparedStatement ps = connection.prepareStatement(INSERT_ROW)) {
506+
for (int j = 0; j < 1000; j++) {
507+
ps.setInt(1, ++idx);
508+
ps.setString(2, prefix + idx);
509+
ps.setDate(3, Date.valueOf(ld.plusDays(idx)));
510+
ps.addBatch();
511+
}
512+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeBatch);
513+
}
514+
515+
// read all
516+
try (Statement st = connection.createStatement()) {
517+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, () -> st.executeQuery(SELECT_ALL));
518+
}
519+
520+
// single update
521+
try (PreparedStatement ps = connection.prepareStatement(UPDATE_ROW)) {
522+
ps.setString(1, "updated-value");
523+
ps.setInt(2, 1);
524+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
525+
}
526+
527+
// single delete
528+
try (PreparedStatement ps = connection.prepareStatement(DELETE_ROW)) {
529+
ps.setInt(1, 2);
530+
ExceptionAssert.ydbException(ERROR_DATA_MANIPULATION, ps::executeUpdate);
531+
}
532+
}
533+
}
459534
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<slf4j.version>1.7.36</slf4j.version>
2121
<junit.version>5.9.3</junit.version>
2222

23-
<ydb.sdk.version>2.3.3</ydb.sdk.version>
23+
<ydb.sdk.version>2.3.5</ydb.sdk.version>
2424
</properties>
2525

2626
<licenses>

0 commit comments

Comments
 (0)