[NO ISSUE] Update version, enhance fetchResult()
Details:
- Change version to 0.9.8-SNAPSHOT
- Add SubmitStatementOptions parameter
to ADBProtocolBase.fetchResult()
- Added executionId into SubmitStatementOptions
Change-Id: Id77be49aa749f7b5667144e3b0ddb5a224cd260d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb-clients/+/15923
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@uci.edu>
diff --git a/asterixdb-jdbc/asterix-jdbc-core/pom.xml b/asterixdb-jdbc/asterix-jdbc-core/pom.xml
index 1fc08fe..b4a7163 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/pom.xml
+++ b/asterixdb-jdbc/asterix-jdbc-core/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>apache-asterixdb-jdbc</artifactId>
<groupId>org.apache.asterix</groupId>
- <version>0.9.7-SNAPSHOT</version>
+ <version>0.9.8-SNAPSHOT</version>
</parent>
<artifactId>asterix-jdbc-core</artifactId>
diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBPreparedStatement.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBPreparedStatement.java
index 7a6d5af..f87eede 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBPreparedStatement.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBPreparedStatement.java
@@ -54,8 +54,7 @@
ADBProtocolBase.SubmitStatementOptions stmtOptions = createSubmitStatementOptions();
stmtOptions.compileOnly = true;
stmtOptions.timeoutSeconds = 0; /* TODO:timeout */
- ADBProtocolBase.QueryServiceResponse response =
- connection.protocol.submitStatement(sql, null, null, stmtOptions);
+ ADBProtocolBase.QueryServiceResponse response = connection.protocol.submitStatement(sql, null, stmtOptions);
int parameterCount = connection.protocol.getStatementParameterCount(response);
boolean isQuery = connection.protocol.isStatementCategory(response,
ADBProtocolBase.QueryServiceResponse.StatementCategory.QUERY);
diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocolBase.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocolBase.java
index 6bf6c1f..3186aa0 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocolBase.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocolBase.java
@@ -85,10 +85,11 @@
public abstract boolean ping(int timeoutSeconds);
- public abstract QueryServiceResponse submitStatement(String sql, List<?> args, UUID executionId,
- SubmitStatementOptions options) throws SQLException;
+ public abstract QueryServiceResponse submitStatement(String sql, List<?> args, SubmitStatementOptions options)
+ throws SQLException;
- public abstract JsonParser fetchResult(QueryServiceResponse response) throws SQLException;
+ public abstract JsonParser fetchResult(QueryServiceResponse response, SubmitStatementOptions options)
+ throws SQLException;
public abstract void cancelRunningStatement(UUID executionId) throws SQLException;
@@ -264,6 +265,7 @@
public boolean forceReadOnly;
public boolean compileOnly;
public boolean sqlCompatMode;
+ public UUID executionId;
}
public static class QueryServiceResponse {
diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBStatement.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBStatement.java
index 6eea813..cdbece6 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBStatement.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBStatement.java
@@ -90,6 +90,7 @@
protected final ConcurrentLinkedQueue<WeakReference<ADBResultSet>> resultSetsWithoutResources;
// execute() result field
+ protected ADBProtocolBase.SubmitStatementOptions executeStmtOptions;
protected ADBProtocolBase.QueryServiceResponse executeResponse;
protected ADBResultSet executeResultSet;
@@ -158,9 +159,9 @@
// note: we're not assigning executeResponse field at this method
try {
ADBProtocolBase.SubmitStatementOptions stmtOptions = createSubmitStatementOptions();
+ stmtOptions.executionId = executionId;
stmtOptions.forceReadOnly = true;
- ADBProtocolBase.QueryServiceResponse response =
- connection.protocol.submitStatement(sql, args, executionId, stmtOptions);
+ ADBProtocolBase.QueryServiceResponse response = connection.protocol.submitStatement(sql, args, stmtOptions);
boolean isQuery = connection.protocol.isStatementCategory(response,
ADBProtocolBase.QueryServiceResponse.StatementCategory.QUERY);
if (!isQuery) {
@@ -168,7 +169,7 @@
}
warnings = connection.protocol.getWarningIfExists(response);
updateCount = -1;
- return fetchResultSet(response);
+ return fetchResultSet(response, stmtOptions);
} finally {
resetExecutionId();
}
@@ -219,8 +220,8 @@
protected int executeUpdateImpl(String sql, List<Object> args) throws SQLException {
try {
ADBProtocolBase.SubmitStatementOptions stmtOptions = createSubmitStatementOptions();
- ADBProtocolBase.QueryServiceResponse response =
- connection.protocol.submitStatement(sql, args, executionId, stmtOptions);
+ stmtOptions.executionId = executionId;
+ ADBProtocolBase.QueryServiceResponse response = connection.protocol.submitStatement(sql, args, stmtOptions);
boolean isQuery = connection.protocol.isStatementCategory(response,
ADBProtocolBase.QueryServiceResponse.StatementCategory.QUERY);
// TODO: remove result set on the server (both query and update returning cases)
@@ -259,9 +260,10 @@
protected boolean executeImpl(String sql, List<Object> args) throws SQLException {
try {
ADBProtocolBase.SubmitStatementOptions stmtOptions = createSubmitStatementOptions();
- ADBProtocolBase.QueryServiceResponse response =
- connection.protocol.submitStatement(sql, args, executionId, stmtOptions);
+ stmtOptions.executionId = executionId;
+ ADBProtocolBase.QueryServiceResponse response = connection.protocol.submitStatement(sql, args, stmtOptions);
warnings = connection.protocol.getWarningIfExists(response);
+ executeStmtOptions = stmtOptions;
boolean isQuery = connection.protocol.isStatementCategory(response,
ADBProtocolBase.QueryServiceResponse.StatementCategory.QUERY);
if (isQuery) {
@@ -347,9 +349,10 @@
if (response == null) {
return null;
}
- ADBResultSet rs = fetchResultSet(response);
+ ADBResultSet rs = fetchResultSet(response, executeStmtOptions);
executeResultSet = rs;
executeResponse = null;
+ executeStmtOptions = null;
return rs;
}
@@ -406,7 +409,8 @@
// ResultSet lifecycle
- protected ADBResultSet fetchResultSet(ADBProtocolBase.QueryServiceResponse execResponse) throws SQLException {
+ protected ADBResultSet fetchResultSet(ADBProtocolBase.QueryServiceResponse execResponse,
+ ADBProtocolBase.SubmitStatementOptions stmtOptions) throws SQLException {
List<ADBColumn> columns = connection.protocol.getColumns(execResponse);
if (getLogger().isLoggable(Level.FINER)) {
getLogger().log(Level.FINE, "result schema " + columns);
@@ -417,7 +421,7 @@
connection.protocol.fetchExplainOnlyResult(execResponse, stringSer::serializeToString);
return createSystemResultSet(columns, explainResult);
} else {
- JsonParser rowParser = connection.protocol.fetchResult(execResponse);
+ JsonParser rowParser = connection.protocol.fetchResult(execResponse, stmtOptions);
return createResultSetImpl(columns, rowParser, true, maxRows);
}
}
diff --git a/asterixdb-jdbc/asterix-jdbc-driver/pom.xml b/asterixdb-jdbc/asterix-jdbc-driver/pom.xml
index 8c03da0..3ef116a 100644
--- a/asterixdb-jdbc/asterix-jdbc-driver/pom.xml
+++ b/asterixdb-jdbc/asterix-jdbc-driver/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>apache-asterixdb-jdbc</artifactId>
<groupId>org.apache.asterix</groupId>
- <version>0.9.7-SNAPSHOT</version>
+ <version>0.9.8-SNAPSHOT</version>
</parent>
<artifactId>asterix-jdbc-driver</artifactId>
diff --git a/asterixdb-jdbc/asterix-jdbc-driver/src/main/java/org/apache/asterix/jdbc/ADBProtocol.java b/asterixdb-jdbc/asterix-jdbc-driver/src/main/java/org/apache/asterix/jdbc/ADBProtocol.java
index 2f95b57..bb477b0 100644
--- a/asterixdb-jdbc/asterix-jdbc-driver/src/main/java/org/apache/asterix/jdbc/ADBProtocol.java
+++ b/asterixdb-jdbc/asterix-jdbc-driver/src/main/java/org/apache/asterix/jdbc/ADBProtocol.java
@@ -207,8 +207,8 @@
}
@Override
- public QueryServiceResponse submitStatement(String sql, List<?> args, UUID executionId,
- SubmitStatementOptions options) throws SQLException {
+ public QueryServiceResponse submitStatement(String sql, List<?> args, SubmitStatementOptions options)
+ throws SQLException {
HttpPost httpPost = new HttpPost(queryEndpoint);
httpPost.setHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_JSON
.withParameters(new BasicNameValuePair(FORMAT_LOSSLESS_ADM, Boolean.TRUE.toString())).toString());
@@ -239,8 +239,8 @@
if (options.dataverseName != null) {
jsonGen.writeStringField(DATAVERSE, options.dataverseName);
}
- if (executionId != null) {
- jsonGen.writeStringField(CLIENT_CONTEXT_ID, executionId.toString());
+ if (options.executionId != null) {
+ jsonGen.writeStringField(CLIENT_CONTEXT_ID, options.executionId.toString());
}
if (args != null && !args.isEmpty()) {
jsonGen.writeFieldName(ARGS);
@@ -305,7 +305,7 @@
}
@Override
- public JsonParser fetchResult(QueryServiceResponse response) throws SQLException {
+ public JsonParser fetchResult(QueryServiceResponse response, SubmitStatementOptions options) throws SQLException {
if (response.handle == null) {
throw getErrorReporter().errorInProtocol();
}
diff --git a/asterixdb-jdbc/asterix-jdbc-taco/pom.xml b/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
index 71eef77..ff13772 100644
--- a/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
+++ b/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
@@ -23,7 +23,7 @@
<parent>
<artifactId>apache-asterixdb-jdbc</artifactId>
<groupId>org.apache.asterix</groupId>
- <version>0.9.7-SNAPSHOT</version>
+ <version>0.9.8-SNAPSHOT</version>
</parent>
<artifactId>asterix-jdbc-taco</artifactId>
<packaging>jar</packaging>
diff --git a/asterixdb-jdbc/pom.xml b/asterixdb-jdbc/pom.xml
index 9e318bb..2996e7f 100644
--- a/asterixdb-jdbc/pom.xml
+++ b/asterixdb-jdbc/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.asterix</groupId>
<artifactId>apache-asterixdb-jdbc</artifactId>
- <version>0.9.7-SNAPSHOT</version>
+ <version>0.9.8-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.apache</groupId>