Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to specify confOverlay when executing statement with RESTful API #4639

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/client/rest/rest_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ Create an operation with EXECUTE_STATEMENT type

#### Request Body

| Name | Description | Type |
|:-------------|:---------------------------------------------------------------|:--------|
| statement | The SQL statement that you execute | String |
| runAsync | The flag indicates whether the query runs synchronously or not | Boolean |
| queryTimeout | The interval of query time out | Long |
| Name | Description | Type |
|:-------------|:---------------------------------------------------------------|:---------------|
| statement | The SQL statement that you execute | String |
| runAsync | The flag indicates whether the query runs synchronously or not | Boolean |
| queryTimeout | The interval of query time out | Long |
| confOverlay | The conf to overlay only for current operation | Map of key=val |

#### Response Body

Expand Down
1 change: 1 addition & 0 deletions docs/deployment/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## Upgrading from Kyuubi 1.7.0 to 1.7.1

* Since Kyuubi 1.7.1, `protocolVersion` is removed from the request parameters of the REST API `Open(create) a session`. All removed or unknown parameters will be silently ignored and affects nothing.
* Since Kyuubi 1.7.1, `confOverlay` is supported in the request parameters of the REST API `Create an operation with EXECUTE_STATEMENT type`.

## Upgrading from Kyuubi 1.6 to 1.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.kyuubi.client.api.v1.dto;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand All @@ -25,13 +27,20 @@ public class StatementRequest {
private String statement;
private boolean runAsync;
private Long queryTimeout;
private Map<String, String> confOverlay;

public StatementRequest() {}

public StatementRequest(String statement, boolean runAsync, Long queryTimeout) {
this(statement, runAsync, queryTimeout, Collections.emptyMap());
}

public StatementRequest(
String statement, boolean runAsync, Long queryTimeout, Map<String, String> confOverlay) {
this.statement = statement;
this.runAsync = runAsync;
this.queryTimeout = queryTimeout;
this.confOverlay = confOverlay;
}

public String getStatement() {
Expand All @@ -58,6 +67,17 @@ public void setQueryTimeout(Long queryTimeout) {
this.queryTimeout = queryTimeout;
}

public Map<String, String> getConfOverlay() {
if (confOverlay == null) {
return Collections.emptyMap();
}
return confOverlay;
}

public void setConfOverlay(Map<String, String> confOverlay) {
this.confOverlay = confOverlay;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
fe.be.executeStatement(
sessionHandleStr,
request.getStatement,
Map.empty,
request.getConfOverlay.asScala.toMap,
request.isRunAsync,
request.getQueryTimeout)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.apache.kyuubi.server.api.v1

import java.nio.charset.StandardCharsets
import java.util
import java.util.Base64
import java.util.{Base64, Collections}
import javax.ws.rs.client.Entity
import javax.ws.rs.core.{GenericType, MediaType, Response}

Expand Down Expand Up @@ -192,14 +192,26 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {

val pathPrefix = s"api/v1/sessions/$sessionHandle"

val statementReq = new StatementRequest("show tables", true, 3000)
var statementReq = new StatementRequest("show tables", true, 3000)
response = webTarget
.path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
var operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle !== null)

statementReq = new StatementRequest(
"spark.sql(\"show tables\")",
true,
3000,
Collections.singletonMap(KyuubiConf.OPERATION_LANGUAGE.key, "SCALA"))
response = webTarget
.path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle !== null)

response = webTarget.path(s"$pathPrefix/operations/typeInfo").request()
.post(Entity.entity(null, MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
Expand Down