FrontendServiceSuite get schemas
This commit is contained in:
parent
64cfb8cd95
commit
2f564c6b20
@ -17,7 +17,11 @@
|
||||
|
||||
package org.apache.kyuubi.operation
|
||||
|
||||
import org.apache.hive.service.rpc.thrift.{TRowSet, TTableSchema}
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
import org.apache.hive.service.rpc.thrift.{TColumn, TRow, TRowSet, TStringColumn, TTableSchema}
|
||||
|
||||
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
|
||||
import org.apache.kyuubi.operation.OperationType.OperationType
|
||||
@ -37,7 +41,12 @@ class NoopOperation(typ: OperationType, session: Session)
|
||||
|
||||
override def getResultSetSchema: TTableSchema = new TTableSchema()
|
||||
|
||||
override def getNextRowSet(order: FetchOrientation, rowSetSize: Int): TRowSet = new TRowSet()
|
||||
override def getNextRowSet(order: FetchOrientation, rowSetSize: Int): TRowSet = {
|
||||
val col = TColumn.stringVal(new TStringColumn(Seq(typ.toString).asJava, ByteBuffer.allocate(0)))
|
||||
val tRowSet = new TRowSet(0, new java.util.ArrayList[TRow](0))
|
||||
tRowSet.addToColumns(col)
|
||||
tRowSet
|
||||
}
|
||||
|
||||
override def shouldRunAsync: Boolean = false
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ package org.apache.kyuubi.service
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
import org.apache.hive.service.rpc.thrift.{TCLIService, TCloseSessionReq, TGetCatalogsReq, TOpenSessionReq, TOperationType, TSessionHandle, TStatus, TStatusCode}
|
||||
import org.apache.hive.service.rpc.thrift.{TCLIService, TCloseSessionReq, TFetchOrientation, TFetchResultsReq, TGetCatalogsReq, TGetSchemasReq, TOpenSessionReq, TOperationHandle, TOperationType, TSessionHandle, TStatus, TStatusCode}
|
||||
import org.apache.thrift.protocol.TBinaryProtocol
|
||||
import org.apache.thrift.transport.TSocket
|
||||
|
||||
@ -80,6 +80,19 @@ class FrontendServiceSuite extends KyuubiFunSuite {
|
||||
}
|
||||
}
|
||||
|
||||
private def checkOperationResult(
|
||||
client: TCLIService.Iface, handle: TOperationHandle): Unit = {
|
||||
val tFetchResultsReq = new TFetchResultsReq()
|
||||
tFetchResultsReq.setOperationHandle(handle)
|
||||
tFetchResultsReq.setFetchType(0)
|
||||
tFetchResultsReq.setOrientation(TFetchOrientation.FETCH_NEXT)
|
||||
tFetchResultsReq.setMaxRows(10)
|
||||
val resp = client.FetchResults(tFetchResultsReq)
|
||||
val expected = handle.getOperationType.toString
|
||||
val actual = resp.getResults.getColumns.get(0).getStringVal.getValues.get(0)
|
||||
assert(actual === expected)
|
||||
}
|
||||
|
||||
test("open session") {
|
||||
withThriftClient { client =>
|
||||
val req = new TOpenSessionReq()
|
||||
@ -107,6 +120,18 @@ class FrontendServiceSuite extends KyuubiFunSuite {
|
||||
val opHandle = resp.getOperationHandle
|
||||
assert(opHandle.getOperationType === TOperationType.GET_CATALOGS)
|
||||
assert(resp.getStatus.getStatusCode === TStatusCode.SUCCESS_STATUS)
|
||||
checkOperationResult(client, opHandle)
|
||||
}
|
||||
}
|
||||
|
||||
test("get schemas") {
|
||||
withSessionHandle { (client, handle) =>
|
||||
val req = new TGetSchemasReq(handle)
|
||||
val resp = client.GetSchemas(req)
|
||||
val opHandle = resp.getOperationHandle
|
||||
assert(opHandle.getOperationType === TOperationType.GET_SCHEMAS)
|
||||
assert(resp.getStatus.getStatusCode === TStatusCode.SUCCESS_STATUS)
|
||||
checkOperationResult(client, opHandle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user