Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Feb 20, 2023
1 parent 45c60dd commit 5f16855
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,43 +183,43 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
i.getSetField.name(),
i.getSetField match {
case TColumnValue._Fields.STRING_VAL =>
if (i.isSetStringVal) {
if (i.getStringVal.isSetValue) {
i.getStringVal.getFieldValue(TStringValue._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.BOOL_VAL =>
if (i.isSetBoolVal) {
if (i.getBoolVal.isSetValue) {
i.getBoolVal.getFieldValue(TBoolValue._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.BYTE_VAL =>
if (i.isSetByteVal) {
if (i.getByteVal.isSetValue) {
i.getByteVal.getFieldValue(TByteValue._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.DOUBLE_VAL =>
if (i.isSetDoubleVal) {
if (i.getDoubleVal.isSetValue) {
i.getDoubleVal.getFieldValue(TDoubleValue._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.I16_VAL =>
if (i.isSetI16Val) {
if (i.getI16Val.isSetValue) {
i.getI16Val.getFieldValue(TI16Value._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.I32_VAL =>
if (i.isSetI32Val) {
if (i.getI32Val.isSetValue) {
i.getI32Val.getFieldValue(TI32Value._Fields.VALUE)
} else {
null
}
case TColumnValue._Fields.I64_VAL =>
if (i.isSetI64Val) {
if (i.getI64Val.isSetValue) {
i.getI64Val.getFieldValue(TI64Value._Fields.VALUE)
} else {
null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,31 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper
assert(logRowSet.getRowCount == 1)
}

test("test get result row set with null value") {
val opHandleStr = getOpHandleStr(
s"""
|select
|cast(null as string) as c1,
|cast(null as boolean) as c2,
|cast(null as byte) as c3,
|cast(null as double) as c4,
|cast(null as short) as c5,
|cast(null as int) as c6,
|cast(null as bigint) as c7
|""".stripMargin)
checkOpState(opHandleStr, FINISHED)
val response = webTarget.path(
s"api/v1/operations/$opHandleStr/rowset")
.queryParam("maxrows", "2")
.queryParam("fetchorientation", "FETCH_NEXT")
.request(MediaType.APPLICATION_JSON).get()
assert(200 == response.getStatus)
val logRowSet = response.readEntity(classOf[ResultRowSet])
assert(logRowSet.getRows.asScala.head.getFields.asScala.map(_.getValue).toList ===
List(null, null, null, null, null, null, null))
assert(logRowSet.getRowCount == 1)
}

def getOpHandleStr(statement: String = "show tables"): String = {
val sessionHandle = fe.be.openSession(
HIVE_CLI_SERVICE_PROTOCOL_V2,
Expand Down

0 comments on commit 5f16855

Please sign in to comment.