Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Mar 30, 2023
1 parent f4f2bc8 commit 0fedbb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class StatementRequest {

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;
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,
request.getConfOverlay.asScala,
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

0 comments on commit 0fedbb5

Please sign in to comment.