Skip to content

Commit eb88e21

Browse files
committed
Added option to read raw protobuf message in QueryStream
1 parent cd27600 commit eb88e21

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

query/src/main/java/tech/ydb/query/QueryStream.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import tech.ydb.core.Issue;
88
import tech.ydb.core.Result;
9+
import tech.ydb.proto.ValueProtos;
910
import tech.ydb.query.result.QueryInfo;
1011
import tech.ydb.query.result.QueryResultPart;
1112

@@ -15,9 +16,16 @@
1516
*/
1617
@ExperimentalApi("QueryService is experimental and API may change without notice")
1718
public interface QueryStream {
19+
20+
@FunctionalInterface
1821
interface PartsHandler {
1922
default void onIssues(Issue[] issues) { }
23+
2024
void onNextPart(QueryResultPart part);
25+
26+
default void onNextRawPart(long index, ValueProtos.ResultSet rs) {
27+
onNextPart(new QueryResultPart(index, rs));
28+
}
2129
}
2230

2331
CompletableFuture<Result<QueryInfo>> execute(PartsHandler handler);

query/src/main/java/tech/ydb/query/impl/SessionImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import tech.ydb.query.QueryStream;
3030
import tech.ydb.query.QueryTransaction;
3131
import tech.ydb.query.result.QueryInfo;
32-
import tech.ydb.query.result.QueryResultPart;
3332
import tech.ydb.query.result.QueryStats;
3433
import tech.ydb.query.settings.AttachSessionSettings;
3534
import tech.ydb.query.settings.BeginTransactionSettings;
@@ -304,7 +303,7 @@ public CompletableFuture<Result<QueryInfo>> execute(PartsHandler handler) {
304303
if (msg.hasResultSet()) {
305304
long index = msg.getResultSetIndex();
306305
if (handler != null) {
307-
handler.onNextPart(new QueryResultPart(index, msg.getResultSet()));
306+
handler.onNextRawPart(index, msg.getResultSet());
308307
} else {
309308
logger.trace("{} lost result set part with index {}", SessionImpl.this, index);
310309
}

0 commit comments

Comments
 (0)