Skip to content

Commit

Permalink
Fixed issue processing for scheme queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alex268 committed Jul 8, 2024
1 parent c703fc7 commit 8baac04
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions jdbc/src/main/java/tech/ydb/jdbc/context/QueryServiceExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import java.sql.SQLFeatureNotSupportedException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

import tech.ydb.common.transaction.TxMode;
import tech.ydb.core.Issue;
import tech.ydb.core.Result;
import tech.ydb.core.UnexpectedResultException;
import tech.ydb.jdbc.YdbConst;
Expand All @@ -17,7 +19,9 @@
import tech.ydb.jdbc.query.YdbQuery;
import tech.ydb.query.QueryClient;
import tech.ydb.query.QuerySession;
import tech.ydb.query.QueryStream;
import tech.ydb.query.QueryTransaction;
import tech.ydb.query.result.QueryResultPart;
import tech.ydb.query.settings.CommitTransactionSettings;
import tech.ydb.query.settings.ExecuteQuerySettings;
import tech.ydb.query.settings.RollbackTransactionSettings;
Expand Down Expand Up @@ -228,12 +232,31 @@ public void executeSchemeQuery(YdbContext ctx, YdbValidator validator, YdbQuery
final String yql = query.getYqlQuery(null);

try (QuerySession session = createNewQuerySession(validator)) {
validator.call(QueryType.SCHEME_QUERY + " >>\n" + yql,
() -> session.createQuery(yql, TxMode.NONE, Params.empty(), settings).execute()
validator.call(QueryType.SCHEME_QUERY + " >>\n" + yql, () -> session
.createQuery(yql, TxMode.NONE, Params.empty(), settings)
.execute(new IssueHandler(validator))
);
}
}

private class IssueHandler implements QueryStream.PartsHandler {
private final YdbValidator validator;

public IssueHandler(YdbValidator validator) {
this.validator = validator;
}

@Override
public void onIssues(Issue[] issues) {
validator.addStatusIssues(Arrays.asList(issues));
}

@Override
public void onNextPart(QueryResultPart part) {
// nothing
}
}

@Override
public boolean isValid(YdbValidator validator, int timeout) throws SQLException {
ensureOpened();
Expand Down

0 comments on commit 8baac04

Please sign in to comment.