|
4 | 4 | import java.sql.SQLException; |
5 | 5 | import java.sql.SQLFeatureNotSupportedException; |
6 | 6 | import java.time.Duration; |
7 | | -import java.util.ArrayList; |
8 | 7 | import java.util.Arrays; |
9 | 8 | import java.util.Collections; |
10 | | -import java.util.List; |
11 | 9 | import java.util.concurrent.TimeUnit; |
12 | 10 |
|
13 | 11 | import tech.ydb.common.transaction.TxMode; |
14 | 12 | import tech.ydb.core.Issue; |
15 | 13 | import tech.ydb.core.Result; |
16 | 14 | import tech.ydb.core.UnexpectedResultException; |
17 | 15 | import tech.ydb.jdbc.YdbConst; |
18 | | -import tech.ydb.jdbc.YdbResultSet; |
19 | 16 | import tech.ydb.jdbc.YdbStatement; |
20 | 17 | import tech.ydb.jdbc.exception.ExceptionFactory; |
21 | 18 | import tech.ydb.jdbc.impl.YdbQueryResult; |
22 | | -import tech.ydb.jdbc.impl.YdbStaticResultSet; |
23 | 19 | import tech.ydb.jdbc.query.QueryType; |
24 | 20 | import tech.ydb.jdbc.query.YdbQuery; |
25 | 21 | import tech.ydb.query.QueryClient; |
|
32 | 28 | import tech.ydb.query.settings.ExecuteQuerySettings; |
33 | 29 | import tech.ydb.query.settings.QueryExecMode; |
34 | 30 | import tech.ydb.query.settings.RollbackTransactionSettings; |
35 | | -import tech.ydb.query.tools.QueryReader; |
36 | 31 | import tech.ydb.table.query.Params; |
37 | 32 |
|
38 | 33 | /** |
@@ -216,20 +211,17 @@ public YdbQueryResult executeDataQuery( |
216 | 211 | tx = createNewQuerySession(validator).createNewTransaction(txMode); |
217 | 212 | } |
218 | 213 |
|
219 | | - try { |
220 | | - QueryReader result = validator.call(QueryType.DATA_QUERY + " >>\n" + yql, |
221 | | - () -> QueryReader.readFrom(tx.createQuery(yql, isAutoCommit, params, settings)) |
222 | | - ); |
223 | | - validator.addStatusIssues(result.getIssueList()); |
| 214 | + String msg = "STREAM_QUERY >>\n" + yql; |
| 215 | + QueryStream stream = tx.createQuery(yql, isAutoCommit, params, settings); |
| 216 | + StreamQueryResult result = new StreamQueryResult(msg, statement, query, stream::cancel); |
224 | 217 |
|
225 | | - List<YdbResultSet> rsList = new ArrayList<>(); |
226 | | - result.forEach(rsr -> rsList.add(new YdbStaticResultSet(statement, rsr))); |
227 | | - return new StaticQueryResult(query, rsList); |
228 | | - } finally { |
| 218 | + result.start(stream).thenRun(() -> { |
229 | 219 | if (!tx.isActive()) { |
230 | 220 | cleanTx(); |
231 | 221 | } |
232 | | - } |
| 222 | + }); |
| 223 | + |
| 224 | + return result; |
233 | 225 | } |
234 | 226 |
|
235 | 227 | @Override |
|
0 commit comments