Skip to content

Commit 1ce80ac

Browse files
committed
Add java doc and new test
1 parent f5724e4 commit 1ce80ac

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

query/src/main/java/tech/ydb/query/settings/ExecuteQuerySettings.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
public class ExecuteQuerySettings extends BaseRequestSettings {
1010
private final QueryExecMode execMode;
1111
private final QueryStatsMode statsMode;
12+
13+
/**
14+
* Resource pool
15+
*/
1216
private final String resourcePool;
1317

1418
private ExecuteQuerySettings(Builder builder) {
@@ -49,6 +53,15 @@ public Builder withStatsMode(QueryStatsMode mode) {
4953
return this;
5054
}
5155

56+
/**
57+
* Set resource pool which query try to use.
58+
* If no pool specify or poolId is empty or poolId equals "default"
59+
* the undeleted resource pool "default" wll be used
60+
*
61+
* @param poolId poolId in ydb
62+
*
63+
* @return builder
64+
*/
5265
public Builder withResourcePool(String poolId) {
5366
this.resourcePool = poolId;
5467
return this;

query/src/test/java/tech/ydb/query/impl/QueryIntegrationResourcePoolTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void selectWithResourcePoolTest() {
8686
try (QuerySession session = client.createSession(Duration.ofSeconds(5)).join().getValue()) {
8787
ExecuteQuerySettings settings = ExecuteQuerySettings.newBuilder()
8888
.withExecMode(QueryExecMode.EXECUTE)
89-
.withResourcePool("test_pool")
89+
.withResourcePool(TEST_RESOURCE_POOL)
9090
.withStatsMode(QueryStatsMode.FULL)
9191
.build();
9292

@@ -99,6 +99,27 @@ public void selectWithResourcePoolTest() {
9999
}
100100
}
101101

102+
@Ignore
103+
@Test
104+
public void selectWithResourcePoolShouldBeCaseSensitiveTest() {
105+
createResourcePool(TEST_RESOURCE_POOL);
106+
try (QueryClient client = QueryClient.newClient(ydbTransport).build()) {
107+
try (QuerySession session = client.createSession(Duration.ofSeconds(5)).join().getValue()) {
108+
ExecuteQuerySettings settings = ExecuteQuerySettings.newBuilder()
109+
.withExecMode(QueryExecMode.EXECUTE)
110+
.withResourcePool(TEST_RESOURCE_POOL.toUpperCase())
111+
.withStatsMode(QueryStatsMode.FULL)
112+
.build();
113+
114+
Assert.assertFalse("Query should fail",
115+
session.createQuery("SELECT id, name FROM " + TEST_TABLE + " ORDER BY id;", TxMode.SERIALIZABLE_RW, Params.empty(), settings).execute()
116+
.join().isSuccess());
117+
}
118+
} finally {
119+
deleteResourcePool(TEST_RESOURCE_POOL, true);
120+
}
121+
}
122+
102123
/**
103124
* Check that we don't cache resource pool in session
104125
*/

0 commit comments

Comments
 (0)